|
@@ -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),
|
|
|
+// ]);
|
|
|
}
|
|
|
|
|
|
|