From ae40c1940f13f3fc56c6be0939cd2a4114a1a207 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 24 Jan 2025 16:07:52 +0800 Subject: [PATCH 01/16] =?UTF-8?q?feat(inventory):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E8=BD=AC=E7=A7=BB=E8=AE=A2=E5=8D=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加订单类型切换逻辑,支持不同类型的库存转移 - 完善订单详情页面,展示转出转入门店/仓库名称 - 增加商品列表展示,包含商品名称等信息 - 优化库存扣减逻辑,根据订单类型进行相应处理 --- .../InventoryTransferOrderLogic.php | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php b/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php index b4bd2a5e..88d2f75f 100644 --- a/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php +++ b/app/admin/logic/inventory_transfer_order/InventoryTransferOrderLogic.php @@ -8,6 +8,8 @@ use app\common\logic\BaseLogic; use app\common\model\inventory_transfer\InventoryTransfer; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; +use app\common\model\system_store\SystemStore; +use app\common\model\warehouse\Warehouse; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use support\exception\BusinessException; use think\facade\Db; @@ -31,6 +33,7 @@ class InventoryTransferOrderLogic extends BaseLogic */ public static function add(array $params,$admin_id): bool { + $types=$params['types']??0; if (empty($params['product_arr'])) { throw new BusinessException('请选择商品'); } @@ -78,22 +81,26 @@ class InventoryTransferOrderLogic extends BaseLogic 'two_type' => $params['two_type'], 'one_id' => $params['one_id'], 'two_id' => $params['two_id'], - 'types' => $params['types']??0, + 'types' => $types, 'mark' => $params['mark']??'', ]); foreach ($insert as $k => $v) { $insert[$k]['oid'] = $order['id']; } InventoryTransfer::insertAll($insert); + if($types==1){ + Db::commit(); + return true; + } foreach ($insert as $v) { if($params['one_type']==1){ - $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find(); - $find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]); - SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); + $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['one_id'])->find(); + $find->save(['stock' =>bcsub( $find['stock'],$v['nums'],2)]); + SqlChannelLog('StoreBranchProduct', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); } elseif ($params['one_type'] == 2) { - $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['one_id'])->find(); - $find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]); - SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); + $find=WarehouseProductStorege::where('product_id', $v['product_id'])->where('warehouse_id', $params['one_id'])->find(); + $find->save(['nums' =>bcsub( $find['nums'],$v['nums'],2)]); + SqlChannelLog('WarehouseProductStorege', $find['id'], $v['nums'], -1, Request()->url(),$admin_id); } if($params['two_type']==1){ $find=StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['two_id'])->find(); @@ -185,6 +192,28 @@ class InventoryTransferOrderLogic extends BaseLogic */ public static function detail($params): array { - return InventoryTransferOrder::findOrEmpty($params['id'])->toArray(); + $data= InventoryTransferOrder::findOrEmpty($params['id']); + $type_name=''; + if($data->one_type==1){ + $data->one_name=SystemStore::where('id',$data->one_id)->value('name'); + $type_name='门店转'; + }else{ + $data->one_name=Warehouse::where('id',$data->one_id)->value('name'); + $type_name='仓库转'; + } + if($data->two_type==1){ + $type_name.='门店'; + $data->two_name=SystemStore::where('id',$data->two_id)->value('name'); + }else{ + $type_name.='仓库'; + $data->two_name=Warehouse::where('id',$data->two_id)->value('name'); + } + $data->type_name=$type_name; + $data['product_list']=InventoryTransfer::where('oid',$params['id'])->select()->each(function ($item) { + $find= StoreProduct::where('id',$item->product_id)->withTrashed()->field('store_name')->find(); + $item->store_name=$find['store_name']; + }) + ->toArray(); + return $data->toArray(); } } \ No newline at end of file From 304e0d3199b5956f436aab7a02e459f89fa36c14 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 24 Jan 2025 17:43:33 +0800 Subject: [PATCH 02/16] =?UTF-8?q?perf(warehouse):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了在搜索产品时对已删除产品的查询,提高搜索效率 - 注释掉了在获取列表时对已删除数据的查询,准备后续彻底移除 --- app/admin/lists/warehouse_product/WarehouseProductLists.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index 0cc4ae86..869ed72a 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -54,7 +54,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt { if ($this->request->get('product_id')) { $product_id = $this->request->get('product_id'); - $ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->withTrashed()->column('id'); + $ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; @@ -64,7 +64,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt } if ($this->request->get('bar_code')) { $bar_code = $this->request->get('bar_code'); - $ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->withTrashed()->column('id'); + $ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->column('id'); if ($ids) { $this->searchWhere[] = ['product_id', 'in', $ids]; $this->ids = $ids; @@ -76,7 +76,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt ->field(['id', 'code','pay_type','oid','admin_id','supplier_id', 'store_id', 'warehouse_id', 'product_id', 'financial_pm', 'batch', 'nums', 'price', 'purchase', 'cost', 'total_price', 'manufacture', 'expiration_date', 'status', 'mark', 'create_time','is_pay']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->withTrashed() + // ->withTrashed() ->select()->each(function ($item) { $item->store_name = ''; $item->image = ''; From 26df751c9940a9f7e90f3ccb82c7461430fae731 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 25 Jan 2025 10:51:58 +0800 Subject: [PATCH 03/16] =?UTF-8?q?fix(purchase):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E4=BA=A7=E5=93=81=E6=8A=A5=E4=BB=B7=E4=B8=AD?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在查询产品时使用 withTrashed() 方法,以支持查询包括软删除的产品 - 添加异常捕获时的调试输出,便于排查问题 --- .../logic/purchase_product_offer/PurchaseProductOfferLogic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 44a1ff63..8dc233dc 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -60,7 +60,7 @@ class PurchaseProductOfferLogic extends BaseLogic if ($mark == '') { $mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark'); } - $find = StoreProduct::where('id', $params['product_id'])->find(); + $find = StoreProduct::where('id', $params['product_id'])->withTrashed()->find(); $purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find(); if ($purchaseProductOffer) { $purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num']; @@ -104,6 +104,7 @@ class PurchaseProductOfferLogic extends BaseLogic return true; } catch (\Exception $e) { Db::rollback(); + d($e); throw new BusinessException($e->getMessage()); } } From b67ecfd595419343bb8a3e505bf300b19e311725 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 25 Jan 2025 12:32:13 +0800 Subject: [PATCH 04/16] =?UTF-8?q?refactor(order):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=A2=84=E8=AE=A2=E5=8D=95=E8=BD=AC=E8=AE=A2=E5=8D=95=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改订单来源为 OrderEnum::SOURCE_20 - 增加用户是否为会员的判断逻辑 - 优化 PayNotifyLogic 中的 addStock 方法,针对预订单转订单情况进行特殊处理 - 新增 OrderEnum 中的订单来源类型 --- .../logic/beforehand_order/BeforehandOrderLogic.php | 12 +++++++++++- app/common/enum/OrderEnum.php | 12 ++++++++++++ app/common/logic/PayNotifyLogic.php | 13 ++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 21411135..de88b04f 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -7,6 +7,7 @@ use app\admin\logic\store_product\StoreProductLogic; use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\api\logic\order\CartLogic; use app\api\logic\order\OrderLogic; +use app\common\enum\OrderEnum; use app\common\model\beforehand_order\BeforehandOrder; use app\common\logic\BaseLogic; use app\common\model\auth\Admin; @@ -260,7 +261,7 @@ class BeforehandOrderLogic extends BaseLogic 'store_id' => $params['store_id'] ?? 0, 'shipping_type' => 2, //配送方式 1=快递 ,2=门店自提 'deduction_price' => 0, //抵扣金额 - 'source' => 2, //后台下单 + 'source' => OrderEnum::SOURCE_20, //来源 'order_type' => $order['order_type'], 'is_storage' => 0, 'verify_code' => createCode($code), @@ -669,6 +670,15 @@ class BeforehandOrderLogic extends BaseLogic $res['examine_name'] = Admin::where('id', $record['check_user_id'])->value('name'); } } + + $res['is_vip']=0; + if($res['uid']>0){ + $user_ship=User::where('id',$res['uid'])->value('user_ship'); + if($user_ship>0){ + $res['is_vip']=1; + } + } + return $res; } diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index 6674b96a..9e6f605e 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -49,6 +49,18 @@ class OrderEnum const USER_ORDER_REFUND = 19;//订单返还 const PAY_BACK =-1; + //-----------------------订单来源-----------------------// + /** + * @SOURCE_0 小程序 + * @SOURCE_1 收银台 + * @SOURCE_2 后台下单 + * @SOURCE_20 预订单转订单 + */ + const SOURCE_0 =0;//小程序 + const SOURCE_1 =1;//收银台 + const SOURCE_2 =2;//后台下单 + const SOURCE_20 =20;//预订单转订单 + /** * 收入支出类型 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index a576278e..c1bec932 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -351,7 +351,7 @@ class PayNotifyLogic extends BaseLogic // $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']); //微信 + self::addStock($order['id'],$order); return true; } @@ -374,7 +374,7 @@ class PayNotifyLogic extends BaseLogic } $user->save(); //增加数量 - self::addStock($order['id']); + self::addStock($order['id'],$order); } if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付 $user = User::where('id', $order['uid'])->findOrEmpty(); @@ -389,7 +389,7 @@ class PayNotifyLogic extends BaseLogic } $user->save(); //增加数量 - self::addStock($order['id']); + self::addStock($order['id'],$order); } UserSignLogic::RefundOrder($order); @@ -427,7 +427,7 @@ class PayNotifyLogic extends BaseLogic $model->status = YesNoEnum::YES; $model->save(); //增加数量 - self::addStock($order['id']); + self::addStock($order['id'],$order); StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); (new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']); @@ -866,8 +866,11 @@ class PayNotifyLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function addStock($oid) + public static function addStock($oid,$order) { + if($order && $order['source']==OrderEnum::SOURCE_20){ + return true; + } $updateData = []; $goods_list = StoreOrderCartInfo::where('oid', $oid)->select()->toArray(); foreach ($goods_list as $v) { From 57bde2df4c74ade0de0b3468832005d7781d82b5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 25 Jan 2025 13:06:12 +0800 Subject: [PATCH 05/16] =?UTF-8?q?fix(app):=20=E4=BF=AE=E5=A4=8D=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E9=80=80=E6=AC=BE=E5=92=8C=E5=BA=93=E5=AD=98=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=9B=B8=E5=85=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化了订单退款流程,增加了对退款金额和支付价格的比较 - 修复了订单支付成功后的库存减少逻辑 - 优化了订单推送和打印相关代码 - 调整了代码格式和缩进,提高了可读性 --- app/common/logic/PayNotifyLogic.php | 66 +++++++++++++++-------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index c1bec932..ade3ec1e 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -284,8 +284,8 @@ class PayNotifyLogic extends BaseLogic // self::dealProductLog($order); if ($order->pay_type == 7) { - $openid=UserAuth::where('user_id',$order['uid'])->value('openid'); - if($openid){ + $openid = UserAuth::where('user_id', $order['uid'])->value('openid'); + if ($openid) { Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $openid, 'logistics_type' => 4]); } } @@ -326,8 +326,8 @@ class PayNotifyLogic extends BaseLogic UserSignLogic::RefundRecharge($orderRe); return true; } - $refund=bcdiv($extra['amount']['refund'], 100, 2); - if($refund==$order['pay_price']){ + $refund = bcdiv($extra['amount']['refund'], 100, 2); + if ($refund == $order['pay_price']) { $order->status = OrderEnum::REFUND_PAY; $order->refund_status = OrderEnum::REFUND_STATUS_FINISH; $order->refund_price = $refund; @@ -351,7 +351,7 @@ class PayNotifyLogic extends BaseLogic // $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'],$order); + self::addStock($order['id'], $order); return true; } @@ -374,7 +374,7 @@ class PayNotifyLogic extends BaseLogic } $user->save(); //增加数量 - self::addStock($order['id'],$order); + self::addStock($order['id'], $order); } if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款支付 $user = User::where('id', $order['uid'])->findOrEmpty(); @@ -389,7 +389,7 @@ class PayNotifyLogic extends BaseLogic } $user->save(); //增加数量 - self::addStock($order['id'],$order); + self::addStock($order['id'], $order); } UserSignLogic::RefundOrder($order); @@ -427,7 +427,7 @@ class PayNotifyLogic extends BaseLogic $model->status = YesNoEnum::YES; $model->save(); //增加数量 - self::addStock($order['id'],$order); + self::addStock($order['id'], $order); StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); (new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']); @@ -502,7 +502,7 @@ class PayNotifyLogic extends BaseLogic $uid = $order['other_uid']; } $cashFlowLogic = new CashFlowLogic(); - $cashFlowLogic->insert($order['store_id'], $order['price'],$orderSn); + $cashFlowLogic->insert($order['store_id'], $order['price'], $orderSn); PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]); PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]); @@ -624,25 +624,27 @@ class PayNotifyLogic extends BaseLogic 'total_price' => bcmul($stock, $storeProduct['purchase'], 2), 'sales' => bcadd($storeProduct['sales'], $v['cart_num'], 2) ], ['id' => $v['product_id']]); - if($storeProduct['product_type']==5){ - continue; + if ($storeProduct['product_type'] == 5) { + continue; } } - if ($branchProduct) { - $stock = bcsub($branchProduct['stock'], $v['cart_num'], 2); - StoreBranchProduct::update([ - 'stock' => $stock, - 'total_price' => bcmul($stock, $branchProduct['purchase'], 2), - 'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2) - ], ['id' => $branchProduct['id']]); - SqlChannelLog('StoreBranchProduct',$branchProduct['id'], $v['cart_num'], -1, Request()->url()); - } else { - StoreProductLogic::ordinary(['id' => $v['product_id']], $v['store_id'], 0, $storeProduct); - StoreBranchProduct::update([ - 'stock' => -$v['cart_num'], - 'sales' => $v['cart_num'] - ], ['product_id' => $v['product_id'],'store_id'=>$v['store_id']]); - SqlChannelLog('StoreBranchProduct',$branchProduct['id'], $v['cart_num'], -1, Request()->url()); + if ($order['source'] != OrderEnum::SOURCE_20) { + if ($branchProduct) { + $stock = bcsub($branchProduct['stock'], $v['cart_num'], 2); + StoreBranchProduct::update([ + 'stock' => $stock, + 'total_price' => bcmul($stock, $branchProduct['purchase'], 2), + 'sales' => bcadd($branchProduct['sales'], $v['cart_num'], 2) + ], ['id' => $branchProduct['id']]); + SqlChannelLog('StoreBranchProduct', $branchProduct['id'], $v['cart_num'], -1, Request()->url()); + } else { + StoreProductLogic::ordinary(['id' => $v['product_id']], $v['store_id'], 0, $storeProduct); + StoreBranchProduct::update([ + 'stock' => -$v['cart_num'], + 'sales' => $v['cart_num'] + ], ['product_id' => $v['product_id'], 'store_id' => $v['store_id']]); + SqlChannelLog('StoreBranchProduct', $branchProduct['id'], $v['cart_num'], -1, Request()->url()); + } } } } catch (\Throwable $e) { @@ -660,8 +662,8 @@ class PayNotifyLogic extends BaseLogic if ($order['uid'] != 1) { Redis::send('order_wetcha_push_send', ['order' => $order]); } - $xprinter=DictData::where('type_value','xprinter')->where('name','xprinter_'.$order['store_id'])->where('status',1)->find(); - if($xprinter){ + $xprinter = DictData::where('type_value', 'xprinter')->where('name', 'xprinter_' . $order['store_id'])->where('status', 1)->find(); + if ($xprinter) { Redis::send('order_xprinter_push_send', ['order' => $order]); } } catch (\Exception $e) { @@ -866,9 +868,9 @@ class PayNotifyLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public static function addStock($oid,$order) + public static function addStock($oid, $order) { - if($order && $order['source']==OrderEnum::SOURCE_20){ + if ($order && $order['source'] == OrderEnum::SOURCE_20) { return true; } $updateData = []; @@ -884,14 +886,14 @@ class PayNotifyLogic extends BaseLogic $updateData[] = [ 'id' => $StoreBranchProduct['id'], 'stock' => $StoreBranchProduct['stock'] + $v['cart_num'], - 'sales' => ['dec', $v['cart_num']] + 'sales' => ['dec', $v['cart_num']] // 'sales' => ['inc', $v['cart_num']] ]; } } (new StoreBranchProduct())->saveAll($updateData); - SqlChannelLog('StoreBranchProduct',0,0,1,Request()->url()); + SqlChannelLog('StoreBranchProduct', 0, 0, 1, Request()->url()); } From 97697e488298dbe63cd5a2db5f18d0c0e70d1f7d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 25 Jan 2025 14:59:58 +0800 Subject: [PATCH 06/16] 1 --- .../BeforehandOrderCartInfoLogic.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index c55c97ad..cf364e96 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -61,8 +61,10 @@ class BeforehandOrderCartInfoLogic extends BaseLogic public static function appendAdd(array $params): bool { $order = BeforehandOrder::where('id', $params['id'])->find(); - if ((!empty($order) && $order->is_confirm == 1 && empty($params['admin_id'])) || $order['is_outbound'] > 0) { - throw new BusinessException('该订单已确认,不能追加商品'); + if(empty($params['admin_id'])){ + if ((!empty($order) && $order->is_confirm == 1 ) || $order['is_outbound'] > 0) { + throw new BusinessException('该订单已确认,不能追加商品'); + } } Db::startTrans(); try { From 6b44bc45ededb13139c0173d4a7a6696325e67d5 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 27 Jan 2025 13:26:55 +0800 Subject: [PATCH 07/16] =?UTF-8?q?refactor(store):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A2=84=E8=AE=A2=E8=AE=A2=E5=8D=95=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=91=98=E5=B7=A5=20ID=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注释掉了 BeforehandOrderController 中获取 store_staff_id 的代码行 - 这个改动可能是为了调整预订订单创建流程,不再需要员工 ID --- .../controller/beforehand_order/BeforehandOrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/controller/beforehand_order/BeforehandOrderController.php b/app/store/controller/beforehand_order/BeforehandOrderController.php index c35a3b14..421f4234 100644 --- a/app/store/controller/beforehand_order/BeforehandOrderController.php +++ b/app/store/controller/beforehand_order/BeforehandOrderController.php @@ -39,7 +39,7 @@ class BeforehandOrderController extends BaseAdminController { $params = $this->request->get(); $params['store_id'] = $this->request->adminInfo['store_id'] ?? 0; - $params['store_staff_id'] = $this->request->adminInfo['admin_id'] ?? 0; + // $params['store_staff_id'] = $this->request->adminInfo['admin_id'] ?? 0; $this->request->setGet($params); return $this->dataLists(new BeforehandOrderLists()); } From 07fb90ca8b7c96539a4440af0c466564b9502255 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 1 Feb 2025 17:01:27 +0800 Subject: [PATCH 08/16] =?UTF-8?q?refactor(admin):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2=E5=92=8C?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整搜索条件数组格式 - 修复商品类型切换后的活动价显示问题 - 优化商品列表的数据处理逻辑 - 美化代码格式,统一代码风格 --- .../lists/store_product/StoreProductLists.php | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 26c664a0..1d9ea3cc 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -35,7 +35,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function setSearch(): array { return [ - '=' => ['cate_id', 'is_show', 'bar_code','id'], + '=' => ['cate_id', 'is_show', 'bar_code', 'id'], 'in' => ['product_type'], '<=' => ['stock'], '%like%' => ['store_name'], @@ -65,8 +65,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $this->searchWhere[] = ['cate_id', '=', $class_all]; } } - $is_warehouse=$this->request->get('is_warehouse',0); - $order_type=$this->request->get('order_type',0); + $is_warehouse = $this->request->get('is_warehouse', 0); + $order_type = $this->request->get('order_type', 0); $userShip = 0; if (!empty($this->params['user_id'])) { $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); @@ -86,9 +86,14 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id'); $query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds); } + $storeId = $this->params['store_id'] ?? 0; + $is_true = true; + if ($storeId > 0) { + $is_true = SystemStore::isSelfOperate($storeId); + } $list = $query->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use($is_warehouse, $userShip,$order_type) { + ->select()->each(function ($item) use ($is_warehouse, $userShip, $order_type, $is_true) { $item['product_id'] = $item['id']; $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { @@ -106,7 +111,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['bar_code'] = ''; } } - switch($item['product_type']){ + switch ($item['product_type']) { case 2: $item['product_type_name'] = '兑换产品'; break; @@ -119,7 +124,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa case 5: $item['product_type_name'] = '批发产品'; break; - case 6: + case 6: $item['product_type_name'] = '零采商品'; break; default: @@ -127,36 +132,36 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); $stock = StoreBranchProduct::where('store_id', '<>', '4')->where('product_id', $item['id'])->sum('stock'); - $category = StoreCategory::where('id','in',[$item['top_cate_id'],$item['two_cate_id'],$item['cate_id']])->column('name'); - $item['cate_name'] =implode('/', $category); - if($is_warehouse==1){ + $category = StoreCategory::where('id', 'in', [$item['top_cate_id'], $item['two_cate_id'], $item['cate_id']])->column('name'); + $item['cate_name'] = implode('/', $category); + if ($is_warehouse == 1) { $item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); - }else{ + } else { $nums = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); $item['stock'] = bcadd($nums, $stock); } if ($userShip == 4) { $item['price'] = $item['cost']; } - if($item['is_show']==1){ - $item['status_msg']='上架|常用'; - }else{ - $item['status_msg']='下架|不常用|是否有替换'; + if ($item['is_show'] == 1) { + $item['status_msg'] = '上架|常用'; + } else { + $item['status_msg'] = '下架|不常用|是否有替换'; } - if ($order_type == 2) { - $price=StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); - if($price>0){ + if ($order_type == 2 && $is_true == false) { + $price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); + if ($price > 0) { $item['price'] = $price; - $item['store_name'] = $item['store_name'].'|活动价'; + $item['store_name'] = $item['store_name'] . '|活动价'; } } - + return $item; })?->toArray(); - if ($userShip > 0 && $userShip != 4) { - $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0); - } + // if ($userShip > 0 && $userShip != 4) { + // $list = StoreProductGroupPrice::resetStoreProductsPrice($list, $userShip, $this->params['store_id'] ?? 0); + // } return $list; } From 38da3cf56f8486d1a15a755a739240724689a444 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 1 Feb 2025 17:08:15 +0800 Subject: [PATCH 09/16] =?UTF-8?q?feat(app):=20=E4=B8=BA=20StoreProductList?= =?UTF-8?q?s=20=E6=B7=BB=E5=8A=A0=E4=BC=9A=E5=91=98=E4=BB=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 StoreProductLists 类中增加了对会员价的处理 - 当 is_true 为 true 且 userShip 大于 0 时,显示会员价 - 会员价显示在商品价格位置,并在店铺名称后添加 "|会员价" 标识 --- app/admin/lists/store_product/StoreProductLists.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 1d9ea3cc..22145502 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -154,6 +154,9 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['price'] = $price; $item['store_name'] = $item['store_name'] . '|活动价'; } + }elseif($is_true == true && $userShip>0){ + $item['price'] = $item['vip_price']; + $item['store_name'] = $item['store_name'] . '|会员价'; } From 198e5e2a7865105b3341ba464989eaa3b9a01ae7 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 13:10:48 +0800 Subject: [PATCH 10/16] =?UTF-8?q?refactor(admin):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除了不必要的条件判断 $is_true == false - 删除了多余的空行,提高了代码可读性 --- app/admin/lists/store_product/StoreProductLists.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 22145502..ac48baa8 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -148,7 +148,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } else { $item['status_msg'] = '下架|不常用|是否有替换'; } - if ($order_type == 2 && $is_true == false) { + if ($order_type == 2) { $price = StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); if ($price > 0) { $item['price'] = $price; @@ -158,8 +158,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa $item['price'] = $item['vip_price']; $item['store_name'] = $item['store_name'] . '|会员价'; } - - return $item; })?->toArray(); // if ($userShip > 0 && $userShip != 4) { From 81c766a2f11591d912c452e58af955cebfb52d9e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 13:18:55 +0800 Subject: [PATCH 11/16] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=BF=AE=E6=94=B9=E6=97=B6=E7=9A=84=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=92=8C=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增加了对订单已出库状态的检查,防止修改已出库订单 - 调整了权限检查逻辑,只允许特定管理员编辑价格 - 优化了订单总价和数量的计算逻辑 - 移除了重复的订单查询代码 --- .../BeforehandOrderCartInfoLogic.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index cf364e96..bfc4112e 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -111,6 +111,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){ throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改'); } + $bhoid = $params['bhoid']; + $order=BeforehandOrder::where('id', $bhoid)->find(); + if($order['outbound_id']>0){ + throw new BusinessException('该订单已出库,不能修改'); + } if($params['total_price']<=0){ $total_price=bcmul($params['purchases'],$params['nums'],2); }else{ @@ -124,12 +129,10 @@ class BeforehandOrderCartInfoLogic extends BaseLogic 'accept_num' => $params['nums'], 'mark' => $params['mark']??'', ]); - $bhoid = $params['bhoid']; $info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price,sum(pay_price) as pay_price')->find(); if($find['is_buyer']==1){ PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]); } - $order=BeforehandOrder::where('id', $bhoid)->find(); $order->save(['total_price' => $info['total_price'],'pay_price' => $info['pay_price'], 'total_num' => $info['cart_num']]); if($order['outbound_id']>0){ From a6c386a29829dc925599ec78f39afab46732c4ab Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 13:52:06 +0800 Subject: [PATCH 12/16] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E5=B7=B2?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E8=AE=A2=E5=8D=95=E4=BF=AE=E6=94=B9=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在同步价格前增加出库状态检查 - 如果订单已出库,则抛出业务异常,禁止修改价格 - 优化查询逻辑,去除不必要的 price 条件 --- .../BeforehandOrderCartInfoLogic.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index bfc4112e..309a9451 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -320,7 +320,11 @@ class BeforehandOrderCartInfoLogic extends BaseLogic public static function syncPrice($params) { - $cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('price', 0)->select()->toArray(); + $outbound_id=BeforehandOrder::where('id', $params['bhoid'])->value('outbound_id'); + if($outbound_id>0){ + throw new BusinessException('该订单已出库,不能修改'); + } + $cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select()->toArray(); $productIds = array_column($cartInfo, 'product_id'); $products = StoreProduct::whereIn('id', $productIds)->select()->toArray(); $products = reset_index($products, 'id'); From 82c1eb1ce61ef0d5166c1577e8cccaa6f96eb291 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 14:22:24 +0800 Subject: [PATCH 13/16] =?UTF-8?q?feat(admin):=20=E6=B7=BB=E5=8A=A0=20demo4?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E5=B9=B6=E5=AE=9E=E7=8E=B0=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E5=90=8C=E6=AD=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 IndexController 中添加 demo4 方法,用于处理价格同步请求 - 在 DemoLogic 中实现 syncPrice 方法,完成价格同步逻辑 - 支持根据是否为 VIP 用户更新商品价格 - 更新订单总价和商品小计价格 - 如果存在出库单,同步更新仓库商品价格 --- app/admin/controller/IndexController.php | 8 ++++ app/api/logic/DemoLogic.php | 47 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/app/admin/controller/IndexController.php b/app/admin/controller/IndexController.php index a0182cb1..57a6d1c7 100644 --- a/app/admin/controller/IndexController.php +++ b/app/admin/controller/IndexController.php @@ -37,4 +37,12 @@ class IndexController extends BaseAdminController $res=DemoLogic::test3($id,$warehouse_id); return $this->success('成功'); } + + public function demo4() + { + $params=$this->request->get(); + $is_vip=$this->request->get('is_vip',0); + $res=DemoLogic::syncPrice($params,$is_vip); + return $this->success('成功'); + } } \ No newline at end of file diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 20886ce2..30a6f092 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -3,6 +3,8 @@ namespace app\api\logic; use app\common\logic\BaseLogic; +use app\common\model\beforehand_order\BeforehandOrder; +use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_group_price\StoreProductGroupPrice; @@ -111,4 +113,49 @@ class DemoLogic extends BaseLogic } } } + + public static function syncPrice($params,$is_vip=0) + { + $outbound_id=BeforehandOrder::where('id', $params['id'])->value('outbound_id'); + + $cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray(); + $productIds = array_column($cartInfo, 'product_id'); + $products = StoreProduct::whereIn('id', $productIds)->select()->toArray(); + $products = reset_index($products, 'id'); + $update = []; + foreach ($cartInfo as $v) { + $product = $products[$v['product_id']]; + if (empty($product)) { + continue; + } + if ($is_vip == 1) { + $price = $product['vip_price']; + } else { + $price = $product['price']; + } + $update[] = [ + 'id' => $v['id'], + 'price' => $price, + 'total_price' => $price * $v['cart_num'], + 'pay_price' => $price * $v['cart_num'], + ]; + } + (new BeforehandOrderCartInfo())->saveAll($update); + $totalPrice = array_sum(array_column($update, 'total_price')); + BeforehandOrder::where('id', $params['id'])->update(['total_price' => $totalPrice,'pay_price' => $totalPrice]); + if($outbound_id){ + WarehouseProduct::where('oid', $outbound_id)->select()->each(function ($item) use($is_vip) { + if($is_vip==0){ + $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->field('purchase,vip_price,price')->find(); + $item->save(['price' => $find['price'], 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'],'total_price' => $find['price'] * $item['nums']]); + }else{ + $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->field('purchase,vip_price,price')->find(); + $item->save(['price' => $find['vip_price'], 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'],'total_price' => $find['vip_price'] * $item['nums']]); + } + }); + $total_price=WarehouseProduct::where('oid', $outbound_id)->sum('total_price'); + BeforehandOrder::where('id', $params['id'])->update(['total_price' => $total_price]); + } + + } } From 7469bd3fe50e5610422700f4d49858af2f41703e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 14:35:10 +0800 Subject: [PATCH 14/16] =?UTF-8?q?fix(api):=20=E4=BF=AE=E6=AD=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=AE=A2=E5=8D=95=E6=80=BB=E9=87=91=E9=A2=9D=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 BeforehandOrder::where('id', $params['id']) 修改为 BeforehandOrder::where('id', $outbound_id') - 此修改确保了更新订单总金额时使用正确的订单 ID --- app/api/logic/DemoLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 30a6f092..57478c09 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -154,7 +154,7 @@ class DemoLogic extends BaseLogic } }); $total_price=WarehouseProduct::where('oid', $outbound_id)->sum('total_price'); - BeforehandOrder::where('id', $params['id'])->update(['total_price' => $total_price]); + BeforehandOrder::where('id', $outbound_id)->update(['total_price' => $total_price]); } } From ffd5fa44c41a4f1ea81da06bced736f02b19263a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 14:36:28 +0800 Subject: [PATCH 15/16] =?UTF-8?q?fix(api):=20=E4=BF=AE=E6=AD=A3=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=AE=A2=E5=8D=95=E6=80=BB=E4=BB=B7=E6=A0=BC=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E8=A1=A8=E5=90=8D=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 BeforehandOrder 修改为 WarehouseOrder,以匹配上下文中的仓库订单逻辑 - 引入 WarehouseOrder 模型用于更新订单总价格 --- app/api/logic/DemoLogic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 57478c09..24349cf1 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -8,6 +8,7 @@ use app\common\model\beforehand_order_cart_info\BeforehandOrderCartInfo; use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_group_price\StoreProductGroupPrice; +use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; use think\facade\Db; @@ -154,7 +155,7 @@ class DemoLogic extends BaseLogic } }); $total_price=WarehouseProduct::where('oid', $outbound_id)->sum('total_price'); - BeforehandOrder::where('id', $outbound_id)->update(['total_price' => $total_price]); + WarehouseOrder::where('id', $outbound_id)->update(['total_price' => $total_price]); } } From b793ace8404c87c15aac5c230a502eea25f8e9c6 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 3 Feb 2025 15:42:39 +0800 Subject: [PATCH 16/16] =?UTF-8?q?fix(api):=20=E4=BF=AE=E5=A4=8D=E6=BC=94?= =?UTF-8?q?=E7=A4=BA=E9=80=BB=E8=BE=91=E4=B8=AD=E4=BA=A7=E5=93=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 DemoLogic 中,将 StoreProduct 查询修改为包含软删除的产品 - 使用 withTrashed() 方法确保可以获取到所有产品,包括已软删除的 --- app/api/logic/DemoLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 24349cf1..5deb97f3 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -121,7 +121,7 @@ class DemoLogic extends BaseLogic $cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray(); $productIds = array_column($cartInfo, 'product_id'); - $products = StoreProduct::whereIn('id', $productIds)->select()->toArray(); + $products = StoreProduct::whereIn('id', $productIds)->withTrashed()->select()->toArray(); $products = reset_index($products, 'id'); $update = []; foreach ($cartInfo as $v) {