fix(order): 修复下单时未检查商品状态导致的异常

- 在计算订单价格时,增加了对商品状态的检查
- 对于下架商品,抛出异常提示用户更换商品后下单
- 修改了查询商品信息时的字段列表,增加了 is_show 和 status 字段
This commit is contained in:
mkm 2024-12-11 18:01:08 +08:00
parent 944aaf2425
commit 1185ecf9ec

View File

@ -92,13 +92,13 @@ class OrderLogic extends BaseLogic
self::$fresh_price = 0; //生鲜金额
/** 计算价格 */
$off_activity = Config::where('name', 'off_activity')->value('value');
$field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
$field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose,is_show';
foreach ($cart_select as $k => $v) {
if($source==0){
$source=$v['source'];
}
if ($source == 2) {
$field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
$field = 'product_id,product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose,status';
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
if($find && $find['status']==0){
throw new BusinessException('订单存在下架商品请更换后下单');