|
@@ -2693,8 +2693,65 @@ class UserRepository extends BaseRepository
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public function extractIntegral($uid)
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 提取分红积分
|
|
|
|
|
+ * @param $uid
|
|
|
|
|
+ * @param $num
|
|
|
|
|
+ * @return true
|
|
|
|
|
+ * @throws DataNotFoundException
|
|
|
|
|
+ * @throws DbException
|
|
|
|
|
+ * @throws ModelNotFoundException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function extractIntegral($uid, $num = 0)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ $info = $this->dao->get($uid);
|
|
|
|
|
+ if ($num == 0) $num = $info['award_integral'];
|
|
|
|
|
+ if ($num > 0) {
|
|
|
|
|
+ // 实例化用户账单仓库,用于处理用户账单相关操作。
|
|
|
|
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
|
|
+ $price = $this->awardIntegralPrice();
|
|
|
|
|
+ $all_price = bcmul($num, $price['price']);
|
|
|
|
|
+ if ($all_price > $info['award_range']) $all_price = $info['award_range'];
|
|
|
|
|
+
|
|
|
|
|
+ if ($all_price > 0) {
|
|
|
|
|
+ //用户获得$all_price的佣金
|
|
|
|
|
+ $userBillRepository->incBill($uid, 'brokerage', 'extract_award', [
|
|
|
|
|
+ 'link_id' => 0,
|
|
|
|
|
+ 'status' => 1,
|
|
|
|
|
+ 'title' => '提取分红积分',
|
|
|
|
|
+ 'number' => $all_price,
|
|
|
|
|
+ 'mark' => $info['nickname'] . '提取' . floatval($num) . '分红积分为' . floatval($all_price) . '佣金(分红积分价格:' . $price['price'] . ')',
|
|
|
|
|
+ 'balance' => bcadd($info['brokerage_price'], $all_price, 2)
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $userRepository = app()->make(UserRepository::class);
|
|
|
|
|
+ $userRepository->incBrokerage($uid, $all_price);
|
|
|
|
|
+ $userRepository->incField($uid, 'brokerage_price', $all_price);
|
|
|
|
|
+ //用户失去$all_price的收益额度
|
|
|
|
|
+ $userBillRepository->decBill($uid, 'award_range', 'extract_award', [
|
|
|
|
|
+ 'link_id' => 0,
|
|
|
|
|
+ 'status' => 1,
|
|
|
|
|
+ 'title' => '提取分红积分',
|
|
|
|
|
+ 'number' => $all_price,
|
|
|
|
|
+ 'mark' => $info['nickname'] . '提取分红积分为佣金,减少分红额度',
|
|
|
|
|
+ 'balance' => bcsub($info['award_range'], $all_price, 2)
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $userRepository->decField($uid, 'award_range', $all_price);
|
|
|
|
|
+ if ($info['award_range'] == $all_price) {
|
|
|
|
|
+ $num = $info['award_integral'];
|
|
|
|
|
+ }
|
|
|
|
|
+ //若用户失去所有收益额度,清空用户的分红积分
|
|
|
|
|
+ $userBillRepository->decBill($uid, 'award_integral', 'extract_award', [
|
|
|
|
|
+ 'link_id' => 0,
|
|
|
|
|
+ 'status' => 1,
|
|
|
|
|
+ 'title' => '提取分红积分',
|
|
|
|
|
+ 'number' => $num,
|
|
|
|
|
+ 'mark' => $info['nickname'] . '提取' . floatval($num) . '分红积分',
|
|
|
|
|
+ 'balance' => bcsub($info['award_integral'], $num, 2)
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $userRepository->decField($uid, 'award_integral', $num);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|