From 5f0f32e5e9ba1fb63d012d3dba5094d3825ba93f Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 6 Mar 2023 18:14:45 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E9=87=91=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=B8=8E=E9=A1=B5=E9=9D=A2=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/Merchant.php | 27 ++ .../system/merchant/MerchantMargin.php | 66 +++- app/admin/route/merchant.php | 13 +- .../merchant/system/merchant/margin/edit.html | 134 +++++++ .../merchant/system/merchant/margin/list.html | 372 ++++++++++++++++++ .../merchant/system/merchant/margin/read.html | 108 +++++ .../system/merchant/margin/read_refund.html | 63 +++ .../merchant/system/merchant/type/add.html | 2 +- .../merchant/system/merchant/type/read.html | 2 +- .../system/merchant/FinancialRecord.php | 14 + .../merchant/system/merchant/Merchant.php | 32 ++ .../system/merchant/MerchantAdmin.php | 14 + .../system/merchant/MerchantApplyments.php | 14 + .../system/merchant/MerchantCategory.php | 14 + .../system/merchant/MerchantIntention.php | 14 + .../merchant/system/merchant/MerchantType.php | 1 - .../model/merchant/system/serve/ServeMeal.php | 14 + .../merchant/system/serve/ServeOrder.php | 102 +++++ app/common/model/merchant/user/User.php | 15 + 19 files changed, 994 insertions(+), 27 deletions(-) create mode 100644 app/admin/controller/merchant/system/merchant/Merchant.php create mode 100644 app/admin/view/merchant/system/merchant/margin/edit.html create mode 100644 app/admin/view/merchant/system/merchant/margin/list.html create mode 100644 app/admin/view/merchant/system/merchant/margin/read.html create mode 100644 app/admin/view/merchant/system/merchant/margin/read_refund.html create mode 100644 app/common/model/merchant/system/merchant/FinancialRecord.php create mode 100644 app/common/model/merchant/system/merchant/Merchant.php create mode 100644 app/common/model/merchant/system/merchant/MerchantAdmin.php create mode 100644 app/common/model/merchant/system/merchant/MerchantApplyments.php create mode 100644 app/common/model/merchant/system/merchant/MerchantCategory.php create mode 100644 app/common/model/merchant/system/merchant/MerchantIntention.php create mode 100644 app/common/model/merchant/system/serve/ServeMeal.php create mode 100644 app/common/model/merchant/system/serve/ServeOrder.php create mode 100644 app/common/model/merchant/user/User.php diff --git a/app/admin/controller/merchant/system/merchant/Merchant.php b/app/admin/controller/merchant/system/merchant/Merchant.php new file mode 100644 index 0000000..425274d --- /dev/null +++ b/app/admin/controller/merchant/system/merchant/Merchant.php @@ -0,0 +1,27 @@ +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']); } /** - * 显示创建资源表单页. - * - * @return \think\Response + * 获取保证金扣费记录 record */ - public function create() + public function getMarginLst() { - // + return View($this->path['read']); } + /** + * 设置扣减保证金表单 + */ + public function setMarginForm() + { + return View($this->path['edit']); + } + + /** + * 设置扣减保证金 + */ + public function setMargin() + { + echo 'fail'; + } + + /** * 保存新建的资源 * @@ -92,14 +126,4 @@ class MerchantMargin extends BaseController // } - /** - * 删除指定资源 - * - * @param int $id - * @return \think\Response - */ - public function delete($id) - { - // - } } diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index 1432f04..4d331a7 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -91,22 +91,29 @@ 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([ + Route::get('read', '/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([ diff --git a/app/admin/view/merchant/system/merchant/margin/edit.html b/app/admin/view/merchant/system/merchant/margin/edit.html new file mode 100644 index 0000000..5cc27c6 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/margin/edit.html @@ -0,0 +1,134 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

保证金扣费

+ + + + + + + + + + + + + + + + + + + + + + +
店铺类型名称* + +
店铺类型要求 + +
店铺保证金 + + + + + + + + + +
+
+ + +
+
+ + 单位:元
+
其它说明 + +
+ +
+ + +
+
+{/block} + + + +{block name="script"} + + + +{/block} + diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html new file mode 100644 index 0000000..3ef43ca --- /dev/null +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -0,0 +1,372 @@ +{extend name="common/base"/} + +{block name="body"} + + +
+ + + +
+ +
+
+ +
+ +
+
+ +
+
-
+
+ +
+
+
+ +
+
+ +
+ + +
+
+ +
+ +
+ +
+ + +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+ + +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+ + + + + +
+
    +
  • 缴存保证金
  • +
  • 退回保证金
  • +
+
+ + +
+ +
+
+ + +
+
+ +
+
+ +
+
+
+ + + + +
+ + + + + + + + + +{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/margin/read.html b/app/admin/view/merchant/system/merchant/margin/read.html new file mode 100644 index 0000000..fb1ffb1 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/margin/read.html @@ -0,0 +1,108 @@ +{extend name="common/base"/} + +{block name="body"} + +
+ +
+
    +
  • 扣费记录
  • +
+
+ + +
+ +
+
+
+
+ +
+ +{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/margin/read_refund.html b/app/admin/view/merchant/system/merchant/margin/read_refund.html new file mode 100644 index 0000000..6bb7943 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/margin/read_refund.html @@ -0,0 +1,63 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

查看店铺类型

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
店铺类型名称
店铺类型要求 + +
店铺保证金
店铺权限 + + +
其它说明 + +
创建时间 + {$detail.create_time} +
修改时间 + {$detail.update_time} +
+
+{/block} + \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/type/add.html b/app/admin/view/merchant/system/merchant/type/add.html index 25d57e3..e2ecbc6 100644 --- a/app/admin/view/merchant/system/merchant/type/add.html +++ b/app/admin/view/merchant/system/merchant/type/add.html @@ -20,7 +20,7 @@ 店铺类型名称* + autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}"> diff --git a/app/admin/view/merchant/system/merchant/type/read.html b/app/admin/view/merchant/system/merchant/type/read.html index 16d33e0..1145f28 100644 --- a/app/admin/view/merchant/system/merchant/type/read.html +++ b/app/admin/view/merchant/system/merchant/type/read.html @@ -7,7 +7,7 @@ {block name="body"}
-

文章详情

+

查看店铺类型

diff --git a/app/common/model/merchant/system/merchant/FinancialRecord.php b/app/common/model/merchant/system/merchant/FinancialRecord.php new file mode 100644 index 0000000..3059e9f --- /dev/null +++ b/app/common/model/merchant/system/merchant/FinancialRecord.php @@ -0,0 +1,14 @@ +hasOne(MerchantType::class, 'mer_type_id', 'type_id'); + } + + public function typeName() + { + return $this->merchantType()->bind(['type_name']); + } +} diff --git a/app/common/model/merchant/system/merchant/MerchantAdmin.php b/app/common/model/merchant/system/merchant/MerchantAdmin.php new file mode 100644 index 0000000..03ec84b --- /dev/null +++ b/app/common/model/merchant/system/merchant/MerchantAdmin.php @@ -0,0 +1,14 @@ +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; + } +} diff --git a/app/common/model/merchant/user/User.php b/app/common/model/merchant/user/User.php new file mode 100644 index 0000000..a0031f5 --- /dev/null +++ b/app/common/model/merchant/user/User.php @@ -0,0 +1,15 @@ + Date: Mon, 6 Mar 2023 18:22:20 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E9=87=91=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=B8=8E=E9=A1=B5=E9=9D=A2=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/merchant/system/Merchant.php | 26 ---------- app/common/model/merchant/system/Merchant.php | 51 ------------------- .../merchant/system/MerchantApplyments.php | 22 -------- .../system/merchant/MerchantMargin.php | 25 --------- 4 files changed, 124 deletions(-) delete mode 100644 app/admin/controller/merchant/system/Merchant.php delete mode 100644 app/common/model/merchant/system/Merchant.php delete mode 100644 app/common/model/merchant/system/MerchantApplyments.php delete mode 100644 app/common/model/merchant/system/merchant/MerchantMargin.php diff --git a/app/admin/controller/merchant/system/Merchant.php b/app/admin/controller/merchant/system/Merchant.php deleted file mode 100644 index 3b67d20..0000000 --- a/app/admin/controller/merchant/system/Merchant.php +++ /dev/null @@ -1,26 +0,0 @@ -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(){} - -} \ No newline at end of file diff --git a/app/common/model/merchant/system/MerchantApplyments.php b/app/common/model/merchant/system/MerchantApplyments.php deleted file mode 100644 index 620fcb8..0000000 --- a/app/common/model/merchant/system/MerchantApplyments.php +++ /dev/null @@ -1,22 +0,0 @@ -select(); - - return $list; - } -} diff --git a/app/common/model/merchant/system/merchant/MerchantMargin.php b/app/common/model/merchant/system/merchant/MerchantMargin.php deleted file mode 100644 index 3860102..0000000 --- a/app/common/model/merchant/system/merchant/MerchantMargin.php +++ /dev/null @@ -1,25 +0,0 @@ - Date: Tue, 7 Mar 2023 00:57:26 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E7=AD=9B=E9=80=89bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/margin/list.html | 97 ++++++++++++++++--- 1 file changed, 82 insertions(+), 15 deletions(-) diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html index 3ef43ca..4dab01b 100644 --- a/app/admin/view/merchant/system/merchant/margin/list.html +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -100,6 +100,7 @@
+
+ +
+
    +
  • +
  • +
