|
@@ -6,6 +6,7 @@ use app\services\user\level\UserLevelServices;
|
|
|
use app\services\user\UserAwardIntegralServices;
|
|
|
use app\services\user\UserBillServices;
|
|
|
use app\services\user\UserBrokerageServices;
|
|
|
+use app\services\user\UserMoneyServices;
|
|
|
use app\services\user\UserServices;
|
|
|
use crmeb\basic\BaseJobs;
|
|
|
use crmeb\traits\QueueTrait;
|
|
@@ -58,6 +59,9 @@ class IntegralJob extends BaseJobs
|
|
|
if ($spread) {
|
|
|
if ($awardIntegralService->getPaySum($spread['uid']) >= 1000 || $awardIntegralService->getHourExtractPaySum($spread['uid'], 24) >= 1000) {
|
|
|
$award_ratio = sys_config('recommend_integral', 0);
|
|
|
+ if ($awardIntegralService->reOrder($user['uid'], $order['id'])) {
|
|
|
+ $award_ratio = sys_config('reorder_recommend_integral', 0);
|
|
|
+ }
|
|
|
$give_action_integral = bcdiv(bcmul($total_price, $award_ratio), 100, 2);
|
|
|
if ($give_action_integral > 0) {
|
|
|
$extract_sum = bcmul($give_action_integral, $rate, 2);
|
|
@@ -177,6 +181,8 @@ class IntegralJob extends BaseJobs
|
|
|
$awardIntegralService = app()->make(UserAwardIntegralServices::class);
|
|
|
/** @var UserBrokerageServices $brokerageService */
|
|
|
$brokerageService = app()->make(UserBrokerageServices::class);
|
|
|
+ /** @var UserMoneyServices $moneyService */
|
|
|
+ $moneyService = app()->make(UserMoneyServices::class);
|
|
|
/** @var UserBillServices $billService */
|
|
|
$billService = app()->make(UserBillServices::class);
|
|
|
/** @var UserServices $userService */
|
|
@@ -212,28 +218,58 @@ class IntegralJob extends BaseJobs
|
|
|
$mark = '用户积分出局,出局时价格' . $price;
|
|
|
$res = $res && $awardIntegralService->addLake(-$real_out, $info['id'], $mark);
|
|
|
|
|
|
+ $to_now_money = 0;
|
|
|
+ $starts_return_time = sys_config('starts_return_time', 0);
|
|
|
+ if ($starts_return_time > 0) {
|
|
|
+ $count = $awardIntegralService->search(['uid' => $user['uid'], 'type' => 0, 'status' => 1])->count();
|
|
|
+ if ($count < $starts_return_time) {
|
|
|
+ $to_now_money = $info['order_price'];
|
|
|
+ if ($to_now_money > $real_out) {
|
|
|
+ $to_now_money = $real_out;
|
|
|
+ }
|
|
|
+ $real_out = bcsub($real_out, $to_now_money, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($to_now_money > 0) {
|
|
|
+ $balance = bcadd($user['now_money'], $to_now_money, 2);
|
|
|
+ $res = $res && $moneyService->income('extract_integral', $info['uid'], [
|
|
|
+ 'type' => $info['type'] ? '贡献分' : '消费分',
|
|
|
+ 'price' => round($price, 2),
|
|
|
+ 'integral_num' => $info['num'],
|
|
|
+ 'number' => floatval($to_now_money),
|
|
|
+ 'frozen_time' => 0
|
|
|
+ ], $balance, $info['id']);
|
|
|
+ // 添加用户佣金
|
|
|
+ $res = $res && $userService->bcInc($info['uid'], 'now_money', $to_now_money, 'uid');
|
|
|
+ }
|
|
|
+
|
|
|
$to_brokerage = bcdiv(bcmul($real_out, sys_config('extract_brokerage_ratio', 0)), 100, 2);
|
|
|
- $balance = bcadd($user['brokerage_price'], $to_brokerage, 2);
|
|
|
- $res = $res && $brokerageService->income('extract_integral', $info['uid'], [
|
|
|
- 'type' => $info['type'] ? '贡献分' : '消费分',
|
|
|
- 'price' => round($price, 2),
|
|
|
- 'integral_num' => $info['num'],
|
|
|
- 'number' => floatval($to_brokerage),
|
|
|
- 'frozen_time' => 0
|
|
|
- ], $balance, $info['id']);
|
|
|
- // 添加用户佣金
|
|
|
- $res = $res && $userService->bcInc($info['uid'], 'brokerage_price', $to_brokerage, 'uid');
|
|
|
+ if ($to_brokerage > 0) {
|
|
|
+ $balance = bcadd($user['brokerage_price'], $to_brokerage, 2);
|
|
|
+ $res = $res && $brokerageService->income('extract_integral', $info['uid'], [
|
|
|
+ 'type' => $info['type'] ? '贡献分' : '消费分',
|
|
|
+ 'price' => round($price, 2),
|
|
|
+ 'integral_num' => $info['num'],
|
|
|
+ 'number' => floatval($to_brokerage),
|
|
|
+ 'frozen_time' => 0
|
|
|
+ ], $balance, $info['id']);
|
|
|
+ // 添加用户佣金
|
|
|
+ $res = $res && $userService->bcInc($info['uid'], 'brokerage_price', $to_brokerage, 'uid');
|
|
|
+ }
|
|
|
|
|
|
$to_energy = bcsub($real_out, $to_brokerage, 2);
|
|
|
- $balance = bcadd($user['energy'], $to_energy, 2);
|
|
|
- $res = $res && $billService->income('extract_integral', $info['uid'], [
|
|
|
- 'type' => $info['type'] ? '贡献分' : '消费分',
|
|
|
- 'price' => round($price, 2),
|
|
|
- 'integral_num' => $info['num'],
|
|
|
- 'number' => floatval($to_energy),
|
|
|
- ], $balance, $info['id']);
|
|
|
- // 添加用户佣金
|
|
|
- $res = $res && $userService->bcInc($info['uid'], 'energy', $to_energy, 'uid');
|
|
|
+ if ($to_energy > 0) {
|
|
|
+ $balance = bcadd($user['energy'], $to_energy, 2);
|
|
|
+ $res = $res && $billService->income('extract_integral', $info['uid'], [
|
|
|
+ 'type' => $info['type'] ? '贡献分' : '消费分',
|
|
|
+ 'price' => round($price, 2),
|
|
|
+ 'integral_num' => $info['num'],
|
|
|
+ 'number' => floatval($to_energy),
|
|
|
+ ], $balance, $info['id']);
|
|
|
+ // 添加用户佣金
|
|
|
+ $res = $res && $userService->bcInc($info['uid'], 'energy', $to_energy, 'uid');
|
|
|
+ }
|
|
|
$res = $res && $awardIntegralService->update($info['id'], ['handle' => 0, 'extract_sum_real' => $sum, 'status' => 1, 'extract_time' => time()]);
|
|
|
}
|
|
|
if ($to_top > 0) {
|