refactor(admin): 优化预订单更新逻辑

- 将订单更新方法从 update 改为 save,提高代码可读性
- 在捕获异常时添加调试信息输出,便于问题排查
This commit is contained in:
mkm 2024-10-18 13:00:10 +08:00
parent f9b5cfa478
commit 2506a02601

View File

@ -117,7 +117,7 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]); PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
} }
$order=BeforehandOrder::where('id', $bhoid)->find(); $order=BeforehandOrder::where('id', $bhoid)->find();
$order->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]); $order->save(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
if($order['outbound_id']>0){ if($order['outbound_id']>0){
$wp= WarehouseProduct::where('oid',$order['outbound_id'])->where('product_id',$find['product_id'])->where('financial_pm',0)->find(); $wp= WarehouseProduct::where('oid',$order['outbound_id'])->where('product_id',$find['product_id'])->where('financial_pm',0)->find();
@ -131,6 +131,7 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
return true; return true;
} catch (\Throwable $e) { } catch (\Throwable $e) {
Db::rollback(); Db::rollback();
d($e);
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
} }