+
+
内容1
+
内容2
+
+
+
@@ -124,8 +137,8 @@
    -
  • 缴存保证金
  • -
  • 退回保证金
  • +
  • 缴存保证金
  • +
  • 退回保证金
@@ -299,7 +312,7 @@ fixed: 'right', field: 'right', title: '操作', - toolbar: '#barDemo', + toolbar: '#refundBar', width: 190, align: 'center' } @@ -343,29 +356,83 @@ }); //监听搜索提交 - // form.on('submit(searchform)', function(data) { - // layui.pageTable.reload({ - // where: { - // keywords: data.field.keywords - // }, - // page: { - // curr: 1 - // } - // }); - // 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 () { + 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; + // } + // }); + + + + + } {/block} From fbfc1785abee5e2af66673684dca6aaec54ee4a0 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Tue, 7 Mar 2023 18:37:32 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=95=86=E6=88=B7=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E4=B8=8E=E4=BF=9D=E8=AF=81=E9=87=91bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.debug | 24 +- .../{ => merchant}/MerchantApplyments.php | 4 +- .../system/merchant/MerchantIntention.php | 158 ++++++++ .../system/merchant/MerchantMargin.php | 73 +++- .../merchant/system/merchant/MerchantType.php | 1 - app/admin/route/merchant.php | 47 ++- .../system/merchant/intention/lst.html | 283 ++++++++++++++ .../system/merchant/intention/mark.html | 57 +++ .../merchant/system/merchant/margin/edit.html | 98 ++--- .../merchant/system/merchant/margin/list.html | 11 +- .../merchant/system/merchant/margin/read.html | 76 ++-- .../merchant/system/merchant/Merchant.php | 50 +++ .../system/merchant/MerchantCategory.php | 3 +- .../system/merchant/MerchantIntention.php | 99 ++++- .../merchant/system/serve/ServeOrder.php | 48 ++- .../model/merchant/user/UserAddress.php | 14 + app/common/model/merchant/user/UserBill.php | 370 ++++++++++++++++++ .../model/merchant/user/UserHistory.php | 14 + app/common/model/merchant/user/UserLabel.php | 14 + .../model/merchant/user/UserMerchant.php | 14 + app/common/model/merchant/user/UserOrder.php | 14 + .../model/merchant/user/UserRecharge.php | 14 + 22 files changed, 1337 insertions(+), 149 deletions(-) rename app/admin/controller/merchant/system/{ => merchant}/MerchantApplyments.php (92%) create mode 100644 app/admin/controller/merchant/system/merchant/MerchantIntention.php create mode 100644 app/admin/view/merchant/system/merchant/intention/lst.html create mode 100644 app/admin/view/merchant/system/merchant/intention/mark.html create mode 100644 app/common/model/merchant/user/UserAddress.php create mode 100644 app/common/model/merchant/user/UserBill.php create mode 100644 app/common/model/merchant/user/UserHistory.php create mode 100644 app/common/model/merchant/user/UserLabel.php create mode 100644 app/common/model/merchant/user/UserMerchant.php create mode 100644 app/common/model/merchant/user/UserOrder.php create mode 100644 app/common/model/merchant/user/UserRecharge.php diff --git a/.env.debug b/.env.debug index 946d744..edce43b 100644 --- a/.env.debug +++ b/.env.debug @@ -4,4 +4,26 @@ APP_DEBUG = true DEFAULT_TIMEZONE = Asia/Shanghai [LANG] -default_lang = zh-cn \ No newline at end of file +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 \ No newline at end of file diff --git a/app/admin/controller/merchant/system/MerchantApplyments.php b/app/admin/controller/merchant/system/merchant/MerchantApplyments.php similarity index 92% rename from app/admin/controller/merchant/system/MerchantApplyments.php rename to app/admin/controller/merchant/system/merchant/MerchantApplyments.php index ba78965..4ee0d93 100644 --- a/app/admin/controller/merchant/system/MerchantApplyments.php +++ b/app/admin/controller/merchant/system/merchant/MerchantApplyments.php @@ -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 { diff --git a/app/admin/controller/merchant/system/merchant/MerchantIntention.php b/app/admin/controller/merchant/system/merchant/MerchantIntention.php new file mode 100644 index 0000000..66f14dd --- /dev/null +++ b/app/admin/controller/merchant/system/merchant/MerchantIntention.php @@ -0,0 +1,158 @@ +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) + { + // + + } +} diff --git a/app/admin/controller/merchant/system/merchant/MerchantMargin.php b/app/admin/controller/merchant/system/merchant/MerchantMargin.php index 1e1a444..1502840 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantMargin.php +++ b/app/admin/controller/merchant/system/merchant/MerchantMargin.php @@ -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) - { - // - } + /** * 显示编辑资源表单页. diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 1a3dff9..c0239c9 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -7,7 +7,6 @@ * @email:q8197264@126.com * @date :2023年03月3日 */ - declare(strict_types=1); namespace app\admin\controller\merchant\system\merchant; diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index 4d331a7..9a13da9 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -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([ diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html new file mode 100644 index 0000000..25f3cc8 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -0,0 +1,283 @@ +{extend name="common/base"/} + +{block name="body"} + + +
+ + + +
+ +
+
+ +
+ +
+
+ +
+
-
+
+ +
+
+
+ +
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ + + +
+ +
+ + +
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+
+
+ +
+ +
店铺类型名称
+
+
+ + + + + + + + + + +{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/intention/mark.html b/app/admin/view/merchant/system/merchant/intention/mark.html new file mode 100644 index 0000000..960b7dc --- /dev/null +++ b/app/admin/view/merchant/system/merchant/intention/mark.html @@ -0,0 +1,57 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

备注

+ + + + +
+ + +
+
+ + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/margin/edit.html b/app/admin/view/merchant/system/merchant/margin/edit.html index 5cc27c6..dc722a9 100644 --- a/app/admin/view/merchant/system/merchant/margin/edit.html +++ b/app/admin/view/merchant/system/merchant/margin/edit.html @@ -17,54 +17,50 @@ - + - + - - + + + + + + + + - +
店铺类型名称*商户名称* - + +
店铺类型要求商户ID - +
店铺保证金 - - - - - - - - - -
-
- - -
-
- - 单位:元
+
商户剩余保证金 + + 单位:元
保证金扣除金额* + + 单位:元
其它说明保证金扣除原因* - +
- +
@@ -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; }); - } diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html index 3ef43ca..35d77a9 100644 --- a/app/admin/view/merchant/system/merchant/margin/list.html +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -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: '
{{d.merchant.mer_name}}
' @@ -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({ diff --git a/app/admin/view/merchant/system/merchant/margin/read.html b/app/admin/view/merchant/system/merchant/margin/read.html index fb1ffb1..1192e1c 100644 --- a/app/admin/view/merchant/system/merchant/margin/read.html +++ b/app/admin/view/merchant/system/merchant/margin/read.html @@ -25,6 +25,18 @@ {block name="script"} {/block} diff --git a/app/common/model/merchant/system/merchant/Merchant.php b/app/common/model/merchant/system/merchant/Merchant.php index 309ef66..11d6f3e 100644 --- a/app/common/model/merchant/system/merchant/Merchant.php +++ b/app/common/model/merchant/system/merchant/Merchant.php @@ -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; + } } diff --git a/app/common/model/merchant/system/merchant/MerchantCategory.php b/app/common/model/merchant/system/merchant/MerchantCategory.php index 102cace..aece970 100644 --- a/app/common/model/merchant/system/merchant/MerchantCategory.php +++ b/app/common/model/merchant/system/merchant/MerchantCategory.php @@ -10,5 +10,6 @@ use think\Model; */ class MerchantCategory extends Model { - // + protected $connection = 'shop'; + protected $table = 'eb_merchant_category'; } diff --git a/app/common/model/merchant/system/merchant/MerchantIntention.php b/app/common/model/merchant/system/merchant/MerchantIntention.php index 061af84..aaba01c 100644 --- a/app/common/model/merchant/system/merchant/MerchantIntention.php +++ b/app/common/model/merchant/system/merchant/MerchantIntention.php @@ -1,8 +1,16 @@ 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; + } } diff --git a/app/common/model/merchant/system/serve/ServeOrder.php b/app/common/model/merchant/system/serve/ServeOrder.php index e027f14..c9818b0 100644 --- a/app/common/model/merchant/system/serve/ServeOrder.php +++ b/app/common/model/merchant/system/serve/ServeOrder.php @@ -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']); diff --git a/app/common/model/merchant/user/UserAddress.php b/app/common/model/merchant/user/UserAddress.php new file mode 100644 index 0000000..29e8d6b --- /dev/null +++ b/app/common/model/merchant/user/UserAddress.php @@ -0,0 +1,14 @@ + '佣金转入余额', + '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); + } +} diff --git a/app/common/model/merchant/user/UserHistory.php b/app/common/model/merchant/user/UserHistory.php new file mode 100644 index 0000000..6a56744 --- /dev/null +++ b/app/common/model/merchant/user/UserHistory.php @@ -0,0 +1,14 @@ +