From 955e28a4c6994ef29c6a71fa6f939536f08d1ed6 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 15:14:05 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index bc82f94b4..f757b8f00 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -30,11 +30,11 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li */ public function setSearch(): array { - $name=$this->request->get('name',''); + $name=$this->request->get('store_name',''); // $where['%pipe_like%'] =['name'=>'store_name|bar_code']; if($name){ if(preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){ - $where['%like%']=['store_name']; + $where['%like%']=['store_name'=>'store_name']; }else{ $where['=']=['bar_code','cate_id']; } From 664d24091cd3d126c6b80d5cff4a7d844c763bff Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 15:22:43 +0800 Subject: [PATCH 02/21] =?UTF-8?q?add=E6=A0=B8=E9=94=80=E7=A0=81=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f41874a8e..6b5d38892 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -23,6 +23,8 @@ use app\common\model\system_store\SystemStoreStaff; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserShip; +use Picqer\Barcode\BarcodeGeneratorJPG; +use Picqer\Barcode\BarcodeGeneratorPNG; use support\exception\BusinessException; use support\Log; use taoser\exception\ValidateException; @@ -227,7 +229,12 @@ class OrderLogic extends BaseLogic if ($params['shipping_type'] == 2) { $_order['status'] = 1; } - + //生成核销码 + $generator = new BarcodeGeneratorPNG(); + $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); + $savePath = 'public/image/barcode/'.time().'.png'; + file_put_contents($savePath, $barcode); + $_order['verify_img'] = $savePath; Db::startTrans(); try { $order = StoreOrder::create($_order); From 14c588718a508fb2f37bcd4fe63ee07233964975 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 15:54:41 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E6=A0=B8=E9=94=80=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/OrderList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index e779a853d..6db6b45a8 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -52,7 +52,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface ->select() ->each(function ($item) { $item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id']) - ->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select() + ->field('product_id,cart_num,verify_code,verify_img,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select() ->each(function ($v) use ($item) { $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->find(); $v['store_name'] = $find['store_name']; From b5d860a4c0061da8099fa2fa4d118749817cd96e Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 16:05:49 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 6b5d38892..3e01812db 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -232,9 +232,10 @@ class OrderLogic extends BaseLogic //生成核销码 $generator = new BarcodeGeneratorPNG(); $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); - $savePath = 'public/image/barcode/'.time().'.png'; + $findPath = '/image/barcode/'.time().'.png'; + $savePath = 'public'.$findPath; file_put_contents($savePath, $barcode); - $_order['verify_img'] = $savePath; + $_order['verify_img'] = $findPath; Db::startTrans(); try { $order = StoreOrder::create($_order); From bd925bed5bb354ada88a2cd534fddff15136f325 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 16:07:09 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/OrderList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index 6db6b45a8..e779a853d 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -52,7 +52,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface ->select() ->each(function ($item) { $item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id']) - ->field('product_id,cart_num,verify_code,verify_img,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select() + ->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select() ->each(function ($v) use ($item) { $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->find(); $v['store_name'] = $find['store_name']; From b818d716f45d6d795e805ea34fb413c2a37fff17 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 12 Jun 2024 16:11:53 +0800 Subject: [PATCH 06/21] =?UTF-8?q?feat(WorkbenchLogic):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B4=AD=E7=89=A9=E8=BD=A6=E7=BB=9F=E8=AE=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/WorkbenchLogic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/WorkbenchLogic.php b/app/admin/logic/WorkbenchLogic.php index 8bf3df71d..f8a7d2f04 100644 --- a/app/admin/logic/WorkbenchLogic.php +++ b/app/admin/logic/WorkbenchLogic.php @@ -16,6 +16,7 @@ namespace app\admin\logic; use app\common\logic\BaseLogic; +use app\common\model\order\Cart; use app\common\model\store_order\StoreOrder; use app\common\model\store_visit\StoreVisit; use app\common\service\ConfigService; @@ -54,7 +55,7 @@ class WorkbenchLogic extends BaseLogic { $browse=StoreVisit::where($where)->count(); $user=0; - $cart=0; + $cart=Cart::where($where)->where('is_fail',0)->sum('cart_num'); $order=StoreOrder::where($where)->count(); $pay=StoreOrder::where($where)->where('paid',1)->count(); $payPrice=StoreOrder::where($where)->where('paid',1)->count('pay_price'); From 8c7684477f51d08e3a17dd71fe1ba5d28e47c432 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 16:39:26 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/OrderList.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index e779a853d..f1ba4dd47 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -54,7 +54,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface $item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id']) ->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select() ->each(function ($v) use ($item) { - $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->find(); + $find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find(); $v['store_name'] = $find['store_name']; $v['image'] = $find['image']; $v['price'] = $find['price']; @@ -67,6 +67,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface if ($item['pay_time']) { $item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']); } + if($item['verify_img']){ + $item['verify_img'] = 'https://'.$this->request->host(true).$item['verify_img']; + } }) ->toArray(); From baa01821e206d901e6952266bd2a33bbdde739eb Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 16:59:33 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 3 ++- app/api/logic/order/OrderLogic.php | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 894f1833a..0ee0d5be4 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -367,7 +367,8 @@ class OrderController extends BaseApiController 'id' => $order_id, 'uid' => $this->userId, ]; - $order = OrderLogic::detail($where); + $url = 'https://'.$this->request->host(true); + $order = OrderLogic::detail($where,$url); if ($order) { return $this->data($order); } else { diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 3e01812db..58003aeb1 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -360,7 +360,7 @@ class OrderLogic extends BaseLogic } - public static function detail($params): array + public static function detail($params,$url=''): array { $find = StoreOrder::where($params)->findOrEmpty()->toArray(); if ($find) { @@ -378,6 +378,10 @@ class OrderLogic extends BaseLogic $store = SystemStore::where('id', $find['store_id'])->field('id,name,phone,address,detailed_address')->find(); $find['store_info'] = $store; + + if($find['verify_img']){ + $find['verify_img'] = 'https://'.$url.$find['verify_img']; + } } return $find; } From acb37149ca928194f354ffb09ec18f5f204ae78c Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 17:09:56 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 58003aeb1..d7e64fbcb 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -380,7 +380,7 @@ class OrderLogic extends BaseLogic $find['store_info'] = $store; if($find['verify_img']){ - $find['verify_img'] = 'https://'.$url.$find['verify_img']; + $find['verify_img'] = $url.$find['verify_img']; } } return $find; From ac86bf341f551496f5e440790b3708eb01585c2b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 12 Jun 2024 18:16:53 +0800 Subject: [PATCH 10/21] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8F=B0=E6=8E=A7=E5=88=B6=E5=99=A8=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=95=86=E5=93=81=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E9=87=8F=E3=80=81=E6=94=AF=E4=BB=98=E9=87=91=E9=A2=9D=E5=92=8C?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E9=87=91=E9=A2=9D=E7=9A=84API=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=9B=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=BD=93=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=87=91=E9=A2=9D=E4=B8=BA0=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E8=BD=AC=E5=8C=96=E7=8E=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84bug=EF=BC=9B=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E4=BA=86=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BD=BF=E5=85=B6=E6=9B=B4?= =?UTF-8?q?=E5=8A=A0=E7=AE=80=E6=B4=81=E6=98=93=E8=AF=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/WorkbenchController.php | 456 ++----------------- app/admin/logic/WorkbenchLogic.php | 188 +++++++- 2 files changed, 216 insertions(+), 428 deletions(-) diff --git a/app/admin/controller/WorkbenchController.php b/app/admin/controller/WorkbenchController.php index fdf23eb00..3ad24544d 100644 --- a/app/admin/controller/WorkbenchController.php +++ b/app/admin/controller/WorkbenchController.php @@ -15,6 +15,8 @@ namespace app\admin\controller; use app\admin\logic\WorkbenchLogic; +use DateInterval; +use DateTime; /** * 工作台 @@ -232,16 +234,16 @@ class WorkbenchController extends BaseAdminController */ public function get_basic() { - $startTime=$this->request->get('start_time');//开始时间 - $endTime=$this->request->get('end_time');//结束时间 - if(empty($startTime)){//如果没有传开始时间,则默认获取最近7天的数据 - $startTime=strtotime(date('Y-m-d')); - $endTime=$startTime+86400; + $startTime = $this->request->get('start_time'); //开始时间 + $endTime = $this->request->get('end_time'); //结束时间 + if (empty($startTime)) { //如果没有传开始时间,则默认获取最近7天的数据 + $startTime = strtotime(date('Y-m-d')); + $endTime = $startTime + 86400; } - $where=[ - ['create_time','between',[$startTime,$endTime]] + $where = [ + ['create_time', 'between', [$startTime, $endTime]] ]; - $data=WorkbenchLogic::get_basic($where); + $data = WorkbenchLogic::get_basic($where); return $this->data($data); } @@ -250,186 +252,41 @@ class WorkbenchController extends BaseAdminController */ public function get_trend() { + $dates = []; + $today = new DateTime(); + $thirtyDaysAgo = new DateTime($today->format('Y-m-d')); + $thirtyDaysAgo->modify('-30 days'); + + for ($i = 0; $i < 31; $i++) { + $date = new DateTime($thirtyDaysAgo->format('Y-m-d')); + $date->modify('+' . $i . ' days'); + $dates[] = $date->format('Y-m-d'); + } $data = [ - "xAxis" => [ - "2024-05-06", - "2024-05-07", - "2024-05-08", - "2024-05-09", - "2024-05-10", - "2024-05-11", - "2024-05-12", - "2024-05-13", - "2024-05-14", - "2024-05-15", - "2024-05-16", - "2024-05-17", - "2024-05-18", - "2024-05-19", - "2024-05-20", - "2024-05-21", - "2024-05-22", - "2024-05-23", - "2024-05-24", - "2024-05-25", - "2024-05-26", - "2024-05-27", - "2024-05-28", - "2024-05-29", - "2024-05-30", - "2024-05-31", - "2024-06-01", - "2024-06-02", - "2024-06-03", - "2024-06-04" - ], + "xAxis" => $dates, "series" => [ [ "name" => "商品浏览量", - "data" => [ - 131, - 275, - 137, - 100, - 221, - 76, - 64, - 83, - 161, - 125, - 120, - 971, - 169, - 84, - 68, - 153, - 470, - 1310, - 621, - 827, - 113, - 595, - 485, - 484, - 535, - 227, - 714, - 144, - 1159, - 731 - ], + "data" => WorkbenchLogic::store_visit_count($dates), "type" => "line", "smooth" => "true", "yAxisIndex" => 1 ], [ "name" => "商品访客量", - "data" => [ - 21, - 26, - 26, - 32, - 26, - 14, - 6, - 13, - 17, - 26, - 24, - 18, - 7, - 6, - 23, - 23, - 23, - 33, - 29, - 61, - 25, - 103, - 55, - 45, - 45, - 30, - 28, - 25, - 41, - 21 - ], + "data" => WorkbenchLogic::store_visit_user($dates), "type" => "line", "smooth" => "true", "yAxisIndex" => 1 ], [ "name" => "支付金额", - "data" => [ - 53.6, - 0.25, - 1231.84, - 0.8, - 0, - 10, - 0, - 0.66, - 7919.2, - 0, - 8040.38, - 0.01, - 0, - 0, - 10.49, - 0, - 0.01, - 599.01, - 100100, - 908.81, - 0, - 1887.06, - 588, - 184.3, - 665.11, - 0, - 0, - 219.2, - 24.09, - 16.99 - ], + "data" => WorkbenchLogic::payPrice($dates), "type" => "bar" ], [ "name" => "退款金额", - "data" => [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 730.8, - 49, - 219, - 0, - 1323.01, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ], + "data" => WorkbenchLogic::refundPrice($dates), "type" => "bar" ] ] @@ -462,44 +319,6 @@ class WorkbenchController extends BaseAdminController "stock" => 16777213, "is_show" => 1 ], - [ - "product_id" => 1670, - "visit" => "949", - "user" => 161, - "cart" => "20", - "orders" => "47", - "pay" => "34", - "price" => "4347.45", - "cost" => "0.00", - "profit" => "1.00", - "collect" => "2", - "changes" => "0.13", - "repeats" => "0.14", - "store_name" => "ECOK2024年春秋季美式复古美拉德风高级感撞色领拉链夹克外套女潮", - "image" => "https://multi-store.crmeb.net/uploads/attach/2024/02/19/5bf089c30da5bdddd815fbf2cba148e6.jpg", - "product_price" => "169.90", - "stock" => 2980, - "is_show" => 1 - ], - [ - "product_id" => 2033, - "visit" => "743", - "user" => 139, - "cart" => "30", - "orders" => "52", - "pay" => "20", - "price" => "3930.50", - "cost" => "0.00", - "profit" => "1.00", - "collect" => "1", - "changes" => "0.04", - "repeats" => "0.50", - "store_name" => "【618抢先购】CT四色眼影盘新色枕边话哑光亮片粉棕彩妆官方正品", - "image" => "https://multi-store.crmeb.net/uploads/attach/2024/05/24/fc63ee052b9dc66bd70a1e013510ded2.jpg", - "product_price" => "490.00", - "stock" => 139994, - "is_show" => 1 - ], ]; return $this->data($data); } @@ -798,6 +617,23 @@ class WorkbenchController extends BaseAdminController //当日订单金额 public function top_trade() { + $dates = []; + $today = new DateTime(); + + $thirtyDaysAgo = new DateTime($today->format('Y-m-d')); + $thirtyDaysAgo->modify('-30 days'); + + for ($i = 0; $i < 31; $i++) { + $date = new DateTime($thirtyDaysAgo->format('Y-m-d')); + $date->modify('+' . $i . ' days'); + $dates[] = $date->format('Y-m-d'); + } + $times = date('Y-m-d'); + $yesterday= date('Y-m-d', strtotime('-1 day')); + $dates_two=[]; + for ($i = 0; $i < 24; $i++) { + $dates_two[]=[$times." ".$i.":00:00",$times." ".$i.":59:59"]; + } $data = [ "left" => [ "name" => "当日订单金额", @@ -829,66 +665,8 @@ class WorkbenchController extends BaseAdminController "24" ], "series" => [ - [ - "money" => 279.47, - "value" => [ - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "4.48", - "257.20", - "0.00", - "16.99", - "0.80", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00" - ] - ], - [ - "money" => 10175.64, - "value" => [ - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.00", - "0.01", - "0.00", - "0.00", - "40.00", - "0.10", - "9938.00", - "0.08", - "30.16", - "0.00", - "0.00", - "0.00", - "163.20", - "4.09", - "0.00", - "0.00" - ] - ] + WorkbenchLogic::day_order_pay_price($dates_two,$times), + WorkbenchLogic::day_order_pay_price($dates_two,$yesterday), ] ], "right" => [ @@ -921,151 +699,13 @@ class WorkbenchController extends BaseAdminController "24" ], "series" => [ - [ - "name" => "今日订单数", - "now_money" => 8, - "last_money" => 13, - "rate" => "-38.46", - "value" => [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 4, - 1, - 0, - 1, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - ], - [ - "name" => "今日支付人数", - "now_money" => 5, - "last_money" => 8, - "rate" => "-37.50", - "value" => [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2, - 1, - 0, - 1, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] - ] + WorkbenchLogic::day_order_count($dates_two,'今日订单数'), + WorkbenchLogic::day_order_user($dates_two,'今日支付人数'), ] ], "month" => [ - [ - "name" => "本月订单数", - "now_money" => 30, - "last_money" => 285, - "rate" => "-89.47", - "value" => [ - "2024-06-01" => 2, - "2024-06-02" => 7, - "2024-06-03" => 13, - "2024-06-04" => 8, - "2024-06-05" => 0, - "2024-06-06" => 0, - "2024-06-07" => 0, - "2024-06-08" => 0, - "2024-06-09" => 0, - "2024-06-10" => 0, - "2024-06-11" => 0, - "2024-06-12" => 0, - "2024-06-13" => 0, - "2024-06-14" => 0, - "2024-06-15" => 0, - "2024-06-16" => 0, - "2024-06-17" => 0, - "2024-06-18" => 0, - "2024-06-19" => 0, - "2024-06-20" => 0, - "2024-06-21" => 0, - "2024-06-22" => 0, - "2024-06-23" => 0, - "2024-06-24" => 0, - "2024-06-25" => 0, - "2024-06-26" => 0, - "2024-06-27" => 0, - "2024-06-28" => 0, - "2024-06-29" => 0, - "2024-06-30" => 0 - ] - ], - [ - "name" => "本月支付人数", - "now_money" => 15, - "last_money" => 79, - "rate" => "-81.01", - "value" => [ - "2024-06-01" => 1, - "2024-06-02" => 4, - "2024-06-03" => 8, - "2024-06-04" => 5, - "2024-06-05" => 0, - "2024-06-06" => 0, - "2024-06-07" => 0, - "2024-06-08" => 0, - "2024-06-09" => 0, - "2024-06-10" => 0, - "2024-06-11" => 0, - "2024-06-12" => 0, - "2024-06-13" => 0, - "2024-06-14" => 0, - "2024-06-15" => 0, - "2024-06-16" => 0, - "2024-06-17" => 0, - "2024-06-18" => 0, - "2024-06-19" => 0, - "2024-06-20" => 0, - "2024-06-21" => 0, - "2024-06-22" => 0, - "2024-06-23" => 0, - "2024-06-24" => 0, - "2024-06-25" => 0, - "2024-06-26" => 0, - "2024-06-27" => 0, - "2024-06-28" => 0, - "2024-06-29" => 0, - "2024-06-30" => 0 - ] - ] + WorkbenchLogic::month_order_count($dates_two,'本月订单数'), + WorkbenchLogic::month_order_count($dates_two,'本月支付人数') ] ] ]; diff --git a/app/admin/logic/WorkbenchLogic.php b/app/admin/logic/WorkbenchLogic.php index f8a7d2f04..f5b85c161 100644 --- a/app/admin/logic/WorkbenchLogic.php +++ b/app/admin/logic/WorkbenchLogic.php @@ -53,27 +53,175 @@ class WorkbenchLogic extends BaseLogic */ public static function get_basic($where) { - $browse=StoreVisit::where($where)->count(); - $user=0; - $cart=Cart::where($where)->where('is_fail',0)->sum('cart_num'); - $order=StoreOrder::where($where)->count(); - $pay=StoreOrder::where($where)->where('paid',1)->count(); - $payPrice=StoreOrder::where($where)->where('paid',1)->count('pay_price'); - $cost=StoreOrder::where($where)->where('paid',1)->sum('cost'); - $refundPrice=StoreOrder::where($where)->where('status','in',[-1,-2])->sum('refund_price'); - $refund=StoreOrder::where($where)->where('status','in',[-1,-2])->count(); - $payPercent=0; + $browse = StoreVisit::where($where)->count(); + $user = 0; + $cart = Cart::where($where)->where('is_fail', 0)->sum('cart_num'); + $order = StoreOrder::where($where)->count(); + $pay = StoreOrder::where($where)->where('paid', 1)->where('refund_status', 0)->count(); + $payPrice = StoreOrder::where($where)->where('paid', 1)->where('refund_status', 0)->sum('pay_price'); + $cost = StoreOrder::where($where)->where('paid', 1)->sum('cost'); + $refundPrice = StoreOrder::where($where)->where('status', 'in', [-1, -2])->sum('refund_price'); + $refund = StoreOrder::where($where)->where('status', 'in', [-1, -2])->count(); + $payPercent = 0; return [ - 'browse'=>['num'=>$browse,'title'=>'浏览量'],//浏览量 - 'user'=>['num'=>$user,'title'=>'访客数'],//访客数 - 'cart'=>['num'=>$cart,'title'=>'加购人数'],//加购人数 - 'order'=>['num'=>$order,'title'=>'订单量'],//订单量 - 'pay'=>['num'=>$pay,'title'=>'支付订单量'],//支付订单量 - 'payPrice'=>['num'=>$payPrice,'title'=>'支付金额'],//支付金额 - 'cost'=>['num'=>$cost,'title'=>'成本'],//成本 - 'refundPrice'=>['num'=>$refundPrice,'title'=>'退款金额'],//退款金额 - 'refund'=>['num'=>$refund,'title'=>'退款订单量'],//退款订单量 - 'payPercent'=>['num'=>$payPercent,'title'=>'支付转化率'],//支付转化率 + 'browse' => ['num' => $browse, 'title' => '浏览量'], //浏览量 + 'user' => ['num' => $user, 'title' => '访客数'], //访客数 + 'cart' => ['num' => $cart, 'title' => '加购人数'], //加购人数 + 'order' => ['num' => $order, 'title' => '订单量'], //订单量 + 'pay' => ['num' => $pay, 'title' => '支付订单量'], //支付订单量 + 'payPrice' => ['num' => $payPrice, 'title' => '支付金额'], //支付金额 + 'cost' => ['num' => $cost, 'title' => '成本'], //成本 + 'refundPrice' => ['num' => $refundPrice, 'title' => '退款金额'], //退款金额 + 'refund' => ['num' => $refund, 'title' => '退款订单量'], //退款订单量 + 'payPercent' => ['num' => $payPercent, 'title' => '支付转化率'], //支付转化率 ]; } + + /** + * 商品浏览量 + */ + public static function store_visit_count($dates) + { + $data = []; + foreach ($dates as $date) { + $data[] = StoreVisit::whereDay('create_time', $date)->cache('store_visit_count_' . $date, 300)->sum('count'); + } + return $data; + } + + /** + * 商品浏览量 + */ + public static function store_visit_user($dates) + { + $data = []; + foreach ($dates as $date) { + $data[] = StoreVisit::whereDay('create_time', $date)->cache('store_visit_user_' . $date, 300)->count('uid'); + } + return $data; + } + /** + * 支付金额 + */ + public static function payPrice($dates) + { + $data = []; + foreach ($dates as $date) { + $data[] = StoreOrder::whereDay('create_time', $date)->cache('payPrice_' . $date, 300)->where('paid', 1)->where('refund_status', 0)->sum('pay_price'); + } + return $data; + } + /** + * 退款金额 + */ + public static function refundPrice($dates) + { + $data = []; + foreach ($dates as $date) { + $data[] = StoreOrder::whereDay('create_time', $date)->where('status', 'in', [-1, -2])->cache('refundPrice_' . $date, 300)->where('paid', 1)->sum('pay_price'); + } + return $data; + } + + /** + * 当日订单金额 + */ + public static function day_order_pay_price($where, $time) + { + $money = StoreOrder::whereDay('create_time', $time)->where('paid', 1)->where('refund_status', 0)->sum('pay_price'); + $data = []; + foreach ($where as $date) { + $data[] = StoreOrder::where('create_time','between', $date)->cache('day_order_pay_price_' . $date[0], 300)->where('paid', 1)->where('refund_status', 0)->sum('pay_price'); + } + + return ['money' => $money, 'value' => $data]; + } + + /** + * 今日订单数 + */ + public static function day_order_count($where,$name) + { + $now_money = StoreOrder::whereDay('create_time')->where('paid', 1)->where('refund_status', 0)->count(); + $last_money = StoreOrder::whereDay('create_time', 'yesterday')->where('paid', 1)->where('refund_status', 0)->count(); + $data = []; + foreach ($where as $date) { + $data[] = StoreOrder::where('create_time','between', $date)->cache('day_order_count' . $date[0], 300)->where('paid', 1)->where('refund_status', 0)->count(); + } + if ($now_money > $last_money) { + if($last_money == 0){ + $rate = bcmul($now_money, '100'); + }else{ + $rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2); + } + } else { + + $rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2); + } + return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data]; + } + + /** + * 今日支付人数 + */ + public static function day_order_user($where,$name) + { + $now_money = StoreOrder::whereDay('create_time')->where('paid', 1)->where('refund_status', 0)->count('uid'); + $last_money = StoreOrder::whereDay('create_time', 'yesterday')->where('paid', 1)->where('refund_status', 0)->count('uid'); + $data = []; + foreach ($where as $date) { + $data[] = StoreOrder::where('create_time','between', $date)->cache('day_order_count' . $date[0], 300)->where('paid', 1)->where('refund_status', 0)->count('uid'); + } + if ($now_money > $last_money) { + if($last_money == 0){ + $rate = bcmul($now_money, '100'); + }else{ + $rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2); + } + } else { + + $rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2); + } + return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data]; + } + /** + * 本月订单数 + */ + public static function month_order_count($name) + { + $now_money = StoreOrder::whereMonth('create_time')->where('paid', 1)->where('refund_status', 0)->count(); + $last_money = StoreOrder::whereMonth('create_time', 'last month')->where('paid', 1)->where('refund_status', 0)->count(); + $data = []; + if ($now_money > $last_money) { + if($last_money == 0){ + $rate = bcmul($now_money, '100'); + }else{ + $rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2); + } + } else { + $rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2); + } + return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data]; + } + + /** + * 本月支付人数 + */ + public static function month_order_user($name) + { + $now_money = StoreOrder::whereMonth('create_time')->where('paid', 1)->where('refund_status', 0)->count('uid'); + $last_money = StoreOrder::whereMonth('create_time','last month')->where('paid', 1)->where('refund_status', 0)->count('uid'); + $data = []; + if ($now_money > $last_money) { + if($last_money == 0){ + $rate = bcmul($now_money, '100'); + }else{ + $rate = bcmul(bcmul($now_money, '100'), bcdiv($last_money, $now_money, 2), 2); + } + } else { + + $rate = bcmul(bcmul($last_money, '100'), bcdiv($now_money, $last_money, 2), 2); + } + return ['name' => $name, 'now_money' => $now_money, 'last_money' => $last_money, 'rate' => $rate, 'value' => $data]; + } } From cf0520f1e69a35ac11a4207d545a460df1c9cc2d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 09:35:33 +0800 Subject: [PATCH 11/21] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91=E5=92=8C=E6=94=AF=E4=BB=98=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AD=98=E5=82=A8=E5=8F=91=E9=80=81=E4=B8=AD=E7=9A=84=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 45 ++-------------------------- app/common/logic/PayNotifyLogic.php | 4 +-- app/queue/redis/StoreStorageSend.php | 4 ++- 3 files changed, 7 insertions(+), 46 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index d7e64fbcb..9713a59a6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -97,14 +97,11 @@ class OrderLogic extends BaseLogic $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; + $cartInfo = $cart_select[$k]; $cartInfo['name'] = $find['store_name']; $cartInfo['image'] = $find['image']; - //计算好vip价格 - // $vipPrice = self::dealVip($find['price']); - // if ($vipPrice) { - // $cartInfo['price'] = $vipPrice; - // } + $cartInfo['vip_price'] = 0; //$cart_select[$k]['total'] - $vipPrice ?? 0; $cart_select[$k]['cart_info'] = json_encode($cartInfo); $cart_select[$k]['branch_product_id'] = $find['branch_product_id']; @@ -120,45 +117,7 @@ class OrderLogic extends BaseLogic } //TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级 $pay_price = self::$pay_price; - // $check = StoreOrder::where('uid',\request()->userId)->count();//首单逻辑 $vipPrice = 0; - // if (isset($check) && $check['status'] == 1) { - // $discountRate = '0.99';//首单逻辑 - // $pay_price 是价格 - // $discountRate = $check['remark'];//折扣 - // $discountRate = bcdiv($discountRate, '10', 2); - // $pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2); - // } else { - /* $userVip = User::where('id', \request()->userId)->value('user_ship'); - if ($userVip) { - switch ($userVip) { - case UserShipEnum::VIP1: - $discountRate = UserShip::where('id', UserShipEnum::VIP1)->value('discount'); - break; - case UserShipEnum::VIP2: - $discountRate = UserShip::where('id', UserShipEnum::VIP2)->value('discount'); - break; - case UserShipEnum::VIP3: - $discountRate = UserShip::where('id', UserShipEnum::VIP3)->value('discount'); - break; - case UserShipEnum::VIP4: - $discountRate = UserShip::where('id', UserShipEnum::VIP4)->value('discount'); - break; - case UserShipEnum::VIP5: - $discountRate = UserShip::where('id', UserShipEnum::VIP5)->value('discount'); - break; - default: - $discountRate = 1; - } - $discountRate = bcdiv($discountRate, '100', 2); - $pay_price = bcdiv(bcmul($pay_price, $discountRate, 4), '1', 2); - }*/ - // } - // if (!empty(self::$total) && !empty($pay_price)) { - // bcscale(2); - // $vipPrice = bcsub(self::$total, $pay_price, 2); - // } - //成本价 收益 $order = [ 'create_time' => time(), diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 5dbdc4903..49338f54b 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -125,9 +125,9 @@ class PayNotifyLogic extends BaseLogic PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); } else { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); - Redis::send('push-platform-print', ['id' => $order['id']], 60); // Db::name('order_middle')->insert(['c_order_id' => $order['id']]); } + Redis::send('push-platform-print', ['id' => $order['id']], 60); if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5); } @@ -241,8 +241,8 @@ class PayNotifyLogic extends BaseLogic PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]); } else { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); - Redis::send('push-platform-print', ['id' => $order['id']], 60); } + Redis::send('push-platform-print', ['id' => $order['id']], 60); return true; } diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 6d58da702..7ceab499a 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -45,8 +45,10 @@ class StoreStorageSend implements Consumer 'bar_code' => $find['bar_code'], 'cate_id' => $find['cate_id'], 'price' => $find['price'], - 'unit' => $find['unit'], 'cost' => $find['cost'], + 'vip_price' => $find['vip_price'], + 'vip_ot_price' => $find['vip_ot_price'], + 'unit' => $find['unit'], 'store_id' => $store_id, 'sales' => 0, 'stock' => 0, From 0451dea85830af6429775909300ca2fb96acd4f6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 09:51:36 +0800 Subject: [PATCH 12/21] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=80=9A=E7=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4Redis=E6=B6=88=E6=81=AF=E7=9A=84=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 49338f54b..5cbe5aebe 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -127,7 +127,7 @@ class PayNotifyLogic extends BaseLogic PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); // Db::name('order_middle')->insert(['c_order_id' => $order['id']]); } - Redis::send('push-platform-print', ['id' => $order['id']], 60); + Redis::send('push-platform-print', ['id' => $order['id']]); if (!empty($extra['payer']['openid']) && $order->pay_type == 7) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 5); } @@ -206,6 +206,7 @@ class PayNotifyLogic extends BaseLogic } $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); + Redis::send('push-platform-print', ['id' => $order['id']]); } /** @@ -242,7 +243,7 @@ class PayNotifyLogic extends BaseLogic } else { PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } - Redis::send('push-platform-print', ['id' => $order['id']], 60); + Redis::send('push-platform-print', ['id' => $order['id']]); return true; } From c88b37c25ebabcf00b195a2896af7ed67522cd0b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 10:01:40 +0800 Subject: [PATCH 13/21] =?UTF-8?q?feat(StoreOrderLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=85=8D=E9=80=81=E6=96=B9=E5=BC=8F=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=80=BC=E4=B8=BA3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/store_order/StoreOrderLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 6fb41bf43..8c921d69a 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -112,7 +112,7 @@ class StoreOrderLogic extends BaseLogic 'reservation_time' => $params['reservation_time'] ?? null, 'cart_id' => implode(',', $cartId), 'store_id' => $params['store_id'] ?? 0, - 'shipping_type' => $params['shipping_type'] ?? 2,//配送方式 1=快递 ,2=门店自提 + 'shipping_type' =>3,//配送方式 1=快递 ,2=门店自提 'activity' =>'减免', 'activity_price' =>self::$activity_price, 'activities'=>$check['status'], From 5e08f9359c2cd52916c46f24605ba029195f83b1 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 13 Jun 2024 10:27:56 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E6=88=B7?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/store/StoreController.php | 18 ++++++++++++- app/api/logic/store/StoreLogic.php | 27 ++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 app/api/logic/store/StoreLogic.php diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index dde6ba987..6b4dd010d 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -4,6 +4,7 @@ namespace app\api\controller\store; use app\api\lists\store\SystemStoreLists; use app\api\controller\BaseApiController; +use app\api\logic\store\StoreLogic; use app\common\service\pay\PayService; use Webman\Config; use hg\apidoc\annotation as ApiDoc; @@ -11,11 +12,26 @@ use hg\apidoc\annotation as ApiDoc; class StoreController extends BaseApiController { - + public $notNeedLogin = ['detail']; public function lists() { return $this->dataLists(new SystemStoreLists()); } + public function detail() + { + $store_id = (int)$this->request->get('store_id'); + $where = [ + 'id' => $store_id + ]; + $info = StoreLogic::search($where); + if ($info) { + return $this->data($info); + } else { + return $this->fail('店铺不存在'); + } + } + + } diff --git a/app/api/logic/store/StoreLogic.php b/app/api/logic/store/StoreLogic.php new file mode 100644 index 000000000..f9fd39616 --- /dev/null +++ b/app/api/logic/store/StoreLogic.php @@ -0,0 +1,27 @@ +field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show', + 'day_time', 'is_store', 'latitude', 'longitude', 'day_start', 'day_end', 'is_store' + , 'is_send' + ]) + ->find() + ->toArray(); + + + } + + +} \ No newline at end of file From f1015916d6f5dd7861e47b341b0863759b2015f4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 13 Jun 2024 11:08:37 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E6=94=B6=E9=93=B6=E6=9C=BA=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=B7=B2=E7=BB=8F=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/enum/OrderEnum.php | 2 + .../logic/store_order/StoreOrderLogic.php | 27 +++++++++++++ .../store_order/StoreOrderController.php | 38 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index b77115f58..c6ea7ec5b 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -85,6 +85,8 @@ class OrderEnum const PAY = 1; const BACK = 0; + /**小程序下单**/ + const ONLINE = [1,2]; /** * 账户类型 * @USER 用户 diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 8c921d69a..7b067a90d 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -202,6 +202,33 @@ class StoreOrderLogic extends BaseLogic return $order->toArray(); } + //核销列表 + public function writeList($params) + { + $pageNo = $params['page_no']; + $pageSize = $params['page_size']; + unset($params['page_no'],$params['page_size']); + $params['paid'] = YesNoEnum::YES; + $params['is_writeoff'] = YesNoEnum::YES; + $order = StoreOrder::with(['user', 'staff', 'product' => function ($query) { + $query->field(['id', 'oid', 'product_id', 'cart_info']); + }])->where($params)->whereIn('shipping_type',OrderEnum::ONLINE) + ->page($pageNo, $pageSize) + ->select()->toArray(); + + foreach ($order as &$value){ + $value['pay_time'] = $value['pay_time'] > 0 ? date('Y-m-d H:i:s', $value['pay_time']) : ''; + $value['status_name'] = OrderEnum::getOrderType($value['status']) ?? ''; + $value['refund_status_name'] = OrderEnum::refundStatus($value['refund_status']) ?? ''; + $value['refund_type_name'] = OrderEnum::refundType($value['refund_type']) ?? ''; + $value['pay_type_name'] =PayEnum::getPaySceneDesc($value['pay_type']) ?? ''; + } + return $order; + } + + + + /** * 订单统计 * @param $storeId diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 24f79e3a7..0dda0ad55 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -251,4 +251,42 @@ class StoreOrderController extends BaseAdminController } return $this->fail('核销失败' . OrderLogic::getError()); } + + + #[ + ApiDoc\Title('订单已核销列表'), + ApiDoc\url('/store/store_order/storeOrder/writeoff_list'), + ApiDoc\Method('POST'), + ApiDoc\NotHeaders(), + ApiDoc\Author('中国队长'), + ApiDoc\Header(ref: [Definitions::class, "token"]), + ApiDoc\Query(name: 'page_no', type: 'int', require: false, desc: '页数 默认1'), + ApiDoc\Query(name: 'page_size', type: 'int', require: false, desc: '每页条数 默认15'), + ApiDoc\ResponseSuccess("data", type: "array"), + ] + public function writeoff_list(StoreOrderLogic $orderLogic) + { + $page_no = (int)$this->request->post('page_no', 1); + $page_size = (int)$this->request->post('page_size', 15); + $params = $this->request->post(); + $params['page_no'] = $page_no; + $params['page_size'] = $page_size; + if (empty($page_no) || empty($page_size)) { + $params['page_no'] = 1; + $params['page_size'] = 15; + } + $params['store_id'] =$this->request->adminInfo['store_id']; + $result = $orderLogic->writeList($params); + + $data = [ + 'lists' => $result, + 'count' => count($result), + 'page_no' => $params['page_no'], + 'page_size' =>$params['page_size'], + ]; + return $this->success('ok',$data); + + } + + } From 8b39a9e635b29a67dececa516ddcc5d236300e4b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 15:15:24 +0800 Subject: [PATCH 16/21] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=92=8C=E4=BC=9A=E5=91=98=E4=BB=B7=E6=A0=BC=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/store_product/StoreProductLogic.php | 17 ++++++++++------- app/queue/redis/StoreStorageSend.php | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 1e95deedd..5f0f40ae7 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -42,25 +42,28 @@ class StoreProductLogic extends BaseLogic 'cate_id' => $params['cate_id'], 'unit' => $params['unit'], 'stock' => $params['stock'], + 'price' => $params['price'], + 'vip_price' => $params['vip_price'], 'cost' => $params['cost'], 'purchase' => $params['purchase'], 'rose' => $params['rose'], 'is_return' => $params['is_return'], ]; - if ($params['rose'] > 0) { - $rose_price = bcmul($params['cost'], $params['rose'], 2); - $data['price'] = bcadd($params['cost'], $rose_price, 2); - } else { - $data['price'] = 0; - } + // if ($params['rose'] > 0) { + // $rose_price = bcmul($params['cost'], $params['rose'], 2); + // $data['price'] = bcadd($params['cost'], $rose_price, 2); + // } else { + // $data['price'] = 0; + // } $res = StoreProduct::create($data); StoreProductAttrValue::create([ "bar_code" => $params["bar_code"] ?? '', "image" => $params["image"] ?? '', + "price" => $params['price'], + 'vip_price' => $params['vip_price'], "cost" => $params['cost'], "purchase" => $params['purchase'], "unit" => $params["unit"], - "price" => $data['price'], "stock" => $params['stock'], "product_id" => $res['id'], "unique" => setUnique($res['id'], '', 0), diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 7ceab499a..a96e88ad4 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -47,7 +47,6 @@ class StoreStorageSend implements Consumer 'price' => $find['price'], 'cost' => $find['cost'], 'vip_price' => $find['vip_price'], - 'vip_ot_price' => $find['vip_ot_price'], 'unit' => $find['unit'], 'store_id' => $store_id, 'sales' => 0, From 69236a50d2788b12ba69d381104cc28cb11f2763 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 15:23:06 +0800 Subject: [PATCH 17/21] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E5=92=8C=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=86VIP?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=86=E5=88=86=E7=B1=BB=E7=BB=9F=E8=AE=A1=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/store_product/StoreProductLists.php | 2 +- .../logic/store_product/StoreProductLogic.php | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index e8f58ed18..a32f501f4 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) + ->field(['id', 'image', 'store_name', 'cate_id', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 5f0f40ae7..7629e7066 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -116,16 +116,16 @@ class StoreProductLogic extends BaseLogic 'purchase' => $params['purchase'], 'rose' => $params['rose'], 'is_return' => $params['is_return'], + 'price' => $params['price'], + 'vip_price' => $params['vip_price'], + 'cost' => $params['cost'], ]; - if ($params['rose'] > 0) { - $rose_price = bcmul($params['cost'], bcdiv($params['rose'], 100, 2), 2); - $data['price'] = bcadd($params['cost'], $rose_price, 2); - } else { - $data['price'] = 0; - } StoreProduct::where('id', $params['id'])->update($data); - + StoreBranchProduct::where('product_id', $params['id'])->update([ + 'price' => $params['price'], 'vip_price' => $params['vip_price'], + 'cost' => $params['cost'] + ]); Db::commit(); return true; } catch (\Exception $e) { @@ -185,21 +185,21 @@ class StoreProductLogic extends BaseLogic $two = StoreCategory::where('id', $one['pid'])->find(); if ($two) { if ($two['pid'] != 0) { - self::cate_update($cate_id,$two['id'],0,3); - self::cate_update($two['id'],$two['pid'],0,2); - self::cate_update($two['pid'],0,0,1); + self::cate_update($cate_id, $two['id'], 0, 3); + self::cate_update($two['id'], $two['pid'], 0, 2); + self::cate_update($two['pid'], 0, 0, 1); } } } } - public static function cate_update($cate_id = 0,$pid=0, $product_id = 0, $level = 1) + public static function cate_update($cate_id = 0, $pid = 0, $product_id = 0, $level = 1) { $find = Db::name('store_product_cate')->where(['store_id' => 1, 'cate_id' => $cate_id, 'level' => $level])->find(); if ($find) { Db::name('store_product_cate')->where('id', $find['id'])->inc('count', 1)->update(); } else { - Db::name('store_product_cate')->insert(['pid'=>$pid,'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); + Db::name('store_product_cate')->insert(['pid' => $pid, 'store_id' => 1, 'cate_id' => $cate_id, 'count' => 1, 'level' => $level, 'create_time' => time(), 'update_time' => time()]); } } /** From ae5f0044b3a673175711bf5f628443d19de516dc Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 16:00:19 +0800 Subject: [PATCH 18/21] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BC=9A?= =?UTF-8?q?=E5=91=98=E6=8A=98=E6=89=A3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 4 ++- app/api/logic/order/OrderLogic.php | 32 +++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 0ee0d5be4..c3223fec8 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -13,6 +13,7 @@ use app\common\logic\PayNotifyLogic; use app\common\model\dict\DictData; use app\common\model\store_order\StoreOrder; use app\common\model\system_store\SystemStoreStaff; +use app\common\model\user\User; use app\common\model\user\UserAddress; use Webman\RedisQueue\Redis; use hg\apidoc\annotation as ApiDoc; @@ -141,7 +142,8 @@ class OrderController extends BaseApiController // $pay_type = (int)$this->request->post('pay_type'); // $auth_code = $this->request->post('auth_code'); //微信支付条码 $params = $this->request->post(); - $res = OrderLogic::cartIdByOrderInfo($cartId, $addressId, null, $params); + $user=User::where('id',$this->userId)->find(); + $res = OrderLogic::cartIdByOrderInfo($cartId, $addressId, $user, $params); if ($res == false) { $msg = OrderLogic::getError(); if ($msg == '购物车为空') { diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 9713a59a6..76fa03d32 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -61,17 +61,16 @@ class OrderLogic extends BaseLogic self::setError('购物车为空'); return false; } - try { + // try { self::$total_price = 0; self::$pay_price = 0; self::$cost = 0; //成本 self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 - /** 计算价格 */ - $check = DictType::where('type', 'activities')->find(); + foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,cost,product_id')->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,product_id')->find(); if (!$find) { continue; } @@ -80,16 +79,16 @@ class OrderLogic extends BaseLogic $cart_select[$k]['price'] = $find['price']; $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 - if (isset($check) && $check['status'] == 1) { - //零售价*折扣率 - $activity_price = bcmul($find['price'], 0.9, 2); - $deduction_price_count=bcmul(bcsub($find['price'], $activity_price, 2),$v['cart_num'], 2); + if ($user && $user['user_ship'] >= 1) { + $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); $cart_select[$k]['deduction_price'] =$deduction_price_count; self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - $find['price'] = $activity_price; + $onePrice = bcsub($find['vip_price'], $find['cost'], 2); + + }else{ + $onePrice = bcsub($find['price'], $find['cost'], 2); } //利润 - $onePrice = bcsub($find['price'], $find['cost'], 2); $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 $cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额 @@ -115,8 +114,7 @@ class OrderLogic extends BaseLogic self::$cost = bcadd(self::$cost, $cart_select[$k]['cost'], 2); self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } - //TODO 收单打9.9折 会员按照比例打折 等级按照充值去升级 - $pay_price = self::$pay_price; + $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 $vipPrice = 0; //成本价 收益 $order = [ @@ -135,7 +133,7 @@ class OrderLogic extends BaseLogic 'shipping_type' => $params['shipping_type'] ?? 2, //配送方式 1=快递 ,2=门店自提 'activity' => '减免', 'activity_price' => self::$activity_price, - 'activities' => $check['status'], + 'activities' => self::$activity_price>0?1:0, 'deduction_price' => self::$activity_price ]; @@ -143,10 +141,10 @@ class OrderLogic extends BaseLogic if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } - } catch (\Exception $e) { - self::setError($e->getMessage()); - return false; - } + // } catch (\Exception $e) { + // self::setError($e->getMessage()); + // return false; + // } return ['order' => $order, 'cart_list' => $cart_select]; } From a1b54043d2a8ed4d75a158b385b280a46b2b095c Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 16:09:31 +0800 Subject: [PATCH 19/21] =?UTF-8?q?feat(StoreOrderLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E6=8A=98=E6=89=A3=E8=AE=A1=E7=AE=97=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=88=A9=E6=B6=A6=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/store_order/StoreOrderLogic.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 7b067a90d..b16abf813 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -48,7 +48,7 @@ class StoreOrderLogic extends BaseLogic /** 计算价格 */ $check = DictType::where('type', 'activities')->find(); foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,cost,product_id')->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,cost,product_id')->find(); if (!$find) { continue; } @@ -57,17 +57,9 @@ class StoreOrderLogic extends BaseLogic $cart_select[$k]['price'] = $find['price']; $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 - if (isset($check) && $check['status'] == 1) { - //零售价*折扣率 - $activity_price = bcmul($find['price'], 0.9, 2); - $deduction_price_count=bcmul(bcsub($find['price'], $activity_price, 2),$v['cart_num'], 2); - $cart_select[$k]['deduction_price'] =$deduction_price_count; - self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - $find['price'] = $activity_price; - } + //利润 - $onePrice = bcsub($find['price'], $find['cost'], 2); - $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 + $cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润 $cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额 $cart_select[$k]['product_id'] = $find['product_id']; From 3f90482d70f849521ca2eb5218c184ce273fd632 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 16:11:14 +0800 Subject: [PATCH 20/21] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=E6=94=AF=E4=BB=98=E7=B1=BB=E5=9E=8B=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E5=92=8C=E8=AE=A2=E5=8D=95=E7=94=9F=E6=88=90=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=EF=BC=8C=E5=B9=B6=E8=B0=83=E6=95=B4=E4=BA=86=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 11 +++-------- app/api/logic/order/OrderLogic.php | 10 +++++----- app/common/logic/store_order/StoreOrderLogic.php | 3 +-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index c3223fec8..fa1f79a2c 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -182,14 +182,9 @@ class OrderController extends BaseApiController return $this->fail('购物车商品不能超过100个'); } - // if ($pay_type == 9 || $pay_type == 17 ||$pay_type==13) { - // if (empty($this->request->userInfo['merchant'])) { - // return $this->fail('请先绑定商户'); - // } - // $mer_id = $this->request->userInfo['merchant']['mer_id']; - // $params['mer_id'] = $mer_id; - // } - $order = OrderLogic::createOrder($cartId, $addressId, null, $params); + $user=User::where('id',$this->userId)->find(); + + $order = OrderLogic::createOrder($cartId, $addressId, $user, $params); if ($order != false) { switch ($pay_type) { case PayEnum::BALANCE_PAY: diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 76fa03d32..3fcabb03b 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -61,7 +61,7 @@ class OrderLogic extends BaseLogic self::setError('购物车为空'); return false; } - // try { + try { self::$total_price = 0; self::$pay_price = 0; self::$cost = 0; //成本 @@ -141,10 +141,10 @@ class OrderLogic extends BaseLogic if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } - // } catch (\Exception $e) { - // self::setError($e->getMessage()); - // return false; - // } + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } return ['order' => $order, 'cart_list' => $cart_select]; } diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index b16abf813..c1111141a 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -46,7 +46,6 @@ class StoreOrderLogic extends BaseLogic self::$activity_price = 0; //活动减少 /** 计算价格 */ - $check = DictType::where('type', 'activities')->find(); foreach ($cart_select as $k => $v) { $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,cost,product_id')->find(); if (!$find) { @@ -107,7 +106,7 @@ class StoreOrderLogic extends BaseLogic 'shipping_type' =>3,//配送方式 1=快递 ,2=门店自提 'activity' =>'减免', 'activity_price' =>self::$activity_price, - 'activities'=>$check['status'], + 'activities' => self::$activity_price>0?1:0, 'default_delivery'=>1, 'original_price'=>self::$total_price, 'deduction_price' => self::$activity_price From 7c35d4e504b631c6e0c261e95d3a68fc52a1ccf9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 13 Jun 2024 16:38:28 +0800 Subject: [PATCH 21/21] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91=E4=BB=A5=E5=A4=84=E7=90=86=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E5=92=8C=E9=94=80=E5=94=AE=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 3fcabb03b..e016bff55 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -203,12 +203,15 @@ class OrderLogic extends BaseLogic $goods_list[$k]['uid'] = request()->userId; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - $stock = StoreBranchProduct::where('id',$v['branch_product_id'])->value('stock'); + $StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->find(); $updateData[] = [ 'id' => $v['branch_product_id'], - 'stock' => $stock-$v['cart_num'], + 'stock' => $StoreBranchProduct['stock']-$v['cart_num'], 'sales' => ['inc', $v['cart_num']] ]; + if($StoreBranchProduct['stock']-$v['cart_num']<=0){ + Db::name('store_product_cate')->where(['cate_id'=>$StoreBranchProduct['cate_id'],'store_id'=>$params['store_id']])->update(['count'=>0]); + } } (new StoreOrderCartInfo())->saveAll($goods_list); (new StoreBranchProduct())->saveAll($updateData);