From 568534719ee08bf6597b10b4c4877374cab8a7a8 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Wed, 15 Mar 2023 19:12:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E9=87=91=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=B0=83=E4=BC=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/financial/Financial.php | 106 +++++++++++++ .../system/merchant/MerchantMargin.php | 11 +- app/admin/route/merchant.php | 7 +- .../merchant/system/merchant/margin/list.html | 144 +++++++++++------- .../merchant/system/serve/ServeOrder.php | 74 +++++---- app/common/model/merchant/user/User.php | 10 +- app/common/model/merchant/user/UserBill.php | 8 + 7 files changed, 268 insertions(+), 92 deletions(-) create mode 100644 app/admin/controller/merchant/system/financial/Financial.php diff --git a/app/admin/controller/merchant/system/financial/Financial.php b/app/admin/controller/merchant/system/financial/Financial.php new file mode 100644 index 0000000..2fea61b --- /dev/null +++ b/app/admin/controller/merchant/system/financial/Financial.php @@ -0,0 +1,106 @@ +getPage(); + $where = $this->request->params(['date','status','financial_type','financial_status','keyword','is_trader','mer_id']); + $where['type'] = 0; + $data = $this->repository->getAdminList($where,$page,$limit); + return app('json')->success($data); + } + + public function getMarginLst() + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['date','status','financial_type','financial_status','keyword','is_trader','mer_id']); + $where['type'] = 1; + $data = $this->repository->getAdminList($where,$page,$limit); + return app('json')->success($data); + } + + + /** + * 显示创建资源表单页. + * + * @return \think\Response + */ + public function create() + { + // + } + + /** + * 保存新建的资源 + * + * @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) + { + // + } +} diff --git a/app/admin/controller/merchant/system/merchant/MerchantMargin.php b/app/admin/controller/merchant/system/merchant/MerchantMargin.php index acff038..68e859b 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantMargin.php +++ b/app/admin/controller/merchant/system/merchant/MerchantMargin.php @@ -56,19 +56,20 @@ class MerchantMargin extends BaseController } /** - * 显示保证金列表 + * 获取保证金列表 * - * @return \think\Response + * @return json */ public function lst(ServeOrderModel $order) { $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 = get_params(['date','keyword','is_trader','category_id','is_margin','type_id']); $where['type'] = 10;//10==保证金 $data = $order->GetList($where, $page, $limit); + return to_assign(0,'success', $data['data']=$data['list']); } @@ -140,6 +141,10 @@ class MerchantMargin extends BaseController } + + + + /** * 保存新建的资源 * diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index f0c5915..e7aebe8 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -164,7 +164,7 @@ Route::group(function(){ // 保证金退还 Route::group('margin/refund', function(){ //退款申请 - Route::get('refund/lst', 'financial.Financial/getMarginLst')->name('systemMarginRefundList')->option([ + Route::get('lst', 'financial.Financial/getMarginLst')->name('systemMarginRefundList')->option([ '_alias' => '退款申请列表', ]); Route::get('refund/show/:id', 'financial.Financial/refundShow')->name('systemMarginRefundShow')->option([ @@ -190,5 +190,8 @@ Route::group(function(){ Route::post('refund/mark/:id', 'financial.Financial/mark')->name('systemMarginRefundMark')->option([ '_alias' => '备注', ]); - }); + })->prefix('merchant.system.financial.Financial')->option([ + '_path' => '/margin', + '_auth' => true, + ]); }); diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html index 6919f65..16ddefb 100644 --- a/app/admin/view/merchant/system/merchant/margin/list.html +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -50,7 +50,7 @@
- @@ -62,10 +62,10 @@
- - - + +
@@ -112,10 +112,10 @@
- - - + +
@@ -147,7 +147,7 @@
- @@ -167,14 +167,14 @@
    -
  • 缴存保证金
  • -
  • 退回保证金
  • +
  • 缴存保证金
  • +
  • 退回保证金
- +
@@ -221,8 +221,8 @@ function gouguInit() { var table = layui.table, tool = layui.tool, form = layui.form; - layui.pageTable = table.render({ - elem: '#reduct_list', + layui.payTable = table.render({ + elem: '#pay_list', title: '保证金列表', toolbar: '#toolbarDemo', url: '/admin/margin/lst', @@ -249,7 +249,7 @@ title: '店铺类型', align: 'center', width: 220, - templet: '
{{d.merchant.type_id}}
' + templet: '
{{d.merchant.merchantType.type_name}}
' }, { field: 'real_name', title: '商户姓名', @@ -266,7 +266,22 @@ field: 'status', title: '状态', align: 'center', - width: 150 + width: 150, + templet: function(d){ + switch (d.merchant.is_margin) { + case 0: + return '
' + case 1: + return '
有未支付
' + case 10: + return '
已支付
' + case -1: + return '
申请退款
' + case -10: + return '
拒绝退款
' + + } + } }, { field: 'pay_time', title: '支付时间', @@ -287,7 +302,7 @@ }); - layui.pageTable = table.render({ + layui.refundTable = table.render({ elem: '#refund_list', title: '退回保证金列表', toolbar: '#refundToolbar', @@ -363,25 +378,10 @@ return data; } - var $ = layui.$, active = { - reload: function(){ - let dataRload = getformdata();; - - //执行重载 - table.reload('testReload', { - page: { - curr: 1 //重新从第 1 页开始 - } - ,where: { - ...dataRload - } - }); - } - }; //监听表格行工具事件 - table.on('tool(reduct_list)', function (obj) { + table.on('tool(pay_list)', function (obj) { var data = obj.data; // console.log(data); if (obj.event === 'reduct') { @@ -407,9 +407,51 @@ return false; }); + //触发事件 + var $ = layui.$, active = { + tabChange: function(){ + //切换到指定Tab项 + // element.tabChange('demo', this.getAttribute('lay-id')); //切换tab + var marign = document.getElementById('set_margin'); + var refund = document.getElementById('refund_margin'); + if ('11'==this.getAttribute('lay-id')) { + marign.style.display = "block"; + refund.style.display = "none"; + }else{ + refund.style.display = "block"; + marign.style.display = "none"; + } + }, + reload: function(){ + let dataRload = getformdata(); + + //执行重载 + table.reload('pay_list', { + page: { + curr: 1 //重新从第 1 页开始 + } + ,where: { + ...dataRload + } + }); + }, + refund_reload: ()=>{ + let dataRload = getformdata(); + + //执行重载 + table.reload('refund_list', { + page: { + curr: 1 //重新从第 1 页开始 + } + ,where: { + ...dataRload + } + }); + } + }; - layui.use(['laydate','element', 'jquery'], + layui.use(['laydate','element','table', 'jquery'], function () { var laydate = layui.laydate; var $ = layui.jquery,element = layui.element; @@ -429,33 +471,23 @@ } }); - //触发事件 - var active = { - tabChange: function(){ - //切换到指定Tab项 - // element.tabChange('demo', this.getAttribute('lay-id')); //切换tab - var marign = document.getElementById('set_margin'); - var refund = document.getElementById('refund_margin'); - if ('11'==this.getAttribute('lay-id')) { - marign.style.display = "block"; - refund.style.display = "none"; - // refund.childNodes().value=''; - }else{ - refund.style.display = "block"; - marign.style.display = "none"; - } - } - }; - $('.site-demo-active').on('click', function(){ + + // 列表切换 + $('.tag-switch').on('click', function(){ var othis = $(this), type = othis.data('type'); active[type] ? active[type].call(this, othis) : ''; + if ('11'==this.getAttribute('lay-id')) { + active['reload'] ? active['reload'].call(this, othis) : ''; + }else{ + active['refund_reload'] ? active['refund_reload'].call(this, othis) : ''; + } }); //监听button提交 form.on('submit(searchform)', function(data) { - layui.pageTable.reload({ + layui.payTable.reload({ where: { ...data.field }, @@ -469,7 +501,7 @@ form.on('select(searchform)', function(e) { let data = getformdata(); - layui.pageTable.reload({ + layui.payTable.reload({ where: { ...data }, @@ -480,12 +512,6 @@ return false; }); - //监听保证金状态select - $('.margin_state .layui-btn').on('click', function(){ - var type = $(this).data('type'); - active[type] ? active[type].call(this) : ''; - }); - //选择时间 form.on('submit(chonse_date)', function(data){ diff --git a/app/common/model/merchant/system/serve/ServeOrder.php b/app/common/model/merchant/system/serve/ServeOrder.php index c9818b0..998de56 100644 --- a/app/common/model/merchant/system/serve/ServeOrder.php +++ b/app/common/model/merchant/system/serve/ServeOrder.php @@ -14,6 +14,7 @@ use think\Model; use app\common\model\merchant\system\merchant\Merchant; use app\common\model\merchant\user\User; use think\db\Query; +use think\facade\Db; /** @@ -22,6 +23,7 @@ class ServeOrder extends Model { protected $connection = 'shop'; protected $talbe = 'eb_serve_order'; + protected $pk = 'mer_id'; // 关联商户表 public function merchant() @@ -35,6 +37,9 @@ class ServeOrder extends Model return $this->hasOne(User::class,'mer_id','ud'); } + /** + * 获取所有商户的保证金数据 + */ function GetList($where, int $page, int $limit) { $where['is_del'] = 0; @@ -54,9 +59,11 @@ class ServeOrder extends Model /** - * @param ServeOrderRepository $orderRepository + * 条件过滤sql * - * @return \think\response\Json + * @param array $where 条件数组 + * + * @return object Query */ public function Search($where):Query { @@ -66,49 +73,62 @@ class ServeOrder extends Model function ($query) use($where){ $query->whereLike('mer_keyword|real_name|mer_name',"%{$where['keyword']}%"); } - ); - $query->when(isset($where['is_trader']) && $where['is_trader'] !== '', + ) + ->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'] !== '', + ) + ->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'] !== '', + ) + ->when(isset($where['type_id']) && $where['type_id'] !== '', function ($query) use($where){ $query->where('type_id',$where['type_id']); } - ); - $query->where('is_del',0); + ) + ->when(isset($where['is_margin']) && $where['is_margin'] !== '', + function($query)use($where){ + $query->where('is_margin', $where['is_margin']); + } + ) + ->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'] !== '', + ) + ->when(isset($where['date']) && $where['date'] !== '', function ($query) use($where){ - getModelTime($query,$where['date'],'ServeOrder.create_time'); + getModelTime($query,$where['date'],'ServeOrder.create_time'); + } + ) + ->when(isset($where['start_date'])&&isset($where['end_date'])&&$where['start_date']!==''&&$where['end_date']!=='', + function($query)use($where){ + $query->where('create_time','between',[$where['start_date'], $where['end_date']]); + } + ) + ->when(isset($where['mer_id']) && $where['mer_id'] !== '', + function ($query) use($where){ + $query->where('ServeOrder.mer_id',$where['mer_id']); + } + ) + ->when(isset($where['status']) && $where['status'] !== '', + function ($query) use($where){ + $query->where('ServeOrder.status',$where['status']); + } + ) + ->when(isset($where['is_del']) && $where['is_del'] !== '', + function ($query) use($where){ + $query->where('ServeOrder.is_del',$where['is_del']); } ); - - $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; } + } diff --git a/app/common/model/merchant/user/User.php b/app/common/model/merchant/user/User.php index a0031f5..8eba854 100644 --- a/app/common/model/merchant/user/User.php +++ b/app/common/model/merchant/user/User.php @@ -1,4 +1,11 @@ '佣金转入余额', @@ -47,6 +48,13 @@ class UserBill extends Model 'now_money/sys_inc_money' => '系统增加余额', ]; + /** + * 关联user模型 + */ + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } /** * TODO: 短信通知待开发