From 02ada622ef522f022c55996e1a568e40f73b2951 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 9 Oct 2024 16:35:46 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E7=B1=BB=E4=B8=AD=E7=9A=84=E9=80=BB=E8=BE=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在BeforehandOrderThreeLists和BeforehandOrderTwoLists类中,添加了判断条件,以防止在outbound_id或warehousing_id为0时执行无效的数据库查询 - 在BeforehandOrderLogic类中,为订单详情添加了order_type字段,以支持不同类型的订单 - 在BeforehandOrderCartInfoLogic类中,修复了一键入库功能的逻辑错误,确保只有在bhoid参数有效时才执行后续操作 --- .../lists/beforehand_order/BeforehandOrderThreeLists.php | 9 +++++++-- .../lists/beforehand_order/BeforehandOrderTwoLists.php | 9 +++++++-- .../logic/beforehand_order/BeforehandOrderLogic.php | 4 +++- .../BeforehandOrderCartInfoLogic.php | 7 +++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php b/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php index 38ff72fc0..726bca26c 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderThreeLists.php @@ -18,7 +18,7 @@ use app\common\model\warehouse_product\WarehouseProduct; */ class BeforehandOrderThreeLists extends BaseAdminDataLists implements ListsSearchInterface { - + public $outbound_id; /** * @notes 设置搜索条件 @@ -48,6 +48,7 @@ class BeforehandOrderThreeLists extends BaseAdminDataLists implements ListsSearc if(empty($outbound_id)){ return []; } + $this->outbound_id=$outbound_id; $this->searchWhere[]=['oid','=',$outbound_id]; $this->searchWhere[]=['financial_pm','=',0]; return WarehouseProduct::where($this->searchWhere)->select() @@ -79,7 +80,11 @@ class BeforehandOrderThreeLists extends BaseAdminDataLists implements ListsSearc */ public function count(): int { - return WarehouseProduct::where($this->searchWhere)->count(); + if($this->outbound_id>0){ + return WarehouseProduct::where($this->searchWhere)->count(); + }else{ + return 0; + } } } \ No newline at end of file diff --git a/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php b/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php index 539019f23..1b47ce629 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderTwoLists.php @@ -19,7 +19,7 @@ use app\common\model\warehouse_product\WarehouseProduct; class BeforehandOrderTwoLists extends BaseAdminDataLists implements ListsSearchInterface { - + public $warehousing_id; /** * @notes 设置搜索条件 * @return \string[][] @@ -48,6 +48,7 @@ class BeforehandOrderTwoLists extends BaseAdminDataLists implements ListsSearchI if(empty($warehousing_id)){ return []; } + $this->warehousing_id=$warehousing_id; $this->searchWhere[]=['oid','=',$warehousing_id]; $this->searchWhere[]=['financial_pm','=',1]; return WarehouseProduct::where($this->searchWhere)->select() @@ -79,7 +80,11 @@ class BeforehandOrderTwoLists extends BaseAdminDataLists implements ListsSearchI */ public function count(): int { - return WarehouseProduct::where($this->searchWhere)->count(); + if($this->warehousing_id>0){ + return WarehouseProduct::where($this->searchWhere)->count(); + }else{ + return 0; + } } } \ No newline at end of file diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 0aba0a355..7f792b6e3 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -41,6 +41,7 @@ class BeforehandOrderLogic extends BaseLogic $total_price = 0; $uid = $params['uid'] ?? 0; foreach ($params['product_arr'] as $k => $v) { + $datas[$k]['mark'] = $v['mark']??''; $datas[$k]['product_id'] = $v['product_id']; $datas[$k]['uid'] = $uid; $datas[$k]['cart_num'] = $v['nums']; @@ -61,7 +62,8 @@ class BeforehandOrderLogic extends BaseLogic 'pay_type' => 0, 'deduction_price' => 0, 'paid' => 0, - 'mark' => $params['mark'] ?? '' + 'mark' => $params['mark'] ?? '', + 'order_type' => $params['order_type'] ?? 0 ]); foreach ($datas as $k => $v) { $datas[$k]['bhoid'] = $order['id']; diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 5a3ad6766..0378d87c3 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -97,8 +97,8 @@ class BeforehandOrderCartInfoLogic extends BaseLogic Db::startTrans(); try { BeforehandOrderCartInfo::where('id', $params['id'])->update([ - 'price' => $params['purchase'], - 'total_price' => $params['total_price'], + 'price' => $params['purchases'], + 'total_price' => bcmul($params['purchases'],$params['nums'],2), 'cart_num' => $params['nums'], ]); $bhoid = $params['bhoid']; @@ -117,6 +117,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic */ public static function oneClickStorage($params) { + if($params['bhoid']<=0){ + throw new BusinessException('参数错误'); + } $count = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0, 'buyer_nums' => 0])->count('id'); $warehousing_id = BeforehandOrder::where('id', $params['bhoid'])->value('warehousing_id'); From 454b9b2e9d1b1a51424d5a254a9556735786774d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 10 Oct 2024 09:23:43 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8C=BA=E5=88=86=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=92=8C=E9=80=80=E8=B4=A7=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=9A=84=E5=85=A5=E5=BA=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改了入库逻辑,以区分采购订单和退货订单: - 采购订单在入库时增加库存 - 退货订单在确认时更新为确认时间 - 为所有订单类型添加了订单类型字段 --- .../beforehand_order/BeforehandOrderLogic.php | 1 + .../SystemStoreStorageLogic.php | 22 +++++++++++-------- .../WarehouseProductLogic.php | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 7f792b6e3..6c95c4652 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -158,6 +158,7 @@ class BeforehandOrderLogic extends BaseLogic 'store_id' => $store_id, 'financial_pm' => 0, 'batch' => 1, + 'order_type' => $order['order_type'], 'nums' => $arr['cart_num'], 'status' => 1, 'admin_id' => $admin_id, diff --git a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php index f1c0d8847..4e221db77 100644 --- a/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php +++ b/app/admin/logic/system_store_storage/SystemStoreStorageLogic.php @@ -64,18 +64,22 @@ class SystemStoreStorageLogic extends BaseLogic Db::startTrans(); try { $find=SystemStoreStorage::where(['id' => $params['id']])->find(); - if($find){ - $find->save(['status'=>1,'staff_id'=>$params['staff_id']??0,'admin_id'=>$params['admin_id']??0,'mark'=>'入库时间:'.date('Y-m-d H:i:s',time())]); - $branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find(); - if($branch_product){ - $branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]); + if($find['order_type']==1){ + $find->save(['status'=>1,'staff_id'=>$params['staff_id']??0,'admin_id'=>$params['admin_id']??0,'mark'=>'入库时间:'.date('Y-m-d H:i:s',time())]); + $branch_product=StoreBranchProduct::where(['product_id'=>$find['product_id'],'store_id'=>$find['store_id']])->find(); + if($branch_product){ + $branch_product->save(['stock'=>$branch_product['stock']+$find['nums']]); + }else{ + $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); + $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); + $storeBranchProduct->stock = $find['nums']; + $storeBranchProduct->save(); + } }else{ - $storeProduct = StoreProduct::where('id', $find['product_id'])->findOrEmpty(); - $storeBranchProduct = StoreProductLogic::ordinary(['id' => $find['product_id']], $find['store_id'], 0, $storeProduct); - $storeBranchProduct->stock = $find['nums']; - $storeBranchProduct->save(); + $find->save(['status'=>1,'staff_id'=>$params['staff_id']??0,'admin_id'=>$params['admin_id']??0,'mark'=>'确认时间:'.date('Y-m-d H:i:s',time())]); } + } Db::commit(); return true; diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 69b21bbb1..a567b737d 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -154,6 +154,7 @@ class WarehouseProductLogic extends BaseLogic SystemStoreStorage::create([ 'store_id' => $params['store_id'], 'admin_id' => $params['admin_id'], + 'order_type' => $params['order_type'], 'staff_id' => 0, 'type' => 1, 'product_id' => $params['product_id'], From 2a784c783c1c61c10440e0e639c7dd7052216865 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 10 Oct 2024 13:32:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E7=9A=84=E8=BF=94=E5=9B=9E=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在StoreOrderController控制器的退款操作中,将简单的成功消息替换为包含状态码和操作结果的详细信息。这样可以提供更丰富的反馈,便于前端处理退款结果。 --- app/admin/controller/store_order/StoreOrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index c34eae335..b986750cf 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -135,7 +135,7 @@ class StoreOrderController extends BaseAdminController if ($res == false) { return $this->fail('退款失败'); } - return $this->success('退款成功'); + return $this->success('退款成功',[],1,1); } /**