fix(admin): 修复后台预订单商品价格逻辑

- 增加用户非会员价格判断,避免非会员显示会员价格
- 优化价格查询逻辑,提高代码可读性和性能
This commit is contained in:
mkm 2024-12-21 23:37:35 +08:00
parent b0af0a70bb
commit 3710728806

View File

@ -371,6 +371,7 @@ class BeforehandOrderLogic extends BaseLogic
if ($count > 0) {
throw new BusinessException('订单中有数量为0的商品请先处理');
}
$user_ship=0;
if($order['uid']>0){
$user_ship=User::where('id', $order['uid'])->value('user_ship')??0;
}
@ -390,7 +391,11 @@ class BeforehandOrderLogic extends BaseLogic
$arr['delivery_time'] = strtotime($delivery_time);
$res = WarehouseOrder::create($arr);
foreach ($info as $key => $arr) {
$price=StoreProductGroupPrice::where('product_id',$arr['product_id'])->where('group_id',$user_ship)->value('price')??0;
if($user_ship==0){
$price=0;
}else{
$price=StoreProductGroupPrice::where('product_id',$arr['product_id'])->where('group_id',$user_ship)->value('price')??0;
}
$data = [
'warehouse_id' => $warehouse_id,
'product_id' => $arr['product_id'],