Kirin vor 2 Monaten
Ursprung
Commit
80f424d17c

+ 16 - 4
app/controller/admin/v1/statistic/OrderStatistic.php

@@ -30,7 +30,10 @@ class OrderStatistic extends AuthController
     public function getBasic()
     {
         $where = $this->request->getMore([
-            ['time', '']
+            ['time', ''],
+            ['order_province', ''],
+            ['order_city', ''],
+            ['order_district', ''],
         ]);
         $data = $this->services->getBasic($where);
         return app('json')->success($data);
@@ -43,7 +46,10 @@ class OrderStatistic extends AuthController
     public function getTrend()
     {
         $where = $this->request->getMore([
-            ['time', '']
+            ['time', ''],
+            ['order_province', ''],
+            ['order_city', ''],
+            ['order_district', ''],
         ]);
         $data = $this->services->getTrend($where);
         return app('json')->success($data);
@@ -56,7 +62,10 @@ class OrderStatistic extends AuthController
     public function getChannel()
     {
         $where = $this->request->getMore([
-            ['time', '']
+            ['time', ''],
+            ['order_province', ''],
+            ['order_city', ''],
+            ['order_district', ''],
         ]);
         $data = $this->services->getChannel($where);
         return app('json')->success($data);
@@ -69,7 +78,10 @@ class OrderStatistic extends AuthController
     public function getType()
     {
         $where = $this->request->getMore([
-            ['time', '']
+            ['time', ''],
+            ['order_province', ''],
+            ['order_city', ''],
+            ['order_district', ''],
         ]);
         $data = $this->services->getType($where);
         return app('json')->success($data);

+ 133 - 107
app/dao/order/StoreOrderDao.php

@@ -53,24 +53,24 @@ class StoreOrderDao extends BaseDao
         $fieldKey = $fieldKey == 'all' ? '' : $fieldKey;
         return parent::search($where)->when($isDel, function ($query) use ($where) {
             $query->where('is_del', $where['is_del']);
-        })->when(isset($where['plat_type']) && in_array($where['plat_type'], [-1, 0, 1, 2]), function ($query) use($where) {
-			switch ($where['plat_type']) {
-				case -1://所有
-					break;
-				case 0://平台
-				 	$query->where('store_id', 0)->where('supplier_id', 0);
-					break;
-				case 1://门店
-					$query->where('store_id', '>', 0);
-					break;
-				case 2://供应商
-					$query->where('supplier_id', '>', 0);
-					break;
-			}
+        })->when(isset($where['plat_type']) && in_array($where['plat_type'], [-1, 0, 1, 2]), function ($query) use ($where) {
+            switch ($where['plat_type']) {
+                case -1://所有
+                    break;
+                case 0://平台
+                    $query->where('store_id', 0)->where('supplier_id', 0);
+                    break;
+                case 1://门店
+                    $query->where('store_id', '>', 0);
+                    break;
+                case 2://供应商
+                    $query->where('supplier_id', '>', 0);
+                    break;
+            }
         })->when(isset($where['is_system_del']), function ($query) {
             $query->where('is_system_del', 0);
         })->when(isset($where['is_coupon']), function ($query) {
-            $query->where('coupon_id','>', 0);
+            $query->where('coupon_id', '>', 0);
         })->when(isset($where['staff_id']) && $where['staff_id'], function ($query) use ($where) {
             $query->where('staff_id', $where['staff_id']);
         })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
@@ -146,8 +146,8 @@ class StoreOrderDao extends BaseDao
                     break;
                 case 8://预售
                     $query->where('type', 6);
-					break;
-				case 9://新人专享
+                    break;
+                case 9://新人专享
                     $query->where('type', 7);
                     break;
                 case 10://抽奖
@@ -161,18 +161,18 @@ class StoreOrderDao extends BaseDao
                     break;
             }
         })->when(isset($where['order_type']) && $where['order_type'] !== '', function ($query) use ($where) {
-			switch ($where['order_type']) {
-				case 5://核销订单
-					$query->where('shipping_type', 2);
-					break;
-				case 6://收银台订单
-					$query->where('shipping_type', 4);
-					break;
-				case 7://配送订单
-					$query->whereIn('shipping_type', [1, 3]);
-					break;
-			}
-		})->when(isset($where['pay_type']), function ($query) use ($where) {
+            switch ($where['order_type']) {
+                case 5://核销订单
+                    $query->where('shipping_type', 2);
+                    break;
+                case 6://收银台订单
+                    $query->where('shipping_type', 4);
+                    break;
+                case 7://配送订单
+                    $query->whereIn('shipping_type', [1, 3]);
+                    break;
+            }
+        })->when(isset($where['pay_type']), function ($query) use ($where) {
             switch ($where['pay_type']) {
                 case 1:
                     $query->where('pay_type', 'weixin');
@@ -200,21 +200,21 @@ class StoreOrderDao extends BaseDao
         })->when($realName && !$fieldKey, function ($query) use ($where) {
             $query->where(function ($que) use ($where) {
                 $que->whereLike('order_id|real_name|user_phone|verify_code', '%' . $where['real_name'] . '%')
-					->whereOr('uid', 'in', function ($q) use ($where) {
-						$q->name('user')->whereLike('nickname|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
-					})->whereOr('uid', 'in', function ($q) use ($where) {
-						$q->name('user_address')->whereLike('real_name|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
-					})->whereOr('id', 'in', function ($que) use ($where) {
-						$que->name('store_order_cart_info')->whereIn('product_id', function ($q) use ($where) {
-							$q->name('store_product')->whereLike('store_name|keyword', '%' . $where['real_name'] . '%')->field(['id'])->select();
-						})->field(['oid'])->select();
-					})->whereOr('activity_id', 'in', function ($que) use ($where) {
-						$que->name('store_seckill')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
-					})->whereOr('activity_id', 'in', function ($que) use ($where) {
-						$que->name('store_bargain')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
-					})->whereOr('activity_id', 'in', function ($que) use ($where) {
-						$que->name('store_combination')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
-					});
+                    ->whereOr('uid', 'in', function ($q) use ($where) {
+                        $q->name('user')->whereLike('nickname|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
+                    })->whereOr('uid', 'in', function ($q) use ($where) {
+                        $q->name('user_address')->whereLike('real_name|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
+                    })->whereOr('id', 'in', function ($que) use ($where) {
+                        $que->name('store_order_cart_info')->whereIn('product_id', function ($q) use ($where) {
+                            $q->name('store_product')->whereLike('store_name|keyword', '%' . $where['real_name'] . '%')->field(['id'])->select();
+                        })->field(['oid'])->select();
+                    })->whereOr('activity_id', 'in', function ($que) use ($where) {
+                        $que->name('store_seckill')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
+                    })->whereOr('activity_id', 'in', function ($que) use ($where) {
+                        $que->name('store_bargain')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
+                    })->whereOr('activity_id', 'in', function ($que) use ($where) {
+                        $que->name('store_combination')->whereLike('title|info', '%' . $where['real_name'] . '%')->field(['id'])->select();
+                    });
             });
         })->when(isset($where['unique']), function ($query) use ($where) {
             $query->where('unique', $where['unique']);
@@ -241,6 +241,18 @@ class StoreOrderDao extends BaseDao
             } else {
                 $query->where('refund_status', 0);
             }
+        })->when(isset($where['area']) && !empty($where['area']), function ($query) use ($where) {
+            if (is_array($where['area'])) {
+                if (($where['area']['order_province'] ?? '') != '') {
+                    $query->where('order_province', $where['area']['order_province']);
+                    if (($where['area']['order_city'] ?? '') != '') {
+                        $query->where('order_city', $where['area']['order_city']);
+                        if (($where['area']['order_district'] ?? '') != '') {
+                            $query->where('order_district', $where['area']['order_district']);
+                        }
+                    }
+                }
+            }
         });
     }
 
@@ -665,9 +677,11 @@ class StoreOrderDao extends BaseDao
      * @param $timeType
      * @param $field
      * @param $str
+     * @param string $orderStatus
+     * @param null $area
      * @return mixed
      */
-    public function getProductTrend($time, $timeType, $field, $str, $orderStatus = '')
+    public function getProductTrend($time, $timeType, $field, $str, $orderStatus = '', $area = null)
     {
         return $this->getModel()->where(function ($query) use ($field, $orderStatus) {
             if ($field == 'pay_time') {
@@ -690,6 +704,18 @@ class StoreOrderDao extends BaseDao
                 $time[1] = date('Y/m/d', strtotime($time[1]) + 86400);
                 $query->whereTime($field, 'between', $time);
             }
+        })->where(function ($query) use ($area) {
+            if (is_array($area)) {
+                if (($area['order_province'] ?? '') != '') {
+                    $query->where('order_province', $area['order_province']);
+                    if (($area['order_city'] ?? '') != '') {
+                        $query->where('order_city', $area['order_city']);
+                        if (($area['order_district'] ?? '') != '') {
+                            $query->where('order_district', $area['order_district']);
+                        }
+                    }
+                }
+            }
         })->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
     }
 
@@ -746,7 +772,7 @@ class StoreOrderDao extends BaseDao
                 } elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
                     $timeUinx = "%Y-%m";
                 } else {
-					$timeUinx = "%Y-%m";
+                    $timeUinx = "%Y-%m";
                 }
                 $query->field("sum($sumField) as number,FROM_UNIXTIME($group, '$timeUinx') as time");
                 $query->group("FROM_UNIXTIME($group, '$timeUinx')");
@@ -776,7 +802,7 @@ class StoreOrderDao extends BaseDao
                 } elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
                     $timeUinx = "%Y-%m";
                 } else {
-					$timeUinx = "%Y-%m";
+                    $timeUinx = "%Y-%m";
                 }
                 $query->field("count($sumField) as number,FROM_UNIXTIME(pay_time, '$timeUinx') as time");
                 $query->group("FROM_UNIXTIME(pay_time, '$timeUinx')");
