Explorar o código

增加是否会员

ZxcZxc123 hai 1 ano
pai
achega
f6903826bf

+ 4 - 6
app/api/controller/order/StoreOrderController.php

@@ -20,7 +20,8 @@ use app\models\store\{StoreBargainUser,
     StoreOrderStatus,
     StorePink,
     StoreProduct,
-    StoreProductReply};
+    StoreProductReply
+};
 use app\models\system\SystemStore;
 use app\models\user\UserAddress;
 use app\models\user\UserLevel;
@@ -63,7 +64,8 @@ class StoreOrderController
         }
         $other = [
             'offlinePostage' => sys_config('offline_postage'),
-            'integralRatio' => sys_config('integral_ratio')
+            'integralRatio' => sys_config('integral_ratio'),
+            'store_order' => $cartGroup['store_order'],
         ];
         $usableCoupons = StoreCouponUser::getUsableCouponList($uid, $cartGroup, $priceGroup['totalPrice']);
         $usableCoupon = isset($usableCoupons[0]) ? $usableCoupons[0] : null;
@@ -353,10 +355,6 @@ class StoreOrderController
     }
 
 
-
-
-
-
     /**
      * 订单列表
      * @param Request $request

+ 7 - 2
app/models/store/StoreCart.php

@@ -157,7 +157,7 @@ class StoreCart extends BaseModel
 
     public static function getUserProductCartList($uid, $cartIds = '', $status = 0)
     {
-        $productInfoField = 'id,image,price,ot_price,vip_price,postage,give_integral,sales,stock,store_name,unit_name,is_show,is_del,is_postage,cost,is_sub,temp_id,store_type';
+        $productInfoField = 'id,image,price,ot_price,vip_price,postage,give_integral,sales,stock,store_name,unit_name,is_show,is_del,is_postage,cost,is_sub,temp_id,store_type,is_best';
         $seckillInfoField = 'id,image,price,ot_price,postage,give_integral,sales,stock,title as store_name,unit_name,is_show,is_del,is_postage,cost,temp_id,weight,volume,start_time,stop_time,time_id';
         $bargainInfoField = 'id,image,min_price as price,price as ot_price,postage,give_integral,sales,stock,title as store_name,unit_name,status as is_show,is_del,is_postage,cost,temp_id,weight,volume';
         $combinationInfoField = 'id,image,price,postage,sales,stock,title as store_name,is_show,is_del,is_postage,cost,temp_id,weight,volume';
@@ -171,6 +171,7 @@ class StoreCart extends BaseModel
         $list = $model->select()->toArray();
         if (!count($list)) return compact('valid', 'invalid');
         $now = time();
+        $store_order = 0;
         foreach ($list as $k => $cart) {
             if ($cart['seckill_id']) {
                 $product = StoreSeckill::field($seckillInfoField)
@@ -270,6 +271,10 @@ class StoreCart extends BaseModel
                 $cart['cart_num'] = $cart['trueStock'];
                 $model->where('id', $cart['id'])->update(['cart_num' => $cart['cart_num']]);
                 $valid[$k] = $cart;
+                if (($valid[$k]['productInfo']['is_best'] ?? 0) > 0) {
+                    $store_order = 1;
+                }
+
             }
 
             unset($valid[$k]['uid'], $valid[$k]['is_del'], $valid[$k]['is_new'], $valid[$k]['is_pay'], $valid[$k]['add_time']);
@@ -284,7 +289,7 @@ class StoreCart extends BaseModel
             }
         }
 
-        return compact('valid', 'invalid');
+        return compact('valid', 'invalid', 'store_order');
     }
 
     /**

+ 3 - 8
app/models/store/StoreOrder.php

@@ -452,6 +452,7 @@ class StoreOrder extends BaseModel
                 'add_time' => time(),
                 'unique' => $key,
                 'shipping_type' => $shipping_type,
+                'store_order' => $other['store_order'] ?? 0
             ];
             if ($shipping_type === 2) {
                 $orderInfo['verify_code'] = self::getStoreCode();
@@ -790,14 +791,8 @@ class StoreOrder extends BaseModel
 //        ) {
 //            $res = $res && self::set_parent($order['uid'], $order['total_price']);
 //        }
-        if ($order['store_order']) {
-            $isBest = Db::table('store_product')->where('is_best', 1)->count();
-            if ($isBest) {
-                $res = $res && self::set_parent($order['uid'], $order['total_price']);
-                if ($res) {
-                    Db::table('store_order')->where('id', $order['id'])->update(['store_order' => 1]);
-                }
-            }
+        if ($order['store_order']) {     //这个订单是报单的
+            $res = $res && self::set_parent($order['uid'], $order['total_price']);
         }
         return false !== $res;
     }