diff --git a/app/common/repositories/user/UserExtractRepository.php b/app/common/repositories/user/UserExtractRepository.php index 8a2fb36..571916e 100644 --- a/app/common/repositories/user/UserExtractRepository.php +++ b/app/common/repositories/user/UserExtractRepository.php @@ -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; @@ -102,15 +103,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 +126,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 +181,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')); }); diff --git a/app/controller/admin/user/UserExtract.php b/app/controller/admin/user/UserExtract.php index eed007b..c002f0d 100644 --- a/app/controller/admin/user/UserExtract.php +++ b/app/controller/admin/user/UserExtract.php @@ -69,6 +69,7 @@ class UserExtract extends BaseController $data['admin_id'] = $this->request->adminId(); $data['status_time'] = date('Y-m-d H:i:s',time()); $this->repository->switchStatus($id,$data); + return app('json')->success('审核成功'); }