@@ -821,7 +847,7 @@ class StoreOrderDao extends BaseDao
                 } elseif ($where['timeKey']['days'] > 30 && $where['timeKey']['days'] < 365) {
                     $timeUinx = "%Y-%m";
                 } else {
-					$timeUinx = "%Y-%m";
+                    $timeUinx = "%Y-%m";
                 }
                 $query->field("count(distinct uid) as number,FROM_UNIXTIME(pay_time, '$timeUinx') as time");
                 $query->group("FROM_UNIXTIME(pay_time, '$timeUinx')");
@@ -987,38 +1013,38 @@ class StoreOrderDao extends BaseDao
                 $query->whereTime($field, 'between', $time);
             }
         })->where('is_del', 0)->where('is_system_del', 0)
-        ->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
+            ->field("FROM_UNIXTIME($field,'$timeType') as days,$str as num")->group('days')->select()->toArray();
     }
 
-	/**
-	 * 获取活动订单列表:
-	 * @param int $id
-	 * @param int $type 0:普通、1:秒杀、2:砍价、3:拼团、4:积分、5:套餐、6:预售、7:新人礼
-	 * @param array $where
-	 * @param int $page
-	 * @param int $limit
-	 * @return array
-	 * @throws \think\db\exception\DataNotFoundException
-	 * @throws \think\db\exception\DbException
-	 * @throws \think\db\exception\ModelNotFoundException
-	 */
-	public function activityStatisticsOrder(int $id, int $type = 1,array $where = [], int $page = 0, int $limit = 0)
-	{
-		return $this->search($where)->where('pid', 'in', [0, -1])->where('paid', 1)->where('type', $type)->where('activity_id', $id)
-			->when($page && $limit, function ($query) use ($page, $limit) {
-				$query->page($page, $limit);
-			})->field(['order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid', 'shipping_type', 'refund_status', 'is_del', 'is_system_del'])->select()->toArray();
-	}
+    /**
+     * 获取活动订单列表:
+     * @param int $id
+     * @param int $type 0:普通、1:秒杀、2:砍价、3:拼团、4:积分、5:套餐、6:预售、7:新人礼
+     * @param array $where
+     * @param int $page
+     * @param int $limit
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function activityStatisticsOrder(int $id, int $type = 1, array $where = [], int $page = 0, int $limit = 0)
+    {
+        return $this->search($where)->where('pid', 'in', [0, -1])->where('paid', 1)->where('type', $type)->where('activity_id', $id)
+            ->when($page && $limit, function ($query) use ($page, $limit) {
+                $query->page($page, $limit);
+            })->field(['order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid', 'shipping_type', 'refund_status', 'is_del', 'is_system_del'])->select()->toArray();
+    }
 
 
-	/**
-	 * 秒杀参与人统计
-	 * @param int $id
-	 * @param string $keyword
-	 * @param int $page
-	 * @param int $limit
-	 * @return mixed
-	 */
+    /**
+     * 秒杀参与人统计
+     * @param int $id
+     * @param string $keyword
+     * @param int $page
+     * @param int $limit
+     * @return mixed
+     */
     public function seckillPeople(int $id, string $keyword, int $page = 0, int $limit = 0)
     {
         return $this->getModel()
@@ -1038,38 +1064,38 @@ class StoreOrderDao extends BaseDao
             })->select()->toArray();
     }
 
