用户提现

main
home.fengxinyhyl 1 year ago
parent 6a4444c65e
commit 8ec5ef2599
  1. 13
      app/common/dao/user/UserExtractDao.php
  2. 53
      app/common/repositories/user/UserAssetsLogRepository.php
  3. 14
      app/common/repositories/user/UserAssetsRepository.php
  4. 115
      app/common/repositories/user/UserExtractRepository.php
  5. 2
      app/controller/admin/user/UserExtract.php
  6. 5
      app/controller/api/Common.php
  7. 4
      app/controller/api/user/User.php
  8. 55
      view/admin/src/views/accounts/extract/index.vue

@ -25,19 +25,12 @@ class UserExtractDao extends BaseDao
public function search(array $where)
{
if(isset($where['wechat']) && $where['wechat'] != '') {
$query = model::hasWhere('user',function ($query)use($where){
$query->where('nickname',"%{$where['wechat']}%");
});
}else{
$query = model::alias('UserExtract');
}
$query = model::alias('UserExtract');
$query->when(isset($where['uid']) && $where['uid'] != '',function($query)use($where){
$query->where('uid',$where['uid']);
})->when(isset($where['extract_type']) && $where['extract_type'] != '',function($query)use($where){
$query->where('extract_type',$where['extract_type']);
})->when(isset($where['keyword']) && $where['keyword'] != '',function($query)use($where){
$query->whereLike('UserExtract.real_name|UserExtract.uid|bank_code|alipay_code|wechat',"%{$where['keyword']}%");
})->when(isset($where['status']) && $where['status'] != '',function($query)use($where){
$query->where('UserExtract.status',$where['status']);
})->when(isset($where['real_name']) && $where['real_name'] != '',function($query)use($where){
@ -46,8 +39,6 @@ class UserExtractDao extends BaseDao
getModelTime($query, $where['date']);
})->when(isset($where['brokerage_level']) && $where['brokerage_level'], function ($query) use ($where) {
$query->join('User user', 'UserExtract.uid = user.uid', 'left')->where('user.brokerage_level', intval($where['brokerage_level']));
})->when(isset($where['user_keyword']) && $where['user_keyword'], function ($query) use ($where) {
$query->join('User user', 'UserExtract.uid = user.uid', 'left')->where('user.uid|user.real_name|user.nickname|user.phone', 'like', '%' . $where['keyword'] . '%');
})->order('UserExtract.create_time DESC');
return $query;

@ -33,37 +33,38 @@ use think\facade\Log;
class UserAssetsLogRepository extends BaseRepository
{
const ASSET_INTEGRAL = 1; // 积分
const ASSET_DIAMOND = 2; // 钻石
const ASSET_STOCK = 3; // 本票
const INTEGRAL_WITHDRAW_SHARE = 1; // '分享奖返佣--提现积分',
const INTEGRAL_BUY_SHARE = 2; // '分享奖返佣--复购积分',
const INTEGRAL_WITHDRAW_SERVE = 3; // '服务奖返佣--提现积分',
const INTEGRAL_BUY_SERVE = 4; // '服务奖返佣--复购积分',
const INTEGRAL_WITHDRAW_SEND = 5; // '他人转让--提现积分',
const INTEGRAL_WITHDRAW_GET = 6; // '转让他人--提现积分',
const ASSET_DIAMOND = 2; // 钻石
const ASSET_STOCK = 3; // 本票
const INTEGRAL_WITHDRAW_SHARE = 1; // '分享奖返佣--提现积分',
const INTEGRAL_BUY_SHARE = 2; // '分享奖返佣--复购积分',
const INTEGRAL_WITHDRAW_SERVE = 3; // '服务奖返佣--提现积分',
const INTEGRAL_BUY_SERVE = 4; // '服务奖返佣--复购积分',
const INTEGRAL_WITHDRAW_SEND = 5; // '他人转让--提现积分',
const INTEGRAL_WITHDRAW_GET = 6; // '转让他人--提现积分',
const INTEGRAL_WITHDRAW_DIAMOND = 7; // '兑换钻石--提现积分',
const INTEGRAL_WITHDRAW_HOT = 8; // '爆单奖--提现积分',
const INTEGRAL_BUY_HOT = 9; // '爆单奖--复购积分',
const INTEGRAL_BUY = 10; // '消费--复购积分',
const INTEGRAL_WITHDRAW = 11; // '提现--提现积分',
const DIAMOND_SEND = 20; //他人转让
const DIAMOND_GET = 21; //转让他人
const DIAMOND_STOCK = 22; //兑换本票
const INTEGRAL_WITHDRAW_HOT = 8; // '爆单奖--提现积分',
const INTEGRAL_BUY_HOT = 9; // '爆单奖--复购积分',
const INTEGRAL_BUY = 10; // '消费--复购积分',
const INTEGRAL_WITHDRAW = 11; // '提现--提现积分',
const DIAMOND_SEND = 20; //他人转让
const DIAMOND_GET = 21; //转让他人
const DIAMOND_STOCK = 22; //兑换本票
const DIAMOND_INTEGRAL = 23; //积分兑换
const DIAMOND_SHARE = 24; //分享奖返佣
const DIAMOND_SERVE = 25; //服务奖返佣
const DIAMOND_DEPOSIT = 26; //预存奖返佣
const DIAMOND_LOTTERY = 27; //幸运大转盘
const DIAMOND_SHARE = 24; //分享奖返佣
const DIAMOND_SERVE = 25; //服务奖返佣
const DIAMOND_DEPOSIT = 26; //预存奖返佣
const DIAMOND_LOTTERY = 27; //幸运大转盘
const STOCK = 30; //钻石兑换
const STATUS_GET = 1; // 获取
const STATUS_USE = 2; // 使用
const STATUS_WITHDRAW = 3; // 提现
const STATUS_BUY = 4; // 消费
const STATUS_REFUND = 5; // 退款
const STATUS_GET = 1; // 获取
const STATUS_USE = 2; // 使用
const STATUS_WITHDRAW = 3; // 提现
const STATUS_BUY = 4; // 消费
const STATUS_REFUND = 5; // 退款
const STATUS_WITHDRAW_REFUSED = 6; // 提现拒绝
public function __construct(UserAssetsLogDao $dao, UserAssetsRepository $userAssetsRepository,

@ -113,6 +113,20 @@ class UserAssetsRepository extends BaseRepository
}
public function withdraw($uid, $integral, $status = UserAssetsLogRepository::STATUS_WITHDRAW){
$logList = array();
$logList[] = array(
'uid' => $uid,
'asset_type' => UserAssetsLogRepository::ASSET_INTEGRAL,
'type' => UserAssetsLogRepository::INTEGRAL_WITHDRAW,
'status' => $status,
'count' => -$integral,
);
$assets = $this->assets($uid);
app()->make(UserAssetsLogRepository::class)->addLog($logList);
$this->dao->update($uid, array('integral_withdraw' => $assets['integral_withdraw'] - $integral));
}
public function lottery($uid, $count){
$logList = array();
$logList[] = array(

@ -59,7 +59,7 @@ class UserExtractRepository extends BaseRepository
public function getWhereCount($id)
{
$where['extract_id'] = $id;
$where['status'] = 0;
$where['status'] = 0;
return $this->dao->getWhereCount($where) > 0;
}
@ -74,11 +74,17 @@ class UserExtractRepository extends BaseRepository
*/
public function getList(array $where, $page, $limit)
{
if (isset($where['keyword']) and $where['keyword'] != '') {
$user = app(UserRepository::class)->getUserByPhone($where['keyword']);
if ($user) {
$where['uid'] = $user['uid'];
}
}
$query = $this->dao->search($where)->with(['user' => function ($query) {
$query->field('uid,avatar,nickname');
$query->field('uid,avatar,nickname,phone');
}]);
$count = $query->count();
$list = $query->page($page, $limit)->select();
$list = $query->page($page, $limit)->select();
return compact('count', 'list');
}
@ -105,39 +111,43 @@ class UserExtractRepository extends BaseRepository
* @author Qinii
* @day 2020-06-16
*/
public function create($user,$data)
public function create($user, $data)
{
event('user.extract.before',compact('user','data'));
$userExtract = Db::transaction(function()use($user,$data){
if($user['brokerage_price'] < (systemConfig('user_extract_min')))
throw new ValidateException('可提现金额不足');
if($data['extract_price'] < (systemConfig('user_extract_min')))
event('user.extract.before', compact('user', 'data'));
$assets = app(UserAssetsRepository::class)->assets($user['uid']);
$config = app(UserAssetsRepository::class)->getConfig();
$userExtract = Db::transaction(function () use ($user, $data, $assets, $config) {
if ($data['extract_price'] < (systemConfig('user_extract_min')))
throw new ValidateException('提现金额不得小于最低额度');
if($user['brokerage_price'] < $data['extract_price'])
if ($assets['integral_withdraw'] + $assets['deposit'] < $data['extract_price'])
throw new ValidateException('提现金额不足');
if($data['extract_type'] == 3) {
$make = app()->make(WechatUserRepository::class);
$openid = $make->idByOpenId((int)$user['wechat_user_id']);
if (!$openid){
$openid = $make->idByRoutineId((int)$user['wechat_user_id']);
if(!$openid) throw new ValidateException('openID获取失败,请确认是微信用户');
}
}
$brokerage_price = bcsub($user['brokerage_price'],$data['extract_price'],2);
$user->brokerage_price = $brokerage_price;
$user->save();
$data['extract_sn'] = $this->createSn();
$data['uid'] = $user['uid'];
$data['balance'] = $brokerage_price;
$data['uid'] = $user['uid'];
$data['fee'] = round($data['extract_price'] * $config['withdrawRate'] / 100, 2);
$data['real_pay'] = $data['extract_price'] - $data['fee'];
/**
* @var UserAssetsRepository $repository
*/
$repository = app(UserAssetsRepository::class);
if ($data['extract_price'] > $assets['deposit']) {
$deposit = $assets['deposit'];
$integral = $data['extract_price'] - $assets['deposit'];
$repository->withdraw($user['uid'], $integral);
$repository->updateAssets($user['uid'], array('deposit' => $deposit), false);
} else {
$deposit = $data['extract_price'];
$repository->updateAssets($user['uid'], array('deposit' => $deposit), false);
}
return $this->dao->create($data);
});
event('user.extract',compact('userExtract'));
event('user.extract', compact('userExtract'));
SwooleTaskService::admin('notice', [
'type' => 'extract',
'type' => 'extract',
'title' => '您有一条新的提醒申请',
'id' => $userExtract->extract_id
'id' => $userExtract->extract_id
]);
}
@ -152,63 +162,34 @@ class UserExtractRepository extends BaseRepository
])->setTitle('提现审核');
}
public function switchStatus($id,$data)
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('用户不存在');
$brokerage_price = 0;
if($data['status'] == -1)
$brokerage_price = bcadd($user['brokerage_price'] ,$extract['extract_price'],2);
$type = systemConfig('sys_extension_type');
$ret = [];
$service = null;
$func = null;
if ($data['status'] == 1 && $extract['extract_type'] == 3 && in_array($type,[1,2])) {
$func = $type == 1 ? 'merchantPay' : 'companyPay';
$ret = [
'sn' => $extract['extract_sn'],
'price' => $extract['extract_price'],
'mark' => '企业付款给用户:'.$user->nickname,
'batch_name' => '企业付款给用户:'.$user->nickname
];
$openid = app()->make(WechatUserRepository::class)->idByOpenId((int)$user['wechat_user_id']);
if ($openid) {
$ret['openid'] = $openid;
$service = WechatService::create();
} else {
$routineOpenid = app()->make(WechatUserRepository::class)->idByRoutineId((int)$user['wechat_user_id']);
if (!$routineOpenid) throw new ValidateException('非微信用户不支持付款到零钱');
$ret['openid'] = $routineOpenid;
$service = MiniProgramService::create();
}
}
$user = app()->make(UserRepository::class)->get($extract['uid']);
if (!$user) throw new ValidateException('用户不存在');
Db::transaction(function()use($id,$data,$user,$brokerage_price,$ret,$service,$func){
event('user.extractStatus.before',compact('id','data'));
if ($ret) $service->{$func}($ret);
if($brokerage_price){
$user->brokerage_price = $brokerage_price;
$user->save();
Db::transaction(function () use ($id, $data, $user, $extract) {
event('user.extractStatus.before', compact('id', 'data'));
if($data['status'] == -1){
app(UserAssetsRepository::class)->updateAssets($user['uid'], array('deposit' => $extract['extract_price']));
}
$userExtract = $this->dao->update($id,$data);
event('user.extractStatus',compact('id','userExtract'));
$userExtract = $this->dao->update($id, $data);
event('user.extractStatus', compact('id', 'userExtract'));
});
Queue::push(SendSmsJob::class,['tempId' => 'EXTRACT_NOTICE', 'id' =>$id]);
}
public function createSn()
{
list($msec, $sec) = explode(' ', microtime());
$msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
$sn = 'ue' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
$sn = 'ue' . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
return $sn;
}
public function getHistoryBank($uid)
{
return $this->dao->getSearch(['uid' => $uid,'extract_type' => 0])->order('create_time DESC')->field('real_name,bank_code,bank_address,bank_name')->find();
return $this->dao->getSearch(['uid' => $uid, 'extract_type' => 0])->order('create_time DESC')->field('real_name,bank_code,bank_address,bank_name')->find();
}
public function detail(int $id)
@ -217,7 +198,7 @@ class UserExtractRepository extends BaseRepository
$query->field('uid,avatar,nickname');
}]);
if(empty($info)){
if (empty($info)) {
throw new ValidateException('数据异常');
}

@ -47,7 +47,7 @@ class UserExtract extends BaseController
public function lst()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['status', 'keyword', 'date', 'extract_type']);
$where = $this->request->params(['status', 'keyword', 'date', 'extract_type', 'phone']);
return app('json')->success($this->repository->getList($where, $page, $limit));
}

@ -31,6 +31,7 @@ use app\common\repositories\system\groupData\GroupDataRepository;
use app\common\repositories\system\groupData\GroupRepository;
use app\common\repositories\system\merchant\MerchantRepository;
use app\common\repositories\system\notice\SystemNoticeConfigRepository;
use app\common\repositories\user\UserAssetsRepository;
use app\common\repositories\user\UserRepository;
use app\common\repositories\user\UserSignRepository;
use app\common\repositories\user\UserVisitRepository;
@ -148,6 +149,10 @@ class Common extends BaseController
}
$recharge_attention = array("");
$rule = app(CacheRepository::class)->getResult("the_lottery_rule");
// $uid = $this->user->uid;
// $assets = app(UserAssetsRepository::class)->assets($uid);
// $total = $assets['deposit_total'];
return app('json')->success(compact('recharge_quota', 'recharge_attention', 'rule'));
}

