统计代支付金额
This commit is contained in:
@@ -65,6 +65,43 @@ class ChargeCashController extends BaseAdminController
|
|||||||
|
|
||||||
public function actionCount()
|
public function actionCount()
|
||||||
{
|
{
|
||||||
|
$query = ChargeCashPayRecord::find();
|
||||||
|
$list = $query->where(['status' => 2])->all();
|
||||||
|
|
||||||
|
$today = 0; // 今日
|
||||||
|
$yesterday = 0; // 昨天
|
||||||
|
$week = 0; // 本周
|
||||||
|
$month = 0; // 本月
|
||||||
|
$total = 0;
|
||||||
|
foreach ($list as $item) {
|
||||||
|
if ($item->updated_at >= strtotime(date('Y-m-d'))) {
|
||||||
|
$today = bcadd($today, $item->charge_cash, 2);
|
||||||
|
$total = bcadd($total, $item->charge_cash, 2);
|
||||||
|
$week = bcadd($week, $item->charge_cash, 2);
|
||||||
|
$month = bcadd($month, $item->charge_cash, 2);
|
||||||
|
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||||
|
} elseif ($item->updated_at >= strtotime(date('Y-m-d', strtotime('-1 day'))) && $item->updated_at < strtotime(date('Y-m-d'))) {
|
||||||
|
$yesterday = bcadd($yesterday, $item->charge_cash, 2);
|
||||||
|
$total = bcadd($total, $item->charge_cash, 2);
|
||||||
|
$week = bcadd($week, $item->charge_cash, 2);
|
||||||
|
$month = bcadd($month, $item->charge_cash, 2);
|
||||||
|
} elseif ($item->updated_at >= strtotime(date('Y-m-d', strtotime('-7 day'))) && $item->updated_at < strtotime(date('Y-m-d', strtotime('-1 day')))) {
|
||||||
|
$week = bcadd($week, $item->charge_cash, 2);
|
||||||
|
$total = bcadd($total, $item->charge_cash, 2);
|
||||||
|
$month = bcadd($month, $item->charge_cash, 2);
|
||||||
|
} elseif ($item->updated_at >= strtotime(date('Y-m-01')) && $item->updated_at < strtotime(date('Y-m-d', strtotime('-7 day')))) {
|
||||||
|
$month = bcadd($month, $item->charge_cash, 2);
|
||||||
|
$total = bcadd($total, $item->charge_cash, 2);
|
||||||
|
} else {
|
||||||
|
$total = bcadd($total, $item->charge_cash, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'today' => $today,
|
||||||
|
'yesterday' => $yesterday,
|
||||||
|
'week' => $week,
|
||||||
|
'month' => $month,
|
||||||
|
'total' => $total
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user