feat(admin): 设置仓库商品信息并优化订单处理逻辑

- 新增 PurchaseProductOfferController 中的 setStoreroomInfo 方法,用于设置仓库商品信息
- 修改 BeforehandOrderCartInfoLogic 中的处理逻辑,增加对总价格的判断和计算
- 在更新订单信息时,增加对出库单中商品价格和总价格的同步更新
This commit is contained in:
mkm 2024-10-18 11:36:46 +08:00
parent f526e60841
commit 7a742331de
2 changed files with 21 additions and 2 deletions

View File

@ -83,6 +83,9 @@ class PurchaseProductOfferController extends BaseAdminController
PurchaseProductOfferLogic::setBatchProcureInfo($params);
return $this->success('设置成功', [], 1, 1);
}
/**
* 设置仓库商品信息
*/
public function setStoreroomInfo()
{
$params = $this->request->post();

View File

@ -8,6 +8,7 @@ use app\common\logic\BaseLogic;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\purchase_product_offer\PurchaseProductOffer;
use app\common\model\warehouse_order\WarehouseOrder;
use app\common\model\warehouse_product\WarehouseProduct;
use support\exception\BusinessException;
use think\facade\Db;
@ -100,9 +101,14 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
if($params['admin_id']==23&&$params['purchases']!=$find['price'] ){
throw new BusinessException('当前账号没有权限编辑价格, 请联系管理员修改');
}
if($params['total_price']<=0){
$total_price=bcmul($params['purchases'],$params['nums'],2);
}else{
$total_price=$params['total_price'];
}
$find->save([
'price' => $params['purchases'],
'total_price' => bcmul($params['purchases'],$params['nums'],2),
'total_price' => $total_price,
'cart_num' => $params['nums'],
]);
$bhoid = $params['bhoid'];
@ -110,7 +116,17 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
if($find['is_buyer']==1){
PurchaseProductOffer::where('order_id',$bhoid)->where('product_id',$find['product_id'])->update(['need_num'=>$params['nums']]);
}
BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
$order=BeforehandOrder::where('id', $bhoid)->find();
$order->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
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_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]);
}
}
Db::commit();
return true;
} catch (\Throwable $e) {