@ -232,10 +232,10 @@ class User extends BaseController
public function spread_info()
{
$user = $this->user;
if (!$user->is_promoter) return app('json')->fail('您还不是分销员');
$make = app()->make(UserBrokerageRepository::class);
$user->append(['one_level_count', 'lock_brokerage', 'two_level_count', 'spread_total', 'yesterday_brokerage', 'total_extract', 'total_brokerage', 'total_brokerage_price']);
$show_brokerage = (bool)$make->search(['type' => 0])->count();
$assets = \app(UserAssetsRepository::class)->assets($user->uid);
$data = [
'total_brokerage_price' => $user->total_brokerage_price,
'lock_brokerage' => $user->lock_brokerage,
@ -245,7 +245,7 @@ class User extends BaseController
'yesterday_brokerage' => $user->yesterday_brokerage,
'total_extract' => $user->total_extract,
'total_brokerage' => $user->total_brokerage,
'brokerage_price' => $user->brokerage_price,
'brokerage_price' => $assets['integral_withdraw'] + $assets['deposit'],
'show_brokerage' => $show_brokerage,
'brokerage' => $show_brokerage ? ($user->brokerage ?: ['brokerage_level' => 0, 'brokerage_name' => '普通分销员']) : null,
'now_money' => $user->now_money,

@ -20,28 +20,13 @@
<el-option label="已拒绝" value="-1"/>
</el-select>
</el-form-item>
<el-form-item label="提现方式:" prop="extract_type">
<el-select
v-model="tableFrom.extract_type"
clearable
filterable
placeholder="请选择"
class="selWidth"
@change="getList(1)"
>
<el-option label="全部" value=""/>
<el-option label="银行卡" value="0"/>
<el-option label="支付宝" value="2"/>
<el-option label="微信" value="1"/>
<el-option label="微信零钱" value="3"/>
</el-select>
</el-form-item>
<el-form-item label="关键字:" prop="keyword">
<el-input v-model="tableFrom.keyword" @keyup.enter.native="getList(1)" placeholder="姓名/支付宝账号/银行卡号" clearable class="selWidth" />
<el-form-item label="手机号:" prop="keyword">
<el-input v-model="tableFrom.keyword" @keyup.enter.native="getList(1)" placeholder="手机号" clearable class="selWidth" />
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="getList(1)">搜索</el-button>
<el-button size="small" @click="searchReset()">重置</el-button>
<el-button size="small" @click="searchReset()">重置</el-button>
</el-form-item>
</el-form>
</div>
@ -51,17 +36,12 @@
</div>
<el-table v-loading="listLoading" :data="tableData.data" size="small" class="table" highlight-current-row>
<el-table-column prop="extract_id" label="序号" width="60" />
<el-table-column label="二维码" min-width="80">
<template slot-scope="scope">
<div class="demo-image__preview">
<el-image v-if="scope.row.extract_pic" :src="scope.row.extract_pic" :preview-src-list="[scope.row.extract_pic]" />
</div>
</template>
</el-table-column>
<el-table-column prop="user.phone" label="手机号" min-width="100" />
<el-table-column prop="user.nickname" label="用户信息" min-width="100" />
<el-table-column prop="uid" label="用户UID" min-width="80" />
<el-table-column prop="real_name" label="户名" min-width="100" />
<el-table-column prop="extract_price" label="提现金额" min-width="90" />
<el-table-column prop="extract_price" label="总额" min-width="90" />
<el-table-column prop="real_pay" label="实际金额" min-width="90" />
<el-table-column prop="fee" label="手续费" min-width="90" />
<el-table-column label="提现方式" min-width="100">
<template slot-scope="scope">
<span>{{ scope.row.extract_type | extractTypeFilter }}</span>
@ -115,7 +95,9 @@
<div class="acea-row">
<div v-if="extractDetail.user" class="list"><label class="name">用户昵称</label>{{ extractDetail.user.nickname }}</div>
<div v-if="extractDetail.user" class="list"><label class="name">用户ID</label><span>{{ extractDetail.user.uid }}</span></div>
<div class="list"><label class="name">提现金额</label>{{ extractDetail.extract_price }}</div>
<div class="list"><label class="name">总额</label>{{ extractDetail.extract_price }}</div>
<div class="list"><label class="name">实际金额</label>{{ extractDetail.real_pay }}</div>
<div class="list"><label class="name">手续费</label>{{ extractDetail.fee }}</div>
<div class="list"><label class="name">申请时间</label><span>{{ extractDetail.create_time }}</span></div>
<div v-if="extractDetail.extract_type==0" class="list"><label class="name">开户人</label>{{ extractDetail.real_name }}</div>
<div v-if="extractDetail.extract_type==0" class="list"><label class="name">银行卡号</label>{{ extractDetail.bank_code }}</div>
@ -137,7 +119,7 @@
<div v-if="extractDetail.status == -1" class="list sp100"><label class="name">拒绝原因</label>{{ extractDetail.fail_msg }}</div>
</div>
</div>
</div>
</div>
</el-dialog>
@ -156,10 +138,10 @@
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
extractListApi,
extractStatusApi,
extractManageExportApi,
import {
extractListApi,
extractStatusApi,
extractManageExportApi,
extractManageAudit,
extractManageDetail
} from '@/api/accounts'
@ -185,6 +167,7 @@ export default {
status: '',
date: '',
keyword: '',
phone:'',
page: 1,
limit: 20
},
@ -294,7 +277,7 @@ export default {
if (lebData.export.length) {
data = data.concat(lebData.export)
excelData.page++
}
}
}
createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename);
return
@ -360,7 +343,7 @@ export default {
<style scoped lang="scss">
.box-container {
overflow: hidden;
}
.list-count{
padding:30px 0;

Loading…
Cancel
Save