|
|
|
@ -15,6 +15,7 @@ namespace app\common\repositories\user; |
|
|
|
|
use app\common\repositories\BaseRepository; |
|
|
|
|
use app\common\dao\user\UserExtractDao as dao; |
|
|
|
|
use app\common\model\user\User as userModel; |
|
|
|
|
use app\common\model\system\config\SystemConfigValue; |
|
|
|
|
use app\common\repositories\wechat\WechatUserRepository; |
|
|
|
|
use crmeb\jobs\SendSmsJob; |
|
|
|
|
use crmeb\services\MiniProgramService; |
|
|
|
@ -129,10 +130,10 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
|
|
|
|
|
//扣除生命值 |
|
|
|
|
$u = userModel::where('uid', $user->uid)->find(); |
|
|
|
|
|
|
|
|
|
$u->hp_value -= $data['extract_price']; |
|
|
|
|
$u->save(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->dao->create($data); |
|
|
|
|
}); |
|
|
|
|
event('user.extract', compact('userExtract')); |
|
|
|
@ -145,6 +146,7 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
|
|
|
|
|
public function switchStatus($id, $data) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$extract = $this->dao->getWhere(['extract_id' => $id]); |
|
|
|
|
$user = app()->make(UserRepository::class)->get($extract['uid']); |
|
|
|
|
if (!$user) throw new ValidateException('用户不存在'); |
|
|
|
@ -175,19 +177,32 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Db::transaction(function () use ($id, $data, $user, $brokerage_price, $ret, $service, $func) { |
|
|
|
|
$pre_price = $extract->pre_price; |
|
|
|
|
$extract_price = $extract['extract_price']; |
|
|
|
|
|
|
|
|
|
Db::transaction(function () use ($id, $data, $user, $brokerage_price, $ret, $service, $func, $pre_price, $extract_price) { |
|
|
|
|
|
|
|
|
|
event('user.extractStatus.before', compact('id', 'data')); |
|
|
|
|
if ($ret) $service->{$func}($ret); |
|
|
|
|
if ($brokerage_price) { |
|
|
|
|
$user->brokerage_price = $brokerage_price; |
|
|
|
|
$user->save(); |
|
|
|
|
} |
|
|
|
|
//拒绝 |
|
|
|
|
if ($data['status'] == -1) { |
|
|
|
|
//回滚生命值 |
|
|
|
|
$user->hp_value += $brokerage_price; |
|
|
|
|
$user->hp_value += $extract_price; |
|
|
|
|
$user->save(); |
|
|
|
|
} else { |
|
|
|
|
//同意的话 |
|
|
|
|
//奖金池 - 申请提现的70% + 申请提现的30% |
|
|
|
|
$a = SystemConfigValue::getDB()->where('config_key', 'all_award')->find(); |
|
|
|
|
$b = $pre_price * 0.7 - $pre_price * 0.3; |
|
|
|
|
$a->value = $a->value - $b; |
|
|
|
|
$a->save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$userExtract = $this->dao->update($id, $data); |
|
|
|
|
event('user.extractStatus', compact('id', 'userExtract')); |
|
|
|
|
}); |
|
|
|
|