From 9cf4e962bcaf7304a14f558829e4b06936650e3d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 6 Jul 2024 16:43:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(statistics):=20=E4=BF=AE=E6=94=B9=E9=94=80?= =?UTF-8?q?=E5=94=AE=E6=8E=92=E5=90=8D=E6=8E=A5=E5=8F=A3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/statistics/controller/IndexController.php | 2 +- app/statistics/logic/OrderLogic.php | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/statistics/controller/IndexController.php b/app/statistics/controller/IndexController.php index d89abbba..400d7243 100644 --- a/app/statistics/controller/IndexController.php +++ b/app/statistics/controller/IndexController.php @@ -105,7 +105,7 @@ class IndexController extends BaseLikeController */ public function sales_ranking() { - $time = $this->request->get('date', date('Y-m-d')); + $time = $this->request->get('date'); $store_id = $this->store_id; $where = []; if ($store_id) { diff --git a/app/statistics/logic/OrderLogic.php b/app/statistics/logic/OrderLogic.php index afdfe3bb..226020c0 100644 --- a/app/statistics/logic/OrderLogic.php +++ b/app/statistics/logic/OrderLogic.php @@ -26,7 +26,7 @@ class OrderLogic extends BaseLogic ]; return $data; } - public static function Currday($where,$date) + public static function Currday($where, $date) { $startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳 $endTime = strtotime($date . ' 23:59:59'); // 当天的结束时间戳 @@ -56,32 +56,36 @@ class OrderLogic extends BaseLogic } return $data; } - public static function dayPayPrice($where,$time) + public static function dayPayPrice($where, $time) { $todayAmount = UserRecharge::where($where) - ->whereDay('create_time',$time) + ->whereDay('create_time', $time) ->sum('price'); $pay_price = StoreOrder::where($where) - ->whereDay('create_time',$time) + ->whereDay('create_time', $time) ->sum('pay_price'); return bcadd($todayAmount, $pay_price, 2); } - public static function dealFlexiblePrice($where,$start,$end) + public static function dealFlexiblePrice($where, $start, $end) { //排除退款 - $todayAmount = UserRecharge::where($where)->where('status',1) + $todayAmount = UserRecharge::where($where)->where('status', 1) ->whereBetweenTime('create_time', $start, $end) ->sum('price'); - $pay_price = StoreOrder::where($where)->where('refund_status',0) + $pay_price = StoreOrder::where($where)->where('refund_status', 0) ->whereBetweenTime('create_time', $start, $end) ->sum('pay_price'); return bcadd($todayAmount, $pay_price, 2); - } - public static function sales($where,$time){ - $select=StoreOrder::where($where)->whereDay('create_time',$time)->limit(10)->order('id desc')->field('id,order_id,pay_price,create_time')->select(); + public static function sales($where, $time) + { + $select = StoreOrder::where($where); + if ($time) { + $select->whereDay('create_time', $time); + } + $select = $select->limit(20)->order('id desc')->field('id,order_id,pay_price,create_time')->select(); return $select?->toArray(); } }