diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index b7967434..36690433 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -83,13 +83,24 @@ 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,top_cate_id,store_info,rose'; + $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); if (!$find) { self::setError('商品不存在'); return false; } + $StoreCategory=StoreCategory::where('id',$find['cate_id'])->find(); + $find['top_cate_id']=$find['cate_id']; + if($StoreCategory && $StoreCategory['pid']>0){ + $StoreCategory2=StoreCategory::where('id',$StoreCategory['pid'])->find(); + if($StoreCategory2 && $StoreCategory['pid']>0){ + $find['top_cate_id']=$StoreCategory2['pid']; + }else{ + $find['top_cate_id']=$StoreCategory['pid']; + } + + } unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 if ($off_activity == 1 || ($user != null && in_array($user['user_ship'], [4, 6, 7]))) {