From 19d4d0478b39442f3f61318ed97e30e886943d1d Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 18:30:07 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 2b449a454..8a124d66a 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -107,10 +107,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) - ->limit($this->limitOffset, $this->limitLength) ->with(['className', 'unitName']) ->order($this->sortOrder) - ->select()?->toArray(); +// ->limit($this->limitOffset, $this->limitLength) + ->page($this->limitOffset +1,$this->limitLength) + ->select()->toArray(); + } From aeb74daca9e8a6dec406f4bbf9a1eea157b61a77 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Thu, 20 Jun 2024 18:47:22 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 8a124d66a..f8e219939 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -63,7 +63,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function setDefaultOrder(): array { - return ['sales' => 'desc', 'price' => 'asc']; + return [ 'price' => 'asc','id' => 'desc']; } /** @@ -108,9 +108,9 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L return StoreBranchProduct::where($this->searchWhere) ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) ->with(['className', 'unitName']) + ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) -// ->limit($this->limitOffset, $this->limitLength) - ->page($this->limitOffset +1,$this->limitLength) +// ->page($this->limitOffset +1,$this->limitLength) ->select()->toArray(); } From 5cadc7aaa01abf3517b1ab2c6e74b08a0505fb5f Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 21 Jun 2024 09:39:32 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8E=82=E5=AE=B6?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/store_product/StoreProductLogic.php | 6 +++++- app/queue/redis/StoreStorageSend.php | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 6aee0d22b..df8425a58 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -49,6 +49,7 @@ class StoreProductLogic extends BaseLogic 'purchase' => $params['purchase'], 'rose' => $params['rose'], 'is_return' => $params['is_return'], + 'manufacturer_information' => $params['manufacturer_information']??'', 'swap' => $params['swap'] ?? 0, 'batch' => $params['batch'] ?? 0, ]; @@ -149,6 +150,7 @@ class StoreProductLogic extends BaseLogic 'price' => $params['price'], 'vip_price' => $params['vip_price'], 'batch' => $params['batch'], + 'manufacturer_information' => $params['manufacturer_information']??'', 'swap' => $params['swap'] ?? 0, ]; @@ -177,7 +179,8 @@ class StoreProductLogic extends BaseLogic StoreBranchProduct::where('product_id', $params['id'])->update([ 'price' => $params['price'], 'vip_price' => $params['vip_price'], 'cost' => $params['cost'], - 'batch'=>$params['batch'],'store_name'=>$params['store_name'] + 'batch'=>$params['batch'],'store_name'=>$params['store_name'], + 'manufacturer_information' => $params['manufacturer_information']??'', ]); Db::commit(); @@ -290,6 +293,7 @@ class StoreProductLogic extends BaseLogic 'store_id' => $store_id, 'sales' => 0, 'stock' => $stock, + 'manufacturer_information' => $find['manufacturer_information']??'', ]; StoreBranchProduct::create($product); $arr = [ diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index d2cb8e0e4..33b263814 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -59,6 +59,7 @@ class StoreStorageSend implements Consumer 'cost' => $find['cost'], 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'], + 'manufacturer_information' => $find['manufacturer_information']??'', 'unit' => $find['unit'], 'batch' => $find['batch'], 'store_id' => $store_id, From 47ce687f907d7ef7fd218856f83fb877da461d48 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 21 Jun 2024 09:51:51 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/store_branch_product/StoreBranchProductLists.php | 2 +- app/admin/lists/store_product/StoreProductLists.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index ff127b729..ea5239d8a 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -63,7 +63,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI } return StoreBranchProduct::where($this->searchWhere)->where($where) - ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price']) + ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 8d2d6969b..12c737412 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','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) + ->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { From ca711b1885c3e31ae4a76ba07a8dea7f00647033 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 21 Jun 2024 10:13:33 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=89=A3=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 7 ----- app/common/logic/PayNotifyLogic.php | 40 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 23cd86736..55140fd6c 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -224,24 +224,17 @@ class OrderLogic extends BaseLogic try { $order = StoreOrder::create($_order); $goods_list = $orderInfo['cart_list']; - $updateData = []; foreach ($goods_list as $k => $v) { $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = $user['id']; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id $StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find(); - $updateData[] = [ - 'id' => $v['branch_product_id'], - '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); $where = ['is_pay' => 0]; Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]); Db::commit(); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 689234048..331948aaf 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -9,6 +9,7 @@ use app\common\enum\user\UserShipEnum; use app\common\model\dict\DictType; use app\common\model\finance\PayNotifyLog; use app\common\model\pay\PayNotify; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; @@ -89,6 +90,7 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']); self::dealProductLog($order); + self::descStock($order['id']); // self::afterPay($order); // Redis::send('push-platform-print', ['id' => $order['id']], 60); // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); @@ -136,6 +138,7 @@ class PayNotifyLogic extends BaseLogic OrderLogic::writeOff($params); } self::dealProductLog($order); + self::descStock($order['id']); // self::afterPay($order); // Redis::send('push-platform-print', ['id' => $order['id']], 60); @@ -175,6 +178,7 @@ class PayNotifyLogic extends BaseLogic } self::dealProductLog($order); + self::descStock($order['id']); // if ($order->pay_type == 9) { // $extra['create_time'] = $order['create_time']; @@ -273,6 +277,7 @@ class PayNotifyLogic extends BaseLogic $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); + self::descStock($order['id']); // Redis::send('push-platform-print', ['id' => $order['id']]); } @@ -304,6 +309,7 @@ class PayNotifyLogic extends BaseLogic self::afterPay($order); } self::dealProductLog($order); + self::descStock($order['id']); // if ($order->pay_type == 9) { // $extra['create_time'] = $order['create_time']; @@ -621,4 +627,38 @@ class PayNotifyLogic extends BaseLogic } + + /** + * 扣库存 + * @param $oid + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function descStock($oid) + { + $updateData = []; + $goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray(); + foreach ($goods_list as $v) { + $StoreBranchProduct =StoreBranchProduct::where( + [ + 'store_id'=>$v['store_id'], + 'product_id'=>$v['product_id'], + ] + )->withTrashed()->find(); + $updateData[] = [ + 'id' => $StoreBranchProduct['id'], + 'stock' => $StoreBranchProduct['stock']-$v['cart_num'], + 'sales' => ['inc', $v['cart_num']] + ]; + + } + + (new StoreBranchProduct())->saveAll($updateData); + + } + + + } From 2332ea4f29af7da397c6078d279edcb5dcfb99f9 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 21 Jun 2024 10:24:57 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=8B=86=E5=88=86=E6=94=B6=E9=93=B6?= =?UTF-8?q?=E6=9C=BA=E5=92=8C=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E6=89=A3=E5=BA=93=E5=AD=98=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 1 + app/common/logic/PayNotifyLogic.php | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 55140fd6c..2cc365e5b 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -440,6 +440,7 @@ class OrderLogic extends BaseLogic // } $order=StoreOrder::where('id',$data['id'])->find(); PayNotifyLogic::afterPay($order); + PayNotifyLogic::descStock($order['id']); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 331948aaf..6fa47d13c 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -90,7 +90,9 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']); self::dealProductLog($order); - self::descStock($order['id']); + if($order['shipping_type'] == 3){ + self::descStock($order['id']); + } // self::afterPay($order); // Redis::send('push-platform-print', ['id' => $order['id']], 60); // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); @@ -138,7 +140,9 @@ class PayNotifyLogic extends BaseLogic OrderLogic::writeOff($params); } self::dealProductLog($order); - self::descStock($order['id']); + if($order['shipping_type'] == 3){ + self::descStock($order['id']); + } // self::afterPay($order); // Redis::send('push-platform-print', ['id' => $order['id']], 60); @@ -178,7 +182,9 @@ class PayNotifyLogic extends BaseLogic } self::dealProductLog($order); - self::descStock($order['id']); + if($order['shipping_type'] == 3){ + self::descStock($order['id']); + } // if ($order->pay_type == 9) { // $extra['create_time'] = $order['create_time']; @@ -277,7 +283,9 @@ class PayNotifyLogic extends BaseLogic $cashFlowLogic = new CashFlowLogic(); $cashFlowLogic->insert($order['store_id'], $order['pay_price']); self::dealProductLog($order); - self::descStock($order['id']); + if($order['shipping_type'] == 3){ + self::descStock($order['id']); + } // Redis::send('push-platform-print', ['id' => $order['id']]); } @@ -309,7 +317,9 @@ class PayNotifyLogic extends BaseLogic self::afterPay($order); } self::dealProductLog($order); - self::descStock($order['id']); + if($order['shipping_type'] == 3){ + self::descStock($order['id']); + } // if ($order->pay_type == 9) { // $extra['create_time'] = $order['create_time'];