商户入驻与保证金bug修复
This commit is contained in:
parent
c2c20eedf7
commit
fbfc1785ab
24
.env.debug
24
.env.debug
@ -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
|
@ -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
|
||||
{
|
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* 店铺入驻申请审核管理
|
||||
*
|
||||
* @author:刘孝全
|
||||
* @email:q8197264@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)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
}
|
@ -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\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;
|
||||
|
||||
/**
|
||||
* 店铺保证金管理类
|
||||
@ -43,7 +47,7 @@ class MerchantMargin extends BaseController
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function lst(ServeOrderModel $order)
|
||||
public function Lst(ServeOrderModel $order)
|
||||
{
|
||||
$params = get_params();
|
||||
$page = empty($params['page'])? 1 : (int)$params['page'];
|
||||
@ -56,28 +60,70 @@ class MerchantMargin extends BaseController
|
||||
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()
|
||||
public function GetMarginLst(UserBillModel $bill)
|
||||
{
|
||||
return View($this->path['read']);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置扣减保证金表单
|
||||
*/
|
||||
public function setMarginForm()
|
||||
public function setMarginForm(MerchantModel $merchant)
|
||||
{
|
||||
return View($this->path['edit']);
|
||||
|
||||
$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()
|
||||
public function setMargin(MerchantModel $merchant)
|
||||
{
|
||||
echo 'fail';
|
||||
$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,'扣除保证金成功',[]);
|
||||
}
|
||||
|
||||
|
||||
@ -92,16 +138,7 @@ class MerchantMargin extends BaseController
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示指定的资源
|
||||
*
|
||||
* @param int $id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function read($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示编辑资源表单页.
|
||||
|
@ -7,7 +7,6 @@
|
||||
* @email:q8197264@126.com
|
||||
* @date :2023年03月3日
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\controller\merchant\system\merchant;
|
||||
|
@ -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([
|
||||
@ -102,10 +137,14 @@ Route::group(function(){
|
||||
Route::get('lst', '/lst')->name('systemMerchantMarginLst')->option([
|
||||
'_alias' => '缴纳记录',
|
||||
]);
|
||||
//扣费记录
|
||||
Route::get('read', '/getMarginLst')->name('systemMarginList')->option([
|
||||
'_alias' => '扣费记录',
|
||||
]);
|
||||
//扣费记录页
|
||||
Route::get('read', '/GetMarginLstForm')->name('systemMarginList')->option([
|
||||
'_alias' => '扣费记录页',
|
||||
]);
|
||||
//扣费记录帐单接口
|
||||
Route::get('reductlst', '/GetMarginLst')->name('systemMarginList')->option([
|
||||
'_alias' => '扣费记录',
|
||||
]);
|
||||
|
||||
//扣除保证金
|
||||
Route::get('form', '/setMarginForm')->name('systemMarginSetForm')->option([
|
||||
|
283
app/admin/view/merchant/system/merchant/intention/lst.html
Normal file
283
app/admin/view/merchant/system/merchant/intention/lst.html
Normal 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}
|
||||
<!-- /脚本 -->
|
57
app/admin/view/merchant/system/merchant/intention/mark.html
Normal file
57
app/admin/view/merchant/system/merchant/intention/mark.html
Normal 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}
|
||||
<!-- /脚本 -->
|
@ -17,54 +17,50 @@
|
||||
<table class="layui-table layui-table-form">
|
||||
|
||||
<tr>
|
||||
<td colspan="2" class="layui-td-gray">店铺类型名称<font>*</font></td>
|
||||
<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="">
|
||||
<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">店铺类型要求</td>
|
||||
<td colspan="2" class="layui-td-gray">商户ID</td>
|
||||
<td colspan="6">
|
||||
<textarea class="layui-textarea" name="type_info"></textarea>
|
||||
<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 colspan="6">
|
||||
<table class="layui-table layui-table-form">
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_margin" value="1" title="有" checked="">
|
||||
<input type="radio" name="is_margin" value="0" title="无" checked="">
|
||||
</div>
|
||||
</td>
|
||||
<td colspan="5"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="text" name="margin" lay-verify="required" lay-reqText="0" autocomplete="off" placeholder="0" class="layui-input" value="">
|
||||
</td>
|
||||
<td colspan="5">单位:元</td>
|
||||
</tr>
|
||||
</table>
|
||||
<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">其它说明</td>
|
||||
<td colspan="2" class="layui-td-gray">保证金扣除原因<font>*</font></td>
|
||||
<td colspan="6">
|
||||
<textarea class="layui-textarea" name="description"></textarea>
|
||||
<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 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>
|
||||
@ -91,41 +87,27 @@
|
||||
height: 500,
|
||||
});
|
||||
|
||||
|
||||
// 店铺权限
|
||||
layui.use(['tree', 'util'], function(){
|
||||
var tree = layui.tree
|
||||
,layer = layui.layer
|
||||
,util = layui.util
|
||||
//模拟数据
|
||||
,data = [];
|
||||
|
||||
|
||||
//监听提交
|
||||
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);
|
||||
}
|
||||
//监听提交
|
||||
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/merchant/type/add', data.field, callback);
|
||||
|
||||
tool.post('/admin/margin/reduct', data.field, callback);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -247,7 +247,7 @@
|
||||
elem: '#refund_list',
|
||||
title: '退回保证金列表',
|
||||
toolbar: '#refundToolbar',
|
||||
url: '/admin/margin/lst',
|
||||
url: '/admin/margin/refund/lst',
|
||||
page: true,
|
||||
limit: 20,
|
||||
cellMinWidth: 300,
|
||||
@ -262,7 +262,7 @@
|
||||
},
|
||||
{
|
||||
field: 'mer_name',
|
||||
title: '商户名称',
|
||||
title: '商户名称1',
|
||||
align: 'center',
|
||||
width: 200,
|
||||
templet: '<div>{{d.merchant.mer_name}}</div>'
|
||||
@ -299,7 +299,7 @@
|
||||
fixed: 'right',
|
||||
field: 'right',
|
||||
title: '操作',
|
||||
toolbar: '#barDemo',
|
||||
toolbar: '#refundBar',
|
||||
width: 190,
|
||||
align: 'center'
|
||||
}
|
||||
@ -334,7 +334,9 @@
|
||||
table.on('tool(refund_list)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'status') {
|
||||
tool.side('/admin/margin/read?id=' + obj.data.mer_id);
|
||||
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);
|
||||
}
|
||||
@ -342,6 +344,7 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//监听搜索提交
|
||||
// form.on('submit(searchform)', function(data) {
|
||||
// layui.pageTable.reload({
|
||||
|
@ -25,6 +25,18 @@
|
||||
<!-- 脚本 -->
|
||||
{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;
|
||||
@ -32,7 +44,15 @@
|
||||
elem: '#reduct_list',
|
||||
title: '扣费记录',
|
||||
toolbar: '#toolbarDemo',
|
||||
url: '/admin/margin/lst',
|
||||
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,
|
||||
@ -40,25 +60,23 @@
|
||||
[
|
||||
{
|
||||
fixed: 'ID',
|
||||
field: 'mer_id',
|
||||
field: 'bill_id',
|
||||
title: 'ID',
|
||||
align: 'center',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
field: 'mer_name',
|
||||
field: 'mark',
|
||||
title: '扣费原因',
|
||||
align: 'center',
|
||||
width: 500,
|
||||
templet: '<div>{{d.merchant.mer_name}}</div>'
|
||||
},{
|
||||
field: 'margin',
|
||||
field: 'number',
|
||||
title: '扣费金额',
|
||||
align: 'center',
|
||||
width: 200,
|
||||
templet: '<div>{{d.merchant.margin}}</div>'
|
||||
},{
|
||||
field: 'pay_time',
|
||||
field: 'create_time',
|
||||
title: '操作时间',
|
||||
align: 'center',
|
||||
width: 200
|
||||
@ -67,41 +85,17 @@
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
//监听表头工具栏事件
|
||||
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) {
|
||||
console.log(obj.data);
|
||||
var data = obj.data;
|
||||
if (obj.event === 'reduct') {
|
||||
tool.side('/admin/margin/read?id=' + obj.data.id);
|
||||
} else if (obj.event === 'record') {
|
||||
tool.side('/admin/margin/form?id=' + obj.data.id);
|
||||
}
|
||||
|
||||
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']
|
||||
});
|
||||
});
|
||||
// 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}
|
||||
|
@ -11,6 +11,8 @@ 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
|
||||
@ -29,4 +31,52 @@ class Merchant extends Model
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,6 @@ use think\Model;
|
||||
*/
|
||||
class MerchantCategory extends Model
|
||||
{
|
||||
//
|
||||
protected $connection = 'shop';
|
||||
protected $table = 'eb_merchant_category';
|
||||
}
|
||||
|
@ -1,8 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* 店铺入驻申请审核管理model
|
||||
*
|
||||
* @author:刘孝全
|
||||
* @email:q8197264@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;
|
||||
|
||||
/**
|
||||
@ -10,5 +18,94 @@ use 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;
|
||||
}
|
||||
}
|
||||
|
@ -62,28 +62,40 @@ class ServeOrder extends Model
|
||||
{
|
||||
$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->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['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['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']);
|
||||
|
14
app/common/model/merchant/user/UserAddress.php
Normal file
14
app/common/model/merchant/user/UserAddress.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
370
app/common/model/merchant/user/UserBill.php
Normal file
370
app/common/model/merchant/user/UserBill.php
Normal file
@ -0,0 +1,370 @@
|
||||
<?php
|
||||
/**
|
||||
* 店铺保证金管理-缴费记录
|
||||
*
|
||||
* @author:刘孝全
|
||||
* @email:q8197264@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);
|
||||
}
|
||||
}
|
14
app/common/model/merchant/user/UserHistory.php
Normal file
14
app/common/model/merchant/user/UserHistory.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
14
app/common/model/merchant/user/UserLabel.php
Normal file
14
app/common/model/merchant/user/UserLabel.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
14
app/common/model/merchant/user/UserMerchant.php
Normal file
14
app/common/model/merchant/user/UserMerchant.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
14
app/common/model/merchant/user/UserOrder.php
Normal file
14
app/common/model/merchant/user/UserOrder.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
14
app/common/model/merchant/user/UserRecharge.php
Normal file
14
app/common/model/merchant/user/UserRecharge.php
Normal 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
|
||||
{
|
||||
//
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user