本地生活商家账单修改日期筛选

This commit is contained in:
wangxiaowei 2024-11-06 11:44:32 +08:00
parent efb9043d29
commit f1c9fd65b8

@ -799,14 +799,19 @@ class LocalStoreLogic extends Logic
])->sum('total_amount'); ])->sum('total_amount');
// 统计当日数据: 总共支付交易笔数 report = 1(日报) report = 2(月报) // 统计当日数据: 总共支付交易笔数 report = 1(日报) report = 2(月报)
$current_day_start = date('Y-m-d 00:00:00');
$current_day_end = date('Y-m-d 23:59:59');
$trade_where = $where; $trade_where = $where;
$time_where = []; $time_where = [];
$filter_month_total_amount = 0; $filter_month_total_amount = 0;
// $post['filter_day'] = array(
// 'startDate' => '2024-10-01',
// 'endDate' => '2024-10-31'
// );
if (empty($post['filter_day'])) { if (empty($post['filter_day'])) {
// 日报 月报
$current_day_start = date('Y-m-d 00:00:00');
$current_day_end = date('Y-m-d 23:59:59');
if ($post['report'] == 1) { if ($post['report'] == 1) {
unset($trade_where[2]); unset($trade_where[2]);
} }
@ -817,12 +822,12 @@ class LocalStoreLogic extends Logic
// 日期筛选 // 日期筛选
$time_where['start'] = $post['filter_day']['startDate']; $time_where['start'] = $post['filter_day']['startDate'];
$time_where['end'] = $post['filter_day']['endDate']; $time_where['end'] = $post['filter_day']['endDate'];
$filter_month_total_amount = $model // $filter_month_total_amount = $model
->where($where) // ->where($where)
->where([ // ->where([
['create_time', '>=', $time_where['start']], // ['create_time', '>=', $time_where['start']],
['create_time', '<=', $time_where['end']] // ['create_time', '<=', $time_where['end']]
])->sum('total_amount'); // ])->sum('total_amount');
} }
// 日报、月报、日期筛选——营业额 // 日报、月报、日期筛选——营业额
@ -851,15 +856,7 @@ class LocalStoreLogic extends Logic
])->count(); ])->count();
// 单笔均价 // 单笔均价
if (empty($post['filter_day'])) {
if ($post['report'] == 1) {
$average_price = $success_trade > 0 ? $current_report_total_amount / $success_trade : 0; $average_price = $success_trade > 0 ? $current_report_total_amount / $success_trade : 0;
} else if ($post['report'] == 2) {
$average_price = $success_trade > 0 ? $current_report_total_amount / $success_trade : 0;
}
} else {
$average_price = $success_trade > 0 ? $filter_month_total_amount / $success_trade : 0;
}
return [ return [
'history_total_amount' => number_format($history_total_amount, 2, '.', ''), 'history_total_amount' => number_format($history_total_amount, 2, '.', ''),