main
1748153932 11 months ago
parent 8c972ece5c
commit d753240be6
  1. 21
      app/common/repositories/user/UserExtractRepository.php
  2. 16
      app/controller/api/user/User.php
  3. 17
      app/controller/api/user/UserExtract.php

@ -15,6 +15,7 @@ namespace app\common\repositories\user;
use app\common\repositories\BaseRepository; use app\common\repositories\BaseRepository;
use app\common\dao\user\UserExtractDao as dao; use app\common\dao\user\UserExtractDao as dao;
use app\common\model\user\User as userModel; use app\common\model\user\User as userModel;
use app\common\model\system\config\SystemConfigValue;
use app\common\repositories\wechat\WechatUserRepository; use app\common\repositories\wechat\WechatUserRepository;
use crmeb\jobs\SendSmsJob; use crmeb\jobs\SendSmsJob;
use crmeb\services\MiniProgramService; use crmeb\services\MiniProgramService;
@ -129,10 +130,10 @@ class UserExtractRepository extends BaseRepository
//扣除生命值 //扣除生命值
$u = userModel::where('uid', $user->uid)->find(); $u = userModel::where('uid', $user->uid)->find();
$u->hp_value -= $data['extract_price']; $u->hp_value -= $data['extract_price'];
$u->save(); $u->save();
return $this->dao->create($data); return $this->dao->create($data);
}); });
event('user.extract', compact('userExtract')); event('user.extract', compact('userExtract'));
@ -145,6 +146,7 @@ class UserExtractRepository extends BaseRepository
public function switchStatus($id, $data) public function switchStatus($id, $data)
{ {
$extract = $this->dao->getWhere(['extract_id' => $id]); $extract = $this->dao->getWhere(['extract_id' => $id]);
$user = app()->make(UserRepository::class)->get($extract['uid']); $user = app()->make(UserRepository::class)->get($extract['uid']);
if (!$user) throw new ValidateException('用户不存在'); 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')); event('user.extractStatus.before', compact('id', 'data'));
if ($ret) $service->{$func}($ret); if ($ret) $service->{$func}($ret);
if ($brokerage_price) { if ($brokerage_price) {
$user->brokerage_price = $brokerage_price; $user->brokerage_price = $brokerage_price;
$user->save(); $user->save();
} }
//拒绝
if ($data['status'] == -1) { if ($data['status'] == -1) {
//回滚生命值 //回滚生命值
$user->hp_value += $brokerage_price; $user->hp_value += $extract_price;
$user->save(); $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); $userExtract = $this->dao->update($id, $data);
event('user.extractStatus', compact('id', 'userExtract')); event('user.extractStatus', compact('id', 'userExtract'));
}); });

@ -403,12 +403,18 @@ class User extends BaseController
$list['user']['hp_value'] = $user->hp_value; $list['user']['hp_value'] = $user->hp_value;
$list['user']['all_value'] = $user->all_value; $list['user']['all_value'] = $user->all_value;
$list['user']['brokerage_price'] = $user->brokerage_price; $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']['proportion'] = $shishi;
//手续费
$list['user']['shouxufei'] = 0.06;
return app('json')->success($list); return app('json')->success($list);

@ -30,7 +30,7 @@ class UserExtract extends BaseController
* @param App $app * @param App $app
* @param repository $repository * @param repository $repository
*/ */
public function __construct(App $app,repository $repository) public function __construct(App $app, repository $repository)
{ {
parent::__construct($app); parent::__construct($app);
$this->repository = $repository; $this->repository = $repository;
@ -38,32 +38,33 @@ class UserExtract extends BaseController
public function lst() public function lst()
{ {
[$page,$limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params(['status']); $where = $this->request->params(['status']);
$where['uid'] = $this->request->uid(); $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) public function create(validate $validate)
{ {
$data = $this->checkParams($validate); $data = $this->checkParams($validate);
$user = $this->request->userInfo(); $user = $this->request->userInfo();
if($data['extract_type'] == 3 && !systemConfig('sys_extension_type') ) return app('json')->fail('未开启付款到零钱'); if ($data['extract_type'] == 3 && !systemConfig('sys_extension_type')) return app('json')->fail('未开启付款到零钱');
$this->repository->create($user,$data); $this->repository->create($user, $data);
return app('json')->success('申请已提交'); return app('json')->success('申请已提交');
} }
public function checkParams(validate $validate) 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); $validate->check($data);
return $data; return $data;
} }
public function bankLst() public function bankLst()
{ {
[$page,$limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$data = app()->make(GroupDataRepository::class)->groupData('bank_list',0,$page,100); $data = app()->make(GroupDataRepository::class)->groupData('bank_list', 0, $page, 100);
return app('json')->success($data); return app('json')->success($data);
} }

Loading…
Cancel
Save