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

This commit is contained in:
wangxiaowei 2024-11-06 11:28:25 +08:00
parent b184dfadbc
commit efb9043d29

@ -767,8 +767,6 @@ class LocalStoreLogic extends Logic
public static function countData($post, $user_id)
{
// ->where(['lso.state' => 1, 'lso.pay_shop_type' => 1, 'lso.lstore_id' => $data['lstore_id']])
$where = [
['lstore_id', '=', $post['lstore_id']],
['pay_shop_type', '=', 1],
@ -800,21 +798,15 @@ class LocalStoreLogic extends Logic
['create_time', '<=', $last_month_end]
])->sum('total_amount');
// 当日营业额
// 统计当日数据: 总共支付交易笔数 report = 1(日报) report = 2(月报)
$current_day_start = date('Y-m-d 00:00:00');
$current_day_end = date('Y-m-d 23:59:59');
$current_day_total_amount = $model
->where($where)
->where([
['create_time', '>=', $current_day_start],
['create_time', '<=', $current_day_end]
])->sum('total_amount');
// 统计当日数据: 总共支付交易笔数 report = 1(日报) report = 2(月报)
$trade_where = $where;
$time_where = [];
$filter_month_total_amount = 0;
if (empty($filter_day)) {
if (empty($post['filter_day'])) {
if ($post['report'] == 1) {
unset($trade_where[2]);
}
@ -833,6 +825,14 @@ class LocalStoreLogic extends Logic
])->sum('total_amount');
}
// 日报、月报、日期筛选——营业额
$current_report_total_amount = $model
->where($where)
->where([
['create_time', '>=', $time_where['start']],
['create_time', '<=', $time_where['end']]
])->sum('total_amount');
// 总共交易笔数
$count_trade = $model
->where($trade_where)
@ -851,11 +851,11 @@ class LocalStoreLogic extends Logic
])->count();
// 单笔均价
if (empty($filter_day)) {
if (empty($post['filter_day'])) {
if ($post['report'] == 1) {
$average_price = $success_trade > 0 ? $current_day_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_month_total_amount / $success_trade : 0;
$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;
@ -865,7 +865,7 @@ class LocalStoreLogic extends Logic
'history_total_amount' => number_format($history_total_amount, 2, '.', ''),
'current_month_total_amount' => number_format($current_month_total_amount, 2, '.', ''),
'last_month_total_amount' => number_format($last_month_total_amount, 2, '.', ''),
'current_day_total_amount' => number_format($current_day_total_amount, 2, '.', ''),
'current_report_total_amount' => number_format($current_report_total_amount, 2, '.', ''),
'count_trade' => $count_trade,
'success_trade' => $success_trade,
'average_price' => number_format($average_price, 2, '.', '')