From e5b9785c3221a6c796346d7e14467a1790dc93b6 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Mon, 20 Dec 2021 17:53:03 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Coupon.php | 1 + app/controller/manager/Coupon.php | 7 ++++++ app/model/Deduction.php | 4 ++++ app/repository/BusinessRepository.php | 2 +- public/static/manager/js/bill.js | 24 +++++++++++++++++-- .../js/business/business_deduction_list.js | 8 +++++++ public/static/manager/js/coupon/index.js | 5 +++- view/manager/bill/index.html | 2 +- .../business/business_deduction_list.html | 5 +++- view/manager/business/business_detail.html | 2 +- 10 files changed, 53 insertions(+), 7 deletions(-) diff --git a/app/controller/api/Coupon.php b/app/controller/api/Coupon.php index f5a592a..f54c5c8 100644 --- a/app/controller/api/Coupon.php +++ b/app/controller/api/Coupon.php @@ -439,6 +439,7 @@ class Coupon extends Base // 3. 写入商家扣费记录 $deductionData = [ "money" => $deductionMoney, + "user_code" => $account->user_code, "business_code" => $business->code, "business_name" => $business->business_name, "balance" => $business->balance - $deductionMoney, diff --git a/app/controller/manager/Coupon.php b/app/controller/manager/Coupon.php index 60d668a..970de6c 100644 --- a/app/controller/manager/Coupon.php +++ b/app/controller/manager/Coupon.php @@ -104,6 +104,13 @@ class Coupon extends Base } else { $item->state_text = '已过期'; } + //渠道商名称 + if(isset($item->business) && $item->business && !empty($item->business->agency_code)){ + $item->agency_text = BusinessModel::where("code",$time->item->business->agency_code)->value("business_name",''); + }else{ + $item->agency_text = ''; + } + }); return $this->json(0, 'success', $list); } diff --git a/app/model/Deduction.php b/app/model/Deduction.php index babf6e7..8b0d3f4 100644 --- a/app/model/Deduction.php +++ b/app/model/Deduction.php @@ -23,4 +23,8 @@ class Deduction extends Base { return $this->hasOne(CouponBill::class,"id","bill_id"); } + public function account() + { + return $this->hasOne(Account::class,"user_code","user_code"); + } } \ No newline at end of file diff --git a/app/repository/BusinessRepository.php b/app/repository/BusinessRepository.php index db75910..fe99e85 100644 --- a/app/repository/BusinessRepository.php +++ b/app/repository/BusinessRepository.php @@ -114,7 +114,7 @@ class BusinessRepository extends Repository public function businessDeductionList($where, int $page = 1, int $limit = 0, array $order = ["create_time" => "desc", "id" => "desc"]) { return Deduction::findList($where, [], $page, $limit, function ($q) { - return $q->with(["couponMain","bill"]); + return $q->with(["couponMain","bill","account"]); }, $order); } diff --git a/public/static/manager/js/bill.js b/public/static/manager/js/bill.js index 357ad71..1686032 100644 --- a/public/static/manager/js/bill.js +++ b/public/static/manager/js/bill.js @@ -11,7 +11,10 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"] //index页面 if ($('.location-index-page').length > 0) { miniTab.listen(); - + var exportDataTitle= + ["用户昵称","商家昵称","优惠券名称","持有比例(渠道商:平台:消费者)","金额","时间"] + ; + var exportData =[]; // 渲染表格 let listUrl = $('#table-container').data('url'); let insTb = table.render({ @@ -55,6 +58,19 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"] done: function (res, curr, count) { Tools.setInsTb(insTb); + var rdata=[]; + res.data.forEach(function (d,index) { + rdata[index] = [ + d.nick_name , + d.business_name , + d.coupon_main_name , + ("比例:"+d.commission_agency +":"+ d.commission_admin+ ":"+ d.commission_consumer + + "金额:" + d.agency_money+":" + d.admin_money + ":" + d.consumer_money) , + d.money, + d.create_time, + ] + }) + exportData=rdata } }); @@ -81,7 +97,11 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"] ,type: 'datetime' }); - + $("#exports").on("click",function(){ + //console.log(exportData) + table.exportFile(exportDataTitle,exportData, 'xls'); + return false; + }) } diff --git a/public/static/manager/js/business/business_deduction_list.js b/public/static/manager/js/business/business_deduction_list.js index 8ba3595..33bc024 100644 --- a/public/static/manager/js/business/business_deduction_list.js +++ b/public/static/manager/js/business/business_deduction_list.js @@ -39,6 +39,14 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function }, page: true, cols: [[ + + {templet : function (d) { + if(d.account!=undefined&& d.account){ + return d.account.nick_name; + } + return ''; + }, title: '消费者昵称'}, + {templet: '#row-cover', title: '消费者头像'}, {field: 'business_name', title: '商家名称'}, {field: 'create_time', title: '扣费时间'}, {field: 'money', title: '扣费金额'}, diff --git a/public/static/manager/js/coupon/index.js b/public/static/manager/js/coupon/index.js index 3270269..fe8537e 100644 --- a/public/static/manager/js/coupon/index.js +++ b/public/static/manager/js/coupon/index.js @@ -17,7 +17,9 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect','laydate'] let insTb = table.render({ elem: '#table-container', toolbar: '#toolbar-tpl', - defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 + defaultToolbar: [ + + { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 title: '搜索' , layEvent: 'search' , icon: 'layui-icon-search' @@ -56,6 +58,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect','laydate'] } return ''; }, title: '商家简称'}, + {field: 'agency_text', title: '渠道商名称'}, {field: 'money', title: '金额'}, {field: 'deduction_money', title: '扣费'}, {field: 'start_time', title: '开始时间'}, diff --git a/view/manager/bill/index.html b/view/manager/bill/index.html index 19465fc..f5506ed 100644 --- a/view/manager/bill/index.html +++ b/view/manager/bill/index.html @@ -152,6 +152,7 @@ @@ -159,7 +160,6 @@ \ No newline at end of file diff --git a/view/manager/business/business_deduction_list.html b/view/manager/business/business_deduction_list.html index 1bbe9bb..9a8f86e 100644 --- a/view/manager/business/business_deduction_list.html +++ b/view/manager/business/business_deduction_list.html @@ -64,9 +64,12 @@ diff --git a/view/manager/business/business_detail.html b/view/manager/business/business_detail.html index 05d6b6c..200c73d 100644 --- a/view/manager/business/business_detail.html +++ b/view/manager/business/business_detail.html @@ -6,7 +6,7 @@