From cd434745c863bdae976ce901c58b96eb2ea8cd1a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 9 Dec 2023 11:45:28 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/store/product/StoreSpu.php | 2 +- app/controller/merchant/store/StoreImport.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 01c1dbd4..76bff57e 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -71,7 +71,7 @@ class StoreSpu extends BaseController unset($where['type_id'], $where['street_id']); $where['is_gift_bag'] = 0; - $where['product_type'] = 0; + $where['product_type'] = $where['product_type']??0; $where['order'] = $where['order'] ?: 'star'; if ($where['is_trader'] != 1) unset($where['is_trader']); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); diff --git a/app/controller/merchant/store/StoreImport.php b/app/controller/merchant/store/StoreImport.php index 4eb82a7e..e0bcfac6 100644 --- a/app/controller/merchant/store/StoreImport.php +++ b/app/controller/merchant/store/StoreImport.php @@ -87,7 +87,7 @@ class StoreImport extends BaseController $file = $this->request->file('file'); if (!$file) return app('json')->fail('请上传EXCEL文件'); $file = is_array($file) ? $file[0] : $file; - validate(["file|文件" => ['fileExt' => 'xlsx',]])->check(['file' => $file]); + validate(["file|文件" => ['fileExt' => 'xlsx',]],['请上传xlsx后缀的文件'])->check(['file' => $file]); $upload = UploadService::create(1); $ret = $upload->to('excel')->move('file'); if ($ret === false) return app('json')->fail($upload->getError()); From 11b03d78802bfa379f4625ce443d60401f6032e0 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 13:35:47 +0800 Subject: [PATCH 02/14] fixed --- app/controller/api/dataview/Order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controller/api/dataview/Order.php b/app/controller/api/dataview/Order.php index fd838855..86b8b55a 100755 --- a/app/controller/api/dataview/Order.php +++ b/app/controller/api/dataview/Order.php @@ -577,7 +577,7 @@ class Order extends BaseController unset($where['date']); $status = $where['status']; unset($where['status']); - $query = $dao->search($where, null)->where($repository->getOrderType($status))>with([ + $query = $dao->search($where, null)->where($repository->getOrderType($status))->with([ 'orderProduct', 'merchant' => function ($query) { return $query->field('mer_id,mer_name,is_trader'); @@ -588,7 +588,7 @@ class Order extends BaseController 'user' => function ($query) { $query->field('uid,nickname,avatar'); }, - ]);; + ]); $count = $query->count(); $list = $query->page($page, $limit)->select(); return app('json')->success(compact('count', 'list')); From d126b7991f122e726a825d0c264158fea7daaefa Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 13:36:46 +0800 Subject: [PATCH 03/14] =?UTF-8?q?add=20=E5=95=86=E6=88=B7=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=BB=9F=E8=AE=A1=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Merchant.php | 45 ++++++++++++++++++++++++ route/api.php | 1 + 2 files changed, 46 insertions(+) diff --git a/app/controller/api/dataview/Merchant.php b/app/controller/api/dataview/Merchant.php index d8cbc481..88315b6a 100644 --- a/app/controller/api/dataview/Merchant.php +++ b/app/controller/api/dataview/Merchant.php @@ -2,9 +2,13 @@ namespace app\controller\api\dataview; +use app\common\repositories\store\order\StoreOrderRepository; +use app\common\repositories\user\UserRelationRepository; +use app\common\repositories\user\UserVisitRepository; use crmeb\basic\BaseController; use app\common\repositories\system\merchant\MerchantRepository as repository; use think\App; +use think\Db; use think\exception\ValidateException; class Merchant extends BaseController @@ -37,4 +41,45 @@ class Merchant extends BaseController $where = $this->request->params([ 'status', 'statusTag', 'is_trader', 'category_id', 'type_id', 'area_id', 'street_id']); return app('json')->success($this->repository->lst($where, $page, $limit)); } + + // 商户统计 + public function merchantCountMain() + { + $merId = $this->request->param('mer_id'); + $today = $this->mainGroup('today', $merId); + $yesterday = $this->mainGroup('yesterday', $merId); + $lastWeek = $this->mainGroup(date('Y-m-d', strtotime('- 7day')), $merId); + $lastWeekRate = []; + foreach ($lastWeek as $k => $item) { + if ($item == $today[$k]) + $lastWeekRate[$k] = 0; + else if ($item == 0) + $lastWeekRate[$k] = $today[$k]; + else if ($today[$k] == 0) + $lastWeekRate[$k] = -$item; + else + $lastWeekRate[$k] = (float)bcdiv(bcsub($today[$k], $item, 4), $item, 4); + } + $day = date('Y-m-d'); + return app('json')->success(compact('today', 'yesterday', 'lastWeekRate', 'day')); + } + + public function mainGroup($date, $merId) + { + $userVisitRepository = app()->make(UserVisitRepository::class); + $repository = app()->make(StoreOrderRepository::class); + $relationRepository = app()->make(UserRelationRepository::class); + + $payPrice = (float)$repository->dayOrderPrice($date, $merId); + $payUser = (float)$repository->dayOrderUserNum($date, $merId); + $visitNum = (float)$userVisitRepository->dateVisitUserNum($date, $merId); + $likeStore = (float)$relationRepository->dayLikeStore($date, $merId); + $productNum = \think\facade\Db::name('store_product')->alias('p')->field('count(p.product_id) as think_count') + ->join('merchant m', 'm.mer_id = p.mer_id') + ->whereTime('p.create_time', '<=', $date) + ->where('m.mer_id', $merId) + ->count(); + // Db::name('store_product')->where('mer_id', $merId)->count(); + return compact('productNum','payPrice', 'payUser', 'visitNum', 'likeStore'); + } } \ No newline at end of file diff --git a/route/api.php b/route/api.php index 38f63fcb..f61f3a21 100644 --- a/route/api.php +++ b/route/api.php @@ -756,6 +756,7 @@ Route::group('api/', function () { // api.dataview.Merchant Route::get('merchant_list', 'Merchant/merchantList'); + Route::get('merchant_count_main', 'Merchant/merchantCountMain'); // api.dataview.Finance Route::get('withdraw_list', 'Finance/withdrawList'); From e4308834d5eff414fecde5341106b73298844b05 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 14:37:49 +0800 Subject: [PATCH 04/14] =?UTF-8?q?fixed=20=E9=A6=96=E9=A1=B5=20=E5=9C=B0?= =?UTF-8?q?=E5=8C=BA=E5=BA=97=E9=93=BA=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controller/api/dataview/User.php b/app/controller/api/dataview/User.php index aef30ed0..684075c4 100644 --- a/app/controller/api/dataview/User.php +++ b/app/controller/api/dataview/User.php @@ -73,7 +73,7 @@ class User extends BaseController $merchantTotalCount = 0; // 查镇的用户统计不需要查店铺数 - if ($this->streetCode != '') { + if ($this->streetCode == '') { // 该地区下所有乡镇 $geoStreetList = Db::name('geo_street')->where('area_code',$this->areaCode)->select()->toArray(); From 2d23b227a6ddc5b153c2d1d33246a21bc8edda43 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 15:08:17 +0800 Subject: [PATCH 05/14] =?UTF-8?q?add=20=E5=95=86=E6=88=B7-=E5=95=86?= =?UTF-8?q?=E5=93=81=E9=94=80=E5=94=AE=E6=8E=92=E8=A1=8C=EF=BC=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=AE=BF=E5=AE=A2=E6=8E=92=E8=A1=8C=EF=BC=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=8A=A0=E8=B4=AD=E6=8E=92=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Merchant.php | 70 ++++++++++++++++++++++++ route/api.php | 3 + 2 files changed, 73 insertions(+) diff --git a/app/controller/api/dataview/Merchant.php b/app/controller/api/dataview/Merchant.php index 88315b6a..95b96472 100644 --- a/app/controller/api/dataview/Merchant.php +++ b/app/controller/api/dataview/Merchant.php @@ -2,7 +2,12 @@ namespace app\controller\api\dataview; +use app\common\model\store\order\StoreOrderProduct; +use app\common\model\store\product\Product as model; +use app\common\model\user\UserVisit; +use app\common\repositories\store\order\StoreOrderProductRepository; use app\common\repositories\store\order\StoreOrderRepository; +use app\common\repositories\store\product\ProductRepository; use app\common\repositories\user\UserRelationRepository; use app\common\repositories\user\UserVisitRepository; use crmeb\basic\BaseController; @@ -10,6 +15,7 @@ use app\common\repositories\system\merchant\MerchantRepository as repository; use think\App; use think\Db; use think\exception\ValidateException; +use think\facade\Cache; class Merchant extends BaseController { @@ -82,4 +88,68 @@ class Merchant extends BaseController // Db::name('store_product')->where('mer_id', $merId)->count(); return compact('productNum','payPrice', 'payUser', 'visitNum', 'likeStore'); } + + public function merchantProductRanking(StoreOrderProductRepository $repository) + { + $startDate = $this->request->param('start_date'); + $endDate = $this->request->param('end_date'); + $merId = $this->request->param('mer_id'); + $res = Cache::store('file')->remember(self::class . '@merchantProductRanking' . $merId. $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) { + $list = StoreOrderProduct::getDB()->alias('A')->leftJoin('StoreOrder B', 'A.order_id = B.order_id') + ->field(\think\facade\Db::raw('sum(A.product_num) as total,A.product_id,cart_info')) + ->whereBetweenTime('B.pay_time', $startDate, $endDate) + ->where('B.mer_id', $merId) + ->where('B.paid', 1)->group('A.product_id')->limit(30)->order('total DESC')->select(); + $totalCount = 0; + foreach ($list as $item) { + $totalCount += $item['total']; + } + return compact('list', 'totalCount'); + }, 2000 + random_int(600, 1200)); + return app('json')->success($res); + } + + public function merchantProductVisit(UserVisitRepository $repository) + { + $startDate = $this->request->param('start_date'); + $endDate = $this->request->param('end_date'); + $merId = $this->request->param('mer_id'); + $res = Cache::store('file')->remember(self::class . '@merchantProductVisit' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) { + $list = UserVisit::getDB()->alias('A')->join('StoreProduct B', 'A.type_id = B.product_id') + ->join('Merchant C', 'C.mer_id = B.mer_id') + ->field(\think\facade\Db::raw('count(A.type_id) as total,B.image,B.store_name')) + ->whereBetweenTime('A.create_time', $startDate, $endDate) + ->where('A.type', 'product')->where('B.mer_id', $merId)->group('A.type_id')->order('total DESC') + ->limit(30)->select(); + $totalCount = 0; + foreach ($list as $item) { + $totalCount += $item['total']; + } + return compact('list', 'totalCount'); + }, 2000 + random_int(600, 1200)); + return app('json')->success($res); + } + + public function merchantProductCart(ProductRepository $repository) + { + $startDate = $this->request->param('start_date'); + $endDate = $this->request->param('end_date'); + $merId = $this->request->param('mer_id'); + $res = Cache::store('file')->remember(self::class . '@merchantProductCart' . $merId . $startDate. $endDate, function () use ($repository, $startDate, $endDate, $merId) { + $list = \app\common\model\store\product\Product::getDB()->alias('A')->leftJoin('StoreCart B', 'A.product_id = B.product_id') + ->field(\think\facade\Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image')) + ->whereBetweenTime('B.create_time', $startDate, $endDate) + ->where('A.mer_id', $merId) + ->where('B.product_type', 0)->where('B.is_pay', 0)->where('B.is_del', 0) + ->where('B.is_new', 0)->where('B.is_fail', 0)->group('A.product_id')->limit(30)->order('total DESC')->select(); + $totalCount = 0; + foreach ($list as $item) { + $totalCount += $item['total']; + } + return compact('list', 'totalCount'); + }, 2000 + random_int(600, 1200)); + + return app('json')->success($res); + } + } \ No newline at end of file diff --git a/route/api.php b/route/api.php index f61f3a21..944abc26 100644 --- a/route/api.php +++ b/route/api.php @@ -757,6 +757,9 @@ Route::group('api/', function () { // api.dataview.Merchant Route::get('merchant_list', 'Merchant/merchantList'); Route::get('merchant_count_main', 'Merchant/merchantCountMain'); + Route::get('merchant_product_ranking', 'Merchant/merchantProductRanking'); + Route::get('merchant_product_visit', 'Merchant/merchantProductVisit'); + Route::get('merchant_product_cart', 'Merchant/merchantProductCart'); // api.dataview.Finance Route::get('withdraw_list', 'Finance/withdrawList'); From b04bca9d80984ced47efd30e237159e437e34f9c Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 15:49:18 +0800 Subject: [PATCH 06/14] =?UTF-8?q?add=20=E9=95=87=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Order.php | 65 +++++++++++++++++++++++++++ route/api.php | 1 + 2 files changed, 66 insertions(+) diff --git a/app/controller/api/dataview/Order.php b/app/controller/api/dataview/Order.php index 86b8b55a..319feac2 100755 --- a/app/controller/api/dataview/Order.php +++ b/app/controller/api/dataview/Order.php @@ -4,6 +4,7 @@ namespace app\controller\api\dataview; use app\common\dao\store\order\StoreOrderDao; use app\common\dao\store\order\StoreRefundOrderDao; +use app\common\model\store\order\StoreOrder; use app\common\repositories\BaseRepository; use app\common\repositories\store\order\StoreOrderRepository; use app\common\repositories\store\order\StoreRefundOrderRepository; @@ -607,4 +608,68 @@ class Order extends BaseController return app('json')->success($data); } + public function orderUserNumCount() + { + // 订单数 + $orderNum = $this->dayOrderNum('today'); + + $yesterdayNum = $this->dayOrderNum('yesterday'); + $monthOrderNum = $this->dayOrderNum(date('Y/m/d', strtotime('first day of')) . ' 00:00:00' . '-' . date('Y/m/d H:i:s')); + + $date = date('Y/m/01 00:00:00', strtotime('last Month')) . '-' . date('Y/m/d 00:00:00', strtotime('-1 day', strtotime('first day of'))); + $beforeOrderNum = $this->dayOrderNum($date); + + $monthOrderNumRate = $this->getRate($beforeOrderNum, $monthOrderNum); + $orderNumRate = $this->getRate($yesterdayNum, $orderNum); + + + // 支付数 + $orderPayNum = $this->dayOrderUserNum('today'); + $yesterdayNum = $this->dayOrderUserNum('yesterday'); + $monthOrderPayNum = $this->dayOrderUserNum(date('Y/m/d', strtotime('first day of')) . ' 00:00:00' . '-' . date('Y/m/d H:i:s')); + + $date = gmdate('Y/m/01 00:00:00', strtotime('last Month')) . '-' . date('Y/m/d 00:00:00', strtotime('-1 day', strtotime('first day of'))); + $beforeOrderNum = $this->dayOrderUserNum($date); + + $monthOrderPayRate = $this->getRate($beforeOrderNum, $monthOrderNum); + $orderOrderPayRate = $this->getRate($yesterdayNum, $orderNum); + + return app('json')->success(compact('orderNum', 'monthOrderNum', 'monthOrderNumRate', 'orderNumRate', 'orderPayNum', 'monthOrderPayNum', 'monthOrderPayRate', 'orderOrderPayRate')); + } + + public function dayOrderNum($day) + { + return StoreOrder::getDB()->alias('o') + ->join('product_order_log pog', 'o.order_id=pog.order_id') + ->where('o.paid', 1) + ->when($day, function ($query, $day) { + getModelTime($query, $day, 'o.pay_time'); + }) + ->where('pog.street_code', $this->streetCode) + ->count(); + } + + public function dayOrderUserNum($day, $merId = null) + { + return StoreOrder::getDB()->alias('o') + ->join('product_order_log pog', 'o.order_id=pog.order_id') + ->where('o.paid', 1) + ->when($day, function ($query, $day) { + getModelTime($query, $day, 'o.pay_time'); + }) + ->where('pog.street_code', $this->streetCode)->group('o.uid')->count(); + } + + protected function getRate($last, $today, $scale = 2) + { + if ($last == $today) + return 0; + else if ($last == 0) + return $today; + else if ($today == 0) + return -$last; + else + return (float)bcdiv(bcsub($today, $last, $scale), $last, $scale); + } + } \ No newline at end of file diff --git a/route/api.php b/route/api.php index 944abc26..9697bb20 100644 --- a/route/api.php +++ b/route/api.php @@ -742,6 +742,7 @@ Route::group('api/', function () { Route::get('take_order_list', 'Order/takeOrderList'); Route::get('take_order_count_title', 'Order/takeOrderCountTitle'); Route::get('street_currday_order_count', 'Order/streetCurrDayOrderCount'); + Route::get('order_user_num_count', 'Order/orderUserNumCount'); // api.dataview.User Route::get('user_merchat_count', 'User/userMerchantCount'); From b10c7ad25b2ee14d966c775cde9616d8f4b40217 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 16:50:36 +0800 Subject: [PATCH 07/14] =?UTF-8?q?update=20=E5=95=86=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=BF=94=E5=9B=9E=E5=95=86=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Login.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controller/api/dataview/Login.php b/app/controller/api/dataview/Login.php index 7d9b0aa7..2cf657b2 100644 --- a/app/controller/api/dataview/Login.php +++ b/app/controller/api/dataview/Login.php @@ -56,6 +56,7 @@ class Login extends BaseController $msg = '账号或密码错误'; throw new ValidateException($msg); } + $user['merchant'] = Db::name('merchant')->where('uid', $user['uid'])->find(); $expire = time()+ 3600 * 24; $token = md5($expire); // 缓存token From 2b61ed16f080b2447b4d86db0301ae07980f6f66 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 16:58:00 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E5=8C=BA=E5=8E=BF=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=99=BB=E5=BD=95=E5=95=86=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Merchant.php | 13 ++++++++++++- route/api.php | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/controller/api/dataview/Merchant.php b/app/controller/api/dataview/Merchant.php index 95b96472..3a0f666c 100644 --- a/app/controller/api/dataview/Merchant.php +++ b/app/controller/api/dataview/Merchant.php @@ -13,7 +13,7 @@ use app\common\repositories\user\UserVisitRepository; use crmeb\basic\BaseController; use app\common\repositories\system\merchant\MerchantRepository as repository; use think\App; -use think\Db; +use think\facade\Db; use think\exception\ValidateException; use think\facade\Cache; @@ -152,4 +152,15 @@ class Merchant extends BaseController return app('json')->success($res); } + public function merchant() + { + $merId = $this->request->param('mer_id'); + $merchant = Db::name('merchant')->where('mer_id', $merId)->find(); + $expire = time()+ 3600 * 24; + $token = md5($expire); + // 缓存token + Cache::set($token.'_merchant_'.$merchant['uid'], $expire); + return app('json')->success(compact('merchant', 'token', 'expire')); + } + } \ No newline at end of file diff --git a/route/api.php b/route/api.php index 9697bb20..48c5d40e 100644 --- a/route/api.php +++ b/route/api.php @@ -761,6 +761,7 @@ Route::group('api/', function () { Route::get('merchant_product_ranking', 'Merchant/merchantProductRanking'); Route::get('merchant_product_visit', 'Merchant/merchantProductVisit'); Route::get('merchant_product_cart', 'Merchant/merchantProductCart'); + Route::get('merchant', 'Merchant/merchant'); // api.dataview.Finance Route::get('withdraw_list', 'Finance/withdrawList'); From a5b83d5103d12afee5c175b06c06260e7bef98e5 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 16:59:08 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E5=8C=BA=E5=8E=BF=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=99=BB=E5=BD=95=E5=95=86=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Merchant.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/controller/api/dataview/Merchant.php b/app/controller/api/dataview/Merchant.php index 3a0f666c..4e6b353f 100644 --- a/app/controller/api/dataview/Merchant.php +++ b/app/controller/api/dataview/Merchant.php @@ -156,11 +156,7 @@ class Merchant extends BaseController { $merId = $this->request->param('mer_id'); $merchant = Db::name('merchant')->where('mer_id', $merId)->find(); - $expire = time()+ 3600 * 24; - $token = md5($expire); - // 缓存token - Cache::set($token.'_merchant_'.$merchant['uid'], $expire); - return app('json')->success(compact('merchant', 'token', 'expire')); + return app('json')->success(compact('merchant')); } } \ No newline at end of file From 9a5cda0dbacca11e746dd0385fab90f5afbc132f Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 17:57:57 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E9=85=8D=E9=80=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Logistics.php | 24 +++++++++++++++++++++++ route/api.php | 1 + 2 files changed, 25 insertions(+) diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index dd74bb53..5435f8ef 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -188,4 +188,28 @@ class Logistics extends BaseController $latestTenOrder = Db::connect('logistics')->name('logistics')->field('receiver_address')->where(['status'=>1, 'courier_id' => $courierId])->order('id', 'desc')->limit(10)->select()->toArray(); return app('json')->success(compact('latestOrder', 'latestTenOrder')); } + + public function logisticsList() + { + $type = $this->request->param('type'); + $courierId = $this->request->param('courier_id'); + $list = []; + $count = 0; + if ($type == 1) { + // 待取货 + $list = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->select(); + $count = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->count(); + } + if ($type == 2) { + // 配送中 + $list = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->select(); + $count = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->count(); + } + if ($type == 3) { + // 已完成 + $list = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->select(); + $count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->count(); + } + return app('json')->success(compact('count', 'list')); + } } \ No newline at end of file diff --git a/route/api.php b/route/api.php index 48c5d40e..79264e97 100644 --- a/route/api.php +++ b/route/api.php @@ -727,6 +727,7 @@ Route::group('api/', function () { Route::get('latest_logistics', 'Logistics/latestLogistics'); Route::get('logistics_count', 'Logistics/logisticsCount'); Route::get('logistics_map_count', 'Logistics/logisticsMapCount'); + Route::get('logistics_list', 'Logistics/logisticsList'); /**---------------------物流溯源监控大屏api---------------------- end **/ From 6c7d09acd8be9c3611e23bb46746e1a00cbd5a93 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 18:14:39 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E9=85=8D=E9=80=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Logistics.php | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index 5435f8ef..e8811b1b 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -193,22 +193,36 @@ class Logistics extends BaseController { $type = $this->request->param('type'); $courierId = $this->request->param('courier_id'); + $startTime = $this->request->param('start_time'); + $endTime = $this->request->param('end_time'); $list = []; $count = 0; if ($type == 1) { // 待取货 - $list = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->select(); - $count = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->count(); + $list = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ + $query->whereBetween('qh_time', [$startTime, $endTime]); + })->select(); + $count = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ + $query->whereBetween('qh_time', [$startTime, $endTime]); + })->count(); } if ($type == 2) { // 配送中 - $list = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->select(); - $count = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->count(); + $list = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ + $query->whereBetween('create_time', [$startTime, $endTime]); + })->select(); + $count = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ + $query->whereBetween('create_time', [$startTime, $endTime]); + })->count(); } if ($type == 3) { // 已完成 - $list = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->select(); - $count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->count(); + $list = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ + $query->whereBetween('ps_time', [$startTime, $endTime]); + })->select(); + $count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ + $query->whereBetween('ps_time', [$startTime, $endTime]); + })->count(); } return app('json')->success(compact('count', 'list')); } From b97d9878b09219373c1c2693f4cfe1b7dce7db95 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 9 Dec 2023 18:17:35 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E9=85=8D=E9=80=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Logistics.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index e8811b1b..7bb44361 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -220,9 +220,10 @@ class Logistics extends BaseController $list = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ $query->whereBetween('ps_time', [$startTime, $endTime]); })->select(); + $count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->when($startTime&&$endTime,function ($query) use ($startTime, $endTime){ $query->whereBetween('ps_time', [$startTime, $endTime]); - })->count(); + })->count(); } return app('json')->success(compact('count', 'list')); } From df86becb41411cb171f7c6a85001245d6c0a8c9c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 11 Dec 2023 10:09:25 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E9=93=BE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/product/SpuDao.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index d8cb201d..a07990af 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -29,11 +29,15 @@ class SpuDao extends BaseDao { $order = 'P.sort DESC'; if(isset($where['order'])){ - if(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])){ + if(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales','procure_price_asc','procure_price_desc'])){ if ($where['order'] == 'price_asc') { $order = 'S.price ASC'; } else if ($where['order'] == 'price_desc') { $order = 'S.price DESC'; + } else if ($where['order'] == 'procure_price_asc') { + $order = 'S.procure_price ASC'; + } else if ($where['order'] == 'procure_price_desc') { + $order = 'S.procure_price DESC'; } else { $order = 'P.'.$where['order'] . ' DESC'; } From a9fabbaa95ea211b924117ef49211a23622781ed Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 11 Dec 2023 10:44:42 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/product/SpuDao.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index a07990af..378e4b1c 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -29,16 +29,12 @@ class SpuDao extends BaseDao { $order = 'P.sort DESC'; if(isset($where['order'])){ - if(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales','procure_price_asc','procure_price_desc'])){ + if(in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])){ if ($where['order'] == 'price_asc') { $order = 'S.price ASC'; } else if ($where['order'] == 'price_desc') { $order = 'S.price DESC'; - } else if ($where['order'] == 'procure_price_asc') { - $order = 'S.procure_price ASC'; - } else if ($where['order'] == 'procure_price_desc') { - $order = 'S.procure_price DESC'; - } else { + }else { $order = 'P.'.$where['order'] . ' DESC'; } }elseif($where['order'] == 'star'){