Kirin před 3 měsíci
rodič
revize
283b1ad72b

+ 25 - 4
app/services/user/AwardIntegralServices.php

@@ -227,11 +227,32 @@ class AwardIntegralServices extends BaseServices
 
     public function upSpeedIntegral(int $id, string $total)
     {
-        $inc_integral = $total;
+
         $origin = $this->get($id);
-        return $this->dao->update($id, [
-            'up_speed' => bcadd((string)$origin['up_speed'], (string)$inc_integral, 2),
-        ]);
+        $real_send = $total;
+        $left = $origin['num'] - $origin['sent_num'];
+        $update = [];
+        if ($real_send >= $left) {
+            $real_send = $left;
+            $update['up_speed_used'] = $origin['up_speed'];
+            $update['sent_num'] = $origin['num'];
+            $update['status'] = 1;
+        } else {
+            $update['sent_num'] = bcadd((string)$origin['sent_num'], (string)$real_send, 2);
+        }
+        $update['extract_num'] = bcadd((string)$real_send, (string)$origin['extract_num'], 2);
+        $res = $this->dao->update($id, $update);
+        /** @var UserBillServices $billService */
+        $billService = app()->make(UserBillServices::class);
+        $billService->income('integral_speed_up', $origin['uid'], $real_send, $this->getIntegralSum(['uid' => $origin['uid']], 'extract_num') + $real_send, $origin['id']);
+        if (($update['status'] ?? 0) == 1) {
+            $res = $res && $this->extract($origin['id'], $update['extract_num'], true);
+        }
+        return $res;
+        //        $inc_integral = $total;
+//        return $this->dao->update($id, [
+//            'up_speed' => bcadd((string)$origin['up_speed'], (string)$inc_integral, 2),
+//        ]);
     }
 
 

+ 8 - 0
app/services/user/UserBillServices.php

@@ -58,6 +58,14 @@ class UserBillServices extends BaseServices
             'status' => 1,
             'pm' => 1
         ],
+        'integral_speed_up' => [
+            'title' => '参考分加速释放',
+            'category' => 'award_integral',
+            'type' => 'speed_up',
+            'mark' => '加速释放{%num%}参考分',
+            'status' => 1,
+            'pm' => 1
+        ],
         'extract_award_integral' => [
             'title' => '参考分提取',
             'category' => 'award_integral',