From efb9043d2951a9f1264bd300766127ec348051df Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Wed, 6 Nov 2024 11:28:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E7=94=9F=E6=B4=BB=E5=95=86?= =?UTF-8?q?=E5=AE=B6=E8=B4=A6=E5=8D=95=E4=BF=AE=E6=94=B9=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/LocalStoreLogic.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index 4d723736..d0175634 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -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, '.', '')