From d753240be619fe2027043e493918a5d355d8f10e Mon Sep 17 00:00:00 2001 From: 1748153932 <1748153932@qq.com> Date: Fri, 29 Dec 2023 18:17:29 +0800 Subject: [PATCH] 123213 --- .../user/UserExtractRepository.php | 21 ++++++++++++++++--- app/controller/api/user/User.php | 16 +++++++++----- app/controller/api/user/UserExtract.php | 17 ++++++++------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/app/common/repositories/user/UserExtractRepository.php b/app/common/repositories/user/UserExtractRepository.php index a8bd5fa..2312056 100644 --- a/app/common/repositories/user/UserExtractRepository.php +++ b/app/common/repositories/user/UserExtractRepository.php @@ -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')); }); diff --git a/app/controller/api/user/User.php b/app/controller/api/user/User.php index 3b13cac..9afe799 100644 --- a/app/controller/api/user/User.php +++ b/app/controller/api/user/User.php @@ -403,12 +403,18 @@ class User extends BaseController $list['user']['hp_value'] = $user->hp_value; $list['user']['all_value'] = $user->all_value; $list['user']['brokerage_price'] = $user->brokerage_price; - //可提现金额 - $list['user']['may_value'] = 111; + + //当前平台奖池总奖金 + $all = systemConfig('all_award'); + //当前平台增值积分总个数 + $allBrandValue = userModel::getDB()->where('status', 1)->sum('brokerage_price') ?? 1; + + //增值积分实时价格=当前平台奖池总奖金/当前平台增值积分总个数 + $shishi = $all / $allBrandValue; + //平台增值积分实时价格 - $list['user']['proportion'] = 1; - //手续费 - $list['user']['shouxufei'] = 0.06; + $list['user']['proportion'] = $shishi; + return app('json')->success($list); diff --git a/app/controller/api/user/UserExtract.php b/app/controller/api/user/UserExtract.php index b889ed1..addbc0c 100644 --- a/app/controller/api/user/UserExtract.php +++ b/app/controller/api/user/UserExtract.php @@ -30,7 +30,7 @@ class UserExtract extends BaseController * @param App $app * @param repository $repository */ - public function __construct(App $app,repository $repository) + public function __construct(App $app, repository $repository) { parent::__construct($app); $this->repository = $repository; @@ -38,32 +38,33 @@ class UserExtract extends BaseController public function lst() { - [$page,$limit] = $this->getPage(); + [$page, $limit] = $this->getPage(); $where = $this->request->params(['status']); $where['uid'] = $this->request->uid(); - return app('json')->success($this->repository->getList($where,$page,$limit)); + return app('json')->success($this->repository->getList($where, $page, $limit)); } public function create(validate $validate) { $data = $this->checkParams($validate); $user = $this->request->userInfo(); - if($data['extract_type'] == 3 && !systemConfig('sys_extension_type') ) return app('json')->fail('未开启付款到零钱'); - $this->repository->create($user,$data); + if ($data['extract_type'] == 3 && !systemConfig('sys_extension_type')) return app('json')->fail('未开启付款到零钱'); + $this->repository->create($user, $data); return app('json')->success('申请已提交'); } public function checkParams(validate $validate) { - $data = $this->request->params(['extract_type','bank_code','bank_address','alipay_code','wechat','extract_pic','extract_price','real_name','bank_name']); + $data = $this->request->params(['extract_type', 'bank_code', 'bank_address', 'alipay_code', 'wechat', + 'extract_pic', 'extract_price', 'real_name', 'bank_name', 'real_price', 'pre_price']); $validate->check($data); return $data; } public function bankLst() { - [$page,$limit] = $this->getPage(); - $data = app()->make(GroupDataRepository::class)->groupData('bank_list',0,$page,100); + [$page, $limit] = $this->getPage(); + $data = app()->make(GroupDataRepository::class)->groupData('bank_list', 0, $page, 100); return app('json')->success($data); }