-	/**
-	 * @param int $pid
-	 * @return array
-	 * @throws \think\db\exception\DataNotFoundException
-	 * @throws \think\db\exception\DbException
-	 * @throws \think\db\exception\ModelNotFoundException
-	 */
-	public function getSubOrderNotSendList(int $pid)
-	{
-		return $this->getModel()->where('pid', $pid)->where('status', 1)->select()->toArray();
-	}
+    /**
+     * @param int $pid
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getSubOrderNotSendList(int $pid)
+    {
+        return $this->getModel()->where('pid', $pid)->where('status', 1)->select()->toArray();
+    }
 
-	/**
-	 * @param int $pid
-	 * @param int $order_id
-	 * @return int
-	 * @throws \think\db\exception\DbException
-	 */
-	public function getSubOrderNotSend(int $pid, int $order_id)
-	{
-		return $this->getModel()->where('pid', $pid)->where('status', 0)->where('id', '<>', $order_id)->count();
-	}
+    /**
+     * @param int $pid
+     * @param int $order_id
+     * @return int
+     * @throws \think\db\exception\DbException
+     */
+    public function getSubOrderNotSend(int $pid, int $order_id)
+    {
+        return $this->getModel()->where('pid', $pid)->where('status', 0)->where('id', '<>', $order_id)->count();
+    }
 
