预存列表

main
home.fengxinyhyl 9 months ago
parent 56ca235aa1
commit 1683db1235
  1. 9
      app/common/dao/user/DepositRecordDao.php
  2. 10
      app/common/model/user/DepositRecord.php
  3. 9
      app/common/repositories/user/DepositRecordRepository.php
  4. 32
      app/controller/admin/system/Deposit.php
  5. 6
      route/admin/system.php
  6. 9
      view/admin/src/api/user.js
  7. 2
      view/admin/src/router/modules/user.js
  8. 93
      view/admin/src/views/user/deposit/list.vue

@ -15,6 +15,7 @@ use app\common\model\user\DepositRecord;
use app\common\model\user\UserAssets;
use app\common\model\user\UserRecharge;
use app\common\repositories\store\order\StoreOrderRepository;
use think\db\BaseQuery;
class DepositRecordDao extends BaseDao
{
@ -32,4 +33,12 @@ class DepositRecordDao extends BaseDao
public function getSum($uid, $field){
return DepositRecord::where('uid', $uid)->where('status','in', [1,2])->sum($field);
}
public function search($where){
$query = DepositRecord::when(isset($where['uid']) && $where['uid'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('uid', $where['uid']);
})
->where('status', 'in', [1,3]);
return $query;
}
}

@ -11,6 +11,7 @@
namespace app\common\model\user;
use app\common\model\BaseModel;
use app\common\model\store\Deposit;
class DepositRecord extends BaseModel
@ -40,5 +41,14 @@ class DepositRecord extends BaseModel
return $params;
}
public function user()
{
return $this->hasOne(User::class, 'uid', 'uid');
}
public function deposit()
{
return $this->hasOne(Deposit::class, 'id', 'deposit_id');
}
}

@ -56,9 +56,16 @@ class DepositRecordRepository extends BaseRepository
public function getList($where, $page, $limit)
{
$query = $this->dao->searchJoinQuery($where)->order('a.pay_time DESC,a.create_time DESC');
$query = $this->dao->search($where)->with(['user', 'deposit'])->order('create_time DESC');
$count = $query->count();
$list = $query->page($page, $limit)->select();
$dailyRepository = app(DepositRecordDailyRepository::class);
foreach ($list as &$item){
$daily = $dailyRepository->getWhere(['record_id' =>$item['id']]);
$item['diamond_current'] = $daily? $daily['diamond'] : 0;
}
return compact('count', 'list');
}

@ -15,6 +15,8 @@ namespace app\controller\admin\system;
use app\common\repositories\store\DepositRepository;
use app\common\repositories\user\DepositRecordRepository;
use app\common\repositories\user\UserAssetsRepository;
use app\validate\admin\DepositValidate;
use crmeb\basic\BaseController;
use FormBuilder\Exception\FormBuilderException;
@ -22,6 +24,7 @@ use think\App;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Request;
/**
* Class UserGroup
@ -36,15 +39,21 @@ class Deposit extends BaseController
*/
protected $repository;
/**
* @var DepositRecordRepository
*/
protected $recordRepository;
/**
* UserGroup constructor.
* @param App $app
* @param DepositRepository $repository
*/
public function __construct(App $app, DepositRepository $repository)
public function __construct(App $app, DepositRepository $repository, DepositRecordRepository $recordRepository)
{
parent::__construct($app);
$this->repository = $repository;
$this->recordRepository = $recordRepository;
}
/**
@ -61,6 +70,27 @@ class Deposit extends BaseController
return app('json')->success($this->repository->getList(['status' => 1], $page, $limit));
}
public function userList()
{
[$page, $limit] = $this->getPage();
$uid = Request::get('uid');
return app('json')->success($this->recordRepository->getList(['uid' =>$uid], $page, $limit));
}
public function userFree($id)
{
$item = $this->recordRepository->get($id);
if(empty($item)){
\app('json')->fail('查找不到记录');
}
$item->status = 3;
$item->save();
app(UserAssetsRepository::class)->updateAssets($item['uid'], array('deposit' => $item['price']));
return app('json')->success([1]);
}
/**
* @return mixed
* @throws FormBuilderException

@ -37,6 +37,12 @@ Route::group(function () {
Route::get('lst', '/lst')->name('systemDepositLst')->option([
'_alias' => '预存管理',
]);
Route::get('user/lst', '/userList')->name('systemDepositLst')->option([
'_alias' => '用户预存列表',
]);
Route::post('user/free/:id', '/userFree')->name('systemDepositLst')->option([
'_alias' => '用户预存解冻',
]);
Route::post('create/deposit', '/create')->name('systemDepositCreate')->option([
'_alias' => '预存添加',
]);

@ -107,6 +107,13 @@ export function depositFormApi() {
export function depositLstApi(data) {
return request.get('deposit/lst', data)
}
export function depositUserLstApi(data) {
return request.get('deposit/user/lst', data)
}
export function depositUserFreeApi(id) {
return request.post(`deposit/user/free/${id}`)
}
/**
* @description 预存管理 -- 删除
*/
@ -522,4 +529,4 @@ export function getLotteryData(data) {
// 保存抽奖
export function setLotteryData(data) {
return request.post('lottery/save', data)
}
}

