|
|
|
@ -14,6 +14,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\repositories\wechat\WechatUserRepository; |
|
|
|
|
use crmeb\jobs\SendSmsJob; |
|
|
|
|
use crmeb\services\MiniProgramService; |
|
|
|
@ -22,6 +23,7 @@ use crmeb\services\WechatService; |
|
|
|
|
use think\exception\ValidateException; |
|
|
|
|
use think\facade\Db; |
|
|
|
|
use think\facade\Queue; |
|
|
|
|
use app\common\repositories\user\UserRepository; |
|
|
|
|
|
|
|
|
|
class UserExtractRepository extends BaseRepository |
|
|
|
|
{ |
|
|
|
@ -67,6 +69,8 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
*/ |
|
|
|
|
public function getList(array $where, $page, $limit) |
|
|
|
|
{ |
|
|
|
|
$a = UserRepository::transAdd(); |
|
|
|
|
echo 13;die; |
|
|
|
|
$query = $this->dao->search($where)->with(['user' => function ($query) { |
|
|
|
|
$query->field('uid,avatar,nickname'); |
|
|
|
|
}]); |
|
|
|
@ -102,15 +106,13 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
{ |
|
|
|
|
event('user.extract.before', compact('user', 'data')); |
|
|
|
|
$userExtract = Db::transaction(function () use ($user, $data) { |
|
|
|
|
if ($user['hp_value'] < (systemConfig('user_extract_min'))) |
|
|
|
|
if ($user['hp_value'] < ($data['extract_price'])) |
|
|
|
|
throw new ValidateException('生命值不足,无法提现'); |
|
|
|
|
|
|
|
|
|
if ($user['brokerage_price'] < (systemConfig('user_extract_min'))) |
|
|
|
|
throw new ValidateException('可提增值积分不足'); |
|
|
|
|
if ($data['extract_price'] < (systemConfig('user_extract_min'))) |
|
|
|
|
throw new ValidateException('提现金额不得小于最低额度'); |
|
|
|
|
if ($user['brokerage_price'] < $data['extract_price']) |
|
|
|
|
throw new ValidateException('提现金额不足'); |
|
|
|
|
throw new ValidateException('可提增值积分不足'); |
|
|
|
|
if ($data['extract_type'] == 3) { |
|
|
|
|
$make = app()->make(WechatUserRepository::class); |
|
|
|
|
$openid = $make->idByOpenId((int)$user['wechat_user_id']); |
|
|
|
@ -127,6 +129,12 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
$data['uid'] = $user['uid']; |
|
|
|
|
$data['balance'] = $brokerage_price; |
|
|
|
|
|
|
|
|
|
//扣除生命值 |
|
|
|
|
$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')); |
|
|
|
@ -176,6 +184,12 @@ class UserExtractRepository extends BaseRepository |
|
|
|
|
$user->brokerage_price = $brokerage_price; |
|
|
|
|
$user->save(); |
|
|
|
|
} |
|
|
|
|
if ($data['status'] == -1) { |
|
|
|
|
//回滚生命值 |
|
|
|
|
$user->hp_value += $brokerage_price; |
|
|
|
|
$user->save(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userExtract = $this->dao->update($id, $data); |
|
|
|
|
event('user.extractStatus', compact('id', 'userExtract')); |
|
|
|
|
}); |
|
|
|
|