收款统计
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\dashboard;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\FinReceipt;
|
||||
use support\Request;
|
||||
|
||||
class FinStatisticsController extends BaseController
|
||||
{
|
||||
/**
|
||||
* 收款记录统计
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function statistics(Request $request)
|
||||
{
|
||||
try {
|
||||
$query = FinReceipt::where('payment_apply_id','>',0);
|
||||
|
||||
$result = [];
|
||||
//已认领数量
|
||||
$result['claimed_num'] = $query->count();
|
||||
//已认领金额
|
||||
$result['claimed_amount'] = $query->sum('amount');
|
||||
|
||||
|
||||
$query = FinReceipt::whereNull('payment_apply_id');
|
||||
|
||||
//未认领数量
|
||||
$result['unclaimed_num'] = $query->count();
|
||||
//未认领金额
|
||||
$result['unclaimed_amount'] = $query->sum('amount');
|
||||
|
||||
//已超时未认领数量
|
||||
$result['timeout'] = $query->where('created_at','<',time()-24*3600)->count();
|
||||
|
||||
return $this->success($result);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user