@ -51,7 +51,7 @@ const userRouter =
},
{
path: 'deposit/list',
component: () => import('@/views/user/list'),
component: () => import('@/views/user/deposit/list'),
name: 'depositList',
meta: { title: '预存列表', noCache: true }
},

@ -1,9 +1,23 @@
<template>
<div class="divBox">
<div class="selCard">
<el-form inline size="small" label-width="85px">
<div class="acea-row search-form">
<div>
<el-form-item label="id:">
<el-input placeholder="请输入内容" v-model="tableFrom.uid" class="input-with-select selWidth" clearable @keyup.enter.native="getList(1)">
</el-input>
</el-form-item>
</div>
<el-form-item class="search-form-sub">
<el-button type="primary" size="small" @click="getList(1)">搜索</el-button>
</el-form-item>
</div>
</el-form>
</div>
<el-card>
<div class="mb20">
<el-button size="small" type="primary" @click="onAdd">{{ '添加预存'}}</el-button>
</div>
<el-table
v-loading="listLoading"
:data="tableData.data"
@ -19,42 +33,61 @@
</template>
</el-table-column>
<el-table-column
:label="'预存金额'"
label="用户手机号"
min-width="180"
>
<template slot-scope="{row}">
<span v-text="row.money" />
<span v-text="row.user.phone" />
</template>
</el-table-column>
<el-table-column
prop="cycle"
label="提现周期"
label="预存金额"
min-width="180"
>
<template slot-scope="{row}">
<span v-text="row.price" />
</template>
</el-table-column>
<el-table-column
label="预存时间"
min-width="180"
>
<template slot-scope="{row}">
<span v-text="row.create_time" />
</template>
</el-table-column>
<el-table-column
prop="deposit.cycle"
label="提现周期(天)"
min-width="150"
/>
<el-table-column
prop="count"
label="名额"
prop="diamond_current"
label="已获得钻石"
min-width="150"
/>
<el-table-column
prop="diamond"
prop="deposit.diamond"
label="赠送钻石/天"
min-width="150"
/>
<el-table-column
prop="diamond_max"
prop="deposit.diamond_max"
label="钻石最大值"
min-width="150"
/>
<el-table-column
prop="create_time"
label="创建时间"
min-width="150"
/>
label="预存状态"
min-width="180"
>
<template slot-scope="{row}">
<span >{{ row.status == 1? '冻结' : '解冻' }}</span>
</template>
</el-table-column>
<el-table-column label="操作" min-width="90" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="small" @click="onEdit(scope.row.id)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
<el-button v-if="scope.row.status == 1" type="text" size="small" @click="handleFree(scope.row.id, scope.$index)">解冻</el-button>
</template>
</el-table-column>
</el-table>
@ -84,16 +117,15 @@
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {
depositLstApi,
depositFormApi,
depositEditApi,
depositDeleteApi,
depositUserLstApi,
depositUserFreeApi,
} from '@/api/user'
export default {
name: 'UserGroup',
data() {
return {
tableFrom: {
uid:'',
page: 1,
limit: 20
},
@ -120,7 +152,7 @@ export default {
//
getList() {
this.listLoading = true
depositLstApi(this.tableFrom).then(res => {
depositUserLstApi(this.tableFrom).then(res => {
this.tableData.data = res.data.list
this.tableData.total = res.data.count
this.listLoading = false
@ -137,20 +169,11 @@ export default {
this.tableFrom.limit = val
this.getList()
},
//
onAdd() {
this.$modalForm(depositFormApi()).then(() => this.getList())
},
//
onEdit(id) {
this.$modalForm(depositEditApi(id)).then(() => this.getList())
},
//
handleDelete(id, idx) {
this.$modalSure('删除').then(() => {
depositDeleteApi(id).then(({ message }) => {
//
handleFree(id, idx) {
this.$modalSure('解冻').then(() => {
depositUserFreeApi(id).then(({ message }) => {
this.$message.success(message)
this.tableData.data.splice(idx, 1)
this.getList()
}).catch(({ message }) => {
this.$message.error(message)

Loading…
Cancel
Save