修改本地生活商家交易数据统计
This commit is contained in:
parent
9fceb91243
commit
ab30f1ece3
@ -811,28 +811,52 @@ class LocalStoreLogic extends Logic
|
||||
|
||||
// 统计当日数据: 总共支付交易笔数 report = 1(日报) report = 2(月报)
|
||||
$trade_where = $where;
|
||||
unset($trade_where[2]);
|
||||
$time_where = [];
|
||||
$filter_month_total_amount = 0;
|
||||
if (empty($filter_day)) {
|
||||
if ($post['report'] == 1) {
|
||||
unset($trade_where[2]);
|
||||
}
|
||||
|
||||
$time_where['start'] = $post['report'] == 1 ? $current_day_start : $current_month_start;
|
||||
$time_where['end'] = $post['report'] == 1 ? $current_day_end : $current_month_end;
|
||||
} else {
|
||||
// 日期筛选
|
||||
$time_where['start'] = $post['filter_day']['startDate'];
|
||||
$time_where['end'] = $post['filter_day']['endDate'];
|
||||
$filter_month_total_amount = $model
|
||||
->where($where)
|
||||
->where([
|
||||
['dtime', '>=', $time_where['start']],
|
||||
['dtime', '<=', $time_where['end']]
|
||||
])->sum('goods_total_price');
|
||||
}
|
||||
|
||||
// 总共交易笔数
|
||||
$count_trade = $model
|
||||
->where($post['report'] == 1 ? $trade_where : $where)
|
||||
->where($trade_where)
|
||||
->where([
|
||||
['dtime', '>=', $post['report'] == 1 ? $current_day_start : $current_month_start],
|
||||
['dtime', '<=', $post['report'] == 1 ? $current_day_end : $current_month_end]
|
||||
['dtime', '>=', $time_where['start']],
|
||||
['dtime', '<=', $time_where['end']]
|
||||
])->count();
|
||||
|
||||
// 支付成功交易笔数
|
||||
$success_trade = $model
|
||||
->where($post['report'] == 1 ? $trade_where : $where)
|
||||
->where($trade_where)
|
||||
->where([
|
||||
['dtime', '>=', $post['report'] == 1 ? $current_day_start : $current_month_start],
|
||||
['dtime', '<=', $post['report'] == 1 ? $current_day_end : $current_month_end]
|
||||
['dtime', '>=', $time_where['start']],
|
||||
['dtime', '<=', $time_where['end']]
|
||||
])->count();
|
||||
|
||||
// 单笔交易
|
||||
if ($post['report'] == 1) {
|
||||
$average_price = $success_trade > 0 ? $current_day_total_amount / $success_trade : 0;
|
||||
} elseif ($post['report'] == 2) {
|
||||
$average_price = $success_trade > 0 ? $current_month_total_amount / $success_trade : 0;
|
||||
// 单笔均价
|
||||
if (empty($filter_day)) {
|
||||
if ($post['report'] == 1) {
|
||||
$average_price = $success_trade > 0 ? $current_day_total_amount / $success_trade : 0;
|
||||
} else if ($post['report'] == 2) {
|
||||
$average_price = $success_trade > 0 ? $current_month_total_amount / $success_trade : 0;
|
||||
}
|
||||
} else {
|
||||
$average_price = $success_trade > 0 ? $filter_month_total_amount / $success_trade : 0;
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user