1748153932 1 year ago
parent 5e151a4689
commit 6dceaa0ac2
  1. 19
      app/common/repositories/user/UserExtractRepository.php
  2. 1
      app/controller/admin/user/UserExtract.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'));
});

@ -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('审核成功');
}

Loading…
Cancel
Save