Merge branch 'master' of git.excellentkk.cn:mkm/nk-lihaink-cn

This commit is contained in:
monanxiao 2023-03-08 10:35:25 +08:00
commit a1d3f7b7e0
35 changed files with 2241 additions and 143 deletions

View File

@ -4,4 +4,26 @@ APP_DEBUG = true
DEFAULT_TIMEZONE = Asia/Shanghai
[LANG]
default_lang = zh-cn
default_lang = zh-cn
[DATABASE]
TYPE = mysql
HOSTNAME = 192.168.0.106
DATABASE = nk_lihaink_cn
PREFIX = cms_
USERNAME = root
PASSWORD = 123321a
HOSTPORT = 3306
CHARSET = utf8mb4
DEBUG = true
[DATABASESHOP]
TYPE = mysql
HOSTNAME = 47.108.186.87
HOSTPORT = 3306
USERNAME = shop_lihaink_com
PASSWORD = EeYym2PFctFfrMde
DATABASE = shop_lihaink_com
PREFIX = eb_
CHARSET = utf8
DEBUG = true

View File

@ -6,6 +6,7 @@
namespace app\admin\controller\merchant\system;
use app\admin\BaseController;
use app\common\model\merchant\system\merchant\Merchant as MerchantModel;
class Merchant extends BaseController{

View File

@ -6,11 +6,11 @@
*
* @ 商户入驻申请管理
*/
namespace app\admin\controller\merchant\system;
namespace app\admin\controller\merchant\system\merchant;
use app\admin\BaseController;
use app\validate\merchant\MerchantApplymentsValidate;
use app\admin\model\merchant\MerchantApplyments as MerchantApplymentsModel;
use app\common\model\merchant\system\merchant\MerchantApplyments as MerchantApplymentsModel;
class MerchantApplyments extends BaseController
{

View File

@ -0,0 +1,158 @@
<?php
/**
* 店铺入驻申请审核管理
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\admin\controller\merchant\system\merchant;
use app\admin\BaseController;
use think\facade\Request;
use app\common\model\merchant\system\merchant\MerchantIntention as MerchantIntentionModel;
use think\facade\View;
use app\common\model\merchant\system\merchant\MerchantCategory;
use app\common\model\merchant\system\merchant\MerchantType;
class MerchantIntention extends BaseController
{
protected $path;
protected $request;
protected $intention;
public function __construct(Request $request, MerchantIntentionModel $intention)
{
$this->request = $request;
$this->intention = $intention;
$this->path = [
'index' => 'merchant/system/merchant/intention/lst',
'mark' => 'merchant/system/merchant/intention/mark',
'read' => 'merchant/system/merchant/intention/read',
'add' => 'merchant/system/merchant/intention/add'
];
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function Index(MerchantCategory $category, MerchantType $type)
{
// 商户分类
$category = $category->select();
//审核
// 店铺类弄
$type = $type->select();
// search
View::assign('category',$category);
View::assign('type',$type);
return View($this->path['index']);
}
public function Lst()
{
$params = get_params();
$page = empty($params['page'])? 1 : (int)$params['page'];
$limit = empty($params['limit'])? (int)get_config('app . page_size') : (int)$params['limit'];
$where = get_params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']);
$data = $this->intention->GetList($where, $page, $limit);
return to_assign(0, '', $data);
}
public function StatusForm()
{
return View($this->path['index']);
}
public function MarkForm()
{
$id = get_params('id');
View::assign('id', $id);
return View($this->path['mark']);
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function SetMark()
{
$id = get_params('id');
$mark = get_params('mark');
if (!$this->intention->getWhereCount($id))
return to_assign(1, '数据不存在');
$rows = $this->intention->Edit($id, ['mark' => $mark]);
return $rows>0?to_assign(1, '修改成功'):to_assign(0, '修改失败');
}
/**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request)
{
//
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
//
}
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
//
}
}

View File

@ -11,8 +11,12 @@ declare (strict_types = 1);
namespace app\admin\controller\merchant\system\merchant;
use app\admin\BaseController;
use think\Request;
use app\common\model\merchant\system\merchant\MerchantMargin as MarchantMarginModel;
use app\common\model\merchant\system\serve\ServeOrder as ServeOrderModel;
use app\common\model\merchant\user\UserBill as UserBillModel;
use app\common\model\merchant\system\merchant\Merchant as MerchantModel;
use think\facade\View;
use think\exception\ValidateException;
use think\facade\Request;
/**
* 店铺保证金管理类
@ -21,32 +25,108 @@ class MerchantMargin extends BaseController
{
protected $margin;
protected $path;
public function __construct(MarchantMarginModel $margin)
public function __construct()
{
$this->margin = $margin;
// $this->margin = $margin;
$this->path = [
'index' => 'merchant/system/merchant/margin/list',
'read' => 'merchant/system/merchant/margin/read',
'edit' => 'merchant/system/merchant/margin/edit'
];
}
public function Index()
{
return View($this->path['index']);
}
/**
* 显示资源列表
* 显示保证金列表
*
* @return \think\Response
*/
public function lst()
public function Lst(ServeOrderModel $order)
{
echo 'margin list';
$params = get_params();
$page = empty($params['page'])? 1 : (int)$params['page'];
$limit = empty($params['limit'])? (int)get_config('app . page_size') : (int)$params['limit'];
$where = ['date','keyword','is_trader','category_id','type_id'];
$where['type'] = 10;//10==保证金
$data = $order->GetList($where, $page, $limit);
return to_assign(0,'success', $data['data']=$data['list']);
}
/**
* 打开保证金扣费记录面
*
* @param int $id
* @return \think\Response
*/
public function GetMarginLstForm($id)
{
view::assign('id', $id);
return View($this->path['read']);
}
/**
* 获取保证金扣费记录 record
*
*/
public function GetMarginLst(UserBillModel $bill)
{
$params = get_params();
$mer_id = empty($params['id']) ? 0 : $params['id'];
$page = empty($params['page'])? 1 : (int)$params['page'];
$limit = empty($params['limit'])? (int)get_config('app . page_size') :(int)$params['limit'];
$where['mer_id'] = (int)$mer_id;
$where['category'] = 'mer_margin';
$data = $bill->GetList($where, $page, $limit);
return to_assign(0,'请求成功', $data);
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
* 设置扣减保证金表单
*/
public function create()
public function setMarginForm(MerchantModel $merchant)
{
//
$mer_id = get_params('id');
$data = $merchant->GetMerchantById($mer_id);
if (isset($data->is_margin) && $data->is_margin !== 10) {
throw new ValidateException('商户无保证金可扣');
}
return View($this->path['edit'], ['data'=>$data]);
}
/**
* 设置扣减保证金
*/
public function setMargin(MerchantModel $merchant)
{
$data = get_params(['mer_id','number','mer_name','margin','mark']);
if (empty($data['mer_name']) || empty($data['mer_id'])) {
return to_assign(0,'商户信息不能为空');
}
$data['title'] = '保证金扣除';
$data['type'] = 'mer_margin';//明细类型=保证金扣除
if (!empty($data['number']) && $data['number'] < 0)
return to_assign(0,'扣除金额不能小于0');
$data = $merchant->SetMargin($data);
return to_assign(0,'扣除保证金成功',[]);
}
/**
* 保存新建的资源
*
@ -58,16 +138,7 @@ class MerchantMargin extends BaseController
//
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
@ -92,14 +163,4 @@ class MerchantMargin extends BaseController
//
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
//
}
}

View File

@ -7,7 +7,6 @@
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare(strict_types=1);
namespace app\admin\controller\merchant\system\merchant;

View File

@ -44,6 +44,41 @@ Route::group(function(){
'_auth' => true,
]);
//入驻申请列表
Route::group('merchant/intention', function () {
Route::get('index', '/index')->name('systemMerchantIntentionLst')->option([
'_alias' => '列表',
]);
Route::get('lst', '/lst')->name('systemMerchantIntentionLst')->option([
'_alias' => '列表',
]);
Route::post('status', '/switchStatus')->name('systemMerchantIntentionStatus')->option([
'_alias' => '审核',
]);
Route::delete('delete', '/delete')->name('systemMerchantIntentionDelete')->option([
'_alias' => '删除',
]);
Route::get('markform', '/markform')->name('systemMerchantIntentionMarkForm')->option([
'_alias' => '备注',
'_auth' => false,
'_form' => 'systemMerchantIntentionMark',
]);
Route::get('statusform', '/statusForm')->name('systemMerchantIntentionStatusForm')->option([
'_alias' => '申请商户',
'_auth' => false,
'_form' => 'systemMerchantIntentionStatus',
]);
Route::post('mark', '/setmark')->name('systemMerchantIntentionMark')->option([
'_alias' => '备注',
]);
Route::get('excel', '/excel');
})->prefix('merchant.system.merchant.MerchantIntention')->option([
'_path' => '/merchant/application',
'_auth' => true,
]);
// 店铺类型
Route::group('/merchant/type',function(){
Route::get('index', '/index')->name('systemMerchantTypeLst')->option([
@ -91,22 +126,33 @@ Route::group(function(){
//店铺保证金
Route::group('/margin', function(){
// 主页
Route::get('index', '/index')->name('systemMerchantMarginIndex'
)->option([
'_alias'=>'主页列表 ',
]);
//缴纳记录
Route::get('lst', '/lst')->name('systemMerchantMarginLst')->option([
'_alias' => '缴纳记录',
]);
//扣费记录
Route::get('list/:id', '/getMarginLst')->name('systemMarginList')->option([
'_alias' => '扣费记录',
]);
//扣费记录页
Route::get('read', '/GetMarginLstForm')->name('systemMarginList')->option([
'_alias' => '扣费记录页',
]);
//扣费记录帐单接口
Route::get('reductlst', '/GetMarginLst')->name('systemMarginList')->option([
'_alias' => '扣费记录',
]);
//扣除保证金
Route::get('set/:id/form', '/setMarginForm')->name('systemMarginSetForm')->option([
Route::get('form', '/setMarginForm')->name('systemMarginSetForm')->option([
'_alias' => '扣除保证金表单',
'_auth' => false,
'_form' => 'systemMarginSet',
]);
Route::post('set', '/setMargin')->name('systemMarginSet')->option([
Route::post('reduct', '/setMargin')->name('systemMarginSet')->option([
'_alias' => '扣除保证金',
]);
})->prefix('merchant.system.merchant.MerchantMargin')->option([

View File

@ -0,0 +1,283 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<!-- 时间选择 -->
<div class="layui-form">
<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">日期范围</label>
<div class="layui-inline" id="test6">
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="test-startDate-1" class="layui-input"
placeholder="开始日期">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="test-endDate-1" class="layui-input"
placeholder="结束日期">
</div>
</div>
</div>
<div class="layui-inline" style="width:45%">
<!-- <div class="layui-form-item">
<label class="layui-form-label">关键字</label>
<div class="layui-input-block">
<input style="width:70%;float:left" type="text" name="keywords" placeholder="请输入关键字"
class="layui-input" autocomplete="off" />
<button class="layui-btn layui-btn-normal" lay-submit=""
lay-filter="searchform">提交搜索</button>
</div>
</div> -->
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="width:35%;">
<div class="layui-form-item">
<label class="layui-form-label">商户审核</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value="">全部</option>
<option value="0">待审核</option>
<option value="0">审核通过</option>
<option value="0">审核未通过</option>
</select>
</div>
</div>
</div>
<div class="layui-input-inline" style="width:35%;float:none;">
<div class="layui-form-item">
<label class="layui-form-label">商户分类</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
{volist name="category" key="k" id="vo"}
<option value="0">{$vo.category_name}</option>
{/volist}
</select>
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="width:35%;">
<div class="layui-form-item">
<label class="layui-form-label">店铺类型</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
{volist name="type" key="k" id="vo"}
<option value="0">{$vo.type_name}</option>
{/volist}
</select>
</div>
</div>
</div>
<div class="layui-input-inline" style="width:35%;">
<div class="layui-form-item">
<label class="layui-form-label">关键字</label>
<div class="layui-input-block">
<input style="width:70%;float:left" type="text" name="keywords" placeholder="请输入关键字"
class="layui-input" autocomplete="off" />
<button class="layui-btn layui-btn-normal" lay-submit=""
lay-filter="searchform">提交搜索</button>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" id="intention_list" lay-filter="intention_list">
</table>
</div>
<!-- test end -->
</div>
<!-- 操作 -->
<script type="text/html" id="toolbarDemo"></script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="mark">备注</a>
<a class="layui-btn 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: '#intention_list',
title: '商户入驻申请列表',
toolbar: '#toolbarDemo',
url: '/admin/merchant/intention/lst',
parseData: function(res){ //res 即为原始返回的数据
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.count, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'ID',
field: 'mer_intention_id',
title: 'ID',
align: 'center',
width: 80
},
{
field: 'mer_name',
title: '商户名称',
align: 'center',
width: 200,
}, {
field: 'category_name',
title: '商户分类',
align: 'center',
width: 220,
templet: '<div>{{d.merchantCategory.category_name}}</div>'
},{
field: 'type_name',
title: '店铺类型',
align: 'center',
width: 220,
templet: '<div>{{d.merchantType.type_name}}</div>'
}, {
field: 'name',
title: '商户姓名',
align: 'center',
width: 220,
}, {
field: 'phone',
title: '联系方式',
align: 'center',
width: 100,
}, {
field: 'create_time',
title: '申请时间',
align: 'center',
width: 220,
},{
field: 'images',
title: '资质图片',
align: 'center',
width: 220,
},{
field: 'status',
title: '状态',
align: 'center',
width: 150
}, {
field: 'mark',
title: '备注',
align: 'center',
width: 150
},
{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
width: 190,
align: 'center'
}
]
]
});
//监听表头工具栏事件
// table.on('toolbar(store_product)', function (obj) {
// if (obj.event === 'add') {
// tool.side("/admin/merchant/type/form");
// return false;
// }
// });
//监听表格行工具事件
table.on('tool(intention_list)', function (obj) {
var data = obj.data;
// console.log(data);
if (obj.event === 'mark') {
tool.side('/admin/merchant/intention/markform?id=' + obj.data.mer_intention_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/merchant/intention/del", { id: data.mer_intention_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;
// });
// 日期范围
layui.use('laydate', function () {
var laydate = layui.laydate;
//日期范围
laydate.render({
elem: '#test6'
//设置开始日期、日期日期的 input 选择器
//数组格式为 2.6.6 开始新增,之前版本直接配置 true 或任意分割字符即可
, range: ['#test-startDate-1', '#test-endDate-1']
});
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,57 @@
{extend name="common/base"/}
{block name="style"}
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">备注</h3>
<table class="layui-table layui-table-form">
<tr>
<td colspan="6">
<textarea class="layui-textarea" name="mark"></textarea>
<input type="hidden" name="id" value="{$id}">
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform" type="button">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
var group_access = "{:session('gougu_admin')['group_access']}"
function gouguInit() {
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
//监听提交
form.on('submit(webform)', function (data) {
console.log(data);
if (data.field == '') {
layer.msg('请先完善商品详情');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
tool.post('/admin/merchant/intention/mark', data.field, callback);
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,116 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">保证金扣费</h3>
<table class="layui-table layui-table-form">
<tr>
<td colspan="2" class="layui-td-gray">商户名称<font>*</font></td>
<td colspan="6">
<input type="text" name="mer_name" lay-verify="required"
lay-reqText="商户名称" disabled autocomplete="off" placeholder="商户名称" class="layui-input" value="{$data.mer_name}">
<!-- <input type="text" name="type" lay-verify="required"
lay-reqText="明细类型" hidden= autocomplete="off" placeholder="明细类型" class="layui-input" value="{$data.type}"> -->
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">商户ID</td>
<td colspan="6">
<input type="number" name="mer_id" lay-verify="required" lay-reqText="0" autocomplete="off" disabled placeholder="0" class="layui-input" value="{$data.mer_id}">
</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">商户剩余保证金</td>
<td >
<input type="number" name="margin" lay-verify="required" lay-reqText="0" autocomplete="off" disabled placeholder="0" class="layui-input" value="{$data.margin}">
</td>
<td >单位:元</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">保证金扣除金额<font>*</font></td>
<td >
<input type="number" name="number" lay-verify="required" lay-reqText="0" autocomplete="off" placeholder="0" class="layui-input" value="">
</td>
<td >单位:元</td>
</tr>
<tr>
<td colspan="2" class="layui-td-gray">保证金扣除原因<font>*</font></td>
<td colspan="6">
<textarea class="layui-textarea" name="mark"></textarea>
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform" type='button'>扣除保证金</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool','treeGrid', 'tagpicker', 'tinymce', 'admin'];
var group_access = "{:session('gougu_admin')['group_access']}"
function gouguInit() {
var treeGrid = layui.treeGrid,table = layui.table
var tool = layui.tool;
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500,
});
//监听提交
form.on('submit(webform)', function (data) {
// console.log(data.field);
// data.field.content = tinyMCE.editors['container_content'].getContent();
if (data.field == '') {
layer.msg('请先完善表单输入');
return false;
}
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
tool.post('/admin/margin/reduct', data.field, callback);
return true;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,442 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<!-- 时间选择 -->
<div class="layui-form">
<form class="layui-form" action="">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">日期范围</label>
<div class="layui-inline" id="test6">
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="test-startDate-1" class="layui-input"
placeholder="开始日期">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="test-endDate-1" class="layui-input"
placeholder="结束日期">
</div>
</div>
</div>
<div class="layui-inline" style="width:45%">
<div class="layui-form-item">
<label class="layui-form-label">关键字</label>
<div class="layui-input-block">
<input style="width:70%;float:left" type="text" name="keywords" placeholder="请输入关键字"
class="layui-input" autocomplete="off" />
<button class="layui-btn layui-btn-normal" lay-submit=""
lay-filter="searchform">提交搜索</button>
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="width:35%;float:none;">
<div class="layui-form-item">
<label class="layui-form-label">商户类别</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
</div>
<div class="layui-input-inline" style="width:35%;">
<div class="layui-form-item">
<label class="layui-form-label">商户分类</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="width:35%;">
<div class="layui-form-item">
<label class="layui-form-label">店铺类型</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
</div>
<div class="layui-input-inline" style="width:35%;">
<div class="layui-form-item">
<label class="layui-form-label">保证金状态</label>
<div class="layui-input-block">
<select name="interest" lay-filter="aihao">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
<div class="layui-tab" lay-filter="demo" lay-allowclose="true">
<ul class="layui-tab-title">
<li class="layui-this" lay-id="11"></li>
<li lay-id="22"></li>
</ul>
<div class="layui-tab-content">
<div class="layui-this" lay-id="11" class="layui-tab-item layui-show">内容1</div>
<div lay-id="22" class="layui-tab-item">内容2</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<!-- test end -->
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li lay-id="11" class="layui-this site-demo-active" data-type="tabChange">缴存保证金</li>
<li lay-id="22" class="site-demo-active" data-type="tabChange">退回保证金</li>
</ul>
<div class="layui-tab-content" style="height: 100px;">
<!-- 缴存列表 -->
<div class="layui-tab-item layui-show">
<table class="layui-hide" id="reduct_list" lay-filter="reduct_list">
</table>
</div>
<!-- 退回保证金列表 -->
<div class="layui-tab-item">
<div class="layui-tab-item layui-show">
<table class="layui-hide" id="refund_list" lay-filter="refund_list">
</table>
</div>
</div>
</div>
</div>
</div>
<!-- 操作 -->
<script type="text/html" id="toolbarDemo"></script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="reduct">保证金扣费</a>
<a class="layui-btn layui-btn-xs" lay-event="record">扣费记录</a>
</div>
</script>
<!-- 操作 -->
<script type="text/html" id="refundToolbar"></script>
<script type="text/html" id="refundBar">
<div class="layui-btn-group">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="status">审核</a>
<a class="layui-btn layui-btn-xs" lay-event="mark">备注</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: '#reduct_list',
title: '保证金列表',
toolbar: '#toolbarDemo',
url: '/admin/margin/lst',
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'ID',
field: 'mer_id',
title: 'ID',
align: 'center',
width: 80
},
{
field: 'mer_name',
title: '商户名称',
align: 'center',
width: 200,
templet: '<div>{{d.merchant.mer_name}}</div>'
}, {
field: 'type_id',
title: '店铺类型',
align: 'center',
width: 220,
templet: '<div>{{d.merchant.type_id}}</div>'
}, {
field: 'real_name',
title: '商户姓名',
align: 'center',
width: 220,
templet: '<div>{{d.merchant.real_name}}</div>'
}, {
field: 'margin',
title: '保证金额度',
align: 'center',
width: 100,
templet: '<div>{{d.merchant.margin}}</div>'
}, {
field: 'status',
title: '状态',
align: 'center',
width: 150
}, {
field: 'pay_time',
title: '支付时间',
align: 'center',
width: 150
},
{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
width: 190,
align: 'center'
}
]
]
});
layui.pageTable = table.render({
elem: '#refund_list',
title: '退回保证金列表',
toolbar: '#refundToolbar',
url: '/admin/margin/refund/lst',
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'ID',
field: 'mer_id',
title: 'ID',
align: 'center',
width: 80
},
{
field: 'mer_name',
title: '商户名称1',
align: 'center',
width: 200,
templet: '<div>{{d.merchant.mer_name}}</div>'
}, {
field: 'type_id',
title: '店铺类型',
align: 'center',
width: 220,
templet: '<div>{{d.merchant.type_id}}</div>'
}, {
field: 'real_name',
title: '商户姓名',
align: 'center',
width: 220,
templet: '<div>{{d.merchant.real_name}}</div>'
}, {
field: 'margin',
title: '保证金额度',
align: 'center',
width: 100,
templet: '<div>{{d.merchant.margin}}</div>'
}, {
field: 'status',
title: '状态',
align: 'center',
width: 150
}, {
field: 'pay_time',
title: '支付时间',
align: 'center',
width: 150
},
{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#refundBar',
width: 190,
align: 'center'
}
]
]
});
//监听表头工具栏事件
// table.on('toolbar(store_product)', function (obj) {
// if (obj.event === 'add') {
// tool.side("/admin/merchant/type/form");
// return false;
// }
// });
//监听表格行工具事件
table.on('tool(reduct_list)', function (obj) {
var data = obj.data;
console.log(data);
if (obj.event === 'reduct') {
tool.side('/admin/margin/form?id=' + obj.data.mer_id);
} else if (obj.event === 'record') {
tool.side('/admin/margin/read?id=' + obj.data.mer_id);
}
return false;
});
//监听表格行工具事件
table.on('tool(refund_list)', function (obj) {
var data = obj.data;
if (obj.event === 'status') {
alert("审核");
tool.post('/admin/margin/status?id=' + obj.data.mer_id, obj.data);
} else if (obj.event === 'mark') {
tool.side('/admin/margin/form?id=' + obj.data.mer_id);
}
return false;
});
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
return false;
});
// 日期范围
layui.use(['laydate','element'], function () {
var laydate = layui.laydate;
var $ = layui.jquery,element = layui.element;
//日期范围
laydate.render({
elem: '#test6'
//设置开始日期、日期日期的 input 选择器
//数组格式为 2.6.6 开始新增,之前版本直接配置 true 或任意分割字符即可
, range: ['#test-startDate-1', '#test-endDate-1']
,done: function(value, date, endDate){
if (value) {
// 时间选择
console.log(value); //得到日期生成的值2017-08-18
console.log(date); //得到日期时间对象:{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
console.log(endDate); //得结束的日期时间对象开启范围选择range: true才会返回。对象成员同上。
alert(1);
layui.pageTable.reload({
where: {
keywords: data.field.keywords
},
page: {
curr: 1
}
});
} else {
// 重置
}
}
});
//触发事件
var active = {
tabChange: function(){
//切换到指定Tab项
element.tabChange('demo', this.getAttribute('lay-id')); //切换到:用户管理
// 展示
this.getAttribute()
// 删除
}
};
$('.site-demo-active').on('click', function(){
var othis = $(this), type = othis.data('type');
active[type] ? active[type].call(this, othis) : '';
});
//Hash地址的定位
// var layid = location.hash.replace(/^#test=/, '');
// element.tabChange('test', layid);
});
// table.on('laydate', function (obj) {
// if (obj.event === 'add') {
// tool.side("/admin/merchant/type/form");
// return false;
// }
// });
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,102 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this">扣费记录</li>
</ul>
<div class="layui-tab-content" style="height: 100px;">
<!-- 缴存列表 -->
<div class="layui-tab-item layui-show">
<table class="layui-hide" id="reduct_list" lay-filter="reduct_list">
</table>
</div>
</div>
</div>
</div>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
var context = "";
if (r != null)
context = decodeURIComponent(r[2]);
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : context;
}
// alert(GetQueryString("id"));
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table, tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#reduct_list',
title: '扣费记录',
toolbar: '#toolbarDemo',
url: '/admin/margin/reductlst?id='+GetQueryString("id"),
parseData: function(res){ //res 即为原始返回的数据
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.count, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
limit: 20,
cellMinWidth: 300,
cols: [
[
{
fixed: 'ID',
field: 'bill_id',
title: 'ID',
align: 'center',
width: 80
},
{
field: 'mark',
title: '扣费原因',
align: 'center',
width: 500,
},{
field: 'number',
title: '扣费金额',
align: 'center',
width: 200,
},{
field: 'create_time',
title: '操作时间',
align: 'center',
width: 200
}
]
]
});
// 日期范围
// layui.use('laydate', function () {
// var laydate = layui.laydate;
// //日期范围
// laydate.render({
// elem: '#test6'
// //设置开始日期、日期日期的 input 选择器
// //数组格式为 2.6.6 开始新增,之前版本直接配置 true 或任意分割字符即可
// , range: ['#test-startDate-1', '#test-endDate-1']
// });
// });
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -0,0 +1,63 @@
{extend name="common/base"/}
{block name="style"}
<style>
.content-article img{max-width:88%!important; height:auto!important; margin:6px 0!important; border-radius:4px;}
</style>
{/block}
<!-- 主体 -->
{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">店铺类型名称</td>
<td colspan="7"><input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">店铺类型要求</td>
<td colspan="7">
<input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_info}" readonly>
</td>
</tr>
<tr>
<td class="layui-td-gray">店铺保证金</td>
<td colspan="7"><input type="text" name="price" lay-verify="required" lay-reqText="请输入商品关键字"
autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.margin}" readonly></td>
</tr>
<tr>
<td class="layui-td-gray">店铺权限</td>
<td colspan="3">
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">其它说明</td>
<td colspan="6">
<textarea class="layui-textarea" name="store_info" readonly>{$detail.store_info}</textarea>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">创建时间</td>
<td colspan="6">
{$detail.create_time}
</td>
</tr>
<tr>
<td class="layui-td-gray" style="text-align:left">修改时间</td>
<td colspan="6">
{$detail.update_time}
</td>
</tr>
</table>
</div>
{/block}
<!-- /主体 -->

View File

@ -20,7 +20,7 @@
<td colspan="2" class="layui-td-gray">店铺类型名称<font>*</font></td>
<td colspan="6">
<input type="text" name="type_name" lay-verify="required" lay-reqText="请输入商品名称"
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="123131{$detail.type_name}">
autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}">
</td>
</tr>

View File

@ -7,7 +7,7 @@
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-4">
<h3 class="pb-3">文章详情</h3>
<h3 class="pb-3">查看店铺类型</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">店铺类型名称</td>

View File

@ -1,51 +0,0 @@
<?php
/**
* @usage 商户管理
* @
* @author 刘孝全
*/
namespace app\common\model\merchant\system;
use think\model;
use think\facade\Db;
/**
* 商户管理model
*/
class Merchant extends Model
{
/**
* 店铺类型.
*
*@param int $page 当前页数
*@param int $limit 获取记录行数
*
*@return Array $list
*/
public function GetType($offset,$limit){
$rows = empty($limit) ? get_config('app . page_size') : $limit;
$where = [];
$list = self::where($where)
->field('id,user_id,title,content,create_time,status,is_read,read_time')
->page($offset)
->limit($limit)
->select();
return $list;
}
/**
* @ 店铺类型说明
*
* return string
*/
public function GetDescription(){}
/**
* @ 店铺保证金
*
* return list
*/
public function Getdeposit(){}
}

View File

@ -1,22 +0,0 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\system;
use think\Model;
/**
* @mixin \think\Model
*/
class MerchantApplyments extends Model
{
protected $table = "eb_merchant_intention";
function __construct(){}
function GetList(){
$list = self::where()->select();
return $list;
}
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\Model;
/**
* @mixin \think\Model
*/
class FinancialRecord extends Model
{
//
}

View File

@ -0,0 +1,82 @@
<?php
/**
* 店铺管理 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月6日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\Model;
use app\common\model\merchant\user\UserBill as UserBillModel;
use think\exception\ValidateException;
/**
* @mixin \think\Model
*/
class Merchant extends Model
{
protected $connection = 'shop';
protected $table = 'eb_merchant';
public function merchantType()
{
return $this->hasOne(MerchantType::class, 'mer_type_id', 'type_id');
}
public function typeName()
{
return $this->merchantType()->bind(['type_name']);
}
/**
* 扣除保证金
*@param array $data [mer_id] => 75
[number] => 2
[mer_name] => teert
[margin] => 10
[mark] => qweqer
[title] => 保证金扣除
[balance] => 8.00
*@return
*/
public function SetMargin($data)
{
$merchant = $this->GetMerchantById($data['mer_id']);
if ($merchant->is_margin !== 10) {
throw new ValidateException('商户未支付保证金或已申请退款');
}
if ($data['number'] < 0) {
throw new ValidateException('扣除保证金额不能小于0');
}
if (bccomp($merchant->margin, $data['number'], 2) == -1) {
throw new ValidateException('扣除保证金额不足');
}
$data['balance'] = bcsub($merchant->margin, $data['number'], 2);
Merchant::transaction(function () use ($merchant, $data) {
$merchant->margin = $data['balance'];
$merchant->save();
$bill = new UserBillModel();
$bill->Bill(0, 'mer_margin', $data['type'], 0, $data);
});
// return [];
}
/**
* 查询指定商户信息
*/
public function GetMerchantById($mer_id)
{
$merchant = Merchant::where('mer_id', $mer_id)->find();
return $merchant;
}
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\Model;
/**
* @mixin \think\Model
*/
class MerchantAdmin extends Model
{
//
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\Model;
/**
* @mixin \think\Model
*/
class MerchantApplyments extends Model
{
//
}

View File

@ -0,0 +1,15 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use think\Model;
/**
* @mixin \think\Model
*/
class MerchantCategory extends Model
{
protected $connection = 'shop';
protected $table = 'eb_merchant_category';
}

View File

@ -0,0 +1,111 @@
<?php
/**
* 店铺入驻申请审核管理model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\system\merchant;
use app\common\model\merchant\system\merchant\MerchantCategory;
use think\Model;
/**
* @mixin \think\Model
*/
class MerchantIntention extends Model
{
protected $connection = 'shop';
protected $table = 'eb_merchant_intention';
protected function merchantCategory()
{
return $this->hasOne(MerchantCategory::class, 'merchant_category_id', 'merchant_category_id');
}
protected function merchantType()
{
return $this->hasOne(MerchantType::class, 'mer_type_id', 'mer_type_id');
}
/**
* 查询入驻申请列表
*/
public function GetList(array $where, $page, $limit)
{
$query = self::search($where);
$count = $query->count();
$list = $query->page($page, $limit)->order('create_time DESC , status ASC')->with(['merchantCategory', 'merchantType'])->select();
return compact('count', 'list');
}
/**
* 查询条件组合
* @param array $where 查询条件
* @return mixed $query
*/
protected function search(array $where)
{
$query = self::when(isset($where['mer_id']) && $where['mer_id'] !== '',
function ($query) use ($where) {
$query->where('mer_id', $where['mer_id']);
})
->when(isset($where['uid']) && $where['uid'] !== '',
function ($query) use ($where) {
$query->where('uid', $where['uid']);
})
->when(isset($where['status']) && $where['status'] !== '',
function ($query) use ($where) {
$query->where('status', (int)$where['status']);
})
->when(isset($where['mer_intention_id']) && $where['mer_intention_id'] !== '',
function ($query) use ($where) {
$query->where('mer_intention_id', $where['mer_intention_id']);
})
->when(isset($where['category_id']) && $where['category_id'] !== '',
function ($query) use ($where) {
$query->where('merchant_category_id', $where['category_id']);
})
->when(isset($where['type_id']) && $where['type_id'] !== '',
function ($query) use ($where) {
$query->where('mer_type_id', $where['type_id']);
})
->when(isset($where['keyword']) && $where['keyword'] !== '',
function ($query) use ($where) {
$query->where('mer_name|phone|mark', 'like', '%' . $where['keyword'] . '%');
})
->when(isset($where['date']) && $where['date'] !== '',
function ($query) use ($where) {
getModelTime($query, $where['date']);
}
)
->where('is_del', 0);
return $query;
}
public function Edit($id, $data)
{
$rows = self::where('mer_intention_id',$id)->update($data);
return $rows;
}
public function form($id, $data)
{
$this->getModel()::getDB()->where($this->getPk(), $id)->update(['status' => $data['status'], 'mark' => $data['mark']]);
}
public function GetWhereCount($mer_intention_id)
{
$count = self::where(['mer_intention_id' => $mer_intention_id, 'is_del' => 0])->fetchSql()->count();
return $count;
}
}

View File

@ -1,25 +0,0 @@
<?php
/**
* 店铺保证金model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
namespace app\common\model\merchant\system\merchant;
use think\Model;
class MerchantMargin extends Model
{
protected $connection = 'shop';
protected $table = '';
function GetList()
{
$list = self::select();
return $list;
}
}

View File

@ -12,7 +12,6 @@ namespace app\common\model\merchant\system\merchant;
use think\exception\ValidateException;
use think\Model;
use think\facade\Db;
/**
* @mixin \think\Model

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\system\serve;
use think\Model;
/**
* @mixin \think\Model
*/
class ServeMeal extends Model
{
//
}

View File

@ -0,0 +1,114 @@
<?php
/**
* 店铺所向平台订购服务的订单 model
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月3日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\system\serve;
use think\Model;
use app\common\model\merchant\system\merchant\Merchant;
use app\common\model\merchant\user\User;
use think\db\Query;
/**
*/
class ServeOrder extends Model
{
protected $connection = 'shop';
protected $talbe = 'eb_serve_order';
// 关联商户表
public function merchant()
{
return $this->hasOne(Merchant::class,'mer_id','mer_id');
}
// 关联用户表
public function userInfo()
{
return $this->hasOne(User::class,'mer_id','ud');
}
function GetList($where, int $page, int $limit)
{
$where['is_del'] = 0;
$query = self::Search($where)->with([
'merchant' => function($query){
$query->with(['merchantType']);
$query->field('mer_id,mer_name,is_trader,mer_avatar,type_id,mer_phone,mer_address,is_margin,margin,real_name,ot_margin');
}
])->order('ServeOrder.create_time DESC');
$count = $query->count();
$list = $query->page((int)$page, (int)$limit)->select();
return compact('count','list');
}
/**
* @param ServeOrderRepository $orderRepository
*
* @return \think\response\Json
*/
public function Search($where):Query
{
$query = self::hasWhere('merchant',function($query) use($where) {
$query->when(isset($where['keyword']) && $where['keyword'] !== '',
function ($query) use($where){
$query->whereLike('mer_keyword|real_name|mer_name',"%{$where['keyword']}%");
}
);
$query->when(isset($where['is_trader']) && $where['is_trader'] !== '',
function ($query) use($where){
$query->where('is_trader',$where['is_trader']);
}
);
$query->when(isset($where['category_id']) && $where['category_id'] !== '',
function ($query) use($where){
$query->where('category_id',$where['category_id']);
}
);
$query->when(isset($where['type_id']) && $where['type_id'] !== '',
function ($query) use($where){
$query->where('type_id',$where['type_id']);
}
);
$query->where('is_del',0);
});
$query->when(isset($where['type']) && $where['type'] !== '',
function ($query) use($where){
$query->where('ServeOrder.type',$where['type']);
}
);
$query->when(isset($where['date']) && $where['date'] !== '',
function ($query) use($where){
getModelTime($query,$where['date'],'ServeOrder.create_time');
}
);
$query->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use($where){
$query->where('ServeOrder.mer_id',$where['mer_id']);
});
$query->when(isset($where['status']) && $where['status'] !== '', function ($query) use($where){
$query->where('ServeOrder.status',$where['status']);
});
$query->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use($where){
$query->where('ServeOrder.is_del',$where['is_del']);
});
return $query;
}
}

View File

@ -0,0 +1,15 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class User extends Model
{
protected $connection = 'shop';
// protected $table = 'user';
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserAddress extends Model
{
//
}

View File

@ -0,0 +1,370 @@
<?php
/**
* 店铺保证金管理-缴费记录
*
* @author刘孝全
* @emailq8197264@126.com
* @date 2023年03月6日
*/
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserBill extends Model
{
protected $connection = 'shop';
protected $table = 'eb_user_bill';
const TYPE_INFO = [
'brokerage/now_money' => '佣金转入余额',
'brokerage/order_one' => '获得一级推广佣金',
'brokerage/order_two' => '获得二级推广佣金',
'brokerage/refund_one' => '退还一级佣金',
'brokerage/refund_two' => '退还二级佣金',
'integral/cancel' => '退回积分',
'integral/deduction' => '购买商品',
'integral/lock' => '下单赠送积分',
'integral/refund' => '订单退款',
'integral/refund_lock' => '扣除赠送积分',
'integral/sign_integral' => '签到赠送积分',
'integral/spread' => '邀请好友',
'integral/sys_dec' => '系统减少积分',
'integral/sys_inc' => '系统增加积分',
'integral/timeout' => '积分过期',
'mer_integral/deduction' => '积分抵扣',
'mer_integral/refund' => '订单退款',
'mer_lock_money/order' => '商户佣金冻结',
'now_money/brokerage' => '佣金转入余额',
'now_money/pay_product' => '购买商品',
'now_money/presell' => '支付预售尾款',
'now_money/recharge' => '余额充值',
'now_money/sys_dec_money' => '系统减少余额',
'now_money/sys_inc_money' => '系统增加余额',
];
/**
* TODO: 短信通知待开发
* 创建用户帐单
*
* @param int $uid
* @param string $category
* @param string $type
* @param int $pm
* @param array $data
* @return BaseDao|Model
*/
public function Bill(int $uid, string $category, string $type, int $pm, array $data)
{
$data['category'] = $category;
$data['type'] = $type;
$data['uid'] = $uid;
$data['pm'] = $pm;
$bill = self::create($data);
if($category == 'now_money'){
// 暂不发短信
// Queue::push(SendSmsJob::class,['tempId' => 'USER_BALANCE_CHANGE','id' => $bill->bill_id]);
}
return $bill;
}
// protected function getModel(): string
// {
// return UserBill::class;
// }
/**
* 获取查询用户保证金帐单记录
* @param array $where 查询条件
* @param int $page 当前页
* @param int $limit 每页记录数
*
* @return array
*/
public function GetList($where, $page, $limit)
{
$query = self::SearchJoin($where)->order('a.create_time DESC');
$count = $query->count();
$list = $query->page($page, $limit)->select();
return compact('count', 'list');
}
/**
* @param array $where
* @param $data
* @return int
* @throws \think\db\exception\DbException
* @author xaboy
* @day 2020/6/22
*/
public function updateBill(array $where, $data)
{
return UserBill::where($where)->limit(1)->update($data);
}
/**
* 查询历史佣金记录
*
* @param $time
* @return \think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author xaboy
* @day 2020/6/22
*/
public function getTimeoutBrokerageBill($time)
{
return UserBill::where('create_time', '<=', $time)->where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->with('user')->where('status', 0)->select();
}
/**
* 查询历史积分记录
*/
public function getTimeoutIntegralBill($time)
{
return UserBill::where('create_time', '<=', $time)->where('category', 'integral')
->where('type', 'lock')->with('user')->where('status', 0)->select();
}
public function getTimeoutMerchantMoneyBill($time)
{
return UserBill::where('create_time', '<=', $time)->where('category', 'mer_computed_money')->where('type','order')
->where('status', 0)->select();
}
public function refundMerchantMoney($order_id, $type, $mer_id)
{
return UserBill::where('link_id', $order_id)->where('mer_id', $mer_id)
->where('category', 'mer_refund_money')->where('type', $type)->sum('number');
}
public function merchantLickMoney($merId = null)
{
$lst = UserBill::where('category', 'mer_lock_money')->when($merId, function ($query, $val) {
$query->where('mer_id', $val);
})->where('status', 0)->select()->toArray();
$lockMoney = 0;
if (count($lst)) {
$lockMoney = -1 * UserBill::whereIn('link_id', array_column($lst, 'link_id'))
->where('category', 'mer_refund_money')->sum('number');
}
foreach ($lst as $bill) {
$lockMoney = bcadd($lockMoney, $bill['number'], 2);
}
$lockMoney = bcadd($lockMoney, UserBill::getDB()
->where('category', 'mer_computed_money')->when($merId, function ($query, $val) {
$query->where('mer_id', $val);
})->where('status', 0)->where('type', 'order')->sum('number'), 2);
return $lockMoney;
}
/**
* @param $uid
* @return float
* @author xaboy
* @day 2020/6/22
*/
public function lockBrokerage($uid)
{
$lst = UserBill::where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->where('uid', $uid)->where('status', 0)->field('link_id,number')->select()->toArray();
$refundPrice = 0;
if (count($lst)) {
$refundPrice = -1 * UserBill::whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number');
}
foreach ($lst as $bill) {
$refundPrice = bcadd($refundPrice, $bill['number'], 2);
}
return $refundPrice;
}
public function lockIntegral($uid = null, $order_id = null)
{
$lst = UserBill::where('category', 'integral')
->where('type', 'lock')->when($order_id, function ($query, $order_id) {
$query->where('link_id', $order_id);
})->when($uid, function ($query, $uid) {
$query->where('uid', $uid);
})->where('status', 0)->field('link_id,number')->select()->toArray();
$lockIntegral = 0;
if (count($lst)) {
$lockIntegral = -1 * UserBill::whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
->where('category', 'integral')->where('type', 'refund_lock')->sum('number');
}
foreach ($lst as $bill) {
$lockIntegral = bcadd($lockIntegral, $bill['number'], 0);
}
return $lockIntegral;
}
public function deductionIntegral($uid)
{
return UserBill::where('uid', $uid)
->where('category', 'integral')->where('type', 'deduction')->sum('number');
}
public function totalGainIntegral($uid)
{
return UserBill::where('uid', $uid)
->where('category', 'integral')->where('pm', 1)->whereNotIn('type', ['refund', 'cancel'])->sum('number');
}
/**
* @param $uid
* @return float
* @author xaboy
* @day 2020/6/22
*/
public function totalBrokerage($uid)
{
return bcsub(UserBill::where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->where('uid', $uid)->sum('number'),
UserBill::where('uid', $uid)
->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number'), 2);
}
/**
* @param $uid
* @return float
* @author xaboy
* @day 2020/6/22
*/
public function yesterdayBrokerage($uid)
{
return getModelTime(UserBill::where('category', 'brokerage')
->whereIn('type', ['order_one', 'order_two'])->where('uid', $uid), 'yesterday')->sum('number');
}
/**
* @param array $where
* @return \think\db\BaseQuery
* @author xaboy
* @day 2020/6/22
*/
public function search(array $where)
{
return UserBill::when(isset($where['now_money']) && in_array($where['now_money'], [0, 1, 2]), function ($query) use ($where) {
if ($where['now_money'] == 0)
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'recharge', 'sys_inc_money', 'sys_dec_money', 'brokerage', 'presell', 'refund']);
else if ($where['now_money'] == 1)
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'sys_dec_money', 'presell']);
else if ($where['now_money'] == 2)
$query->where('category', 'now_money')->whereIn('type', ['recharge', 'sys_inc_money', 'brokerage', 'refund']);
})
->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
$query->where('uid', $where['uid'])->where('mer_id', 0);
})
->when(isset($where['pm']) && $where['pm'] !== '', function ($query) use ($where) {
$query->where('pm', $where['pm']);
})
->when(isset($where['category']) && $where['category'] !== '', function ($query) use ($where) {
$query->where('category', $where['category']);
})
->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
$query->where('status', $where['status']);
})
->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
getModelTime($query, $where['date'], 'create_time');
})
->when(isset($where['day']) && $where['day'] !== '', function ($query) use ($where) {
$query->whereDay('create_time', $where['day']);
})
->when(isset($where['month']) && $where['month'] !== '', function ($query) use ($where) {
$query->whereMonth('create_time', $where['month']);
})
->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
$data = explode('/', $where['type'], 2);
if (count($data) > 1) {
$query->where('category', $data[0])->where('type', $data[1]);
} else {
$query->where('type', $where['type']);
}
})
->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
$query->where('mer_id', $where['mer_id']);
})
->when(isset($where['link_id']) && $where['link_id'] !== '', function ($query) use ($where) {
$query->where('link_id', $where['link_id']);
});
}
public function userNowMoneyIncTotal($uid)
{
return $this->search(['uid' => $uid, 'now_money' => 2])->sum('number');
}
/**
* 查询用户帐单
* @param array $where 查询条件
* @return Query
*/
public function SearchJoin(array $where)
{
$query = UserBill::alias('a')->leftJoin('User b', 'a.uid = b.uid')
->field('a.bill_id,a.pm,a.title,a.number,a.balance,a.mark,a.create_time,a.status,b.nickname,a.uid,a.category')
->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
$query->where('a.mer_id', $where['mer_id']);
})
->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) {
$data = explode('/', $where['type'], 2);
if (count($data) > 1) {
$query->where('a.category', $data[0])->where('type', $data[1]);
} else {
$query->where('a.type', $where['type']);
}
})
->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
getModelTime($query, $where['date'], 'a.create_time');
})
->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
$query->whereLike('a.uid|b.nickname|a.title', "%{$where['keyword']}%");
})
->when(isset($where['category']) && $where['category'] !== '', function ($query) use ($where) {
$query->where('a.category', $where['category']);
})->where('category', '<>', 'sys_brokerage');
return $query;
}
public function refundBrokerage($order_id, $uid)
{
return UserBill::where('link_id', $order_id)->where('uid', $uid)
->where('category', 'brokerage')->whereIn('type', ['refund_two', 'refund_one'])->sum('number');
}
public function refundIntegral($order_id, $uid)
{
return UserBill::where('link_id', $order_id)->where('uid', $uid)
->where('category', 'integral')->where('type', 'refund_lock')->sum('number');
}
public function validIntegral($uid, $start, $end)
{
$lst = UserBill::where('category', 'integral')
->where('type', 'lock')->whereBetween('create_time', [$start, $end])->where('uid', $uid)->where('status', 1)->field('link_id,number')->select()->toArray();
$integral = 0;
if (count($lst)) {
$integral = -1 * UserBill::whereIn('link_id', array_column($lst, 'link_id'))->where('uid', $uid)
->where('category', 'integral')->where('type', 'refund_lock')->sum('number');
}
foreach ($lst as $bill) {
$integral = bcadd($integral, $bill['number'], 0);
}
$integral2 = UserBill::where('uid', $uid)->whereBetween('create_time', [$start, $end])
->where('category', 'integral')->where('pm', 1)->whereNotIn('type', ['lock', 'refund'])->sum('number');
$integral3 = UserBill::where('uid', $uid)->whereBetween('create_time', [$start, $end])
->where('category', 'integral')->where('type', 'sys_dec')->sum('number');
return (int)max(bcsub(bcadd($integral, $integral2, 0), $integral3, 0), 0);
}
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserHistory extends Model
{
//
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserLabel extends Model
{
//
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserMerchant extends Model
{
//
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserOrder extends Model
{
//
}

View File

@ -0,0 +1,14 @@
<?php
declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
/**
* @mixin \think\Model
*/
class UserRecharge extends Model
{
//
}