From 3e6abe5957a0763aa3343763e5e00e64380fa8f0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 16:27:55 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=B5=84?= =?UTF-8?q?=E9=87=91=E6=B5=81=E5=8A=A8=E9=80=BB=E8=BE=91=E4=BB=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=95=86=E5=BA=97=E8=B4=A2=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/StoreFinanceFlowLogic.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index a845c7ed1..5692b9299 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -148,16 +148,21 @@ class StoreFinanceFlowLogic extends BaseLogic { StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1]); StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1]); + $store=SystemStore::where('id',$store_id)->find(); + $capitalFlowDao = new CapitalFlowLogic($store); if ($money > 0) { + $capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money); SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); } if ($deposit > 0) { + $capitalFlowDao->storeIncome('store_paid_deposit_add', 'order', $order_id, $money); SystemStore::where('id', $store_id)->inc('paid_deposit', $deposit)->update(); } $find = StoreFinanceFlow::where(['order_id' => $order_id, 'financial_pm' => 1, 'financial_type' => 16, 'status' => 0])->find(); StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 16])->update(['status' => 1]); if ($find) { if ($find['number'] > 0) { + $capitalFlowDao->storeIncome('store_attrition_add', 'order', $order_id, $money); SystemStore::where('id', $store_id)->inc('attrition', $find['number'])->update(); } } From e90e666738de74a926979cd6cdee53898acc858d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 17:04:09 +0800 Subject: [PATCH 02/13] =?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=E4=BB=BB=E5=8A=A1=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 37 ++++++++++-------------------- process/Task.php | 13 +++++++---- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 99a17ec55..d27b03bd8 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -83,27 +83,12 @@ class OrderLogic extends BaseLogic self::$fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose'; + $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find(); + $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); if (!$find) { - // unset($cart_select[$k]); - // continue; - $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id,cate_id,store_info,rose'; - $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); - if ($find) { - $cate_id = StoreCategory::where('id', $find['cate_id'])->value('pid'); - if ($cate_id > 0) { - $cate_id = StoreCategory::where('id', $cate_id)->value('pid'); - if ($cate_id > 0) { - $cate_id = StoreCategory::where('id', $cate_id)->value('pid'); - $find['top_cate_id'] = $cate_id; - } else { - $find['top_cate_id'] = $cate_id; - } - } - } - $cart_select[$k]['status'] = 1; //缺货标识 + self::setError('商品不存在'); + return false; } unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 @@ -152,7 +137,6 @@ class OrderLogic extends BaseLogic $cartInfo['name'] = $find['store_name']; $cartInfo['image'] = $find['image']; $cart_select[$k]['cart_info'] = json_encode($cartInfo); - $cart_select[$k]['branch_product_id'] = $find['branch_product_id']; //理论上每笔都是拆分了 $cart_select[$k]['name'] = $find['store_name']; $cart_select[$k]['imgs'] = $find['image']; @@ -339,11 +323,14 @@ class OrderLogic extends BaseLogic $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - $updateData[] = [ - 'id' => $v['branch_product_id'], - 'sales' => ['inc', $v['cart_num']], - 'stock' => ['dec', $v['cart_num']], - ]; + $id=StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$params['store_id'])->value('id'); + if($id){ + $updateData[] = [ + 'id' => $id, + 'sales' => ['inc', $v['cart_num']], + 'stock' => ['dec', $v['cart_num']], + ]; + } $updateDataTwo[] = [ 'id' => $v['product_id'], 'sales' => ['inc', $v['cart_num']] diff --git a/process/Task.php b/process/Task.php index 70503c56f..c860a4658 100644 --- a/process/Task.php +++ b/process/Task.php @@ -30,11 +30,14 @@ class Task $updateData = []; $updateDataTwo = []; foreach ($arr as $v) { - $updateData[] = [ - 'id' => $v['branch_product_id'], - 'sales' => ['dec', $v['cart_num']], - 'stock' => ['inc', $v['cart_num']], - ]; + $id=StoreBranchProduct::where('product_id',$v['product_id'])->where('store_id',$v['store_id'])->value('id'); + if($id){ + $updateData[] = [ + 'id' => $id, + 'sales' => ['dec', $v['cart_num']], + 'stock' => ['inc', $v['cart_num']], + ]; + } $updateDataTwo[] = [ 'id' => $v['product_id'], 'sales' => ['dec', $v['cart_num']] From 795d19dda38a15351f3e23f7fb7aa220c89f4774 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 20:10:55 +0800 Subject: [PATCH 03/13] =?UTF-8?q?feat(OrderLogic,=20PayNotifyLogic,=20Task?= =?UTF-8?q?):=20=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=A0=B8=E9=94=80=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=B5=84=E9=87=91=E6=B5=81=E5=8A=A8?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8F=8A=E8=AE=A2=E5=8D=95=E8=B4=AD=E7=89=A9?= =?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/logic/order/OrderLogic.php | 46 +---------------------------- app/common/logic/PayNotifyLogic.php | 16 ++++------ process/Task.php | 3 ++ 3 files changed, 10 insertions(+), 55 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index d27b03bd8..1cdece94e 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -594,6 +594,7 @@ class OrderLogic extends BaseLogic 'writeoff_time' => time(), 'is_writeoff' => YesNoEnum::YES, 'store_id' => $params['store_id'], + 'status' => 1, 'staff_id' => $params['staff_id'] ?? 0, 'update_time' => time(), ], ['oid' => $order['id']]); @@ -627,51 +628,6 @@ class OrderLogic extends BaseLogic } } - //不走二次分钱的核销 - public static function lessWriteOff($params): bool - { - $data = StoreOrder::with('store')->where([ - 'verify_code' => $params['verify_code'] - ])->find(); - if (empty($data)) { - return false; - } - Db::startTrans(); - try { - StoreOrder::update([ - 'verify_code' => $params['verify_code'] . '-1', - 'status' => OrderEnum::RECEIVED_GOODS, - 'is_writeoff' => OrderEnum::IS_OK, - 'update_time' => time(), - 'store_id' => $params['store_id'], - 'staff_id' => $params['staff_id'] ?? 0, - ], ['id' => $data['id']]); - (new StoreOrderCartInfo())->update([ - 'verify_code' => $params['verify_code'] . '-1', - 'writeoff_time' => time(), - 'is_writeoff' => YesNoEnum::YES, - 'store_id' => $params['store_id'], - 'staff_id' => $params['staff_id'] ?? 0, - 'update_time' => time(), - ], ['oid' => $data['id']]); - // $financeFlow = (new StoreFinanceFlowLogic)->getStoreOrder($data['id'], $data['store_id']); - // if (!empty($financeFlow)) { - // $capitalFlowLogic = new CapitalFlowLogic($data->store, 'store'); - // $capitalFlowLogic->storeIncome('store_order_income', 'order', $data['id'], $financeFlow['number']); - // } - $order = StoreOrder::where('id', $data['id'])->find(); - PayNotifyLogic::descSwap($order['id']); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; - } - } - - - public static function write_count($info, $params) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 9184b6019..640bc4113 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -160,14 +160,6 @@ class PayNotifyLogic extends BaseLogic ]; UserSign::create($sing); - if ($order && $order['store_id']) { - $params = [ - 'verify_code' => $order['verify_code'], - 'store_id' => $order['store_id'], - 'staff_id' => $order['staff_id'] - ]; - OrderLogic::lessWriteOff($params); - } self::dealProductLog($order); } @@ -329,8 +321,8 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); $deal_money = bcdiv($extra['amount']['refund'], 100, 2); //对应比例得退礼品券逻辑 - $discount = self::getDiscount($user->user_ship); - $total_price = bcmul($order->refund_price, $discount, 2); + // $discount = self::getDiscount($user->user_ship); + // $total_price = bcmul($order->refund_price, $discount, 2); if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付 $user->now_money = bcadd($user->now_money, $deal_money, 2); @@ -352,6 +344,8 @@ class PayNotifyLogic extends BaseLogic return true; } + //订单购物详情 + StoreOrderCartInfo::where('oid',$order['id'])->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]); //积分 UserSignLogic::RefundOrder($order); //微信日志 user_order_refund @@ -394,6 +388,8 @@ class PayNotifyLogic extends BaseLogic $model->save(); //增加数量 self::addStock($order['id']); + StoreOrderCartInfo::where('oid',$order['id'])->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]); + return true; } diff --git a/process/Task.php b/process/Task.php index c860a4658..a08bae717 100644 --- a/process/Task.php +++ b/process/Task.php @@ -2,6 +2,7 @@ namespace process; +use app\common\enum\OrderEnum; use app\common\logic\PayNotifyLogic; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; @@ -26,6 +27,8 @@ class Task $oid = StoreOrder::where($where)->column('id'); // 删除时间设置为当前时间,即删除 if ($oid) { StoreOrder::where('id', 'in', $oid)->update(['delete_time' => time()]); + StoreOrderCartInfo::where('oid','in',$oid)->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]); + $arr = StoreOrderCartInfo::where('oid', 'in', $oid)->field('store_id,product_id,cart_num')->select(); $updateData = []; $updateDataTwo = []; From 081c89442cbd6da3db074210d542e0caf7eb198f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 20:30:40 +0800 Subject: [PATCH 04/13] =?UTF-8?q?feat(OrderLogic):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81=E5=AD=97=E6=AE=B5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 1cdece94e..b7967434f 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -83,7 +83,7 @@ class OrderLogic extends BaseLogic self::$fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose'; + $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,top_cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); if (!$find) { @@ -115,7 +115,7 @@ class OrderLogic extends BaseLogic $deduction_price = bcsub($cart_select[$k]['total_price'], $cart_select[$k]['pay_price'], 2); $cart_select[$k]['deduction_price'] = $deduction_price; //抵扣金额 } - $cart_select[$k]['product_id'] = $find['product_id']; + $cart_select[$k]['product_id'] = $find['id']; $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; From 1151b8fb4e1d487a9a049173b22ffcf6237ddcf3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 20:38:11 +0800 Subject: [PATCH 05/13] =?UTF-8?q?feat(OrderLogic):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81=E5=AD=97=E6=AE=B5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index b7967434f..366904332 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -83,13 +83,24 @@ class OrderLogic extends BaseLogic self::$fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,top_cate_id,store_info,rose'; + $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); if (!$find) { self::setError('商品不存在'); return false; } + $StoreCategory=StoreCategory::where('id',$find['cate_id'])->find(); + $find['top_cate_id']=$find['cate_id']; + if($StoreCategory && $StoreCategory['pid']>0){ + $StoreCategory2=StoreCategory::where('id',$StoreCategory['pid'])->find(); + if($StoreCategory2 && $StoreCategory['pid']>0){ + $find['top_cate_id']=$StoreCategory2['pid']; + }else{ + $find['top_cate_id']=$StoreCategory['pid']; + } + + } unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) { From 3f9bda6bef1658bebcba8842600678fee71ffd34 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 20:50:03 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat(OrderLogic):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E4=BA=86=E7=94=9F=E6=88=90=E6=A0=B8=E9=94=80=E7=A0=81=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E4=BB=A5=E4=BC=98=E5=8C=96=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 366904332..2196187d1 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -315,12 +315,12 @@ class OrderLogic extends BaseLogic throw new \Exception('余额不足'); } //生成核销码 - $generator = new BarcodeGeneratorPNG(); - $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); - $findPath = '/image/barcode/' . time() . '.png'; - $savePath = public_path() . $findPath; - file_put_contents($savePath, $barcode); - $_order['verify_img'] = $findPath; + // $generator = new BarcodeGeneratorPNG(); + // $barcode = $generator->getBarcode($verify_code, $generator::TYPE_CODE_128); + // $findPath = '/image/barcode/' . time() . '.png'; + // $savePath = public_path() . $findPath; + // file_put_contents($savePath, $barcode); + // $_order['verify_img'] = $findPath; Db::startTrans(); try { $order = StoreOrder::create($_order); From ee8a43b2acc6a7f8466284638956de6d13b2028e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 20:54:45 +0800 Subject: [PATCH 07/13] =?UTF-8?q?feat(OrderLogic):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81=E5=AD=97=E6=AE=B5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 2196187d1..841082a8a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -71,7 +71,7 @@ class OrderLogic extends BaseLogic self::setError('购物车为空'); return false; } - try { + // try { self::$total_price = 0; self::$pay_price = 0; self::$cost = 0; //成本由采购价替代原成本为门店零售价 @@ -94,7 +94,7 @@ class OrderLogic extends BaseLogic $find['top_cate_id']=$find['cate_id']; if($StoreCategory && $StoreCategory['pid']>0){ $StoreCategory2=StoreCategory::where('id',$StoreCategory['pid'])->find(); - if($StoreCategory2 && $StoreCategory['pid']>0){ + if($StoreCategory2 && $StoreCategory2['pid']>0){ $find['top_cate_id']=$StoreCategory2['pid']; }else{ $find['top_cate_id']=$StoreCategory['pid']; @@ -246,10 +246,10 @@ class OrderLogic extends BaseLogic } } } - } 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, 'shopInfo' => $store['near_store']]; } From f33a4d4ae8598ae092f427ffdac1fa7d2ad16447 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 20:55:28 +0800 Subject: [PATCH 08/13] =?UTF-8?q?feat(OrderLogic):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=95=86=E5=93=81=E5=AD=97=E6=AE=B5=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 841082a8a..4f0656041 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -71,7 +71,7 @@ class OrderLogic extends BaseLogic self::setError('购物车为空'); return false; } - // try { + try { self::$total_price = 0; self::$pay_price = 0; self::$cost = 0; //成本由采购价替代原成本为门店零售价 @@ -246,10 +246,10 @@ class OrderLogic extends BaseLogic } } } - // } 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, 'shopInfo' => $store['near_store']]; } From e0b7f75fdc2af9398758380edd120301c386b63f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 21:05:55 +0800 Subject: [PATCH 09/13] =?UTF-8?q?feat(PayNotifyLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AE=A2=E5=8D=95=E6=8E=A8=E9=80=81=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=8E=92=E9=99=A4=E7=89=B9=E5=AE=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E8=AE=A2=E5=8D=95=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PayNotifyLogic.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 640bc4113..893cc57fc 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -566,7 +566,9 @@ class PayNotifyLogic extends BaseLogic $user_ship = 0; $order['dealVipAmount'] = 0; try { - Redis::send('order_wetcha_push_send', ['order' => $order]); + if($order['uid']!=1){ + Redis::send('order_wetcha_push_send', ['order' => $order]); + } } catch (\Exception $e) { Log::error('订单推送失败:' . $e->getMessage()); // 异常处理代码,例如记录日志或发送通知等。 From 87f40a0b04046c6f3f6f61a53d94f826bbf17fce Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 2 Aug 2024 23:56:37 +0800 Subject: [PATCH 10/13] =?UTF-8?q?feat(StoreOrderController,=20PayNotifyLog?= =?UTF-8?q?ic,=20StoreFinanceFlowLogic):=20=E6=9B=B4=E6=96=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E9=80=80=E6=AC=BE=E9=80=BB=E8=BE=91=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E8=B5=84=E9=87=91=E6=B5=81=E5=8A=A8=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store_order/StoreOrderController.php | 7 +- app/common/logic/PayNotifyLogic.php | 32 ++++---- app/common/logic/StoreFinanceFlowLogic.php | 75 +++++++++++-------- 3 files changed, 67 insertions(+), 47 deletions(-) diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index 414312813..0aa21ccc8 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -116,8 +116,11 @@ class StoreOrderController extends BaseAdminController if(empty($detail)){ return $this->fail('无该订单请检查'); } - StoreOrderLogic::refund($detail,$params); - return $this->fail('退款失败'); + $res=StoreOrderLogic::refund($detail,$params); + if($res==false){ + return $this->fail('退款失败'); + } + return $this->success('退款成功'); } } \ No newline at end of file diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 893cc57fc..f0d160fcb 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -315,43 +315,47 @@ class PayNotifyLogic extends BaseLogic $order->refund_reason_time = time(); $order->refund_num += 1; $order->save(); - //日志记录 - //加用户余额,采购款, 日志记录 加数量 - $user = User::where('id', $order['uid'])->findOrEmpty(); - $capitalFlowDao = new CapitalFlowLogic($user); - $deal_money = bcdiv($extra['amount']['refund'], 100, 2); + // $deal_money = bcdiv($extra['amount']['refund'], 100, 2); //对应比例得退礼品券逻辑 // $discount = self::getDiscount($user->user_ship); // $total_price = bcmul($order->refund_price, $discount, 2); + + //订单购物详情 + StoreOrderCartInfo::where('oid',$order['id'])->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]); + + //处理财务流水退还 + (new StoreFinanceFlowLogic())->store_finance_back($orderSn); if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付 - $user->now_money = bcadd($user->now_money, $deal_money, 2); + $user= User::where('id', $order['uid'])->findOrEmpty(); + $capitalFlowDao = new CapitalFlowLogic($user); + $user->now_money = bcadd($user['now_money'], $order['pay_price'], 2); $user->save(); //增加数量 self::addStock($order['id']); //退款 - $capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money); + $capitalFlowDao->userIncome('system_balance_add', 'system_back', $order['id'], $order['pay_price']); } if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付 - $user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2); + $user= User::where('id', $order['uid'])->findOrEmpty(); + $capitalFlowDao = new CapitalFlowLogic($user); + $user->purchase_funds = bcadd($user['purchase_funds'],$order['pay_price'], 2); $user->save(); //增加数量 self::addStock($order['id']); //退款 - $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); + $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $order['pay_price']); } UserSignLogic::RefundOrder($order); return true; } - //订单购物详情 - StoreOrderCartInfo::where('oid',$order['id'])->update(['status'=>OrderEnum::REFUND_STATUS_FINISH]); //积分 UserSignLogic::RefundOrder($order); //微信日志 user_order_refund - $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); - //处理财务流水退还 - (new StoreFinanceFlowLogic())->store_finance_back($orderSn); + $user= User::where('id', $order['uid'])->findOrEmpty(); + $capitalFlowDao = new CapitalFlowLogic($user); + $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1); self::addStock($order['id']); //微信 return true; // self::afterPay($order,$extra['transaction_id']); diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 5692b9299..854ba05ac 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -134,8 +134,8 @@ class StoreFinanceFlowLogic extends BaseLogic */ public function updateStatusUser($id, $uid, $money, $order_id) { - $flow=StoreFinanceFlow::where('id', $id)->find(); - StoreFinanceFlow::where('order_id',$order_id)->where('financial_type',$flow['financial_type'])->update(['status'=>1]); + $flow = StoreFinanceFlow::where('id', $id)->find(); + StoreFinanceFlow::where('order_id', $order_id)->where('financial_type', $flow['financial_type'])->update(['status' => 1]); $find = User::where('id', $uid)->find(); $capitalFlowDao = new CapitalFlowLogic($find); $capitalFlowDao->userIncome('system_balance_add', 'order', $order_id, $money); @@ -148,8 +148,8 @@ class StoreFinanceFlowLogic extends BaseLogic { StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 11])->update(['status' => 1]); StoreFinanceFlow::where(['order_id' => $order_id, 'financial_type' => 2])->update(['status' => 1]); - $store=SystemStore::where('id',$store_id)->find(); - $capitalFlowDao = new CapitalFlowLogic($store); + $store = SystemStore::where('id', $store_id)->find(); + $capitalFlowDao = new CapitalFlowLogic($store, 'store'); if ($money > 0) { $capitalFlowDao->storeIncome('store_money_add', 'order', $order_id, $money); SystemStore::where('id', $store_id)->inc('store_money', $money)->update(); @@ -178,36 +178,49 @@ class StoreFinanceFlowLogic extends BaseLogic */ public function store_finance_back($orderSn) { - $data = StoreFinanceFlow::where('order_sn', $orderSn) - ->where(['financial_pm' => 1]) - ->select()->toArray(); - foreach ($data as &$value) { - unset($value['id']); - $value['financial_record_sn'] = (new StoreFinanceFlowLogic)->getSn(); - $value['financial_pm'] = 0; - $value['financial_type'] = OrderEnum::PAY_BACK; - $value['create_time'] = time(); - if ($value['status'] == 1) { - switch ($value['type']) { - case 0: + $list=StoreFinanceFlow::where('order_sn', $orderSn) + ->where(['financial_pm' => 1, 'status' => 1]) + ->select(); + foreach ($list as $k => $value) { + //用户 + switch ($value['type']) { + case 0: + if ($value['financial_type'] == 12&& $value['other_uid']>0) { $user = User::where('id', $value['other_uid'])->findOrEmpty(); $capitalFlowDao = new CapitalFlowLogic($user); - $capitalFlowDao->userExpense('system_now_money_back', 'system_back', $value['order_id'], $value['number']); - break; - case 1: - if ($value['number'] > 0 &&$value['financial_type']==2) { - SystemStore::where('id', $value['store_id'])->dec('store_money',$value['number'])->update(); - } - if ($value['number'] > 0 &&$value['financial_type']==11) { - SystemStore::where('id', $value['store_id'])->dec('paid_deposit',$value['number'])->update(); - } - if ($value['number'] > 0 &&$value['financial_type']==16) { - SystemStore::where('id', $value['store_id'])->dec('attrition',$value['number'])->update(); - } - break; - } + $user->now_money = bcsub($user['now_money'],$value['number'], 2); + $user->save(); + // Log::error('aa'.$a); + // Log::error('aa'.$user['now_money']); + // Log::error('aa'.$value['number']); + $capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'],'',$value['pay_type']); + } + break; + //商户 + case 1: + if ($value['number'] > 0 && $value['financial_type'] == 2) { + SystemStore::where('id', $value['store_id'])->dec('store_money', $value['number'])->update(); + } + if ($value['number'] > 0 && $value['financial_type'] == 16) { + SystemStore::where('id', $value['store_id'])->dec('attrition', $value['number'])->update(); + } + break; } + } - (new StoreFinanceFlow)->saveAll($data); + $find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status',1)->find(); + if ($find && $find['number'] > 0) { + SystemStore::where('id', $find['store_id'])->dec('paid_deposit', $find['number'])->update(); + } + // $data = StoreFinanceFlow::where('order_sn', $orderSn)->select(); + // foreach ($data as $k => &$value) { + // $value['status'] = -1; + // $value['financial_record_sn'] = (new StoreFinanceFlowLogic)->getSn(); + // $value['financial_pm'] = 0; + // $value['financial_type'] = OrderEnum::PAY_BACK; + // $value['create_time'] = time(); + // } + StoreFinanceFlow::where('order_sn', $orderSn)->update(['status'=>-1]); + // (new StoreFinanceFlow)->saveAll($data); } } From 02835aab30f026cd8c22cbef4d48b3eeabcd25a8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 3 Aug 2024 00:07:48 +0800 Subject: [PATCH 11/13] =?UTF-8?q?feat(TradeStatisticLogic):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=A4=E6=98=93=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=94=AF=E4=BB=98=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/statistic/TradeStatisticLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index e9fc6a7b0..456a0d25d 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -754,12 +754,12 @@ class TradeStatisticLogic extends BaseLogic // } switch ($selectType) { case "sum": - $totalMoney = $storeOrder->where('pay_type', 17)->when(isset($where['timeKey']), function ($query) use ($where) { + $totalMoney = $storeOrder->where(['pay_type'=>17,'paid'=>1,'refund_status',0])->when(isset($where['timeKey']), function ($query) use ($where) { $query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time'])); })->sum($offlineSumField); break; case "group": - $totalMoney = $storeOrder->getCurveData(['pay_type' => 17], $where, 'sum(pay_price)', $group); + $totalMoney = $storeOrder->getCurveData(['pay_type'=>17,'paid'=>1,'refund_status',0], $where, 'sum(pay_price)', $group); break; default: throw new \Exception('getOfflineTotalMoney:selectType参数错误'); From 89775fdccbfaf6210138c4209ab04f7690d87db8 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 3 Aug 2024 00:09:11 +0800 Subject: [PATCH 12/13] =?UTF-8?q?feat(TradeStatisticLogic):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=A4=E6=98=93=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=94=AF=E4=BB=98=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/logic/statistic/TradeStatisticLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index 456a0d25d..123d2b182 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -754,12 +754,12 @@ class TradeStatisticLogic extends BaseLogic // } switch ($selectType) { case "sum": - $totalMoney = $storeOrder->where(['pay_type'=>17,'paid'=>1,'refund_status',0])->when(isset($where['timeKey']), function ($query) use ($where) { + $totalMoney = $storeOrder->where(['pay_type'=>17,'paid'=>1,'refund_status'=>0])->when(isset($where['timeKey']), function ($query) use ($where) { $query->whereBetweenTime('create_time', strtotime($where['timeKey']['start_time']), strtotime($where['timeKey']['end_time'])); })->sum($offlineSumField); break; case "group": - $totalMoney = $storeOrder->getCurveData(['pay_type'=>17,'paid'=>1,'refund_status',0], $where, 'sum(pay_price)', $group); + $totalMoney = $storeOrder->getCurveData(['pay_type'=>17,'paid'=>1,'refund_status'=>0], $where, 'sum(pay_price)', $group); break; default: throw new \Exception('getOfflineTotalMoney:selectType参数错误'); From d9fca4bf1534ac7bde3b7ce1d99dcb0ce718cdeb Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 3 Aug 2024 11:22:35 +0800 Subject: [PATCH 13/13] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E7=AE=A1=E7=90=86=E9=80=BB=E8=BE=91=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=93=E5=BA=93=E5=BA=93=E5=AD=98=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=92=8C=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/statistic/TradeStatisticLogic.php | 16 ++++++++-------- .../SystemStoreStorageLogic.php | 19 +++++++++++++------ .../WarehouseProductLogic.php | 4 ++-- app/queue/redis/StoreStorageSend.php | 7 +++++-- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/app/admin/logic/statistic/TradeStatisticLogic.php b/app/admin/logic/statistic/TradeStatisticLogic.php index 123d2b182..5c2d1e276 100644 --- a/app/admin/logic/statistic/TradeStatisticLogic.php +++ b/app/admin/logic/statistic/TradeStatisticLogic.php @@ -314,7 +314,7 @@ class TradeStatisticLogic extends BaseLogic $depositWehre['financial_type'] = 11; $orderDepositMoney = $this->getFinanceFlow($depositWehre, "sum"); $lastOrderDepositMoney = $this->getFinanceFlow($dateWhere, "sum", "", $isNum); - $OrderDepositCurve = $this->getFinanceFlow($where, "group", "create_time"); + $OrderDepositCurve = $this->getFinanceFlow($depositWehre, "group", "create_time"); $OrderDepositChain = countRate($orderDepositMoney, $lastOrderDepositMoney); $topData[8] = [ @@ -483,17 +483,17 @@ class TradeStatisticLogic extends BaseLogic $orderGroup = "create_time"; $OrderMoney = $this->getOrderTotalMoney($where, $selectType, $orderGroup); //用户充值收入 - $rechargeGroup = "create_time"; - $RechargeMoneyHome = $this->getRechargeTotalMoney($where, $selectType, $rechargeGroup); - $RechargeMoneyAdmin = $this->getBillYeTotalMoney($where, $selectType, $rechargeGroup); - $RechargeMoney = $this->totalArrData([$RechargeMoneyHome, $RechargeMoneyAdmin]); + // $rechargeGroup = "create_time"; + // $RechargeMoneyHome = $this->getRechargeTotalMoney($where, $selectType, $rechargeGroup); + // $RechargeMoneyAdmin = $this->getBillYeTotalMoney($where, $selectType, $rechargeGroup); + // $RechargeMoney = $this->totalArrData([$RechargeMoneyHome, $RechargeMoneyAdmin]); //购买会员收入 - $memberGroup = "create_time"; - $MemberMoney = $this->getMemberTotalMoney($where, $selectType, $memberGroup); + // $memberGroup = "create_time"; + // $MemberMoney = $this->getMemberTotalMoney($where, $selectType, $memberGroup); //线下收款收入 $offlineGroup = "create_time"; $OfflineMoney = $this->getOfflineTotalMoney($where, $selectType, $offlineGroup); - return $this->totalArrData([$OrderMoney, $RechargeMoney, $MemberMoney, $OfflineMoney]); + return $this->totalArrData([$OrderMoney, $OfflineMoney]); } diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index f9f75441f..3b7014ecb 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -8,6 +8,8 @@ use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue use app\common\model\system_store_storage\SystemStoreStorage; use app\common\logic\BaseLogic; use app\common\model\store_product\StoreProduct; +use app\common\model\warehouse_product\WarehouseProduct; +use app\common\model\warehouse_product_storege\WarehouseProductStorege; use think\facade\Db; @@ -59,11 +61,12 @@ class SystemStoreStorageLogic extends BaseLogic */ public static function edit(array $params): bool { - $stock=StoreProduct::where('id', $params['product_id'])->value('stock'); - $nums=SystemStoreStorage::where('id', $params['id'])->value('nums'); - $stock=bcadd($stock,$nums); - if($stock<$params['nums']){ - self::setError('库存不足,主库为:'.$stock); + $find=SystemStoreStorage::where('id', $params['id'])->find(); + + //查看仓库库存 + $productStorege=WarehouseProductStorege::where('product_id', $params['product_id'],['warehouse_id'=>$find['warehouse_id']])->find(); + if($productStorege && $productStorege['nums']<$params['nums']){ + self::setError('库存不足,仓库库存为:'.$productStorege['nums']); return false; } Db::startTrans(); @@ -71,8 +74,12 @@ class SystemStoreStorageLogic extends BaseLogic SystemStoreStorage::where('id', $params['id'])->update([ 'nums' => $params['nums'], 'admin_id' => $params['admin_id'], + 'status' => 0, + 'mark' => '', ]); - StoreProduct::where('id', $params['product_id'])->update(['stock'=>bcsub($stock,$params['nums'])]); + StoreProduct::where('id', $params['product_id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update(); + WarehouseProductStorege::where('id',$productStorege['id'])->inc('stock',bcsub($find['nums'] ,$params['nums'],2))->update(); + WarehouseProduct::where('id',$find['outbound_id'])->update(['nums',$params['nums']]); Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 665401481..15f03eb72 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -90,10 +90,10 @@ class WarehouseProductLogic extends BaseLogic if(isset($params['expiration_date']) &&$params['expiration_date']!=''){ $data['expiration_date']=strtotime($params['expiration_date']); } - WarehouseProduct::where('id', $params['id'])->update($data); + $res=WarehouseProduct::where('id', $params['id'])->update($data); Db::commit(); - return true; + return $res; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 5d51219af..0ae7662a8 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -169,6 +169,7 @@ class StoreStorageSend implements Consumer 'nums' => $product_arr['stock'], 'admin_id' => $admin_id, 'type' => $stock_type, + 'warehouse_id'=>$warehouse_id, ]; $data=[ 'warehouse_id'=>$warehouse_id, @@ -187,11 +188,13 @@ class StoreStorageSend implements Consumer $storage['mark'] = '库存不足,分库存为:' .$warehouse['nums']; $data['mark'] = '库存不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock']; } + $res=WarehouseProductLogic::add($data); + $storage['outbound_id']=$res['id']??0; SystemStoreStorage::create($storage); - WarehouseProductLogic::add($data); } else { + $res=WarehouseProductLogic::add($data); + $storage['outbound_id']=$res['id']??0; SystemStoreStorage::create($storage); - WarehouseProductLogic::add($data); } }