Kirin 9 ヶ月 前
コミット
0757f00250
1 ファイル変更22 行追加5 行削除
  1. 22 5
      app/controller/api/v1/PublicController.php

+ 22 - 5
app/controller/api/v1/PublicController.php

@@ -70,12 +70,29 @@ class PublicController extends BaseController
 
     public function test()
     {
-        $list = UserIntegral::where('price', 99.99999999)->select();
-        foreach ($list as $v) {
-            $p = bcdiv($v['sum_price'], $v['num'], 8);
-            if ($p != $v['price']) {
-                UserIntegral::where('id', $v['id'])->update(['price' => $p]);
+        $userService = app()->make(UserServices::class);
+        /** @var UserLevelServices $levelServices */
+        $levelServices = app()->make(UserLevelServices::class);
+        /** @var UserAwardIntegralServices $awardIntegralService */
+        $awardIntegralService = app()->make(UserAwardIntegralServices::class);
+        $user = $userService->getUserInfo(139126);
+        $pass = [$user['uid']];
+        $send = 0;
+        while ($spread && !in_array($spread['uid'], $pass) && $spread['is_promoter']) {
+            //先发奖,再结算等级
+            $level = $levelServices->getUserLevel($spread['uid']);
+            $ratio = $level['levelInfo']['group_award'] ?? 0;
+            $give_action_integral = bcdiv(bcmul(2000, $ratio), 100, 2);
+            if ($give_action_integral > $send) {
+                $real_send = bcsub($give_action_integral, $send, 2);
+                if ($awardIntegralService->getPaySum($spread['uid']) >= 0 || $awardIntegralService->getHourExtractPaySum($spread['uid'], 24) > 0 || $spread['award_switch']) {
+                    $mark = '团队用户' . $user['nickname'] . "({$user['uid']})" . '购买商品,获得团队级差积分';
+                    var_dump($mark);
+                }
+                $send = $give_action_integral;
             }
+            $pass[] = $spread['uid'];
+            $spread = $userService->getUserInfo($spread['spread_uid']);
         }
     }