refactor(admin): 优化仓库产品价格更新逻辑

- 将 WarehouseProduct 的 update 方法改为 save 方法,以适应 Laravel 框架的最佳实践
- 优化代码结构,提高可读性和维护性
This commit is contained in:
mkm 2024-10-18 12:57:50 +08:00
parent 07b5564e0e
commit f9b5cfa478

View File

@ -122,7 +122,7 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
if($order['outbound_id']>0){
$wp= WarehouseProduct::where('oid',$order['outbound_id'])->where('product_id',$find['product_id'])->where('financial_pm',0)->find();
if($wp){
$wp->update(['price'=>$params['purchases'],'total_price'=>$total_price]);
$wp->save(['price'=>$params['purchases'],'total_price'=>$total_price]);
$wp_total_price=WarehouseProduct::where('oid', $order['outbound_id'])->where('financial_pm',0)->sum('total_price');
WarehouseOrder::where('id', $order['outbound_id'])->update(['total_price' => $wp_total_price]);
}