hrjy 3 years ago
parent
commit
4fd1c68044

+ 1 - 1
app/api/controller/order/StoreOrderController.php

@@ -677,7 +677,7 @@ class StoreOrderController
         $order = StoreOrder::where('order_id', $data['order_id'])->find();
         if (!$order) return app('json')->fail('订单不查找');
         $coupon = StoreCouponUser::alias('a')
-            ->field('a.id,a.coupon_title,a.coupon_price,a.add_time,a.end_time,a.code,a.status,c.id as store_id ,c.name,c.phone,c.address,c.detailed_address,c.image,c.day_time,c.latitude,c.longitude')
+            ->field('a.id,a.coupon_title,a.coupon_price,a.add_time,a.end_time,a.code,a.status,c.id as c_id ,c.name,c.phone,c.address,c.detailed_address,c.image,c.day_time,c.latitude,c.longitude')
             ->leftJoin('store_coupon b', 'b.id = a.cid')
             ->leftJoin('system_store c', 'b.store_id = c.id')
             ->where('a.order_id', $data['order_id'])

+ 7 - 1
app/api/controller/user/UserController.php

@@ -671,7 +671,13 @@ class UserController
             ['limit', 10]
         ], $request);
 
-        $coupon = StoreCouponUser::where('uid', $request->uid())->where('status', $data['status'])->select();
+        $coupon = StoreCouponUser::alias('a')
+            ->field('a.*,c.id as c_id,c.name,c.image,c.latitude,c.longitude,c.detailed_address')
+            ->leftJoin('store_coupon b', 'a.cid = b.id')
+            ->leftJoin('system_store c', 'b.store_id = c.id')
+            ->where('a.uid', $request->uid())
+            ->where('a.status', $data['status'])
+            ->select();
         $coupon = count($coupon) > 0?$coupon->toArray() : [];
         return app('json')->success($coupon);
     }

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

@@ -873,17 +873,22 @@ class StoreOrder extends BaseModel
         $top1 = User::where('uid', $uid)->find(); // 一级上级
 
         $top2 = User::where('uid', $top1['spread_uid'])->find(); // 二级上级
-        $top1['brokerage_price'] += 1200;//直推
-        $top2['brokerage_price'] += 600;//间推
-        if ($top1['level'] == 2){
-            $top1->save();
-            UserBill::income('佣金', $top1['uid'], 'now_money', 'brokerage', 1200, 0, $top1['brokerage_price'], '直推2999礼包奖励');
+        if ($top1){
+            $top1['brokerage_price'] += 1200;//直推
+            if ($top1['level'] == 2){
+                $top1->save();
+                UserBill::income('佣金', $top1['uid'], 'now_money', 'brokerage', 1200, 0, $top1['brokerage_price'], '直推2999礼包奖励');
+            }
         }
-        if ($top2['level'] == 2){
-            $top2->save();
-            UserBill::income('佣金', $top2['uid'], 'now_money', 'brokerage', 600, 0, $top2['brokerage_price'], '间推2999礼包奖励');
+        if ($top2) {
+            $top2['brokerage_price'] += 600;//间推
+            if ($top2['level'] == 2){
+                $top2->save();
+                UserBill::income('佣金', $top2['uid'], 'now_money', 'brokerage', 600, 0, $top2['brokerage_price'], '间推2999礼包奖励');
+            }
         }
 
+
     }
 
     /**