-	/**
-	 * @param int $pid
-	 * @param int $order_id
-	 * @return int
-	 * @throws \think\db\exception\DbException
-	 */
-	public function getSubOrderNotTake(int $pid, int $order_id)
-	{
-		return $this->getModel()->where('pid', $pid)->where('status', 1)->where('id', '<>', $order_id)->count();
-	}
+    /**
+     * @param int $pid
+     * @param int $order_id
+     * @return int
+     * @throws \think\db\exception\DbException
+     */
+    public function getSubOrderNotTake(int $pid, int $order_id)
+    {
+        return $this->getModel()->where('pid', $pid)->where('status', 1)->where('id', '<>', $order_id)->count();
+    }
 
 }

+ 44 - 25
app/services/statistic/OrderStatisticServices.php

@@ -30,18 +30,22 @@ class OrderStatisticServices extends BaseServices
     {
         /** @var StoreOrderServices $orderService */
         $orderService = app()->make(StoreOrderServices::class);
-        $data['pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time']], 'pay_price', true);
-        $data['ali_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'alipay'], 'pay_price', true);
-        $data['wechat_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'weixin'], 'pay_price', true);
-        $data['yue_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'yue'], 'pay_price', true);
-        $data['integral_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time']], 'use_integral', true);
-        $data['offline_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'offline'], 'pay_price', true);
-        $data['award_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time']], 'award_price', true);
-        $data['pay_count'] = $orderService->count(['paid' => 1, 'pid' => 0, 'time' => $where['time']]);
-        $data['refund_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'is_refund' => 1, 'time' => $where['time']], 'pay_price', true);
-        $data['refund_count'] = $orderService->count(['paid' => 1, 'pid' => 0, 'is_refund' => 1, 'time' => $where['time']]);
-        $data['coupon_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time']], 'coupon_price', true);
-        $data['coupon_count'] = $orderService->search(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'is_coupon' => 1])->count();
+        $area = [];
+        if (!empty($where['order_province'])) $area['order_province'] = $where['order_province'];
+        if (!empty($where['order_city'])) $area['order_city'] = $where['order_city'];
+        if (!empty($where['order_district'])) $area['order_district'] = $where['order_district'];
+        $data['pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'area' => $area], 'pay_price', true);
+        $data['ali_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'alipay', 'area' => $area], 'pay_price', true);
+        $data['wechat_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'weixin', 'area' => $area], 'pay_price', true);
+        $data['yue_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'yue', 'area' => $area], 'pay_price', true);
+        $data['integral_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'area' => $area], 'use_integral', true);
+        $data['offline_pay_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'pay_type' => 'offline', 'area' => $area], 'pay_price', true);
+        $data['award_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'area' => $area], 'award_price', true);
+        $data['pay_count'] = $orderService->count(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'area' => $area]);
+        $data['refund_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'is_refund' => 1, 'time' => $where['time'], 'area' => $area], 'pay_price', true);
+        $data['refund_count'] = $orderService->count(['paid' => 1, 'pid' => 0, 'is_refund' => 1, 'time' => $where['time'], 'area' => $area]);
+        $data['coupon_price'] = $orderService->sum(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'area' => $area], 'coupon_price', true);
+        $data['coupon_count'] = $orderService->search(['paid' => 1, 'pid' => 0, 'time' => $where['time'], 'is_coupon' => 1, 'area' => $area])->count();
         return $data;
     }
 
@@ -52,18 +56,23 @@ class OrderStatisticServices extends BaseServices
      */
     public function getTrend($where)
     {
+        $area = [];
+        if (!empty($where['order_province'])) $area['order_province'] = $where['order_province'];
+        if (!empty($where['order_city'])) $area['order_city'] = $where['order_city'];
+        if (!empty($where['order_district'])) $area['order_district'] = $where['order_district'];
+
         $time = explode('-', $where['time']);
         if (count($time) != 2) throw new AdminException('参数错误');
         $dayCount = (strtotime($time[1]) - strtotime($time[0])) / 86400 + 1;
         $data = [];
         if ($dayCount == 1) {
-            $data = $this->trend($time, 0);
+            $data = $this->trend($time, $area, 0);
         } elseif ($dayCount > 1 && $dayCount <= 31) {
-            $data = $this->trend($time, 1);
+            $data = $this->trend($time, $area, 1);
         } elseif ($dayCount > 31 && $dayCount <= 92) {
-            $data = $this->trend($time, 3);
+            $data = $this->trend($time, $area, 3);
         } elseif ($dayCount > 92) {
-            $data = $this->trend($time, 30);
+            $data = $this->trend($time, $area, 30);
         }
         return $data;
     }
@@ -75,7 +84,7 @@ class OrderStatisticServices extends BaseServices
      * @param false $excel
      * @return array
      */
-    public function trend($time, $num, $excel = false)
+    public function trend($time, $area, $num, $excel = false)
     {
         /** @var StoreOrderServices $storeOrder */
         $storeOrder = app()->make(StoreOrderServices::class);
@@ -98,12 +107,12 @@ class OrderStatisticServices extends BaseServices
                 }
             }
         }
-        $pay_price = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'sum(pay_price)', 'pay'), 'num', 'days');
-        $pay_count = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'count(id)', 'pay'), 'num', 'days');
-        $refund_price = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'sum(pay_price)', 'refund'), 'num', 'days');
-        $refund_count = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'count(id)', 'refund'), 'num', 'days');
-        $coupon_price = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'sum(coupon_price)', 'coupon'), 'num', 'days');
-        $coupon_count = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'count(id)', 'coupon'), 'num', 'days');
+        $pay_price = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'sum(pay_price)', 'pay', $area), 'num', 'days');
+        $pay_count = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'count(id)', 'pay', $area), 'num', 'days');
+        $refund_price = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'sum(pay_price)', 'refund', $area), 'num', 'days');
+        $refund_count = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'count(id)', 'refund', $area), 'num', 'days');
+        $coupon_price = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'sum(coupon_price)', 'coupon', $area), 'num', 'days');
+        $coupon_count = array_column($storeOrder->getProductTrend($time, $timeType, 'add_time', 'count(id)', 'coupon', $area), 'num', 'days');
         $data = $series = [];
         foreach ($xAxis as $item) {
             $data['订单金额'][] = isset($pay_price[$item]) ? floatval($pay_price[$item]) : 0;
@@ -130,6 +139,11 @@ class OrderStatisticServices extends BaseServices
      */
     public function getChannel($where)
     {
+        $area = [];
+        if (!empty($where['order_province'])) $area['order_province'] = $where['order_province'];
+        if (!empty($where['order_city'])) $area['order_city'] = $where['order_city'];
+        if (!empty($where['order_district'])) $area['order_district'] = $where['order_district'];
+
         /** @var StoreOrderServices $orderService */
         $orderService = app()->make(StoreOrderServices::class);
 
@@ -139,7 +153,7 @@ class OrderStatisticServices extends BaseServices
         foreach ($bing_xdata as $key => $item) {
             $bing_data[] = [
                 'name' => $item,
-                'value' => $orderService->count(['paid' => 1, 'pid' => 0, 'is_channel' => $key, 'time' => $where['time']]),
+                'value' => $orderService->count(['paid' => 1, 'pid' => 0, 'is_channel' => $key, 'time' => $where['time'], 'area' => $area]),
                 'itemStyle' => ['color' => $color[$key]]
             ];
         }
@@ -167,6 +181,11 @@ class OrderStatisticServices extends BaseServices
         /** @var StoreOrderServices $orderService */
         $orderService = app()->make(StoreOrderServices::class);
 
+        $area = [];
+        if (!empty($where['order_province'])) $area['order_province'] = $where['order_province'];
+        if (!empty($where['order_city'])) $area['order_city'] = $where['order_city'];
+        if (!empty($where['order_district'])) $area['order_district'] = $where['order_district'];
+
         $bing_xdata = ['普通订单', '秒杀订单', '砍价订单', '拼团订单', '套餐订单', '预售订单', '新人订单', '抽奖订单', '拼单订单', '桌码订单'];
         $color = ['#64a1f4', '#3edeb5', '#70869f', '#ffc653', '#fc7d6a', '#b37feb', '#ff85c0', '#6dd230', '#e8ea48', '#ef3737'];
         $bing_data = [];
@@ -175,7 +194,7 @@ class OrderStatisticServices extends BaseServices
             if ($key > 4) $keys = $key + 3;
             $bing_data[] = [
                 'name' => $item,
-                'value' => $orderService->together(['paid' => 1, 'pid' => 0, 'type' => $keys, 'time' => $where['time']], 'pay_price', 'sum'),
+                'value' => $orderService->together(['paid' => 1, 'pid' => 0, 'type' => $keys, 'time' => $where['time'], 'area' => $area], 'pay_price', 'sum'),
                 'itemStyle' => ['color' => $color[$key]]
             ];
         }