Kirin преди 3 години
родител
ревизия
41d6471291
променени са 1 файла, в които са добавени 21 реда и са изтрити 0 реда
  1. 21 0
      app/models/store/StorePink.php

+ 21 - 0
app/models/store/StorePink.php

@@ -560,6 +560,7 @@ class StorePink extends BaseModel
                         self::pinkReturn($pink_info['order_id_key']);
                         self::pinkReturn($pink_info['order_id_key']);
                     } else {
                     } else {
                         TreeRecommend::insertTree($pink_info['uid'], User::where('uid', $pink_info['uid'])->value('spread_uid'));
                         TreeRecommend::insertTree($pink_info['uid'], User::where('uid', $pink_info['uid'])->value('spread_uid'));
+                        self::pinkIntegral($pink_info['order_id_key']);
                     }
                     }
                 }
                 }
             }
             }
@@ -626,6 +627,26 @@ class StorePink extends BaseModel
         return $res;
         return $res;
     }
     }
 
 
+    public static function pinkIntegral($order_id)
+    {
+        $product = StoreOrder::get($order_id);
+        if (!$product) return self::setErrorInfo('数据不存在');
+        $cart_info = StoreOrderCartInfo::where('cart_id', 'in', $product['cart_id'])->select();
+        $return = 0;
+        foreach ($cart_info as $v) {
+            $info = $v['cart_info'];
+            $return += $info['cart_num'] * ($info['productInfo']['attrInfo']['integral']);
+        }
+
+        $res = true;
+        if ($return > 0) {
+            $balance = User::where('uid', $product['uid'])->value('integral');
+            $res = $res && UserBill::income('拼团中奖送响亮积分', $product['uid'], 'integral', 'pink_success', $return, $order_id, $balance + $return, '参加拼团中奖,获得响亮积分' . $return);
+            $res = $res && User::where('uid', $product['uid'])->inc('integral', $return)->update();
+        }
+        return $res;
+    }
+
     /*
     /*
      * 获取参团人和团长和拼团总人数
      * 获取参团人和团长和拼团总人数
      * @param array $pink
      * @param array $pink