完善后台相关管理

This commit is contained in:
彭桃 2023-03-15 16:26:36 +08:00 committed by liuxiaoquan
parent 8467082058
commit 6c922cdbe5
11 changed files with 611 additions and 17 deletions

View File

@ -0,0 +1,149 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\UserExtract as UserExtractModel;
use app\admin\validate\UserExtractValidate;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class UserExtract extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->model = new UserExtractModel();
$this->uid = get_login_admin('id');
}
/**
* 数据列表
*/
public function datalist()
{
if (request()->isAjax()) {
$param = get_params();
$where = [];
$list = $this->model->getUserExtractList($where,$param);
foreach ($list as $k =>$v){
$list[$k]['uid'] = Db::connect('shop')->table('eb_user')->where('uid',$v['uid'])->value('nickname');
if($v['extract_type'] == 0){
$list[$k]['extract_type'] = '银行卡';
}
if($v['extract_type'] == 1){
$list[$k]['extract_type'] = '支付宝';
}
if($v['extract_type'] == 2){
$list[$k]['extract_type'] = '微信';
}
if($v['extract_type'] == 3){
$list[$k]['extract_type'] = '零钱';
}
$list[$k]['admin_id'] = Db::connect('shop')->table('eb_system_admin')->where('admin_id',$v['admin_id'])->value('real_name');
}
return table_assign(0, '', $list);
}
else{
return view();
}
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$param = get_params();
// 检验完整性
try {
validate(UserExtractValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$this->model->addUserExtract($param);
}else{
return view();
}
}
/**
* 编辑
*/
public function edit()
{
$param = get_params();
if (request()->isAjax()) {
// 检验完整性
try {
validate(UserExtractValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$this->model->editUserExtract($param);
}else{
$extract_id = isset($param['extract_id']) ? $param['extract_id'] : 0;
$detail = $this->model->getUserExtractById($extract_id);
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param = get_params();
$extract_id = isset($param['extract_id']) ? $param['extract_id'] : 0;
$detail = $this->model->getUserExtractById($extract_id);
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
* type=0,逻辑删除,默认
* type=1,物理删除
*/
public function del()
{
$param = get_params();
$extract_id = isset($param['extract_id']) ? $param['extract_id'] : 0;
$type = 1;
$this->model->delUserExtractById($extract_id,$type);
}
}

View File

@ -129,8 +129,10 @@ class Merchant extends BaseController
$total = StoreOrderModel::where($where)->count();
$list = StoreOrderModel::with(['merchant'])->order('order_id desc')->select();
$list = StoreOrderModel::with(['merchant'])->order('order_id desc')->page($params['page'])->limit($params['limit'])->select();
foreach ($list as $k =>$v){
$list[$k]['uid'] = Db::connect('shop')->table('eb_user')->where('uid',$v['uid'])->value('nickname');
}
View::assign('url', $this->url);
View::assign('list', $list);

View File

@ -0,0 +1,102 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\admin\model;
use think\facade\Db;
use think\model;
class UserExtract extends Model
{
protected $connection = 'shop';
// 设置当前模型对应的完整数据表名称
protected $table = 'eb_user_extract';
/**
* 获取分页列表
* @param $where
* @param $param
*/
public function getUserExtractList($where, $param)
{
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
$order = empty($param['order']) ? 'extract_id desc' : $param['order'];
$list = self::where($where)->field('extract_id,extract_id,uid,extract_sn,real_name,extract_type,bank_code,bank_address,alipay_code,wechat,extract_pic,extract_price,balance,mark,admin_id,fail_msg,status_time,create_time,status,bank_name')->order($order)->paginate($rows, false, ['query' => $param]);
return $list;
}
/**
* 添加数据
* @param $param
*/
public function addUserExtract($param)
{
$insertId = 0;
try {
$param['create_time'] = time();
$insertId = self::strict(false)->field(true)->insertGetId($param);
add_log('add', $insertId, $param);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
return to_assign(0,'操作成功',['aid'=>$insertId]);
}
/**
* 编辑信息
* @param $param
*/
public function editUserExtract($param)
{
try {
$param['update_time'] = time();
self::where('extract_id', $param['extract_id'])->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
return to_assign();
}
/**
* 根据id获取信息
* @param $id
*/
public function getUserExtractById($id)
{
$info = self::where('extract_id', $id)->find();
return $info;
}
/**
* 删除信息
* @param $id
* @return array
*/
public function delUserExtractById($id,$type=0)
{
if($type==0){
//逻辑删除
try {
$param['delete_time'] = time();
self::where('extract_id', $id)->update(['delete_time'=>time()]);
add_log('delete', $id);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
}
else{
//物理删除
try {
self::where('extract_id', $id)->delete();
add_log('delete', $id);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
}
return to_assign();
}
}

View File

@ -0,0 +1,20 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\admin\validate;
use think\Validate;
class UserExtractValidate extends Validate
{
protected $rule = [
'extract_id' => 'require',
];
protected $message = [
'extract_id.require' => 'ID不能为空',
];
}

View File

@ -19,7 +19,7 @@
<!--</script>-->
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
<div class="layui-btn-group"><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
</script>
{/block}

View File

@ -21,13 +21,13 @@
<script type="text/html" id="thumb">
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加">+ 添加</span>
{/if}
</div>
</script>
<!--<script type="text/html" id="toolbarDemo">-->
<!-- <div class="layui-btn-container">-->
<!-- {if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}-->
<!-- <span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加">+ 添加</span>-->
<!-- {/if}-->
<!-- </div>-->
<!--</script>-->
<script type="text/html" id="barDemo">
<div class="layui-btn-group">

View File

@ -21,13 +21,13 @@
<script type="text/html" id="thumb">
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加">+ 添加</span>
{/if}
</div>
</script>
<!--<script type="text/html" id="toolbarDemo">-->
<!-- <div class="layui-btn-container">-->
<!-- {if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}-->
<!-- <span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加">+ 添加</span>-->
<!-- {/if}-->
<!-- </div>-->
<!--</script>-->
<script type="text/html" id="barDemo">
<div class="layui-btn-group">

View File

@ -0,0 +1,45 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">新建用户提现表</h3>
<table class="layui-table layui-table-form">
<tr><td class="layui-td-gray-2">ID<font>*</font></td>
<td><input type="text" name="extract_id" lay-verify="required" lay-reqText="请完善ID" value="" autocomplete="off" placeholder="请输入ID" class="layui-input"></td><td colspan='4'></td>
</tr>
</table>
<div class="pt-3">
<input type="hidden" name="extract_id" value="0"/>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
var moduleInit = ['tool'];
function gouguInit() {
var form = layui.form, tool = layui.tool;
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.sideClose(1000);
}
}
tool.post("/admin/user_extract/add", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,218 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<form class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
</form>
<table class="layui-hide" id="user_extract" lay-filter="user_extract"></table>
</div>
<!--<script type="text/html" id="toolbarDemo">-->
<!-- <div class="layui-btn-container">-->
<!-- <span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加用户提现表">+ 添加用户提现表</span>-->
<!-- </div>-->
<!--</script>-->
<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#user_extract',
title: '用户提现表列表',
toolbar: '#toolbarDemo',
url: '/admin/user_extract/datalist',
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'left',
field: 'extract_id',
title: '编号',
align: 'center',
width: 80
},{
field: 'uid',
title: '用户 id',
align: 'center',
width: 100
},{
field: 'extract_sn',
title: '单号',
align: 'center',
width: 100
},{
field: 'real_name',
title: '姓名',
align: 'center',
width: 100
},{
field: 'extract_type',
title: '提现方式',
align: 'center',
width: 100
},{
field: 'bank_code',
title: '银行卡',
align: 'center',
width: 100
},{
field: 'bank_address',
title: '开户地址',
align: 'center',
width: 100
},
// {
// field: 'alipay_code',
// title: '支付宝账号',
// align: 'center',
// width: 100
// },{
// field: 'wechat',
// title: '微信号',
// align: 'center',
// width: 100
// },{
// field: 'extract_pic',
// title: '收款码',
// align: 'center',
// width: 100
// },
{
field: 'extract_price',
title: '提现金额',
align: 'center',
width: 100
},{
field: 'balance',
title: '余额',
align: 'center',
width: 100
},{
field: 'mark',
title: '管理员备注',
align: 'center',
width: 100
},{
field: 'admin_id',
title: '审核管理员',
align: 'center',
width: 100
},{
field: 'fail_msg',
title: '无效原因',
align: 'center',
width: 100
},{
field: 'status_time',
title: '无效时间',
align: 'center',
width: 100
},{
field: 'create_time',
title: '添加时间',
align: 'center',
width: 100
},{
field: 'status',
title: '状态',
align: 'center',
width: 100,
templet: function (d)
{
if (d.status == '-1') {
html = '<span style="color:#FB3205">未通过</span>';
}
if (d.status =='0') {
html = '<span style="color:#12bb37">审核中</span>';
}
if (d.status == '1') {
html = '<span style="color:#1159F3">已提现</span>';
}
return html;
},
},{
field: 'bank_name',
title: '银行名称',
align: 'center',
width: 100
},
{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
width: 136,
align: 'center'
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(user_extract)', function(obj){
if (obj.event === 'add') {
tool.side("/admin/user_extract/add");
return false;
}
});
//监听表格行工具事件
table.on('tool(user_extract)', function(obj) {
var data = obj.data;
if (obj.event === 'read') {
tool.side('/admin/user_extract/read?extract_id='+obj.data.extract_id);
}
else if (obj.event === 'edit') {
tool.side('/admin/user_extract/edit?extract_id='+obj.data.extract_id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/admin/user_extract/del", { extract_id: data.extract_id }, callback);
layer.close(index);
});
}
return false;
});
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,45 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">编辑用户提现表</h3>
<table class="layui-table layui-table-form">
<tr><td class="layui-td-gray-2">ID<font>*</font></td>
<td><input type="text" name="extract_id" lay-verify="required" lay-reqText="请完善ID" value="{$detail.extract_id}" autocomplete="off" placeholder="请输入ID" class="layui-input"></td><td colspan='4'></td>
</tr>
</table>
<div class="py-3">
<input type="hidden" name="extract_id" value="{$detail.extract_id}"/>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
var moduleInit = ['tool'];
function gouguInit() {
var form = layui.form, tool = layui.tool;
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.sideClose(1000);
}
}
tool.post("/admin/user_extract/edit", data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,13 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-4">
<h3 class="pb-3">用户提现表详情</h3>
<table class="layui-table layui-table-form">
<tr><td class="layui-td-gray-2">ID</td>
<td>{$detail.extract_id}</td><td colspan='4'></td>
</tr>
</table>
</div>
{/block}
<!-- /主体 -->