|
|
|
@ -3,6 +3,8 @@ declare (strict_types=1); |
|
|
|
|
|
|
|
namespace app\controller\admin; |
|
|
|
|
|
|
|
use app\model\InvoiceHead; |
|
|
|
use app\model\WechatUser; |
|
|
|
use app\util\ReturnCode; |
|
|
|
use think\Response; |
|
|
|
|
|
|
|
@ -48,4 +50,36 @@ class Index extends Base { |
|
|
|
return $this->buildFailed(ReturnCode::FILE_SAVE_ERROR, '文件上传失败'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @return Response |
|
|
|
*/ |
|
|
|
public function statistics(): Response |
|
|
|
{ |
|
|
|
try { |
|
|
|
$data = []; |
|
|
|
|
|
|
|
$wechatUserTotal = (new WechatUser)->where('delete_time', 0)->count('id'); |
|
|
|
$data['wechat_user_total'] = $wechatUserTotal; |
|
|
|
|
|
|
|
$data['invoice_head_data'] = [['type' => '机构', 'count' => 0], ['type' => '个人', 'count' => 0]]; |
|
|
|
$invoice_head_field = "type, count(id) as `count`"; |
|
|
|
$invoice_head_data = (new InvoiceHead)->field($invoice_head_field)->group('type')->select()->toArray(); |
|
|
|
if ($invoice_head_data) { |
|
|
|
foreach ($invoice_head_data as $invoice_head_value) { |
|
|
|
if ($invoice_head_value['type'] > 0) { |
|
|
|
$data['invoice_head_data'][1]['count'] += $invoice_head_value['count']; |
|
|
|
} else { |
|
|
|
$data['invoice_head_data'][0]['count'] += $invoice_head_value['count']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return $this->buildSuccess($data); |
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
|
return $this->buildFailed(ReturnCode::RECORD_NOT_FOUND, '记录未找到'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|