Explorar o código

fix(order): 修复订单创建中的地址参数处理逻辑

- 将psType默认值从false修改为true以确保地址参数正确传递
- 恢复地址ID检查逻辑,当地址ID为空时将psType设置为false
- 保持产品类型检测逻辑不变,确保yhc来源的特殊处理正常工作
shichen hai 2 meses
pai
achega
bd1b2e3c99
Modificáronse 1 ficheiros con 10 adicións e 10 borrados
  1. 10 10
      app/controller/api/store/order/StoreOrder.php

+ 10 - 10
app/controller/api/store/order/StoreOrder.php

@@ -72,20 +72,20 @@ class StoreOrder extends BaseController
72 72
     {
73 73
         $cartId = (array)$this->request->param('cart_id', []);
74 74
         $addressId = (int)$this->request->param('address_id');
75
-        $psType = $this->request->param('type',false);//是否需要地址 boolean
75
+        $psType = $this->request->param('type', true);//是否需要地址 boolean
76 76
         $uid = $this->request->uid();
77 77
 
78 78
         if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
79 79
             return app('json')->fail('已失效或已下单');
80
-        // if (!$addressId) {
81
-        //     return app('json')->fail('请选择收货地址');
82
-        // }
83
-        $orderInfo = $this->repository->cartIdByOrderInfo($uid, $cartId, $addressId,true,$psType);
84
-        $orderInfo['product_type']=0;
85
-        if($this->source=='yhc'){
86
-            $product_type=Db::name('store_cart')->alias('c')->join('store_product p','c.product_id=p.product_id')->whereIn('cart_id',$cartId)->column('p.type');
87
-            if(in_array(17,$product_type)){
88
-                $orderInfo['product_type']=17;
80
+        if (!$addressId) {
81
+            $psType = false;
82
+        }
83
+        $orderInfo = $this->repository->cartIdByOrderInfo($uid, $cartId, $addressId, true, $psType);
84
+        $orderInfo['product_type'] = 0;
85
+        if ($this->source == 'yhc') {
86
+            $product_type = Db::name('store_cart')->alias('c')->join('store_product p', 'c.product_id=p.product_id')->whereIn('cart_id', $cartId)->column('p.type');
87
+            if (in_array(17, $product_type)) {
88
+                $orderInfo['product_type'] = 17;
89 89
             }
90 90
         }
91 91
         return app('json')->success($orderInfo);