修复添加线上订单和更新购物车信息的问题

- 在添加预订单逻辑中,禁止创建线上订单类型,只能通过转换方式产生
- 更新购物车信息时,同步更新采购产品报价中的需求数量,仅针对买家购物车
This commit is contained in:
mkm 2024-10-13 15:18:58 +08:00
parent c1d1ccc56d
commit a209a3fc2e
2 changed files with 11 additions and 2 deletions

View File

@ -41,6 +41,11 @@ class BeforehandOrderLogic extends BaseLogic
*/ */
public static function add(array $params): bool public static function add(array $params): bool
{ {
$order_type=$params['order_type'] ?? 0;
if($order_type==4){
throw new BusinessException('不能添加线上订单,线上订单只能转换');
}
Db::startTrans(); Db::startTrans();
try { try {
$datas = []; $datas = [];
@ -70,7 +75,7 @@ class BeforehandOrderLogic extends BaseLogic
'deduction_price' => 0, 'deduction_price' => 0,
'paid' => 0, 'paid' => 0,
'mark' => $params['mark'] ?? '', 'mark' => $params['mark'] ?? '',
'order_type' => $params['order_type'] ?? 4 'order_type' => $order_type
]); ]);
foreach ($datas as $k => $v) { foreach ($datas as $k => $v) {
$datas[$k]['bhoid'] = $order['id']; $datas[$k]['bhoid'] = $order['id'];

View File

@ -96,13 +96,17 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
{ {
Db::startTrans(); Db::startTrans();
try { try {
BeforehandOrderCartInfo::where('id', $params['id'])->update([ $find=BeforehandOrderCartInfo::where('id', $params['id'])->find();
$find->save([
'price' => $params['purchases'], 'price' => $params['purchases'],
'total_price' => bcmul($params['purchases'],$params['nums'],2), 'total_price' => bcmul($params['purchases'],$params['nums'],2),
'cart_num' => $params['nums'], 'cart_num' => $params['nums'],
]); ]);
$bhoid = $params['bhoid']; $bhoid = $params['bhoid'];
$info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find(); $info = BeforehandOrderCartInfo::where('bhoid', $bhoid)->field('sum(cart_num) as cart_num,sum(total_price) as total_price')->find();
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']]); BeforehandOrder::where('id', $bhoid)->update(['total_price' => $info['total_price'], 'total_num' => $info['cart_num']]);
Db::commit(); Db::commit();
return true; return true;