From 5f0f32e5e9ba1fb63d012d3dba5094d3825ba93f Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 6 Mar 2023 18:14:45 +0800 Subject: [PATCH 01/38] =?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 02/38] =?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 03/38] =?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 04/38] =?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 @@ + Date: Wed, 8 Mar 2023 00:54:42 +0800 Subject: [PATCH 05/38] =?UTF-8?q?=E4=BF=9D=E8=AF=81=E9=87=91=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/margin/list.html | 269 +++++++++++------- 1 file changed, 162 insertions(+), 107 deletions(-) diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html index a187ae9..a905bcf 100644 --- a/app/admin/view/merchant/system/merchant/margin/list.html +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -13,7 +13,22 @@
- + +
+
+ + + + + + + +
+
+
+ +
+
-
-
- -
- - -
-
- -
-
+
+
+ +
+ + +
+
+
- + + + + +
+
+
+ +
+ +
+ +
+
+ +
+ + - - - - - - - -
-
-
- -
+ +
+
- @@ -113,20 +126,48 @@
-
-
    -
  • -
  • -
-
-
内容1
-
内容2
+
+
+
+ + + +
@@ -164,7 +205,7 @@
- + - + {/block} \ No newline at end of file From 3b30467251f493a6c80f96b7e4f52f9953b7ae48 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Wed, 8 Mar 2023 10:33:57 +0800 Subject: [PATCH 06/38] =?UTF-8?q?=E5=88=A0=E9=99=A4=C2=A0=20public/.htacce?= =?UTF-8?q?ss=20public/nginx.htaccess=20git=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ public/.htaccess | 8 ------- public/nginx.htaccess | 51 ------------------------------------------- 3 files changed, 2 insertions(+), 59 deletions(-) delete mode 100644 public/.htaccess delete mode 100644 public/nginx.htaccess diff --git a/.gitignore b/.gitignore index 9be8bf4..dac9a40 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ /public/static/home/dev /public/static/home/oa /config/database.php +/public/.htaccess +/public/nginx.htaccess diff --git a/public/.htaccess b/public/.htaccess deleted file mode 100644 index cbc7868..0000000 --- a/public/.htaccess +++ /dev/null @@ -1,8 +0,0 @@ - - Options +FollowSymlinks -Multiviews - RewriteEngine On - - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] - diff --git a/public/nginx.htaccess b/public/nginx.htaccess deleted file mode 100644 index a9942c4..0000000 --- a/public/nginx.htaccess +++ /dev/null @@ -1,51 +0,0 @@ -#ļΪNginxα̬ļ PHPCUSTOMٷַhttp://www.phpcustom.com http://www.lccee.com - - - - - -# 301תãԶ޸Ϊ - if ($Host = 'xxx.com'){ - rewrite ^/(.*)$ http://www.phpcustom.com/$1 permanent; - } - - - - - - -#Ϊphpwind9.0α̬,ȥ#Ч -#------------------------------------------------------------------------------------------------ - -# if (-f $request_filename) { -# break; -# } -# if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") { -# break; -# } -# if (!-e $request_filename) { -# rewrite . /index.php last; -# } - - - - - -# ThinkPHP V5α̬ʾ ȥ´ǰߵ#żЧ - -#------------------------------------------------------------------------------------------------ -#if (!-e $request_filename) { -# rewrite ^(.*)$ /index.php?s=/$1 last; -# break; -# } - -#------------------------------------------------------------------------------------------------ - - - - - - - - - From 2f7e5c4602be036ca0de80722f0e9193dfcdf3a2 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Fri, 10 Mar 2023 01:47:57 +0800 Subject: [PATCH 07/38] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/margin/list.html | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html index a905bcf..c7c5acf 100644 --- a/app/admin/view/merchant/system/merchant/margin/list.html +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -9,20 +9,20 @@
-
+
- - - - - - - + + + + + + +
@@ -31,12 +31,12 @@
-
-
-
@@ -398,13 +398,25 @@ return false; }); + // 获取表单所有参数 + function getformdata() { + var form = $('#filterform').serializeArray(); + var data = new Array(); + for(let i=0;i {/block} \ No newline at end of file From c4935e1f1c9b0f6728a8099942b7e8c3ed04de2b Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Fri, 10 Mar 2023 16:18:11 +0800 Subject: [PATCH 08/38] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.debug | 38 ++- .gitignore | 1 + .../merchant/system/merchant/Merchant.php | 5 +- app/admin/controller/product/Parameter.php | 252 ++++++++++++++++++ app/admin/controller/product/Product.php | 166 ++++++++++-- app/admin/model/EbStoreProduct.php | 186 +++++++++++-- app/admin/model/StoreCategory.php | 45 ++++ app/admin/model/store/paramter/Parameter.php | 59 ++++ .../store/paramter/ParameterTemplate.php | 129 +++++++++ .../model/store/paramter/ParameterValue.php | 35 +++ app/admin/route/menu.php | 17 +- app/admin/route/product.php | 176 ++++++++++++ .../merchant/system/merchant/margin/list.html | 48 +++- app/admin/view/product/parameter/add.html | 178 +++++++++++++ app/admin/view/product/parameter/edit.html | 165 ++++++++++++ app/admin/view/product/parameter/index.html | 195 ++++++++++++++ app/admin/view/product/product/index.html | 211 +++++++++++++-- app/common/controller/FormatList.php | 9 +- .../model/merchant/system/Relevance.php | 104 ++++++++ 19 files changed, 1922 insertions(+), 97 deletions(-) create mode 100644 app/admin/controller/product/Parameter.php create mode 100644 app/admin/model/store/paramter/Parameter.php create mode 100644 app/admin/model/store/paramter/ParameterTemplate.php create mode 100644 app/admin/model/store/paramter/ParameterValue.php create mode 100644 app/admin/route/product.php create mode 100644 app/admin/view/product/parameter/add.html create mode 100644 app/admin/view/product/parameter/edit.html create mode 100644 app/admin/view/product/parameter/index.html create mode 100644 app/common/model/merchant/system/Relevance.php diff --git a/.env.debug b/.env.debug index edce43b..bb4e9b9 100644 --- a/.env.debug +++ b/.env.debug @@ -8,11 +8,32 @@ default_lang = zh-cn [DATABASE] TYPE = mysql -HOSTNAME = 192.168.0.106 +HOSTNAME = 47.92.112.123 DATABASE = nk_lihaink_cn PREFIX = cms_ -USERNAME = root -PASSWORD = 123321a +USERNAME = nk_lihaink_cn +PASSWORD = 5MnmkZTW2tmahha7 +HOSTPORT = 3306 +CHARSET = utf8mb4 +DEBUG = true + +TYPE = mysql +HOSTNAME = 47.92.112.123 +DATABASE = nk_lihaink_cn +PREFIX = cms_ +USERNAME = view_oa_lihaink_cn +PASSWORD = 5MnmkZTW2tmahha7 +HOSTPORT = 3306 +CHARSET = utf8mb4 +DEBUG = true + +[DATABASE] +TYPE = mysql +HOSTNAME = 47.92.112.123 +DATABASE = nk_lihaink_cn +PREFIX = cms_ +USERNAME = view_oa_lihaink_cn +PASSWORD = 5MnmkZTW2tmahha7 HOSTPORT = 3306 CHARSET = utf8mb4 DEBUG = true @@ -26,4 +47,15 @@ PASSWORD = EeYym2PFctFfrMde DATABASE = shop_lihaink_com PREFIX = eb_ CHARSET = utf8 +DEBUG = true + +[DATABASESHOP] +TYPE = mysql +HOSTNAME = 122.9.139.134 +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/.gitignore b/.gitignore index dac9a40..d1f9879 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.gitee *.log *.env +*.env.debug *.lock *.ini .htaccess diff --git a/app/admin/controller/merchant/system/merchant/Merchant.php b/app/admin/controller/merchant/system/merchant/Merchant.php index 425274d..66c8241 100644 --- a/app/admin/controller/merchant/system/merchant/Merchant.php +++ b/app/admin/controller/merchant/system/merchant/Merchant.php @@ -1,7 +1,10 @@ adminInfo = get_login_admin(); + $this->temp = $temp; + $this->url=[ + '/admin/product/params/index', + '/admin/product/params/add', + '/admin/product/params/edit', + '/admin/product/params/del', + ]; + } + + + /** + * 非超级管理员登入 需更新当前用户所属地区 + * @param array $where 地区id数组 + * @return array $where 更改后的地区id数组 + */ + protected function auth(array $where):array + { + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + return $where; + } + + /** + * 商品参数列表 + * @ + */ + public function index(StoreCategory $category) + { + if (request()->isAjax()) { + // Ajax 获取列表数据 + + $params= get_params(); + + // 构建查询条件 + $where = []; + if (isset($params['keywords']) && !empty($params['keywords'])){ + $where[]= ['name','like','%'.$params['keywords'].'%']; + } + $where = $this->auth($where); + + // 获取列表数据 + $page = empty($params['page'])? 1 : (int)$params['page']; + $limit = empty($params['limit'])? (int)get_config('app . page_size') : (int)$params['limit']; + + $where['template_name'] = empty($params['template_name'])?'':$params['template_name']; + $where['cate_id'] = empty($params['cate_id'])?'':$params['cate_id']; + $where['mer_name'] = empty($params['mer_name'])?'':$params['mer_name']; + $where['mer_id'] = empty($params['mer_id'])?'':$params['mer_id']; + + if (isset($params['is_mer'])) { + $merId = $params['mer_id']; + $where['mer_id'] = $merId; + unset($where['is_mer']); + } + $data = $this->temp->getList($where,$page, $limit); + $data['list'] = [[ + 'template_id'=>1, + 'template_name'=>'测试', + 'cateid'=>'', + 'sort'=>'1', + 'create_time'=> '2023-03-09 17:13:22', + ]]; + + return to_assign(0, '', $data); + }else{ + // 初始空页面展示 + $where['mer_id'] = 0; + $where['is_show'] = 0; + $cate_list = $category->getList($where); + $cate_list = FormatList::DropDownMenu($cate_list); + + View::assign('url', $this->url); + View::assign('cate_list', $cate_list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + // $res = StoreBrandCategory::create($data); + + // if ($res){ + // return to_assign(0,'操作成功',['aid'=>$res]); + // } + + // return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + return view(); + } + } + + /** + * + * 编辑 + * + */ + public function edit() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + if (request()->isAjax()) { + + $params = get_params(); + + $data['cate_name'] = $params['cate_name']; // 分类名称 + $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 + $data['pid'] = $params['pid']; // 上级分类 + $data['sort'] = $params['sort']; // 排序 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data); + + if ($res){ + return to_assign(0,'更新成功',['aid'=>$res]); + } + + return to_assign(1, '更新失败,原因:'.$res); + + }else{ + + $storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息 + + View::assign('detail', $storeBrandCtegory); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + // 验证下面是否有子分类 + if(StoreBrandCategory::where('pid', $id)->count()) + { + return to_assign(1, '请先删除子分类!'); + } + + $res = StoreBrandCategory::where('store_brand_category_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + + /** + * + * 子分类 + * + */ + public function street($pcode) + { + $storeBrandCategory = StoreBrandCategory::order('sort desc') + ->where('is_show', 1) + ->where('pid', $pcode) + ->select(); + + return json($storeBrandCategory); + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Product.php b/app/admin/controller/product/Product.php index 0d3466a..f2e4479 100644 --- a/app/admin/controller/product/Product.php +++ b/app/admin/controller/product/Product.php @@ -11,12 +11,14 @@ use think\facade\Db; use think\facade\View; use app\admin\model\Merchant; // 商户模型 use app\admin\model\EbStoreProduct; // 商品模型 +use app\admin\model\StoreCategory; // 商品分类模型 use app\admin\model\GeoCity; // 省市模型 use app\admin\model\GeoArea; // 区域模型 use app\admin\model\GeoStreet; // 街道模型 use app\admin\model\SupplyChain; // 供应链模型 use app\api\model\Area as AreaModel; // 市场区域模型 use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型 +use app\common\controller\FormatList; /** * @@ -25,12 +27,17 @@ use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型 */ class Product extends BaseController { - public function __construct() + + protected $adminInfo; + protected $url; + protected $product; + + public function __construct(EbStoreProduct $product) { $this->adminInfo = get_login_admin(); - $this->category_id=354; + $this->product = $product; $this->url=[ - '/admin/product.product/index?category_id='.$this->category_id, + '/admin/product.product/index', '/admin/product.product/add', '/admin/product.product/edit', '/admin/product.product/delete', @@ -38,42 +45,86 @@ class Product extends BaseController ]; } + protected function auth() + { + $where = []; + if($this->adminInfo['position_id'] != 1){ //不是超级管理员 + $www['admin_id'] = $this->adminInfo['id']; + $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); + if ($user_address){ + if($user_address['auth_range'] == 1){ + $where[] = ['village_id','=',$user_address['village_id']]; + }elseif ($user_address['auth_range'] == 2){ + $where[] = ['street_id','=',$user_address['street_id']]; + }elseif ($user_address['auth_range'] == 3){ + $where[] = ['area_id','=',$user_address['area_id']]; + }else{ + $where[] = ['village_id','=',$user_address['village_id']]; + } + }else{ + $where[] = ['village_id','=','']; + } + } + + return $where; + } + /** * * 供应链团队列表 * */ - public function index() + public function index(StoreCategory $category) { - if (request()->isAjax()) { - + if (true) { + // request()->isAjax() + // Ajax 前端获取数据 $params= get_params(); - $where = []; + $where = self::auth(); if (isset($params['keywords']) && !empty($params['keywords'])){ - $where[]= ['name','like','%'.$params['keywords'].'%']; - } - if($this->adminInfo['position_id'] != 1){ //不是超级管理员 - $www['admin_id'] = $this->adminInfo['id']; - $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); - if ($user_address){ - if($user_address['auth_range'] == 1){ - $where[] = ['village_id','=',$user_address['village_id']]; - }elseif ($user_address['auth_range'] == 2){ - $where[] = ['street_id','=',$user_address['street_id']]; - }elseif ($user_address['auth_range'] == 3){ - $where[] = ['area_id','=',$user_address['area_id']]; - }else{ - $where[] = ['village_id','=',$user_address['village_id']]; - } - }else{ - $where[] = ['village_id','=','']; - } + // $where[]= ['sotre_name','like','%'.$params['keywords'].'%']; + $where['keywords'] = $where['store_name'] = $params['keywords']; } + $page = empty($params['page'])?1:$params['page']; + $limit = empty($params['limit'])?10:$params['limit']; + + // 平台商品分类id + $where['cate_id'] = empty($params['plate_cate'])?'':$params['plate_cate']; + + // 商户商品分类id + $where['mer_cate_id'] = empty($params['store_cate'])?'':$params['store_cate']; + $where['is_trader'] = isset($params['is_trader'])?$params['is_trader']:0; // 是否自营 1自营, 0 不是自营 + + // product + $where['is_gift_bag'] = empty($params['is_gift'])?'':$params['is_gift']; + $where['is_show'] = empty($params['state'])?'':$params['state']; + $where['temp_id'] = empty($params['shipping_tem'])?'':$params['shipping_tem']; + $where['labels'] = empty($params['tag'])?'':$params['tag']; + $where['type'] = 1;//实体商品:0 虚拟商品:1 + $where['status'] = 0;//管理、审核、通过 + + + // $where['is_ficti'] = 1;//是否虚拟销量 + // $where['product_id'] = 0; + // ['order','sort'] + // soft //软删除 + if (!empty(get_params('mer_id'))) { + $mer_id = get_params('mer_id'); + $where = array_merge($where, $this->switchType($where['type'],$mer_id,0)); + } + $mer_id = 77; + + $this->product->getList($mer_id, $where, $page, $limit); + + return; + $total = EbStoreProduct::where($where)->count(); + + $list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select(); View::assign('url', $this->url); @@ -87,12 +138,77 @@ class Product extends BaseController $list = SupplyChain::with(['merchant' => ['merchantType', 'category']])->select(); + // 初始空页面展示 + $where['mer_id'] = 0; + $where['is_show'] = 0; + $cate_list = $category->getList($where); + $cate_list = FormatList::DropDownMenu($cate_list); + + View::assign('cate_list', $cate_list); View::assign('url', $this->url); View::assign('list', $list); return view(); } } + /** + * 与类型相对应的sql字段 + * + * @Author:Liuxiaoquan + * @Date: 2020/5/18 + * @param $type 商 + * @param int|null $merId 商户id + * @param int|null $productType 产品类型 + * @return array $where 条件 + */ + public function switchType($type, ?int $merId = 0, $productType = 0) + { + $stock = 0; + // 获得库存 + // if ($merId) $stock = merchantConfig($merId, 'mer_store_stock'); + switch ($type) { + case 1: + $where = ['is_show' => 1, 'status' => 1,]; + break; + case 2: + $where = ['is_show' => 0, 'status' => 1]; + break; + case 3: + $where = ['is_show' => 1, 'stock' => 0, 'status' => 1]; + break; + case 4: + $where = ['stock' => $stock ? $stock : 0, 'status' => 1]; + break; + case 5: + $where = ['soft' => true]; + break; + case 6: + $where = ['status' => 0]; + break; + case 7: + $where = ['status' => -1]; + break; + case 20: + $where = ['status' => 1]; + break; + default: + // $where = ['is_show' => 1, 'status' => 1]; + break; + } + if ($productType == 0) { + $where['product_type'] = $productType; + if (!$merId) $where['is_gift_bag'] = 0; + } + if ($productType == 1) { + $where['product_type'] = $productType; + } + if ($productType == 10) { + $where['is_gift_bag'] = 1; + } + if (!$merId) $where['star'] = ''; + return $where; + } + /** * * 新增 diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php index b5a873b..67c889a 100644 --- a/app/admin/model/EbStoreProduct.php +++ b/app/admin/model/EbStoreProduct.php @@ -1,4 +1,5 @@ hasOne(Merchant::class, 'mer_id', 'mer_id'); +use think\Model; +use StoreCategory as StoreCategoryModel; + +class EbStoreProduct extends Model +{ + // 设置当前模型的数据库连接 + protected $connection = 'shop'; + + // 设置当前模型对应的完整数据表名称 + protected $table = 'eb_store_product'; + protected $pk = 'product_id'; + + protected $filed = 'Product.product_id,Product.mer_id,brand_id,unit_name,spec_type,mer_status,rate,reply_count,store_info,cate_id,Product.image,slider_image,Product.store_name,Product.keyword,Product.sort,Product.is_show,Product.sales,Product.price,extension_type,refusal,cost,ot_price,stock,is_gift_bag,Product.care_count,Product.status,is_used,Product.create_time,Product.product_type,old_product_id,integral_total,integral_price_total,mer_labels,Product.is_good,Product.is_del,type,param_temp_id'; + + /** + * + * 关联商户 + * + */ + public function merchant() + { + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + + + + + /** + * TODO 商户商品列表 + * @Author:Qinii + * @Date: 2020/5/11 + * @param int $merId + * @param array $where + * @param int $page + * @param int $limit + * @return array + */ + public function getList(?int $mer_id, array $where, int $page, int $limit) + { + $query = self::search($mer_id, $where); + // ->with(['merCateId.category', 'storeCategory', 'brand']); + $count = $query->count(); + $data = $query->field($this->filed)->page($page, $limit)->select(); + + // $data->append(['us_status']); + + // $list = hasMany( + // $data, + // 'mer_labels', + // ProductLabel::class, + // 'product_label_id', + // 'mer_labels', + // ['status' => 1], + // 'product_label_id,product_label_id id,label_name name' + // ); + + return compact('count', 'list'); + } + + + // public function StoreSpu() + // {} + + + /** + * @Author:Qinii + * @Date: 2020/5/11 + * @param int $merId + * @param array $where + * @return mixed + */ + protected function search(?int $merId, array $where) + { + $keyArray = $whereArr = []; + unset($where['type']); + + // 以下字段为要搜索的字段 + $out = ['soft', 'us_status', 'mer_labels', 'sys_labels', 'order', 'hot_type']; + foreach ($where as $key => $item) { + if ($item !== '' && !in_array($key, $out)) { + $keyArray[] = $key; + $whereArr[$key] = $item; + } } - } \ No newline at end of file + // $query = isset($where['soft']) ? model::onlyTrashed()->alias('Product') : model::alias('Product'); + + $query = self::alias('Product'); + if (isset($where['is_trader']) && $where['is_trader'] !== '') { + $query->hasWhere('merchant', function ($query) use ($where) { + $query->where('is_trader', $where['is_trader']); + }); + } + + $query->withSearch($keyArray, $whereArr) + ->Join('StoreSpu U', 'Product.product_id = U.product_id')->where('U.product_type', $where['product_type'] ?? 0) + ->when(($merId !== null), function ($query) use ($merId) { + $query->where('Product.mer_id', $merId); + }) + ->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) { + if ($where['hot_type'] == 'new') + $query->where('is_new', 1); + else if ($where['hot_type'] == 'hot') + $query->where('is_hot', 1); + else if ($where['hot_type'] == 'best') + $query->where('is_best', 1); + else if ($where['hot_type'] == 'good') + $query->where('is_benefit', 1); + }); + + $query->when( + isset($where['pid']) && $where['pid'] !== '', + function ($query) use ($where) { + $ids = array_merge(self::findChildrenId((int)$where['pid']), [(int)$where['pid']]); + if (count($ids)) $query->whereIn('cate_id', $ids); + } + ) + ->when(isset($where['us_status']) && $where['us_status'] !== '', function ($query) use ($where) { + if ($where['us_status'] == 0) { + $query->where('Product.is_show', 0)->where('Product.is_used', 1)->where('Product.status', 1); + } + if ($where['us_status'] == 1) { + $query->where('Product.is_show', 1)->where('Product.is_used', 1)->where('Product.status', 1); + } + if ($where['us_status'] == -1) { + $query->where(function ($query) { + $query->where('Product.is_used', 0)->whereOr('Product.status', '<>', 1); + }); + } + }) + ->when(isset($where['mer_labels']) && $where['mer_labels'] !== '', function ($query) use ($where) { + $query->whereLike('U.mer_labels', "%,{$where['mer_labels']},%"); + }) + ->when(isset($where['sys_labels']) && $where['sys_labels'] !== '', function ($query) use ($where) { + $query->whereLike('U.sys_labels', "%,{$where['sys_labels']},%"); + }) + ->when(isset($where['order']), function ($query) use ($where, $merId) { + if (in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])) { + if ($where['order'] == 'price_asc') { + $where['order'] = 'price ASC'; + } else if ($where['order'] == 'price_desc') { + $where['order'] = 'price DESC'; + } else { + $where['order'] = $where['order'] . ' DESC'; + } + $query->order($where['order'] . ',rank DESC ,create_time DESC '); + } else if ($where['order'] !== '') { + $query->order('U.' . $where['order'] . ' DESC,U.create_time DESC'); + } else { + $query->order('U.create_time DESC'); + } + }) + ->when(isset($where['star']), function ($query) use ($where) { + $query->when($where['star'] !== '', function ($query) use ($where) { + $query->where('U.star', $where['star']); + }); + $query->order('U.star DESC,U.rank DESC,Product.create_time DESC'); + }); + return $query; + } + + public function findChildrenId($id) + { + return StoreCategoryModel::whereLike('path', '%/'. $id . '/%')->column('store_category_id'); + } +} diff --git a/app/admin/model/StoreCategory.php b/app/admin/model/StoreCategory.php index 44807b6..dcb7979 100644 --- a/app/admin/model/StoreCategory.php +++ b/app/admin/model/StoreCategory.php @@ -27,4 +27,49 @@ return $this->hasOne(StoreCategory::class, 'store_category_id', 'pid'); } + /** + * 获取商品分类表数据 + *@author Liuxiaoquan + * + *@param array $where 查询条件 + *@return object|array $list 查询商品分类结果集 + */ + public function getList($where) + { + $where['is_show'] = empty($where['is_show'])? 1 : $where['is_show']; + $list = self::search($where) + ->field('store_category_id as id,pid,cate_name,path,sort,pic,level,is_hot') + ->order('sort DESC')->select(); + + return $list; + } + + /** + * 查询语句构建 + *@author Liuxiaoquan + * + *@param array $where 查询条件 + *@return Query + */ + protected function search($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['level'])&&$where['level']!=='', + function($query)use($where){ + $query->where('level', $where['level']); + } + ) + ->when(isset($where['is_show'])&&$where['is_show']!=='', + function($query)use($where){ + $query->where('is_show', $where['is_show']); + } + ); + + return $query; + } + } \ No newline at end of file diff --git a/app/admin/model/store/paramter/Parameter.php b/app/admin/model/store/paramter/Parameter.php new file mode 100644 index 0000000..c290a29 --- /dev/null +++ b/app/admin/model/store/paramter/Parameter.php @@ -0,0 +1,59 @@ + +// +---------------------------------------------------------------------- + +namespace app\admin\model\store\paramter; + +use think\Model; + +class Parameter extends Model +{ + protected $connection = 'shop'; + protected $pk = 'parameter_id'; + + + // public static function tablePk(): string + // { + // return 'parameter_id'; + // } + + // public static function tableName(): string + // { + // return 'parameter'; + // } + + public function searchTemplateIdAttr($query, $value) + { + $query->where('template_id',$value); + } + + /** + * TODO 搜索 + * @param $where + */ + public function getSearch(array $where) + { + foreach ($where as $key => $item) { + if ($item !== '') { + $keyArray[] = $key; + $whereArr[$key] = $item; + } + } + // var_dump($where); + $class = get_called_class(); + if(empty($keyArray)){ + return $class::self(); + }else{ + return $class::withSearch($keyArray, $whereArr); + } + } + +} diff --git a/app/admin/model/store/paramter/ParameterTemplate.php b/app/admin/model/store/paramter/ParameterTemplate.php new file mode 100644 index 0000000..0d16e07 --- /dev/null +++ b/app/admin/model/store/paramter/ParameterTemplate.php @@ -0,0 +1,129 @@ +hasOne(Merchant::class,'mer_id','mer_id'); + } + + public function parameter() + { + return $this->hasMany(Parameter::class,'template_id','template_id'); + } + + public function cateId() + { + return $this->hasMany(Relevance::class,'left_id','template_id')->where('type', 'product_params_cate'); + } + + public function searchCateIdAttr($query, $value) + { + $id = Relevance::where('right_id',$value)->where('type', 'product_params_cate')->column('left_id'); + $query->where('template_id','in',$id); + } + + public function searchTemplateNameAttr($query, $value) + { + $query->whereLike('template_name',"%{$value}%"); + } + + public function searchTemplateIdsAttr($query, $value) + { + $query->whereIn('template_id',$value); + } + + public function searchMerIdAttr($query, $value) + { + $query->where('mer_id',$value); + } + + public function searchMerNameAttr($query, $value) + { + $value = Merchant::whereLike('mer_name',"%{$value}%")->coupon('mer_id'); + $query->whereIn('mer_id',$value); + } + + public function searchIsMerAttr($query, $value) + { + if ($value == 1) { + $query->where('mer_id','>',0); + } else { + $query->where('mer_id',0); + } + } + + + public function getList($where, $page, $limit) + { + $paramterModel = new Parameter(); + $query = self::getSearch($where)->field('template_id,mer_id,template_name,sort,create_time') + ->with([ + 'cateId' => function($query){ + $query->with(['category' =>function($query) { + $query->field('store_category_id,cate_name'); + }]); + }, + 'merchant' => function($query) { + $query->field('mer_id,mer_name'); + } +// 'parameter' =>function($query){ +// $query->field('parameter_id,template_id,name,value,sort')->order('sort DESC'); +// } + ]) + ->order('sort DESC,create_time DESC'); + $count = $query->count(); + $list = $query->page($page, $limit)->select(); + + return compact('count', 'list'); + } + + +/** + * TODO 搜索 + * @param $where + */ + public static function getSearch(array $where) + { + foreach ($where as $key => $item) { + if ($item !== '') { + $keyArray[] = $key; + $whereArr[$key] = $item; + } + } + + if(empty($keyArray)){ + return new self; + }else{ + return self::withSearch($keyArray, $whereArr); + } + } + +} \ No newline at end of file diff --git a/app/admin/model/store/paramter/ParameterValue.php b/app/admin/model/store/paramter/ParameterValue.php new file mode 100644 index 0000000..7ee9033 --- /dev/null +++ b/app/admin/model/store/paramter/ParameterValue.php @@ -0,0 +1,35 @@ + +// +---------------------------------------------------------------------- + +namespace app\common\model\store\parameter; + +use app\common\model\BaseModel; + +class ParameterValue extends BaseModel +{ + + + public static function tablePk(): string + { + return 'parameter_attr_id'; + } + + public static function tableName(): string + { + return 'parameter_value'; + } + + public function parameter() + { + return $this->hasOne(Parameter::class,'parameter_id','parameter_id'); + } +} diff --git a/app/admin/route/menu.php b/app/admin/route/menu.php index 63c5290..1c8cba7 100644 --- a/app/admin/route/menu.php +++ b/app/admin/route/menu.php @@ -1,14 +1,11 @@ -// +---------------------------------------------------------------------- - +/** + * @date :2023年03月2日 + * @author:刘孝全 + * @email:q8197264@126.com + * + * @ 商户菜单路由 + */ use think\facade\Route; use app\common\middleware\AdminAuthMiddleware; use app\common\middleware\AdminTokenMiddleware; diff --git a/app/admin/route/product.php b/app/admin/route/product.php new file mode 100644 index 0000000..5526b86 --- /dev/null +++ b/app/admin/route/product.php @@ -0,0 +1,176 @@ +name('merchantStoreParameterTemplateLst')->option([ + '_alias' => '列表', + ]); + Route::get('detail/:id', '/detail')->name('merchantStoreParameterTemplateDetail')->option([ + '_alias' => '详情', + ]); + Route::delete('delete/:id', '/delete')->name('merchantStoreParameterTemplateDelete')->option([ + '_alias' => '删除', + ]); + Route::get('add', '/add')->name('merchantStoreParameterTemplateCreate')->option([ + '_alias' => '添加', + ]); + Route::post('update/:id', '/update')->name('merchantStoreParameterTemplateUpdate')->option([ + '_alias' => '编辑', + ]); + Route::get('select', '/select')->option([ + '_alias' => '筛选列表', + '_auth' => false, + ]); + // Route::get('temp/show', '/show')->option([ + // '_alias' => '参数', + // '_auth' => false, + // ]); + })->prefix('product.Parameter')->option([ + '_path' => '/product/params', + '_auth' => true, + ]); + + //商品 + Route::group('store/product', function () { + Route::get('config', '/config')->option([ + '_alias' => '配置', + '_auth' => false, + ]); + Route::get('lst_filter', '/getStatusFilter')->name('merchantStoreProductLstFilter')->option([ + '_alias' => '头部统计', + ]); + Route::get('lst', '/lst')->name('merchantStoreProductLst')->option([ + '_alias' => '列表', + ]); + Route::get('list', '/lst')->option([ + '_alias' => '列表', + '_auth' => false, + ]); + Route::post('create', '/create')->name('merchantStoreProductCreate')->option([ + '_alias' => '添加', + ]); + Route::get('detail/:id', '/detail')->name('merchantStoreProductDetail')->option([ + '_alias' => '详情', + ]); + Route::get('temp_key', '/temp_key')->name('merchantStoreProductTempKey')->option([ + '_alias' => '上传视频配置', + ]); + Route::post('update/:id', '/update')->name('merchantStoreProductUpdate')->option([ + '_alias' => '编辑', + ]); + Route::post('free_trial/:id', '/freeTrial')->name('merchantStoreProductFreeTrial')->option([ + '_alias' => '免审编辑', + ]); + Route::delete('delete/:id', '/delete')->name('merchantStoreProductDelete')->option([ + '_alias' => '删除', + ]); + Route::delete('destory/:id', '/destory')->name('merchantStoreProductDestory')->option([ + '_alias' => '加入回收站', + ]); + Route::post('restore/:id', '/restore')->name('merchantStoreProductRestore')->option([ + '_alias' => '恢复', + ]); + Route::post('status/:id', '/switchStatus')->name('merchantStoreProductSwitchStatus')->option([ + '_alias' => '上下架', + ]); + Route::post('batch_status', '/batchShow')->name('merchantStoreProductSwitchBatchStatus')->option([ + '_alias' => '批量上下架', + ]); + Route::post('batch_temp', '/batchTemplate')->name('merchantStoreProductSwitchBatchTemplate')->option([ + '_alias' => '批量设置运费模板', + ]); + Route::post('batch_labels', '/batchLabels')->name('merchantStoreProductSwitchBatchLabels')->option([ + '_alias' => '批量设置标签', + ]); + Route::post('batch_hot', '/batchHot')->name('merchantStoreProductSwitchBatchHot')->option([ + '_alias' => '批量设置推荐', + ]); + Route::post('batch_ext', '/batchExtension')->name('merchantStoreProductSwitchBatchExtension')->option([ + '_alias' => '批量设置推荐', + ]); + Route::post('batch_svip', '/batchSvipType')->name('merchantStoreProductSwitchBatchSvipType')->option([ + '_alias' => '批量设置会员价', + ]); + Route::post('sort/:id', '/updateSort')->name('merchantStoreProductUpdateSort')->option([ + '_alias' => '排序', + ]); + Route::post('preview', '/preview')->name('merchantStoreProductPreview')->option([ + '_alias' => '预览', + ]); + Route::post('labels/:id', '/setLabels')->name('merchantStoreProductLabels')->option([ + '_alias' => '标签', + ]); + Route::get('attr_value/:id', '/getAttrValue')->name('merchantStoreProductAttrValue')->option([ + '_alias' => '获取规格', + ]); + })->prefix('merchant.store.product.Product')->option([ + '_path' => '/product/list', + '_auth' => true, + '_append'=> [ + [ + '_name' =>'merchantUploadImage', + '_path' =>'/product/list', + '_alias' => '上传图片', + '_auth' => true, + ], + [ + '_name' =>'merchantAttachmentLst', + '_path' =>'/product/list', + '_alias' => '图片列表', + '_auth' => true, + ], + + ] + ]); + + + //商品标签 + Route::group('product/label', function () { + Route::get('lst', '/lst')->name('merchantStoreProductLabelLst')->option([ + '_alias' => '列表', + ]); + Route::get('create/form', '/createForm')->name('merchantStoreProductLabelCreateForm')->option([ + '_alias' => '添加表单', + '_auth' => false, + '_form' => 'merchantStoreProductLabelCreate', + ]); + Route::post('create', '/create')->name('merchantStoreProductLabelCreate')->option([ + '_alias' => '添加', + ]); + Route::get('update/:id/form', '/updateForm')->name('merchantStoreProductLabelUpdateForm')->option([ + '_alias' => '编辑表单', + '_auth' => false, + '_form' => 'merchantStoreProductLabelUpdate', + ]); + Route::post('update/:id', '/update')->name('merchantStoreProductLabelUpdate')->option([ + '_alias' => '编辑', + ]); + Route::get('detail/:id', '/detail')->name('merchantStoreProductLabelDetail')->option([ + '_alias' => '详情', + ]); + Route::delete('delete/:id', '/delete')->name('merchantStoreProductLabelDelete')->option([ + '_alias' => '删除', + ]); + Route::post('status/:id', '/switchWithStatus')->name('merchantStoreProductLabelStatus')->option([ + '_alias' => '修改状态', + ]); + Route::get('option', '/getOptions')->option([ + '_alias' => '筛选', + '_auth' => false, + ]); + + })->prefix('merchant.store.product.ProductLabel')->option([ + '_path' => '/product/label', + '_auth' => true, + ]); +}); \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/margin/list.html b/app/admin/view/merchant/system/merchant/margin/list.html index c7c5acf..2e94988 100644 --- a/app/admin/view/merchant/system/merchant/margin/list.html +++ b/app/admin/view/merchant/system/merchant/margin/list.html @@ -116,7 +116,7 @@
- @@ -231,6 +231,7 @@ const moduleInit = ['tool']; function gouguInit() { var table = layui.table, tool = layui.tool, form = layui.form; + layui.pageTable = table.render({ elem: '#reduct_list', title: '保证金列表', @@ -362,6 +363,32 @@ }); + // 获取表单所有参数 + function getformdata() { + var form = $('#filterform').serializeArray(); + var data = new Array(); + for(let i=0;i + .editormd-code-toolbar select { + display: inline-block + } + + .editormd li { + list-style: inherit; + } + + .layui-td-gray { + width: 110px; + } + + .addrhelper-ok-btn { + display: none; + } + +{/block} + +{block name="body"} + +

添加

+ + + + + + + + + + + + + + + + + + +
参数模板名称* + +
排序 + +
+ + + + + + + + + + + + + + + + + +
参数名称参数值排序操作
+ + + + + + + 删除 +
+ +
+
+
+ + +
+ + +{/block} + + + +{block name="script"} + + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/parameter/edit.html b/app/admin/view/product/parameter/edit.html new file mode 100644 index 0000000..e764766 --- /dev/null +++ b/app/admin/view/product/parameter/edit.html @@ -0,0 +1,165 @@ +{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/product/parameter/index.html b/app/admin/view/product/parameter/index.html new file mode 100644 index 0000000..f2173cd --- /dev/null +++ b/app/admin/view/product/parameter/index.html @@ -0,0 +1,195 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+
+ +
+ + +
+ +
+ + + + + +
+ 平台分类 + + +
+
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/product/index.html b/app/admin/view/product/product/index.html index 57343c8..56e78f9 100644 --- a/app/admin/view/product/product/index.html +++ b/app/admin/view/product/product/index.html @@ -1,14 +1,145 @@ {extend name="common/base"/} {block name="body"} - +
-
-
- -
- -
+
+
+ +
+ +
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ + + +
+
+ + +
+
+ +
+ +
+ + +
+ +
+ + +
+
+ +
@@ -206,29 +337,67 @@ return false; }); - //监听搜索提交 - form.on('submit(searchform)', function(data) { - layui.pageTable.reload({ - where: { - keywords: data.field.keywords, - cate_id: data.field.cate_id - }, - page: { - curr: 1 - } - }); - return false; - }); + - layui.use('rate', function(){ + layui.use(['rate','table'], function(){ var rate = layui.rate; //基础效果 rate.render({ elem: '#is_good' }) + + var $ = layui.$, active = { + reload: function(){ + let dataRload = getformdata();; + console.log(dataRload) + //执行重载 + table.reload('article', { + page: { + curr: 1 //重新从第 1 页开始 + } + ,where: { + ...dataRload + } + }); + } + }; + + + //监听搜索提交 + form.on('submit(searchform)', function(data) { + layui.pageTable.reload({ + where: { + ...data.field + }, + page: { + curr: 1 + } + }); + return false; + }); + + //监听select提交 + form.on('select(seleform)', function(data) { + active['reload'] ? active['reload'].call(this) : ''; + + return false; + }); + }); + + // 获取表单所有参数 + function getformdata() { + var form = $('#filterform').serializeArray(); + var data = new Array(); + for(let i=0;i diff --git a/app/common/controller/FormatList.php b/app/common/controller/FormatList.php index 92eadef..36e4349 100644 --- a/app/common/controller/FormatList.php +++ b/app/common/controller/FormatList.php @@ -21,7 +21,7 @@ class FormatList * * @date 2023-03-3 */ - function FormatCategory(array $data, string $idName = "id", string $fieldName = 'pid', $childrenKey = 'children') + static function FormatCategory(array $data, string $idName = "id", string $fieldName = 'pid', $childrenKey = 'children') { $items = []; foreach ($data as $item) { @@ -49,22 +49,23 @@ class FormatList * * @date 2023-03-3 */ - function DropDownMenu($result, $pid = 0, $level=-1) + static function DropDownMenu($data, $pid = 0, $level=-1) { /*记录排序后的类别数组*/ static $list = array(); static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; $level++; - foreach ($result as $k => $v) { + foreach ($data as $k => $v) { if ($v['pid'] == $pid) { if ($pid != 0) { $v['title'] = $space[$level] . $v['title']; } /*将该类别的数据放入list中*/ $list[] = $v; - self::DropDownMenu($result, $v['id'],$level); + self::DropDownMenu($data, $v['id'],$level); } } + return $list; } } \ No newline at end of file diff --git a/app/common/model/merchant/system/Relevance.php b/app/common/model/merchant/system/Relevance.php new file mode 100644 index 0000000..e2681b9 --- /dev/null +++ b/app/common/model/merchant/system/Relevance.php @@ -0,0 +1,104 @@ +hasOne(User::class,'uid','left_id'); + } + + public function focus() + { + return $this->hasOne(User::class,'uid','right_id'); + } + + public function community() + { + return $this->hasOne(Community::class,'community_id','right_id') + ->bind(['community_id','title','image','start','uid','create_time','count_start','author','is_type']); + } + + public function getIsStartAttr() + { + return self::where('left_id', $this->right_id) + ->where('right_id',$this->left_id) + ->where('type', 'fans') + ->count() > 0; + } + + public function spu() + { + return $this->hasOne(Spu::class, 'spu_id','right_id'); + } + public function merchant() + { + return $this->hasOne(Merchant::class, 'mer_id','right_id'); + } + + public function category() + { + return $this->hasOne(StoreCategory::class, 'store_category_id','right_id'); + } + + + public function auth() + { + return $this->hasOne(Menu::class, 'menu_id','right_id'); + } + + public function searchLeftIdAttr($query, $value) + { + $query->where('left_id', $value); + } + + public function searchRightIdAttr($query, $value) + { + $query->where('right_id', $value); + } + + public function searchTypeAttr($query, $value) + { + $query->where('type', $value); + } + +} From 9aeb4c4dad24e1b8528150b5cd0668038a6a826a Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Fri, 10 Mar 2023 18:22:40 +0800 Subject: [PATCH 09/38] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/product/Product.php | 21 +- app/admin/model/EbStoreProduct.php | 217 +++++---- app/admin/model/ProductLabel.php | 58 +++ app/admin/model/store/Product.php | 536 +++++++++++++++++++++++ app/admin/model/store/ProductCate.php | 32 ++ 5 files changed, 777 insertions(+), 87 deletions(-) create mode 100644 app/admin/model/ProductLabel.php create mode 100644 app/admin/model/store/Product.php create mode 100644 app/admin/model/store/ProductCate.php diff --git a/app/admin/controller/product/Product.php b/app/admin/controller/product/Product.php index f2e4479..d4b44aa 100644 --- a/app/admin/controller/product/Product.php +++ b/app/admin/controller/product/Product.php @@ -95,16 +95,16 @@ class Product extends BaseController $where['cate_id'] = empty($params['plate_cate'])?'':$params['plate_cate']; // 商户商品分类id - $where['mer_cate_id'] = empty($params['store_cate'])?'':$params['store_cate']; - $where['is_trader'] = isset($params['is_trader'])?$params['is_trader']:0; // 是否自营 1自营, 0 不是自营 + // $where['mer_cate_id'] = empty($params['store_cate'])?'':$params['store_cate']; + $where['is_trader'] = isset($params['is_trader'])?$params['is_trader']:1; // 是否自营 1自营, 0 不是自营 // product $where['is_gift_bag'] = empty($params['is_gift'])?'':$params['is_gift']; $where['is_show'] = empty($params['state'])?'':$params['state']; - $where['temp_id'] = empty($params['shipping_tem'])?'':$params['shipping_tem']; + // $where['temp_id'] = empty($params['shipping_tem'])?'':$params['shipping_tem']; $where['labels'] = empty($params['tag'])?'':$params['tag']; $where['type'] = 1;//实体商品:0 虚拟商品:1 - $where['status'] = 0;//管理、审核、通过 + // $where['status'] = 0;//管理、审核、通过 // $where['is_ficti'] = 1;//是否虚拟销量 @@ -117,20 +117,15 @@ class Product extends BaseController } $mer_id = 77; - $this->product->getList($mer_id, $where, $page, $limit); - - return; - - $total = EbStoreProduct::where($where)->count(); + $data = $this->product->getList($mer_id, $where, $page, $limit); - - $list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select(); + // $list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select(); View::assign('url', $this->url); - View::assign('list', $list); + View::assign('list', $data['list']); - $result = ['total' => $total, 'data' => $list]; + $result = ['total' => $data['count'], 'data' => $data['list']]; return table_assign(0, '', $result); diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php index 67c889a..d127f64 100644 --- a/app/admin/model/EbStoreProduct.php +++ b/app/admin/model/EbStoreProduct.php @@ -11,8 +11,49 @@ namespace app\admin\model; use think\Model; -use StoreCategory as StoreCategoryModel; +use app\admin\model\store\ProductCate; + +if (!function_exists('hasMany')) { + function hasMany($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*') + { + $ids = []; + $link = []; + + if (!$collection) return []; + $collection = $collection->toArray(); + foreach ($collection as $k => $item) { + if (is_array($item[$field])) { + $link[$k] = array_unique($item[$field]); + $ids = array_merge($item[$field], $ids); + } else { + $link[$k] = array_unique(explode(',', $item[$field])); + } + $ids = array_merge($link[$k], $ids); + if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]); + } + $ids = array_filter(array_unique($ids)); + if (!count($ids)) { + return $collection; + } + $many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select(); + + if (!$many) return $collection; + $many = $many->toArray(); + foreach ($link as $k => $val) { + foreach ($many as $item) { + if (in_array($item[$searchKey], $val)) { + + if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = []; + + $collection[$k][$insertKey][] = $item; + } + } + } + + return $collection; + } +} class EbStoreProduct extends Model { // 设置当前模型的数据库连接 @@ -30,12 +71,23 @@ class EbStoreProduct extends Model * */ public function merchant() + { + return $this->hasOne(Merchant::class,'mer_id','mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count'); + } + + public function storeCategory() { - return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + return $this->hasOne(StoreCategory::class,'store_category_id','cate_id')->field('store_category_id,cate_name'); + } + public function merCateId() + { + return $this->hasMany(ProductCate::class,'product_id','product_id')->field('product_id,mer_cate_id'); } - - + public function brand() + { + return $this->hasOne(StoreBrand::class,'brand_id','brand_id')->field('brand_id,brand_name'); + } /** * TODO 商户商品列表 @@ -49,22 +101,24 @@ class EbStoreProduct extends Model */ public function getList(?int $mer_id, array $where, int $page, int $limit) { - $query = self::search($mer_id, $where); - // ->with(['merCateId.category', 'storeCategory', 'brand']); + $query = self::search($mer_id, $where) + ->with(['merCateId.category', 'storeCategory', 'brand']); $count = $query->count(); - $data = $query->field($this->filed)->page($page, $limit)->select(); + $data = $query->field($this->filed)->page($page, $limit) + ->order('product_id desc') + ->select(); + $data->append(['us_status']); - // $data->append(['us_status']); + $list = hasMany( + $data, + 'mer_labels', + ProductLabel::class, + 'product_label_id', + 'mer_labels', + ['status' => 1], + 'product_label_id,product_label_id id,label_name name' + ); - // $list = hasMany( - // $data, - // 'mer_labels', - // ProductLabel::class, - // 'product_label_id', - // 'mer_labels', - // ['status' => 1], - // 'product_label_id,product_label_id id,label_name name' - // ); return compact('count', 'list'); } @@ -98,17 +152,31 @@ class EbStoreProduct extends Model $query = self::alias('Product'); if (isset($where['is_trader']) && $where['is_trader'] !== '') { - $query->hasWhere('merchant', function ($query) use ($where) { - $query->where('is_trader', $where['is_trader']); - }); + $query->Join('Merchant', 'Merchant.mer_id = Product.mer_id') + ->where('Merchant.is_trader', $where['is_trader']) + ->when(($merId !== null), + function ($query) use ($merId) { + $query->where('Product.mer_id', $merId); + } + ); + + // $query->hasWhere('merchant', + // function ($query) use ($where) { + // $query->where('is_trader', $where['is_trader']); + // } + // ); } - + $query->withSearch($keyArray, $whereArr) - ->Join('StoreSpu U', 'Product.product_id = U.product_id')->where('U.product_type', $where['product_type'] ?? 0) - ->when(($merId !== null), function ($query) use ($merId) { + ->Join('StoreSpu U', 'Product.product_id = U.product_id') + ->where('U.product_type', $where['product_type'] ?? 0) + ->when(($merId !== null), + function ($query) use ($merId) { $query->where('Product.mer_id', $merId); - }) - ->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) { + } + ) + ->when(isset($where['hot_type']) && $where['hot_type'] !== '', + function ($query) use ($where) { if ($where['hot_type'] == 'new') $query->where('is_new', 1); else if ($where['hot_type'] == 'hot') @@ -117,61 +185,62 @@ class EbStoreProduct extends Model $query->where('is_best', 1); else if ($where['hot_type'] == 'good') $query->where('is_benefit', 1); - }); - - $query->when( - isset($where['pid']) && $where['pid'] !== '', - function ($query) use ($where) { - $ids = array_merge(self::findChildrenId((int)$where['pid']), [(int)$where['pid']]); - if (count($ids)) $query->whereIn('cate_id', $ids); - } - ) - ->when(isset($where['us_status']) && $where['us_status'] !== '', function ($query) use ($where) { - if ($where['us_status'] == 0) { - $query->where('Product.is_show', 0)->where('Product.is_used', 1)->where('Product.status', 1); - } - if ($where['us_status'] == 1) { - $query->where('Product.is_show', 1)->where('Product.is_used', 1)->where('Product.status', 1); - } - if ($where['us_status'] == -1) { - $query->where(function ($query) { - $query->where('Product.is_used', 0)->whereOr('Product.status', '<>', 1); - }); - } - }) - ->when(isset($where['mer_labels']) && $where['mer_labels'] !== '', function ($query) use ($where) { - $query->whereLike('U.mer_labels', "%,{$where['mer_labels']},%"); - }) - ->when(isset($where['sys_labels']) && $where['sys_labels'] !== '', function ($query) use ($where) { - $query->whereLike('U.sys_labels', "%,{$where['sys_labels']},%"); - }) - ->when(isset($where['order']), function ($query) use ($where, $merId) { - if (in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])) { - if ($where['order'] == 'price_asc') { - $where['order'] = 'price ASC'; - } else if ($where['order'] == 'price_desc') { - $where['order'] = 'price DESC'; - } else { - $where['order'] = $where['order'] . ' DESC'; - } - $query->order($where['order'] . ',rank DESC ,create_time DESC '); - } else if ($where['order'] !== '') { - $query->order('U.' . $where['order'] . ' DESC,U.create_time DESC'); - } else { - $query->order('U.create_time DESC'); - } - }) - ->when(isset($where['star']), function ($query) use ($where) { - $query->when($where['star'] !== '', function ($query) use ($where) { - $query->where('U.star', $where['star']); + } + ) + ->when( + isset($where['pid']) && $where['pid'] !== '', + function ($query) use ($where) { + $ids = array_merge(self::findChildrenId((int)$where['pid']), [(int)$where['pid']]); + if (count($ids)) $query->whereIn('cate_id', $ids); + } + ) + ->when(isset($where['us_status']) && $where['us_status'] !== '', function ($query) use ($where) { + if ($where['us_status'] == 0) { + $query->where('Product.is_show', 0)->where('Product.is_used', 1)->where('Product.status', 1); + } + if ($where['us_status'] == 1) { + $query->where('Product.is_show', 1)->where('Product.is_used', 1)->where('Product.status', 1); + } + if ($where['us_status'] == -1) { + $query->where(function ($query) { + $query->where('Product.is_used', 0)->whereOr('Product.status', '<>', 1); }); - $query->order('U.star DESC,U.rank DESC,Product.create_time DESC'); + } + }) + ->when(isset($where['mer_labels']) && $where['mer_labels'] !== '', function ($query) use ($where) { + $query->whereLike('U.mer_labels', "%,{$where['mer_labels']},%"); + }) + ->when(isset($where['sys_labels']) && $where['sys_labels'] !== '', function ($query) use ($where) { + $query->whereLike('U.sys_labels', "%,{$where['sys_labels']},%"); + }) + ->when(isset($where['order']), function ($query) use ($where, $merId) { + if (in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])) { + if ($where['order'] == 'price_asc') { + $where['order'] = 'price ASC'; + } else if ($where['order'] == 'price_desc') { + $where['order'] = 'price DESC'; + } else { + $where['order'] = $where['order'] . ' DESC'; + } + $query->order($where['order'] . ',rank DESC ,create_time DESC '); + } else if ($where['order'] !== '') { + $query->order('U.' . $where['order'] . ' DESC,U.create_time DESC'); + } else { + $query->order('U.create_time DESC'); + } + }) + ->when(isset($where['star']), function ($query) use ($where) { + $query->when($where['star'] !== '', function ($query) use ($where) { + $query->where('U.star', $where['star']); }); + $query->order('U.star DESC,U.rank DESC,Product.create_time DESC'); + }); + return $query; } public function findChildrenId($id) { - return StoreCategoryModel::whereLike('path', '%/'. $id . '/%')->column('store_category_id'); + return StoreCategory::whereLike('path', '%/' . $id . '/%')->column('store_category_id'); } } diff --git a/app/admin/model/ProductLabel.php b/app/admin/model/ProductLabel.php new file mode 100644 index 0000000..e7d8c38 --- /dev/null +++ b/app/admin/model/ProductLabel.php @@ -0,0 +1,58 @@ + +// +---------------------------------------------------------------------- +namespace app\common\model\store\product; + +use app\common\model\BaseModel; + +class ProductLabel extends BaseModel +{ + /** + * TODO + * @return string + * @author Qinii + * @day 8/17/21 + */ + public static function tablePk(): string + { + return 'product_label_id'; + } + + /** + * TODO + * @return string + * @author Qinii + * @day 8/17/21 + */ + public static function tableName(): string + { + return 'store_product_label'; + } + + public function searchMerIdAttr($query, $value) + { + $query->where('mer_id', $value); + } + + public function searchStatusAttr($query, $value) + { + $query->where('status', $value); + } + + public function searchNameAttr($query, $value) + { + $query->whereLike('name', "%{$value}%"); + } + + public function searchIsDelAttr($query, $value) + { + $query->where('is_del', $value); + } +} diff --git a/app/admin/model/store/Product.php b/app/admin/model/store/Product.php new file mode 100644 index 0000000..2c2358d --- /dev/null +++ b/app/admin/model/store/Product.php @@ -0,0 +1,536 @@ + +// +---------------------------------------------------------------------- + +namespace app\common\model\store\product; + +use app\common\dao\store\StoreSeckillActiveDao; +use app\common\model\BaseModel; +use app\common\model\store\coupon\StoreCouponProduct; +use app\common\model\store\Guarantee; +use app\common\model\store\GuaranteeTemplate; +use app\common\model\store\GuaranteeValue; +use app\common\model\store\parameter\ParameterValue; +use app\common\model\store\shipping\ShippingTemplate; +use app\common\model\store\StoreBrand; +use app\common\model\store\StoreCategory; +use app\common\model\store\StoreSeckillActive; +use app\common\model\system\merchant\Merchant; +use app\common\repositories\store\StoreCategoryRepository; +use crmeb\services\VicWordService; +use Darabonba\GatewaySpi\Models\InterceptorContext\request; +use think\db\BaseQuery; +use think\facade\Db; +use think\model\concern\SoftDelete; + +class Product extends BaseModel +{ + use SoftDelete; + + protected $deleteTime = 'is_del'; + protected $defaultSoftDelete = 0; + /** + * @Author:Qinii + * @Date: 2020/5/8 + * @return string + */ + public static function tablePk(): string + { + return 'product_id'; + } + + /** + * @Author:Qinii + * @Date: 2020/5/8 + * @return string + */ + public static function tableName(): string + { + return 'store_product'; + } + + /* + * ----------------------------------------------------------------------------------------------------------------- + * 属性 + * ----------------------------------------------------------------------------------------------------------------- + */ + public function getSliderImageAttr($value) + { + return $value ? explode(',',$value) : []; + } + public function getGiveCouponIdsAttr($value) + { + return $value ? explode(',',$value) : []; + } + public function getMaxExtensionAttr($value) + { + if($this->extension_type){ + $org_extension = ($this->attrValue()->order('extension_two DESC')->value('extension_one')); + } else { + $org_extension = bcmul(($this->attrValue()->order('price DESC')->value('price')) , systemConfig('extension_one_rate'),2); + } + $spreadUser = (request()->isLogin() && request()->userType() == 1 ) ? request()->userInfo() : null; + if ($spreadUser && $spreadUser->brokerage_level > 0 && $spreadUser->brokerage && $spreadUser->brokerage->extension_one_rate > 0) { + $org_extension = bcmul($org_extension, 1 + $spreadUser->brokerage->extension_one_rate, 2); + } + return $org_extension; + } + public function getMinExtensionAttr($value) + { + if($this->extension_type){ + $org_extension = ($this->attrValue()->order('extension_two ASC')->value('extension_two')); + } else { + $org_extension = bcmul(($this->attrValue()->order('price ASC')->value('price')) , systemConfig('extension_one_rate'),2); + } + $spreadUser = (request()->isLogin() && request()->userType() == 1 ) ? request()->userInfo() : null; + if ($spreadUser && $spreadUser->brokerage_level > 0 && $spreadUser->brokerage && $spreadUser->brokerage->extension_one_rate > 0) { + $org_extension = bcmul($org_extension, 1 + $spreadUser->brokerage->extension_one_rate, 2); + } + return $org_extension; + } + + public function check() + { + if(!$this || !$this->is_show || !$this->is_used || !$this->status || $this->is_del || !$this->mer_status) return false; + return true; + } + + /** + * TODO 秒杀商品结束时间 + * @return false|int + * @author Qinii + * @day 2020-08-15 + */ + public function getEndTimeAttr() + { + if($this->product_type !== 1) return true; + $day = date('Y-m-d',time()); + $_day = strtotime($day); + $end_day = strtotime($this->seckillActive['end_day']); + if($end_day >= $_day) + return strtotime($day.$this->seckillActive['end_time'].':00:00'); + if($end_day < strtotime($day)) + return strtotime(date('Y-m-d',$end_day).$this->seckillActive['end_time'].':00:00'); + } + + /** + * TODO 秒杀商品状态 + * @return array|int + * @author Qinii + * @day 2020-08-19 + */ + public function getSeckillStatusAttr() + { + if($this->product_type !== 1) return true; + $day = strtotime(date('Y-m-d',time())); + $_h = date('H',time()); + $start_day = strtotime($this->seckillActive['start_day']); + $end_day = strtotime($this->seckillActive['end_day']); + if(!$this->seckillActive) return ''; + if($this->seckillActive['status'] !== -1){ + //还未开始 + if($start_day > time() || $this->is_show !== 1)return 0; + //已结束 + if($end_day < $day) return -1; + //开始 - 结束 + if($start_day <= $day && $day <= $end_day){ + //未开始 + if($this->seckillActive['start_time'] > $_h) return 0; + //已结束 + if($this->seckillActive['end_time'] <= $_h) return -1; + //进行中 + if($this->seckillActive['start_time'] <= $_h && $this->seckillActive['end_time'] > $_h) return 1; + } + } + //已结束 + return -1; + + } + + public function getImageAttr($value) + { + if (is_int(strpos($value, 'http'))){ + return $value; + }else{ + return rtrim(systemConfig('site_url'),'/') .$value; + } + } + + public function getTopReplyAttr() + { + $res = ProductReply::where('product_id',$this->product_id)->where('is_del',0)->with(['orderProduct'])->field('reply_id,uid,nickname,merchant_reply_content,avatar,order_product_id,product_id,product_score,service_score,postage_score,comment,pics,rate,create_time') + ->order('sort DESC,create_time DESC')->limit(1)->find(); + if(!$res) return null; + if ($res['orderProduct']) + $res['sku'] = $res['orderProduct']['cart_info']['productAttr']['sku']; + unset($res['orderProduct']); + if (strlen($res['nickname']) > 1) { + $str = mb_substr($res['nickname'],0,1) . '*'; + if (strlen($res['nickname']) > 2) { + $str .= mb_substr($res['nickname'], -1,1); + } + $res['nickname'] = $str; + } + + return $res; + } + + public function getUsStatusAttr() + { + return ($this->status == 1) ? ($this->is_used == 1 ? ( $this->is_show ? 1 : 0 ) : -1) : -1; + } + + public function getGuaranteeTemplateAttr() + { + $gua = GuaranteeTemplate::where('guarantee_template_id',$this->guarantee_template_id)->where('status',1)->where('is_del',0)->find(); + if(!$gua) return []; + $guarantee_id = GuaranteeValue::where('guarantee_template_id',$this->guarantee_template_id)->column('guarantee_id'); + return Guarantee::where('guarantee_id','in',$guarantee_id)->where('status',1)->where('is_del',0)->select(); + } + + public function getMaxIntegralAttr() + { + if(systemConfig('integral_status') && merchantConfig($this->mer_id,'mer_integral_status')){ + $price = ($this->attrValue()->order('price DESC')->value('price')); + $rate = ($this->integral_rate < 0) ? merchantConfig($this->mer_id,'mer_integral_rate') : $this->integral_rate; + $rate = $rate < 0 ? $rate / 100 : 0; + return bcmul($price ,$rate,2); + } + return '0'; + } + + public function getHotRankingAttr() + { + if ($this->product_type == 0) { + $where = [ + 'is_show' => 1, + 'status' => 1, + 'is_used' => 1, + 'product_type' => 0, + 'mer_status' => 1, + 'is_gift_bag' => 0, + 'cate_id' => $this->cate_id + ]; + self::where($where)->order('sales DESC'); + } + } + + /** + * TODO 商品参数 + * @author Qinii + * @day 2022/11/24 + */ + public function getParamsAttr() + { + if(in_array($this->product_type,[0,2])) { + $product_id = $this->product_id; + } else { + $product_id = $this->old_product_id; + } + return ParameterValue::where('product_id',$product_id)->order('parameter_value_id ASC')->select(); + } + + public function getParamTempIdAttr($value) + { + return $value ? explode(',',$value) : $value; + } + + /* + * ----------------------------------------------------------------------------------------------------------------- + * 关联模型 + * ----------------------------------------------------------------------------------------------------------------- + */ + public function merCateId() + { + return $this->hasMany(ProductCate::class,'product_id','product_id')->field('product_id,mer_cate_id'); + } + public function attr() + { + return $this->hasMany(ProductAttr::class,'product_id','product_id'); + } + public function attrValue() + { + return $this->hasMany(ProductAttrValue::class,'product_id','product_id'); + } + public function oldAttrValue() + { + return $this->hasMany(ProductAttrValue::class,'product_id','old_product_id'); + } + public function content() + { + return $this->hasOne(ProductContent::class,'product_id','product_id'); + } + protected function temp() + { + return $this->hasOne(ShippingTemplate::class,'shipping_template_id','temp_id'); + } + public function storeCategory() + { + return $this->hasOne(StoreCategory::class,'store_category_id','cate_id')->field('store_category_id,cate_name'); + } + public function merchant() + { + return $this->hasOne(Merchant::class,'mer_id','mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count'); + } + public function reply() + { + return $this->hasMany(ProductReply::class,'product_id','product_id')->order('create_time DESC'); + } + public function brand() + { + return $this->hasOne(StoreBrand::class,'brand_id','brand_id')->field('brand_id,brand_name'); + } + public function seckillActive() + { + return $this->hasOne(StoreSeckillActive::class,'product_id','product_id'); + } + public function issetCoupon() + { + return $this->hasOne(StoreCouponProduct::class, 'product_id', 'product_id')->alias('A') + ->rightJoin('StoreCoupon B', 'A.coupon_id = B.coupon_id')->where(function (BaseQuery $query) { + $query->where('B.is_limited', 0)->whereOr(function (BaseQuery $query) { + $query->where('B.is_limited', 1)->where('B.remain_count', '>', 0); + }); + })->where(function (BaseQuery $query) { + $query->where('B.is_timeout', 0)->whereOr(function (BaseQuery $query) { + $time = date('Y-m-d H:i:s'); + $query->where('B.is_timeout', 1)->where('B.start_time', '<', $time)->where('B.end_time', '>', $time); + }); + })->field('A.product_id,B.*')->where('status', 1)->where('type', 1)->where('send_type', 0)->where('is_del', 0) + ->order('sort DESC,coupon_id DESC')->hidden(['is_del', 'status']); + } + public function assist() + { + return $this->hasOne(ProductAssist::class,'product_id','product_id'); + } + public function productGroup() + { + return $this->hasOne(ProductGroup::class,'product_id','product_id'); + } + public function guarantee() + { + return $this->hasOne(GuaranteeTemplate::class,'guarantee_template_id','guarantee_template_id')->where('status',1)->where('is_del',0); + } + + + /** + * TODO 是否是会员 + * @return bool + * @author Qinii + * @day 2023/1/4 + */ + public function getIsVipAttr() + { + if (request()->isLogin()) { + if (request()->userType() == 1) { + $userInfo = request()->userInfo(); + return $userInfo->is_svip ? true : false; + } else { + return true; + } + } + return false; + } + /** + * TODO 是否展示会员价 + * @return bool + * @author Qinii + * @day 2023/1/4 + */ + public function getShowSvipPriceAttr() + { + if ($this->mer_svip_status != 0 && (systemConfig('svip_show_price') != 1 || $this->is_vip) && $this->svip_price_type > 0 ) { + return true; + } + return false; + } + + + /** + * TODO 是否显示会员价等信息 + * @return array + * @author Qinii + * @day 2022/11/24 + */ + public function getShowSvipInfoAttr() + { + $res = [ + 'show_svip' => true, //是否展示会员入口 + 'is_svip' => false, //当前用户是否是会员 + 'show_svip_price' => false, //是否展示会员价 + 'save_money' => 0, //当前商品会员优化多少钱 + ]; + if ($this->product_type == 0) { + if (!systemConfig('svip_switch_status')) { + $res['show_svip'] = false; + } else { + $res['is_svip'] = $this->is_vip; + if ($this->show_svip_price) { + $res['show_svip_price'] = true; + $res['save_money'] = bcsub($this->price, $this->svip_price, 2); + } + } + } + return $res; + } + + /** + * TODO 获取会员价 + * @return int|string + * @author Qinii + * @day 2023/1/4 + */ + public function getSvipPriceAttr() + { + if ($this->product_type == 0 && $this->mer_svip_status != 0 && $this->show_svip_price) { + //默认比例 + if ($this->svip_price_type == 1) { + $rate = merchantConfig($this->mer_id,'svip_store_rate'); + $svip_store_rate = $rate > 0 ? bcdiv($rate,100,2) : 0; + $price = $this->attrValue()->order('price ASC')->value('price'); + return bcmul($price,$svip_store_rate,2); + } + //自定义 + if ($this->svip_price_type == 2) { + return $this->getData('svip_price'); + } + } + return 0; + } + + + /* + * ----------------------------------------------------------------------------------------------------------------- + * 搜索器 + * ----------------------------------------------------------------------------------------------------------------- + */ + public function searchMerCateIdAttr($query, $value) + { + $cate_ids = (StoreCategory::where('path','like','%/'.$value.'/%'))->column('store_category_id'); + $cate_ids[] = intval($value); + $product_id = ProductCate::whereIn('mer_cate_id',$cate_ids)->column('product_id'); + $query->whereIn('Product.product_id',$product_id); + } + public function searchKeywordAttr($query, $value) + { + if (!$value) return; + if (is_numeric($value)) { + $query->whereLike("Product.store_name|Product.keyword|bar_code|Product.product_id", "%{$value}%"); + } else { + $word = app()->make(VicWordService::class)->getWord($value); + $query->where(function ($query) use ($word, $value) { + foreach ($word as $item) { + $query->whereOr('Product.store_name|Product.keyword', 'LIKE', "%$item%"); + } + $query->order(Db::raw('REPLACE(Product.store_name,\'' . $value . '\',\'\')')); + }); + } + } + public function searchStatusAttr($query, $value) + { + if($value === -1){ + $query->where('Product.status', 'in',[-1,-2]); + }else { + $query->where('Product.status',$value); + } + } + public function searchCateIdAttr($query, $value) + { + $query->where('cate_id',$value); + } + public function searchCateIdsAttr($query, $value) + { + $query->whereIn('cate_id',$value); + } + public function searchIsShowAttr($query, $value) + { + $query->where('is_show',$value); + } + public function searchPidAttr($query, $value) + { + $cateId = app()->make(StoreCategoryRepository::class)->allChildren(intval($value)); + $query->whereIn('cate_id', $cateId); + } + public function searchStockAttr($query, $value) + { + $value ? $query->where('stock','<=', $value) : $query->where('stock', $value); + } + public function searchIsNewAttr($query, $value) + { + $query->where('is_new',$value); + } + public function searchPriceAttr($query, $value) + { + if(empty($value[0]) && !empty($value[1])) + $query->where('price','<',$value[1]); + if(!empty($value[0]) && empty($value[1])) + $query->where('price','>',$value[0]); + if(!empty($value[0]) && !empty($value[1])) + $query->whereBetween('price',[$value[0],$value[1]]); + } + public function searchBrandIdAttr($query, $value) + { + $query->whereIn('brand_id',$value); + } + public function searchIsGiftBagAttr($query, $value) + { + $query->where('is_gift_bag',$value); + } + public function searchIsGoodAttr($query, $value) + { + $query->where('is_good',$value); + } + public function searchIsUsedAttr($query, $value) + { + $query->where('is_used',$value); + } + public function searchProductTypeAttr($query, $value) + { + $query->where('Product.product_type',$value); + } + public function searchSeckillStatusAttr($query, $value) + { + $product_id = (new StoreSeckillActiveDao())->getStatus($value)->column('product_id'); + $query->whereIn('Product.product_id',$product_id); + } + public function searchStoreNameAttr($query, $value) + { + $query->where('Product.store_name','like','%'.$value.'%'); + } + public function searchMerStatusAttr($query, $value) + { + $query->where('mer_status',$value); + } + public function searchProductIdAttr($query, $value) + { + $query->where('Product.product_id',$value); + } + public function searchPriceOnAttr($query, $value) + { + $query->where('price','>=',$value); + } + public function searchPriceOffAttr($query, $value) + { + $query->where('price','<=',$value); + } + public function searchisFictiAttr($query, $value) + { + $query->where('type',$value); + } + public function searchGuaranteeTemplateIdAttr($query, $value) + { + $query->whereIn('guarantee_template_id',$value); + } + public function searchTempIdAttr($query, $value) + { + $query->whereIn('Product.temp_id',$value); + } +} diff --git a/app/admin/model/store/ProductCate.php b/app/admin/model/store/ProductCate.php new file mode 100644 index 0000000..a9d07d6 --- /dev/null +++ b/app/admin/model/store/ProductCate.php @@ -0,0 +1,32 @@ + +// +---------------------------------------------------------------------- + +namespace app\admin\model\store; + +use think\Model; +use app\admin\model\StoreCategory; + +class ProductCate extends Model +{ + protected $connection = 'shop'; + protected $table = 'store_product_cate'; + + public function category() + { + return $this->hasOne(StoreCategory::class,'store_category_id','mer_cate_id')->field('store_category_id,cate_name'); + } + + public function searchProductIdAttr($query, $value) + { + $query->where('product_id',$value); + } +} From 8b208ab7459ce8b1ced6b20a8fd74452cc406029 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Sat, 11 Mar 2023 18:12:45 +0800 Subject: [PATCH 10/38] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E4=B8=8E=E5=88=97=E8=A1=A8=E7=8A=B6=E6=80=81=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/product/Product.php | 30 +- .../controller/product/StoreCategory.php | 56 +++ app/admin/model/EbStoreProduct.php | 164 ++++--- app/admin/model/StoreCategory.php | 32 ++ app/admin/model/store/Product.php | 6 + app/admin/model/store/ProductCate.php | 4 +- app/admin/model/user/UserMerchant.php | 157 +++++++ app/admin/route/product.php | 128 +++++ .../view/product/product/index.back.html | 437 ++++++++++++++++++ app/admin/view/product/product/index.html | 118 +++-- app/common/controller/FormatList.php | 16 +- app/common/model/merchant/user/UserLabel.php | 1 + .../model/merchant/user/UserMerchant.php | 136 +++++- 13 files changed, 1166 insertions(+), 119 deletions(-) create mode 100644 app/admin/controller/product/StoreCategory.php create mode 100644 app/admin/model/user/UserMerchant.php create mode 100644 app/admin/view/product/product/index.back.html diff --git a/app/admin/controller/product/Product.php b/app/admin/controller/product/Product.php index d4b44aa..8f44d77 100644 --- a/app/admin/controller/product/Product.php +++ b/app/admin/controller/product/Product.php @@ -12,14 +12,16 @@ use think\facade\View; use app\admin\model\Merchant; // 商户模型 use app\admin\model\EbStoreProduct; // 商品模型 use app\admin\model\StoreCategory; // 商品分类模型 -use app\admin\model\GeoCity; // 省市模型 -use app\admin\model\GeoArea; // 区域模型 -use app\admin\model\GeoStreet; // 街道模型 -use app\admin\model\SupplyChain; // 供应链模型 -use app\api\model\Area as AreaModel; // 市场区域模型 -use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型 use app\common\controller\FormatList; +// use app\admin\model\GeoCity; // 省市模型 +// use app\admin\model\GeoArea; // 区域模型 +// use app\admin\model\GeoStreet; // 街道模型 +use app\admin\model\SupplyChain; // 供应链模型 +// use app\api\model\Area as AreaModel; // 市场区域模型 +// use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型 + + /** * * 商品控制器 @@ -31,6 +33,7 @@ class Product extends BaseController protected $adminInfo; protected $url; protected $product; + protected $mer_id = 4;//待开发成自动获取商城登陆商户id public function __construct(EbStoreProduct $product) { @@ -71,12 +74,12 @@ class Product extends BaseController /** * - * 供应链团队列表 + * 商户商品列表 * */ public function index(StoreCategory $category) { - if (true) { + if (request()->isAjax()) { // request()->isAjax() // Ajax 前端获取数据 $params= get_params(); @@ -101,9 +104,9 @@ class Product extends BaseController // product $where['is_gift_bag'] = empty($params['is_gift'])?'':$params['is_gift']; $where['is_show'] = empty($params['state'])?'':$params['state']; - // $where['temp_id'] = empty($params['shipping_tem'])?'':$params['shipping_tem']; + $where['temp_id'] = empty($params['shipping_tem'])?'':$params['shipping_tem']; $where['labels'] = empty($params['tag'])?'':$params['tag']; - $where['type'] = 1;//实体商品:0 虚拟商品:1 + $where['type'] = empty($params['type'])?'':$params['type'];//实体商品:0 虚拟商品:1 // $where['status'] = 0;//管理、审核、通过 @@ -111,12 +114,13 @@ class Product extends BaseController // $where['product_id'] = 0; // ['order','sort'] // soft //软删除 - if (!empty(get_params('mer_id'))) { + // $params['mer_id'] = $this->mer_id; + if (!empty($params['mer_id'])) { $mer_id = get_params('mer_id'); $where = array_merge($where, $this->switchType($where['type'],$mer_id,0)); } - $mer_id = 77; - + $mer_id = isset($params['mer_id'])?$params['mer_id']:NULL; + $data = $this->product->getList($mer_id, $where, $page, $limit); diff --git a/app/admin/controller/product/StoreCategory.php b/app/admin/controller/product/StoreCategory.php new file mode 100644 index 0000000..ef7d927 --- /dev/null +++ b/app/admin/controller/product/StoreCategory.php @@ -0,0 +1,56 @@ +category = $category; + } + + protected function getMerId(UserMerchant $user) + { + // $user->isMerUser($uid, $mer_id); + } + + /** + * 平台商品分类Tree列表 + * + */ + public function getList() + { + $where['mer_id'] = 0; + $where['is_show'] = 0; + $list = $this->category->getList($where); + $list = FormatList::DropDownMenu($list); + + return to_assign(0,'', $list); + } + + /** + * 商户商品分类Tree列表 + */ + public function getStoreCategoryList(){ + $data = $this->category->getStoreCategoryList($this->mer_id, 1); + $list = FormatList::FormatCategory($data,'store_category_id', 'pid', 'cate_name','child', 'id', 'title'); + + return to_assign(0, '', $list); + } + +} \ No newline at end of file diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php index d127f64..8fa5554 100644 --- a/app/admin/model/EbStoreProduct.php +++ b/app/admin/model/EbStoreProduct.php @@ -14,46 +14,6 @@ use think\Model; use app\admin\model\store\ProductCate; -if (!function_exists('hasMany')) { - function hasMany($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*') - { - $ids = []; - $link = []; - - if (!$collection) return []; - $collection = $collection->toArray(); - foreach ($collection as $k => $item) { - if (is_array($item[$field])) { - $link[$k] = array_unique($item[$field]); - $ids = array_merge($item[$field], $ids); - } else { - $link[$k] = array_unique(explode(',', $item[$field])); - } - $ids = array_merge($link[$k], $ids); - if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]); - } - $ids = array_filter(array_unique($ids)); - if (!count($ids)) { - return $collection; - } - $many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select(); - - if (!$many) return $collection; - $many = $many->toArray(); - foreach ($link as $k => $val) { - foreach ($many as $item) { - if (in_array($item[$searchKey], $val)) { - - if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = []; - - $collection[$k][$insertKey][] = $item; - } - } - } - - return $collection; - } -} class EbStoreProduct extends Model { // 设置当前模型的数据库连接 @@ -71,9 +31,9 @@ class EbStoreProduct extends Model * */ public function merchant() - { - return $this->hasOne(Merchant::class,'mer_id','mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count'); - } + { + return $this->hasOne(Merchant::class,'mer_id','mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count'); + } public function storeCategory() { @@ -81,13 +41,14 @@ class EbStoreProduct extends Model } public function merCateId() { - return $this->hasMany(ProductCate::class,'product_id','product_id')->field('product_id,mer_cate_id'); + return $this->hasMany(ProductCate::class,'product_id','product_id')->field('product_id, mer_cate_id'); } public function brand() - { - return $this->hasOne(StoreBrand::class,'brand_id','brand_id')->field('brand_id,brand_name'); - } + { + return $this->hasOne(StoreBrand::class,'brand_id','brand_id')->field('brand_id,brand_name'); + } + /** * TODO 商户商品列表 @@ -102,13 +63,15 @@ class EbStoreProduct extends Model public function getList(?int $mer_id, array $where, int $page, int $limit) { $query = self::search($mer_id, $where) - ->with(['merCateId.category', 'storeCategory', 'brand']); + ->with(['merCateId.category', 'storeCategory', 'brand', 'Merchant']); $count = $query->count(); $data = $query->field($this->filed)->page($page, $limit) - ->order('product_id desc') + ->order('Product.product_id desc') + // ->fetchSql() ->select(); + // echo $data;exit('--'); $data->append(['us_status']); - + $list = hasMany( $data, 'mer_labels', @@ -152,22 +115,17 @@ class EbStoreProduct extends Model $query = self::alias('Product'); if (isset($where['is_trader']) && $where['is_trader'] !== '') { - $query->Join('Merchant', 'Merchant.mer_id = Product.mer_id') - ->where('Merchant.is_trader', $where['is_trader']) - ->when(($merId !== null), - function ($query) use ($merId) { - $query->where('Product.mer_id', $merId); - } - ); - + // hasWhere添加别名不生效 alias, 改为Join // $query->hasWhere('merchant', // function ($query) use ($where) { // $query->where('is_trader', $where['is_trader']); // } // ); + $query->Join('Merchant', 'Merchant.mer_id = Product.mer_id') + ->where('Merchant.is_trader', $where['is_trader']); } - $query->withSearch($keyArray, $whereArr) + ->Join('StoreSpu U', 'Product.product_id = U.product_id') ->where('U.product_type', $where['product_type'] ?? 0) ->when(($merId !== null), @@ -187,8 +145,7 @@ class EbStoreProduct extends Model $query->where('is_benefit', 1); } ) - ->when( - isset($where['pid']) && $where['pid'] !== '', + ->when(isset($where['pid']) && $where['pid'] !== '', function ($query) use ($where) { $ids = array_merge(self::findChildrenId((int)$where['pid']), [(int)$where['pid']]); if (count($ids)) $query->whereIn('cate_id', $ids); @@ -239,8 +196,93 @@ class EbStoreProduct extends Model return $query; } + /** + * + */ public function findChildrenId($id) { return StoreCategory::whereLike('path', '%/' . $id . '/%')->column('store_category_id'); } + + protected function hasMany1($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*') + { + $ids = []; + $link = []; + + if (!$collection) return []; + $collection = $collection->toArray(); + foreach ($collection as $k => $item) { + if (is_array($item[$field])) { + $link[$k] = array_unique($item[$field]); + $ids = array_merge($item[$field], $ids); + } else { + $link[$k] = array_unique(explode(',', $item[$field])); + } + $ids = array_merge($link[$k], $ids); + if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]); + } + $ids = array_filter(array_unique($ids)); + if (!count($ids)) { + return $collection; + } + $many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select(); + + if (!$many) return $collection; + $many = $many->toArray(); + foreach ($link as $k => $val) { + foreach ($many as $item) { + if (in_array($item[$searchKey], $val)) { + + if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = []; + + $collection[$k][$insertKey][] = $item; + } + } + } + + return $collection; + } +} + + + +if (!function_exists('hasMany')) { + function hasMany($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*') + { + $ids = []; + $link = []; + + if (!$collection) return []; + $collection = $collection->toArray(); + foreach ($collection as $k => $item) { + if (is_array($item[$field])) { + $link[$k] = array_unique($item[$field]); + $ids = array_merge($item[$field], $ids); + } else { + $link[$k] = array_unique(explode(',', $item[$field])); + } + $ids = array_merge($link[$k], $ids); + if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]); + } + $ids = array_filter(array_unique($ids)); + if (!count($ids)) { + return $collection; + } + $many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select(); + + if (!$many) return $collection; + $many = $many->toArray(); + foreach ($link as $k => $val) { + foreach ($many as $item) { + if (in_array($item[$searchKey], $val)) { + + if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = []; + + $collection[$k][$insertKey][] = $item; + } + } + } + + return $collection; + } } diff --git a/app/admin/model/StoreCategory.php b/app/admin/model/StoreCategory.php index dcb7979..529dc37 100644 --- a/app/admin/model/StoreCategory.php +++ b/app/admin/model/StoreCategory.php @@ -44,6 +44,38 @@ return $list; } + public function getStoreCategoryList(int $merId = 0,$status = 0) + { + $data = self::getAllOptions($merId,$status); + return $data; + } + + /** + * 获取列表 -- 筛选用 + * @Date: 2020/5/16 + * @param int|null $mer_id + * @return mixed + */ + protected function getAllOptions($mer_id = null,$status = null,$level = null) + { + $field = 'pid,cate_name'; + $query = StoreCategory::when(($mer_id !== null), + function($query)use($mer_id){ + $query->where('mer_id', $mer_id); + }) + ->when($status,function($query)use($status){ + $query->where('is_show',$status); + }) + ->when(($level != '' && $level != null),function($query)use($level){ + $query->where('level','<',$level); + } + ); + + + return $query->order('sort DESC,'.$this->getPk().' DESC')->column($field, $this->getPk()); + } + + /** * 查询语句构建 *@author Liuxiaoquan diff --git a/app/admin/model/store/Product.php b/app/admin/model/store/Product.php index 2c2358d..ec16fc5 100644 --- a/app/admin/model/store/Product.php +++ b/app/admin/model/store/Product.php @@ -31,12 +31,18 @@ use think\db\BaseQuery; use think\facade\Db; use think\model\concern\SoftDelete; +/** + * TODO: + */ class Product extends BaseModel { use SoftDelete; + protected $deleteTime = 'is_del'; protected $defaultSoftDelete = 0; + + /** * @Author:Qinii * @Date: 2020/5/8 diff --git a/app/admin/model/store/ProductCate.php b/app/admin/model/store/ProductCate.php index a9d07d6..bd5cbc6 100644 --- a/app/admin/model/store/ProductCate.php +++ b/app/admin/model/store/ProductCate.php @@ -18,11 +18,11 @@ use app\admin\model\StoreCategory; class ProductCate extends Model { protected $connection = 'shop'; - protected $table = 'store_product_cate'; + protected $table = 'eb_store_product_cate'; public function category() { - return $this->hasOne(StoreCategory::class,'store_category_id','mer_cate_id')->field('store_category_id,cate_name'); + return $this->hasOne(StoreCategory::class,'store_category_id','mer_cate_id')->field('store_category_id, cate_name'); } public function searchProductIdAttr($query, $value) diff --git a/app/admin/model/user/UserMerchant.php b/app/admin/model/user/UserMerchant.php new file mode 100644 index 0000000..7f88115 --- /dev/null +++ b/app/admin/model/user/UserMerchant.php @@ -0,0 +1,157 @@ +hasOne(User::class, 'uid', 'uid'); + } + + /** + * @param $value + * @return array + * @author xaboy + * @day 2020-05-09 + */ + public function getLabelIdAttr($value) + { + return $value ? explode(',', $value) : []; + } + + /** + * @param $value + * @return string + * @author xaboy + * @day 2020-05-09 + */ + public function setLabelIdAttr($value) + { + return implode(',', $value); + } + + public function getAuthLabelAttr() + { + return app()->make(UserLabel::class)->whereIn('label_id', $this->label_id)->where('mer_id', $this->mer_id)->where('type', 1)->column('label_id'); + } + + + + /** + * @return string + * @author xaboy + * @day 2020/10/20 + */ + protected function getModel(): string + { + return UserMerchant::class; + } + + /** + * @param $uid + * @param $mer_id + * @return bool + * @author xaboy + * @day 2020/10/20 + */ + public function isMerUser($uid, $mer_id) + { + return $this->existsWhere(compact('uid', 'mer_id')); + } + + /** + * @param $uid + * @param $mer_id + * @return int + * @throws \think\db\exception\DbException + * @author xaboy + * @day 2020/10/20 + */ + public function updateLastTime($uid, $mer_id) + { + return UserMerchant::getDB()->where(compact('uid', 'mer_id'))->update([ + 'last_time' => date('Y-m-d H:i:s') + ]); + } + + /** + * @param array $where + * @return mixed + * @author xaboy + * @day 2020/10/20 + */ + public function search(array $where) + { + return UserMerchant::getDB()->alias('A')->leftJoin('User B', 'A.uid = B.uid') + ->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) { + $query->where('A.mer_id', $where['mer_id']); + })->when(isset($where['nickname']) && $where['nickname'], function (BaseQuery $query) use ($where) { + return $query->where('B.nickname', 'like', '%' . $where['nickname'] . '%'); + })->when(isset($where['sex']) && $where['sex'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('B.sex', intval($where['sex'])); + })->when(isset($where['is_promoter']) && $where['is_promoter'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('B.is_promoter', $where['is_promoter']); + })->when(isset($where['uids']), function (BaseQuery $query) use ($where) { + return $query->whereIn('A.uid', $where['uids']); + })->when(isset($where['user_time_type']) && $where['user_time_type'] !== '' && $where['user_time'] != '', function ($query) use ($where) { + if ($where['user_time_type'] == 'visit') { + getModelTime($query, $where['user_time'], 'A.last_time'); + } + if ($where['user_time_type'] == 'add_time') { + getModelTime($query, $where['user_time'], 'A.create_time'); + } + })->when(isset($where['pay_count']) && $where['pay_count'] !== '', function ($query) use ($where) { + if ($where['pay_count'] == -1) { + $query->where('A.pay_num', 0); + } else { + $query->where('A.pay_num', '>', $where['pay_count']); + } + })->when(isset($where['label_id']) && $where['label_id'] !== '', function (BaseQuery $query) use ($where) { + return $query->whereRaw('CONCAT(\',\',A.label_id,\',\') LIKE \'%,' . $where['label_id'] . ',%\''); + })->when(isset($where['user_type']) && $where['user_type'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('B.user_type', $where['user_type']); + })->where('A.status', 1); + } + + public function numUserIds($mer_id, $min, $max = null) + { + return UserMerchant::getDB()->where('mer_id', $mer_id)->where('pay_num', '>=', $min)->when(!is_null($max), function ($query) use ($max) { + $query->where('pay_num', '<=', $max); + })->group('uid')->column('uid'); + } + + public function priceUserIds($mer_id, $min, $max = null) + { + return UserMerchant::getDB()->where('mer_id', $mer_id)->where('pay_price', '>=', $min)->when(!is_null($max), function ($query) use ($max, $min) { + $query->where('pay_price', $min == $max ? '<=' : '<', $max); + })->group('uid')->column('uid'); + } +} diff --git a/app/admin/route/product.php b/app/admin/route/product.php index 5526b86..c138d1f 100644 --- a/app/admin/route/product.php +++ b/app/admin/route/product.php @@ -134,6 +134,134 @@ Route::group(function () { ]); + //商品分类 + Route::group('store/category', function () { + Route::get('create/form', '/createForm')->name('merchantStoreCategoryCreateForm')->option([ + '_alias' => '添加表单', + '_auth' => false, + '_form' => 'merchantStoreCategoryCreate', + ]); + Route::get('update/form/:id', '/updateForm')->name('merchantStoreCategoryUpdateForm')->option([ + '_alias' => '编辑表单', + '_auth' => false, + '_form' => 'merchantStoreCategoryUpdate', + ]); + Route::post('update/:id', '/update')->name('merchantStoreCategoryUpdate')->option([ + '_alias' => '编辑', + ]); + Route::get('lst', '/lst')->name('merchantStoreCategoryLst')->option([ + '_alias' => '列表', + ]); + Route::get('detail/:id', '/detail')->name('merchantStoreCategoryDtailt')->option([ + '_alias' => '详情', + ]); + Route::post('create', '/create')->name('merchantStoreCategoryCreate')->option([ + '_alias' => '添加', + ]); + Route::delete('delete/:id', '/delete')->name('merchantStoreCategoryDelete')->option([ + '_alias' => '删除', + ]); + Route::post('status/:id', '/switchStatus')->name('merchantStoreCategorySwitchStatus')->option([ + '_alias' => '修改状态', + ]); + Route::get('list', '/getList')->option([ + '_alias' => '筛选', + '_auth' => false, + ])->append(['type' => 1]); + Route::get('select', '/getStoreCategoryList')->option([ + '_alias' => '', + '_auth' => false, + ]); + Route::get('brandlist', '/BrandList')->option([ + '_alias' => '品牌列表', + '_auth' => false, + ]); + })->prefix('product.StoreCategory')->option([ + '_path' => '/product/classify', + '_auth' => true, + '_append'=> [ + [ + '_name' =>'merchantUploadImage', + '_path' =>'/product/classify', + '_alias' => '上传图片', + '_auth' => true, + ], + [ + '_name' =>'merchantAttachmentLst', + '_path' =>'/product/classify', + '_alias' => '图片列表', + '_auth' => true, + ], + ] + ]); + + //品牌分类 + Route::group('store/brand/category', function () { + Route::get('create/form', '/createForm')->name('systemStoreBrandCategoryCreateForm')->option([ + '_alias' => '添加表单', + '_auth' => false, + '_form' => 'systemStoreBrandCategoryCreate', + ]); + Route::get('update/form/:id', '/updateForm')->name('systemStoreBrandCategoryUpdateForm')->option([ + '_alias' => '编辑表单', + '_auth' => false, + '_form' => 'systemStoreBrandCategoryUpdate', + ]); + Route::post('update/:id', '/update')->name('systemStoreBrandCategoryUpdate')->option([ + '_alias' => '编辑', + ]); + Route::get('lst', '/lst')->name('systemStoreBrandCategoryLst')->option([ + '_alias' => '列表', + ]); + Route::get('detail/:id', '/detail')->name('systemStoreBrandCategoryDtailt')->option([ + '_alias' => '详情', + ]); + Route::post('create', '/create')->name('systemStoreBrandCategoryCreate')->option([ + '_alias' => '添加', + ]); + Route::delete('delete/:id', '/delete')->name('systemStoreBrandCategoryDelete')->option([ + '_alias' => '删除', + ]); + Route::post('status/:id', '/switchStatus')->name('systemStoreBrandCategorySwitchStatus')->option([ + '_alias' => '修改状态', + ]); + })->prefix('admin.store.StoreBrandCategory')->option([ + '_path' => '/product/band/brandClassify', + '_auth' => true, + ]); + + //品牌 + Route::group('store/brand', function () { + Route::get('create/form', '/createForm')->name('systemStoreBrandCreateForm')->option([ + '_alias' => '添加表单', + '_auth' => false, + '_form' => 'systemStoreBrandCreate', + ]); + Route::get('update/form/:id', '/updateForm')->name('systemStoreBrandUpdateForm')->option([ + '_alias' => '编辑表单', + '_auth' => false, + '_form' => 'systemStoreBrandUpdate', + ]); + Route::get('lst', '/lst')->name('systemStoreBrandLst')->option([ + '_alias' => '列表', + ]); + Route::post('status/:id', '/switchStatus')->name('systemStoreBrandSwithStatus')->option([ + '_alias' => '修改状态', + ]); + Route::post('create', '/create')->name('systemStoreBrandCreate')->option([ + '_alias' => '添加', + ]); + Route::post('update/:id', '/update')->name('systemStoreBrandUpdate')->option([ + '_alias' => '编辑', + ]); + Route::delete('delete/:id', '/delete')->name('systemStoreBrandDelete')->option([ + '_alias' => '删除', + ]); + })->prefix('admin.store.StoreBrand')->option([ + '_path' => '/product/band/brandList', + '_auth' => true, + ]); + //商品标签 Route::group('product/label', function () { Route::get('lst', '/lst')->name('merchantStoreProductLabelLst')->option([ diff --git a/app/admin/view/product/product/index.back.html b/app/admin/view/product/product/index.back.html new file mode 100644 index 0000000..d3dced9 --- /dev/null +++ b/app/admin/view/product/product/index.back.html @@ -0,0 +1,437 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+ +
+ +
+
+
+
+
+ +
+ + +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ + + +
+
+ + +
+
+ +
+ +
+ + +
+ +
+ + +
+
+ + +
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/product/index.html b/app/admin/view/product/product/index.html index 56e78f9..7a9d803 100644 --- a/app/admin/view/product/product/index.html +++ b/app/admin/view/product/product/index.html @@ -15,11 +15,30 @@ margin-left:unset !important; width:75%; } + #seleform{ + border-color: #eee; + background-color: #fff; + color:#a39f9f; + width:100%; + }
+
+
    +
  • 出售中的商品
  • +
  • 仓库中的商品
  • +
  • 已售罄的商品
  • +
  • 警戒库存
  • +
  • 待审核商品
  • +
  • 审核未通过商品
  • +
  • 回收站商品
  • +
+
+ +
- +
@@ -39,11 +58,8 @@
- + +
@@ -71,8 +87,8 @@
@@ -90,10 +106,6 @@
@@ -108,8 +120,6 @@ - -
@@ -183,6 +193,7 @@ const moduleInit = ['tool']; function gouguInit() { var table = layui.table,tool = layui.tool, form = layui.form; + layui.pageTable = table.render({ elem: '#article', title: '列表', @@ -221,16 +232,6 @@ title: '商品名称', align: 'center', width:120 - },{ - field: 'type_name', - title: '商户类型', - align: 'center', - width:150, - templet: function (d) - { - return d.merchant.merchantType ? d.merchant.merchantType.type_name : '待定'; - } - },{ field: 'product_score', title: '商户类别', @@ -238,7 +239,7 @@ width:150, templet: function (d) { - return d.merchant.category ? d.merchant.category.category_name : '待定'; + return d.storeCategory ? d.storeCategory.cate_name : '待定'; } },{ field: 'price', @@ -276,13 +277,13 @@ return html; }, },{ - field: 'is_used', + field: 'is_show', title: '商品状态', align: 'center', width:150, templet: function (d) { - var html = d.is_used ? '上架显示' : '平台关闭'; + var html = d.is_show ? '上架显示' : '平台关闭'; return html; }, },{ @@ -339,18 +340,17 @@ - layui.use(['rate','table'], function(){ - var rate = layui.rate; + layui.use(['rate','dropdown', 'util', 'layer', 'table'], function(){ + var dropdown = layui.dropdown + ,util = layui.util + ,layer = layui.layer + ,rate = layui.rate + // ,table = layui.table + ,$ = layui.jquery; - //基础效果 - rate.render({ - elem: '#is_good' - }) - var $ = layui.$, active = { reload: function(){ let dataRload = getformdata();; - console.log(dataRload) //执行重载 table.reload('article', { page: { @@ -360,8 +360,45 @@ ...dataRload } }); - } + }, }; + + //商户商品分类菜单 + $.ajax({ + url: '/admin/store/category/select', + method: "get", + data: {}, + success: function(res) { + if (res.code!==0)return ; + + //高级演示 - 各种组合 + dropdown.render({ + elem: '#seleform' + ,isAllowSpread: false //禁止菜单组展开收缩 + ,style: 'width: 200px' //定义宽度,默认自适应 + ,id: 'test777' //定义唯一索引 + ,title: 'title1' + ,data: res.data + ,click: function(item){ + $('#seleform').text(item.title); + $('#seleform').css({color:'rgba(0,0,0,.85)'}); + $('#store_cate').val(item.id); + + active['reload'] ? active['reload'].call(this) : ''; + } + }); + }, + fail:function(){} + }); + + + + //基础效果 + rate.render({ + elem: '#is_good' + }) + + //监听搜索提交 @@ -380,16 +417,23 @@ //监听select提交 form.on('select(seleform)', function(data) { active['reload'] ? active['reload'].call(this) : ''; - return false; }); + // tab 状态列表切换 + $('.site-demo-active').on('click', function(){ + var othis = $(this), type = othis.data('type'); + $('#protype').val(this.getAttribute('type')); + active[type] ? active[type].call(this, othis) : ''; + }); + }); // 获取表单所有参数 function getformdata() { var form = $('#filterform').serializeArray(); + var data = new Array(); for(let i=0;i $v) { if ($v['pid'] == $pid) { + $v['title'] = ''; if ($pid != 0) { $v['title'] = $space[$level] . $v['title']; } diff --git a/app/common/model/merchant/user/UserLabel.php b/app/common/model/merchant/user/UserLabel.php index 6fb528e..64a5468 100644 --- a/app/common/model/merchant/user/UserLabel.php +++ b/app/common/model/merchant/user/UserLabel.php @@ -11,4 +11,5 @@ use think\Model; class UserLabel extends Model { // + } diff --git a/app/common/model/merchant/user/UserMerchant.php b/app/common/model/merchant/user/UserMerchant.php index 5413e54..fadf563 100644 --- a/app/common/model/merchant/user/UserMerchant.php +++ b/app/common/model/merchant/user/UserMerchant.php @@ -4,11 +4,145 @@ declare (strict_types = 1); namespace app\common\model\merchant\user; use think\Model; +use think\db\BaseQuery; /** * @mixin \think\Model */ class UserMerchant extends Model { - // + /** + * @return string|null + * @author xaboy + * @day 2020/10/20 + */ + public static function tablePk(): ?string + { + return 'user_merchant_id'; + } + + /** + * @return string + * @author xaboy + * @day 2020/10/20 + */ + public static function tableName(): string + { + return 'user_merchant'; + } + + public function user() + { + return $this->hasOne(User::class, 'uid', 'uid'); + } + + /** + * @param $value + * @return array + * @author xaboy + * @day 2020-05-09 + */ + public function getLabelIdAttr($value) + { + return $value ? explode(',', $value) : []; + } + + /** + * @param $value + * @return string + * @author xaboy + * @day 2020-05-09 + */ + public function setLabelIdAttr($value) + { + return implode(',', $value); + } + + public function getAuthLabelAttr() + { + return app()->make(UserLabel::class)->whereIn('label_id', $this->label_id)->where('mer_id', $this->mer_id)->where('type', 1)->column('label_id'); + } + + /** + * @param $uid + * @param $mer_id + * @return bool + * @author xaboy + * @day 2020/10/20 + */ + public function isMerUser($uid, $mer_id) + { + return $this->existsWhere(compact('uid', 'mer_id')); + } + + /** + * @param $uid + * @param $mer_id + * @return int + * @throws \think\db\exception\DbException + * @author xaboy + * @day 2020/10/20 + */ + public function updateLastTime($uid, $mer_id) + { + return UserMerchant::where(compact('uid', 'mer_id'))->update([ + 'last_time' => date('Y-m-d H:i:s') + ]); + } + + /** + * @param array $where + * @return mixed + * @author xaboy + * @day 2020/10/20 + */ + public function search(array $where) + { + return UserMerchant::alias('A')->leftJoin('User B', 'A.uid = B.uid') + ->when(isset($where['mer_id']) && $where['mer_id'] !== '', + function ($query) use ($where) { + $query->where('A.mer_id', $where['mer_id']); + } + ) + ->when(isset($where['nickname']) && $where['nickname'], function (BaseQuery $query) use ($where) { + return $query->where('B.nickname', 'like', '%' . $where['nickname'] . '%'); + })->when(isset($where['sex']) && $where['sex'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('B.sex', intval($where['sex'])); + })->when(isset($where['is_promoter']) && $where['is_promoter'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('B.is_promoter', $where['is_promoter']); + })->when(isset($where['uids']), function (BaseQuery $query) use ($where) { + return $query->whereIn('A.uid', $where['uids']); + })->when(isset($where['user_time_type']) && $where['user_time_type'] !== '' && $where['user_time'] != '', function ($query) use ($where) { + if ($where['user_time_type'] == 'visit') { + getModelTime($query, $where['user_time'], 'A.last_time'); + } + if ($where['user_time_type'] == 'add_time') { + getModelTime($query, $where['user_time'], 'A.create_time'); + } + })->when(isset($where['pay_count']) && $where['pay_count'] !== '', function ($query) use ($where) { + if ($where['pay_count'] == -1) { + $query->where('A.pay_num', 0); + } else { + $query->where('A.pay_num', '>', $where['pay_count']); + } + })->when(isset($where['label_id']) && $where['label_id'] !== '', function (BaseQuery $query) use ($where) { + return $query->whereRaw('CONCAT(\',\',A.label_id,\',\') LIKE \'%,' . $where['label_id'] . ',%\''); + })->when(isset($where['user_type']) && $where['user_type'] !== '', function (BaseQuery $query) use ($where) { + return $query->where('B.user_type', $where['user_type']); + })->where('A.status', 1); + } + + public function numUserIds($mer_id, $min, $max = null) + { + return UserMerchant::where('mer_id', $mer_id)->where('pay_num', '>=', $min)->when(!is_null($max), function ($query) use ($max) { + $query->where('pay_num', '<=', $max); + })->group('uid')->column('uid'); + } + + public function priceUserIds($mer_id, $min, $max = null) + { + return UserMerchant::where('mer_id', $mer_id)->where('pay_price', '>=', $min)->when(!is_null($max), function ($query) use ($max, $min) { + $query->where('pay_price', $min == $max ? '<=' : '<', $max); + })->group('uid')->column('uid'); + } } From 7ad82b6c82c2181905c4627df9ffd0071f3315cb Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 10:01:50 +0800 Subject: [PATCH 11/38] =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/model/EbStoreProduct.php | 24 +-- .../system/merchant/intention/lst.html | 143 ++++++++++++------ 2 files changed, 108 insertions(+), 59 deletions(-) diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php index 67c889a..c8b7617 100644 --- a/app/admin/model/EbStoreProduct.php +++ b/app/admin/model/EbStoreProduct.php @@ -49,22 +49,22 @@ class EbStoreProduct extends Model */ public function getList(?int $mer_id, array $where, int $page, int $limit) { - $query = self::search($mer_id, $where); - // ->with(['merCateId.category', 'storeCategory', 'brand']); + $query = self::search($mer_id, $where) + ->with(['merCateId.category', 'storeCategory', 'brand']); $count = $query->count(); $data = $query->field($this->filed)->page($page, $limit)->select(); - // $data->append(['us_status']); + $data->append(['us_status']); - // $list = hasMany( - // $data, - // 'mer_labels', - // ProductLabel::class, - // 'product_label_id', - // 'mer_labels', - // ['status' => 1], - // 'product_label_id,product_label_id id,label_name name' - // ); + $list = hasMany( + $data, + 'mer_labels', + ProductLabel::class, + 'product_label_id', + 'mer_labels', + ['status' => 1], + 'product_label_id,product_label_id id,label_name name' + ); return compact('count', 'list'); } diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html index 25f3cc8..8389bb8 100644 --- a/app/admin/view/merchant/system/merchant/intention/lst.html +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -9,36 +9,41 @@
- +
-
- -
-
- -
-
-
-
- +
+ +
+ +
+
+ + + + + + + + +
-
- -
- +
+
+ +
+
-
+
+ +
-
--> - -
+
@@ -47,12 +52,13 @@
- +
+ + + + + +
@@ -61,7 +67,7 @@
- {volist name="category" key="k" id="vo"} @@ -82,7 +88,7 @@
- {volist name="type" key="k" id="vo"} @@ -253,29 +259,72 @@ }); - //监听搜索提交 - // 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','table','element', 'jquery'], function () { var laydate = layui.laydate; //日期范围 laydate.render({ - elem: '#test6' + elem: '#range_date' //设置开始日期、日期日期的 input 选择器 //数组格式为 2.6.6 开始新增,之前版本直接配置 true 或任意分割字符即可 , range: ['#test-startDate-1', '#test-endDate-1'] + ,done: function(value, date, endDate){ + active['reload'] ? active['reload'].call(this) : ''; + } }); + + + // + var $ = layui.$, active = { + reload: function(){ + let dataRload = getformdata();; + console.log(dataRload) + //执行重载 + table.reload('intention_list', { + page: { + curr: 1 //重新从第 1 页开始 + } + ,where: { + ...dataRload + } + }); + } + }; + + + //监听button提交 + form.on('submit(searchform)', function(data) { + layui.pageTable.reload({ + where: { + ...data.field + }, + page: { + curr: 1 + } + }); + return false; + }); + + //监听select提交 + form.on('select(seleform)', function(data) { + active['reload'] ? active['reload'].call(this) : ''; + + return false; + }); + + + + // 获取表单所有参数 + function getformdata() { + var form = $('#filterform').serializeArray(); + var data = new Array(); + for(let i=0;i From 4b45813ca231a87b30e1f74c1f28b0c05ae857b5 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 10:03:23 +0800 Subject: [PATCH 12/38] =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E9=87=91=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/intention/lst.html | 143 ++++++++++++------ 1 file changed, 96 insertions(+), 47 deletions(-) diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html index 25f3cc8..8389bb8 100644 --- a/app/admin/view/merchant/system/merchant/intention/lst.html +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -9,36 +9,41 @@
- +
-
- -
-
- -
-
-
-
- +
+ +
+ +
+
+ + + + + + + + +
-
- -
- +
+
+ +
+
-
+
+ +
-
--> - -
+
@@ -47,12 +52,13 @@
- +
+ + + + + +
@@ -61,7 +67,7 @@
- {volist name="category" key="k" id="vo"} @@ -82,7 +88,7 @@
- {volist name="type" key="k" id="vo"} @@ -253,29 +259,72 @@ }); - //监听搜索提交 - // 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','table','element', 'jquery'], function () { var laydate = layui.laydate; //日期范围 laydate.render({ - elem: '#test6' + elem: '#range_date' //设置开始日期、日期日期的 input 选择器 //数组格式为 2.6.6 开始新增,之前版本直接配置 true 或任意分割字符即可 , range: ['#test-startDate-1', '#test-endDate-1'] + ,done: function(value, date, endDate){ + active['reload'] ? active['reload'].call(this) : ''; + } }); + + + // + var $ = layui.$, active = { + reload: function(){ + let dataRload = getformdata();; + console.log(dataRload) + //执行重载 + table.reload('intention_list', { + page: { + curr: 1 //重新从第 1 页开始 + } + ,where: { + ...dataRload + } + }); + } + }; + + + //监听button提交 + form.on('submit(searchform)', function(data) { + layui.pageTable.reload({ + where: { + ...data.field + }, + page: { + curr: 1 + } + }); + return false; + }); + + //监听select提交 + form.on('select(seleform)', function(data) { + active['reload'] ? active['reload'].call(this) : ''; + + return false; + }); + + + + // 获取表单所有参数 + function getformdata() { + var form = $('#filterform').serializeArray(); + var data = new Array(); + for(let i=0;i From 3bd30462d7e5f8919171e4c6eb313251b63626e9 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 10:05:57 +0800 Subject: [PATCH 13/38] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/product/Specs.php | 216 ------------------------ app/admin/view/product/specs/add.html | 167 ------------------ app/admin/view/product/specs/edit.html | 165 ------------------ app/admin/view/product/specs/index.html | 152 ----------------- 4 files changed, 700 deletions(-) delete mode 100644 app/admin/controller/product/Specs.php delete mode 100644 app/admin/view/product/specs/add.html delete mode 100644 app/admin/view/product/specs/edit.html delete mode 100644 app/admin/view/product/specs/index.html diff --git a/app/admin/controller/product/Specs.php b/app/admin/controller/product/Specs.php deleted file mode 100644 index c421474..0000000 --- a/app/admin/controller/product/Specs.php +++ /dev/null @@ -1,216 +0,0 @@ -adminInfo = get_login_admin(); - $this->category_id=354; - $this->url=[ - '/admin/product.priceDescription/index?category_id='.$this->category_id, - '/admin/product.priceDescription/add', - '/admin/product.priceDescription/edit', - '/admin/product.priceDescription/del', - '/admin/product.priceDescription/index', - ]; - } - - /** - * - * 商品价格列表 - * - */ - public function index() - { - if (request()->isAjax()) { - - $params= get_params(); - - $where = []; - - if (isset($params['keywords']) && !empty($params['keywords'])){ - $where[]= ['name','like','%'.$params['keywords'].'%']; - } - if($this->adminInfo['position_id'] != 1){ //不是超级管理员 - $www['admin_id'] = $this->adminInfo['id']; - $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find(); - if ($user_address){ - if($user_address['auth_range'] == 1){ - $where[] = ['village_id','=',$user_address['village_id']]; - }elseif ($user_address['auth_range'] == 2){ - $where[] = ['street_id','=',$user_address['street_id']]; - }elseif ($user_address['auth_range'] == 3){ - $where[] = ['area_id','=',$user_address['area_id']]; - }else{ - $where[] = ['village_id','=',$user_address['village_id']]; - } - }else{ - $where[] = ['village_id','=','']; - } - } - - $total = StoreBrandCategory::where($where)->count(); - - $list = StoreBrandCategory::order('sort desc')->select(); - - View::assign('url', $this->url); - View::assign('list', $list); - - $result = ['total' => $total, 'data' => $list]; - - return table_assign(0, '', $result); - - }else{ - - $list = StoreBrandCategory::select(); - - View::assign('url', $this->url); - View::assign('list', $list); - return view(); - } - } - - /** - * - * 新增 - * - */ - public function add() - { - if (request()->isAjax()) { - - $params = get_params(); - - $data['cate_name'] = $params['cate_name']; // 分类名称 - $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 - $data['pid'] = $params['pid']; // 上级分类 - $data['sort'] = $params['sort']; // 排序 - $data['create_time'] = date('Y-m-d H:i:s'); - - // 数据入库 - $res = StoreBrandCategory::create($data); - - if ($res){ - return to_assign(0,'操作成功',['aid'=>$res]); - } - - return to_assign(1, '操作失败,原因:'.$res); - - }else{ - - View::assign('editor', get_system_config('other','editor')); - View::assign('url', $this->url); - return view(); - } - } - - /** - * - * 编辑 - * - */ - public function edit() - { - $id = get_params("id"); - if(!$id) return to_assign(1, '非法操作!'); - - if (request()->isAjax()) { - - $params = get_params(); - - $data['cate_name'] = $params['cate_name']; // 分类名称 - $data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示 - $data['pid'] = $params['pid']; // 上级分类 - $data['sort'] = $params['sort']; // 排序 - $data['create_time'] = date('Y-m-d H:i:s'); - - // 数据更新 - $res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data); - - if ($res){ - return to_assign(0,'更新成功',['aid'=>$res]); - } - - return to_assign(1, '更新失败,原因:'.$res); - - }else{ - - $storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息 - - View::assign('detail', $storeBrandCtegory); - View::assign('url', $this->url); - return view(); - } - - } - - /** - * - * 删除 - * - */ - public function del() - { - $id = get_params("id"); - - if(!$id) return to_assign(1, '非法操作!'); - - // 验证下面是否有子分类 - if(StoreBrandCategory::where('pid', $id)->count()) - { - return to_assign(1, '请先删除子分类!'); - } - - $res = StoreBrandCategory::where('store_brand_category_id', $id)->delete(); - - if ($res){ - return to_assign(0,'操作成功',['aid'=>$res]); - } - - return to_assign(1, '操作失败,原因:'.$res); - - } - - /** - * - * 子分类 - * - */ - public function street($pcode) - { - $storeBrandCategory = StoreBrandCategory::order('sort desc') - ->where('is_show', 1) - ->where('pid', $pcode) - ->select(); - - return json($storeBrandCategory); - } - -} \ No newline at end of file diff --git a/app/admin/view/product/specs/add.html b/app/admin/view/product/specs/add.html deleted file mode 100644 index cd6974f..0000000 --- a/app/admin/view/product/specs/add.html +++ /dev/null @@ -1,167 +0,0 @@ -{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/product/specs/edit.html b/app/admin/view/product/specs/edit.html deleted file mode 100644 index e764766..0000000 --- a/app/admin/view/product/specs/edit.html +++ /dev/null @@ -1,165 +0,0 @@ -{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/product/specs/index.html b/app/admin/view/product/specs/index.html deleted file mode 100644 index 4c48c45..0000000 --- a/app/admin/view/product/specs/index.html +++ /dev/null @@ -1,152 +0,0 @@ -{extend name="common/base"/} - -{block name="body"} - -
-
-
- -
- -
-
-
- - - - - - - - -{/block} - - - -{block name="script"} - -{/block} - \ No newline at end of file From 45468a70a18c95a9ad3d4770dcb58dd01e97d85b Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 11:28:29 +0800 Subject: [PATCH 14/38] =?UTF-8?q?=E5=95=86=E6=88=B7=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantIntention.php | 28 +++- .../system/merchant/intention/lst.html | 47 +++++-- .../system/merchant/intention/status.html | 66 +++++++++ .../system/merchant/MerchantIntention.php | 132 +++++++++++++++++- 4 files changed, 256 insertions(+), 17 deletions(-) create mode 100644 app/admin/view/merchant/system/merchant/intention/status.html diff --git a/app/admin/controller/merchant/system/merchant/MerchantIntention.php b/app/admin/controller/merchant/system/merchant/MerchantIntention.php index 66f14dd..282cf95 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantIntention.php +++ b/app/admin/controller/merchant/system/merchant/MerchantIntention.php @@ -29,6 +29,7 @@ class MerchantIntention extends BaseController $this->intention = $intention; $this->path = [ 'index' => 'merchant/system/merchant/intention/lst', + 'status' => 'merchant/system/merchant/intention/status', 'mark' => 'merchant/system/merchant/intention/mark', 'read' => 'merchant/system/merchant/intention/read', 'add' => 'merchant/system/merchant/intention/add' @@ -69,9 +70,34 @@ class MerchantIntention extends BaseController return to_assign(0, '', $data); } + /** + * 审核表单 + */ public function StatusForm() { - return View($this->path['index']); + $id = get_params('id'); + if (!$this->intention->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) + return to_assign(1,'数据不存在'); + + return View($this->path['status'], ['id'=>$id]); + } + + /** + * 审核 + */ + public function SwitchStatus() + { + $params = get_params(['status','fail_msg','create_mer','id']); + $id = $params['id']; + + //创建 + if (!$this->intention->GetWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) + return to_assign(1,'数据不存在'); + + $params['status'] = $params['status'] == 1 ? 1 : 2; + $this->intention->updateStatus($id, $params); + + return to_assign(0,'修改成功'); } public function MarkForm() diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html index 8389bb8..99b24ba 100644 --- a/app/admin/view/merchant/system/merchant/intention/lst.html +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -17,15 +17,15 @@
-
- - - - - - - - +
+ + + + + + + +
@@ -52,8 +52,8 @@
-
- +
+ @@ -67,10 +67,10 @@
- {volist name="category" key="k" id="vo"} - + {/volist}
@@ -88,10 +88,10 @@
- {volist name="type" key="k" id="vo"} - + {/volist}
@@ -124,6 +124,7 @@ +{/block} + \ No newline at end of file diff --git a/app/common/model/merchant/system/merchant/MerchantIntention.php b/app/common/model/merchant/system/merchant/MerchantIntention.php index aaba01c..febcf25 100644 --- a/app/common/model/merchant/system/merchant/MerchantIntention.php +++ b/app/common/model/merchant/system/merchant/MerchantIntention.php @@ -12,6 +12,7 @@ namespace app\common\model\merchant\system\merchant; use app\common\model\merchant\system\merchant\MerchantCategory; use think\Model; +use think\exception\ValidateException; /** * @mixin \think\Model @@ -102,10 +103,139 @@ class MerchantIntention extends Model $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(); + echo $count = self::where(['mer_intention_id' => $mer_intention_id, 'is_del' => 0])->count(); return $count; } + + /** + * 审核 + * TODO: 未完全 + */ + public function updateStatus($id, $data) + { + $create = $data['create_mer'] == 1; + unset($data['create_mer']); + $intention = $this->search(['mer_intention_id' => $id])->find(); + $smsData = []; + if (!$intention) + throw new ValidateException('信息不存在'); + if ($intention->status) + throw new ValidateException('状态有误,修改失败'); + + //TODO: 此处需开发为可配置字段 + $config = ['broadcast_room_type'=>0, 'broadcast_goods_type'=>0]; + + $margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']); + $data['is_margin'] = $margin['is_margin'] ?? -1; + $data['margin'] = $margin['margin'] ?? 0; + $merData = []; + if ($create) { + $password = substr($intention['phone'], -6); + $merData = [ + 'mer_name' => $intention['mer_name'], + 'mer_phone' => $intention['phone'], + 'mer_account' => $intention['phone'], + 'category_id' => $intention['merchant_category_id'], + 'type_id' => $intention['mer_type_id'], + 'real_name' => $intention['name'], + 'status' => 1, + 'is_audit' => 1, + // 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, + // 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, + 'is_bro_room' => empty($config['broadcast_room_type']) ? 0 : 1, + 'is_bro_goods' => !empty($config['broadcast_goods_type']) ? 0 : 1, + 'mer_password' => $password, + 'is_margin' => $margin['is_margin'] ?? -1, + 'margin' => $margin['margin'] ?? 0, + 'area_id' => $intention['area_id'] ?? 0, + 'geo_street' => $intention['street_id'] ?? 0, + 'village_id' => $intention['village_id'] ?? 0, + 'is_nmsc' => $intention['is_nmsc'] ?? 0, + ]; + if ($data['status'] == 1) { + $data['fail_msg'] = ''; + $smsData = [ + 'date' => date('m月d日', strtotime($intention->create_time)), + 'mer' => $intention['mer_name'], + 'phone' => $intention['phone'], + 'pwd' => $password ?? '', + // 'site_name' => systemConfig('site_name'), + ]; + } + } + if ($data['status'] == 2) { + $smsData = [ + 'phone' => $intention['phone'], + 'date' => date('m月d日', strtotime($intention->create_time)), + 'mer' => $intention['mer_name'], + // 'site' => systemConfig('site_name'), + ]; + } + + self::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData) { + if ($data['status'] == 1) { + if ($create) { + $merchant = self::createMerchant($merData); + $data['mer_id'] = $merchant->mer_id; + // 暂不开通通知 + // Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]); + } + } else { + // Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_FAIL', 'id' => $smsData]); + } + $intention->save($data); + }); + } + + + + /** + * @param array $data + * @author xaboy + * @day 2020-04-17 + */ + protected function createMerchant(array $data) + { + if ($this->fieldExists('mer_name', $data['mer_name'])) + throw new ValidateException('商户名已存在'); + if ($data['mer_phone'] && isPhone($data['mer_phone'])) + throw new ValidateException('请输入正确的手机号'); + $merchantCategoryRepository = app()->make(MerchantCategoryRepository::class); + $adminRepository = app()->make(MerchantAdminRepository::class); + + if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) + throw new ValidateException('商户分类不存在'); + if ($adminRepository->fieldExists('account', $data['mer_account'])) + throw new ValidateException('账号已存在'); + + /** @var MerchantAdminRepository $make */ + $make = app()->make(MerchantAdminRepository::class); + + $margin = app()->make(MerchantTypeRepository::class)->get($data['type_id']); + $data['is_margin'] = $margin['is_margin'] ?? -1; + $data['margin'] = $margin['margin'] ?? 0; + + return Db::transaction(function () use ($data, $make) { + $account = $data['mer_account']; + $password = $data['mer_password']; + unset($data['mer_account'], $data['mer_password']); + + $merchant = $this->dao->create($data); + $make->createMerchantAccount($merchant, $account, $password); + $address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['geo_street']]); + if($data['area_id'] && $data['village_id']){ + Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); + } + app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id); + app()->make(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id); + return $merchant; + }); + } + } From 09c655dc214aeef1e3a1414d879b533fdc865adc Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 14:26:53 +0800 Subject: [PATCH 15/38] =?UTF-8?q?=E5=95=86=E6=88=B7=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8bug=E4=BF=AE=E5=A4=8Dv1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/merchant/common.php | 899 ++++++++++++++++++ .../model/merchant/store/ShippingTemplate.php | 118 +++ .../merchant/store/ShippingTemplateFree.php | 23 + .../merchant/store/ShippingTemplateRegion.php | 28 + .../store/ShippingTemplateUndelive.php | 15 + .../merchant/store/product/ProductCopy.php | 91 ++ .../merchant/system/config/SystemConfig.php | 15 + .../system/config/SystemConfigClassify.php | 14 + .../system/config/SystemConfigValue.php | 155 +++ .../merchant/system/merchant/Merchant.php | 67 ++ .../system/merchant/MerchantAdmin.php | 51 + .../system/merchant/MerchantCategory.php | 27 + .../system/merchant/MerchantIntention.php | 49 +- 13 files changed, 1534 insertions(+), 18 deletions(-) create mode 100644 app/common/model/merchant/common.php create mode 100644 app/common/model/merchant/store/ShippingTemplate.php create mode 100644 app/common/model/merchant/store/ShippingTemplateFree.php create mode 100644 app/common/model/merchant/store/ShippingTemplateRegion.php create mode 100644 app/common/model/merchant/store/ShippingTemplateUndelive.php create mode 100644 app/common/model/merchant/store/product/ProductCopy.php create mode 100644 app/common/model/merchant/system/config/SystemConfig.php create mode 100644 app/common/model/merchant/system/config/SystemConfigClassify.php create mode 100644 app/common/model/merchant/system/config/SystemConfigValue.php diff --git a/app/common/model/merchant/common.php b/app/common/model/merchant/common.php new file mode 100644 index 0000000..b61090b --- /dev/null +++ b/app/common/model/merchant/common.php @@ -0,0 +1,899 @@ + +// +---------------------------------------------------------------------- + +// 应用公共文件 + +use app\common\model\merchant\system\config\SystemConfigValue; +// use app\common\model\merchant\system\groupData\GroupData; +// use crmeb\services\UploadService; +// use Swoole\Lock; +use think\db\BaseQuery; + +if (!function_exists('isDebug')) { + function isDebug(): bool + { + return !!env('APP_DEBUG'); + } +} + +if (!function_exists('formToData')) { + function formToData($form): array + { + $rule = $form->formRule(); + $action = $form->getAction(); + $method = $form->getMethod(); + $title = $form->getTitle(); + $config = (object)$form->formConfig(); + $admin = config('admin.api_admin_prefix'); + $merchant = config('admin.api_merchant_prefix'); + $api = $action; + if (strpos($api, '/' . $admin) === 0) { + $api = substr($api, strlen($admin) + 1); + } else if (strpos($api, '/' . $merchant) === 0) { + $api = substr($api, strlen($merchant) + 1); + } + $api = str_replace('.html', '', $api); + return compact('rule', 'action', 'method', 'title', 'config', 'api'); + } +} + +if (!function_exists('getDistance')) { + + function getDistance($lat1, $lng1, $lat2, $lng2) + { + //将角度转为狐度 + $radLat1 = deg2rad($lat1); //deg2rad()函数将角度转换为弧度 + $radLat2 = deg2rad($lat2); + $radLng1 = deg2rad($lng1); + $radLng2 = deg2rad($lng2); + $a = $radLat1 - $radLat2; + $b = $radLng1 - $radLng2; + $s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6371; + return round($s, 1); + } +} + +/** + * 无线级分类处理 + * + * @param array $data 数据源 + * @param string $idName 主键 + * @param string $fieldName 父级字段 + * @param string $childrenKey 子级字段名 + * @return array + * @author 张先生 + * @date 2020-03-27 + */ +if (!function_exists('formatCategory')) { + function formatCategory(array $data, string $idName = "id", string $fieldName = 'pid', $childrenKey = 'children') + { + $items = []; + foreach ($data as $item) { + $items[$item[$idName]] = $item; + } + $result = array(); + foreach ($items as $item) { + if (isset($items[$item[$fieldName]])) { + $items[$item[$fieldName]][$childrenKey][] = &$items[$item[$idName]]; + } else if ($item[$fieldName] == 0) { + $result[] = &$items[$item[$idName]]; + } + } + return $result; + } +} + +if (!function_exists('formatTreeList')) { + function formatTreeList(&$options, $name, $pidName = 'pid', $pid = 0, $level = 0, &$data = []): array + { + $_options = $options; + foreach ($_options as $k => $option) { + if ($option[$pidName] == $pid) { + $data[] = ['value' => $k, 'label' => str_repeat('|---', $level + 1) . $option[$name]]; + unset($options[$k]); + formatTreeList($options, $name, $pidName, $k, $level + 1, $data); + } + } + return $data; + } +} + +if (!function_exists('formatTree')) { + function formatTree(&$options, $name, $pidName = 'pid', $pid = 0, $level = 0, $data = []): array + { + $_options = $options; + foreach ($_options as $k => $option) { + if ($option[$pidName] == $pid) { + $value = ['id' => $k, 'title' => $option[$name]]; + unset($options[$k]); + $value['children'] = formatTree($options, $name, $pidName, $k, $level + 1); + $data[] = $value; + } + } + return $data; + } +} + +if (!function_exists('formatCascaderData')) { + function formatCascaderData(&$options, $name, $baseLevel = 0, $pidName = 'pid', $pid = 0, $level = 0, $data = []): array + { + $_options = $options; + foreach ($_options as $k => $option) { + if ($option[$pidName] == $pid) { + $value = ['value' => $k, 'label' => $option[$name]]; + unset($options[$k]); + $value['children'] = formatCascaderData($options, $name, $baseLevel, $pidName, $k, $level + 1); + if (!count($value['children'])) unset($value['children']); + $data[] = $value; + } + } + return $data; + } +} + + +/** + * @function toMap 数组重新组装 + * @param array $data 数据 + * @param string $field key + * @param string $value value default null + * @return array + * @author 张先生 + * @date 2020-04-01 + */ +if (!function_exists('toMap')) { + function toMap(array $data, $field = 'id', $value = '') + { + $result = array(); + + if (empty($data)) { + return $result; + } + + //开始处理数据 + foreach ($data as $item) { + $val = $item; + if (!empty($value)) { + $val = $item[$value]; + } + $result[$item[$field]] = $val; + } + + return $result; + } +} + +/** + * @function getUniqueListByArray 从数组中获取某个字段的值,重新拼装成新的一维数组 + * @param array $data 数据 + * @param string $field key + * @return array + * @author 张先生 + * @date 2020-04-01 + */ +if (!function_exists('getUniqueListByArray')) { + function getUniqueListByArray(array $data, $field = 'id') + { + return array_unique(array_values(array_column($data, $field))); + } +} + + +if (!function_exists('isPhone')) { + function isPhone($test) + { + return !preg_match("/^1[3456789]{1}\d{9}$/", $test); + } +} + +if (!function_exists('getMonth')) { + /** + * 获取本季度 time + * @param int|string $time + * @param $ceil + * @return array + */ + function getMonth($time = '', $ceil = 0) + { + if ($ceil != 0) + $season = ceil(date('n') / 3) - $ceil; + else + $season = ceil(date('n') / 3); + $firstday = date('Y-m-01', mktime(0, 0, 0, ($season - 1) * 3 + 1, 1, date('Y'))); + $lastday = date('Y-m-t', mktime(0, 0, 0, $season * 3, 1, date('Y'))); + return array($firstday, $lastday); + } +} + + +if (!function_exists('getModelTime')) { + /** + * @param BaseQuery $model + * @param string $section + * @param string $prefix + * @param string $field + * @return mixed + * @author xaboy + * @day 2020-04-29 + */ + function getModelTime(BaseQuery $model, string $section, $prefix = 'create_time', $field = '-',$time = '') + { + if (!isset($section)) return $model; + switch ($section) { + case 'today': + $model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('today')), date('Y-m-d H:i:s', strtotime('tomorrow -1second'))]); + break; + case 'week': + $model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('this week 00:00:00')), date('Y-m-d H:i:s', strtotime('next week 00:00:00 -1second'))]); + break; + case 'month': + $model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('first Day of this month 00:00:00')), date('Y-m-d H:i:s', strtotime('first Day of next month 00:00:00 -1second'))]); + break; + case 'year': + $model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('this year 1/1')), date('Y-m-d H:i:s', strtotime('next year 1/1 -1second'))]); + break; + case 'yesterday': + $model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('yesterday')), date('Y-m-d H:i:s', strtotime('today -1second'))]); + break; + case 'quarter': + list($startTime, $endTime) = getMonth(); + $model = $model->where($prefix, '>', $startTime); + $model = $model->where($prefix, '<', $endTime); + break; + case 'lately7': + $model = $model->where($prefix, 'between', [date('Y-m-d', strtotime("-7 day")), date('Y-m-d H:i:s')]); + break; + case 'lately30': + $model = $model->where($prefix, 'between', [date('Y-m-d', strtotime("-30 day")), date('Y-m-d H:i:s')]); + break; + default: + if (strstr($section, $field) !== false) { + list($startTime, $endTime) = explode($field, $section); + if (strlen($startTime) == 4) { + $model->whereBetweenTime($prefix, date('Y-m-d H:i:s', strtotime($section)), date('Y-m-d H:i:s', strtotime($section . ' +1day -1second'))); + } else { + if ($startTime == $endTime) { + $model = $model->whereBetweenTime($prefix, date('Y-m-d 0:0:0', strtotime($startTime)), date('Y-m-d 23:59:59', strtotime($endTime))); + } else if(strpos($startTime, ':')) { + $model = $model->whereBetweenTime($prefix, $startTime, $endTime); + } else { + $model = $model->whereBetweenTime($prefix, date('Y-m-d H:i:s', strtotime($startTime)), date('Y-m-d H:i:s', strtotime($endTime . ' +1day -1second'))); + } + } + } + break; + } + return $model; + } +} + +if (!function_exists('hasMany')) { + function hasMany($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*') + { + $ids = []; + $link = []; + + if (!$collection) return []; + $collection = $collection->toArray(); + foreach ($collection as $k => $item) { + if (is_array($item[$field])) { + $link[$k] = array_unique($item[$field]); + $ids = array_merge($item[$field], $ids); + } else { + $link[$k] = array_unique(explode(',', $item[$field])); + } + $ids = array_merge($link[$k], $ids); + if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]); + } + $ids = array_filter(array_unique($ids)); + if (!count($ids)) { + return $collection; + } + $many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select(); + + if (!$many) return $collection; + $many = $many->toArray(); + foreach ($link as $k => $val) { + foreach ($many as $item) { + if (in_array($item[$searchKey], $val)) { + + if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = []; + + $collection[$k][$insertKey][] = $item; + } + } + } + + return $collection; + } +} + +if (!function_exists('activeProductSku')) { + //格式活动商品SKU + function activeProductSku($activeData, $type = null) + { + $make = app()->make(\app\common\model\merchant\store\product\Product::class); + $price = 0; + $data = []; + foreach($activeData as $key => $value) { + $maxPrice = 0; + $must_price = 0; + $attrValue = []; + if(is_null($value['product'])) continue; + $productSku = $value['productSku']; + $productAttr = $value['product']['attr']; + $productAttrValue = $value['product']['attrValue']; + unset($value['productSku'], $value['product']['attrValue'], $value['product']['attr']); + foreach ($productAttrValue as $attr_value) { + if (!empty($productSku)){ + foreach ($productSku as $sk => $sv) { + if ( $sv['unique'] == $attr_value['unique']) { + if ($type == 'discounts') { + unset($attr_value['ot_price'], $attr_value['price']); + $attr_value['ot_price'] = $sv['price']; + $attr_value['price'] = $sv['active_price']; + $_price = bcsub($sv['price'], $sv['active_price'], 2); + if ($value['type']){ + $must_price = $must_price > $_price ? $must_price : $_price; + } else { + $maxPrice = $maxPrice > $_price ? $maxPrice : $_price; + } + } else { + $attr_value['productSku'] = $sv; + } + $attrValue[] = $attr_value; + } + } + } + } + $attr = $make->detailAttr($productAttr); + if ($type == 'discounts') { + $sku = $make->detailAttrValue($attrValue, null); + $value['product']['sku'] = $sku; + + } else { + $value['product']['attrValue'] = $attrValue; + } + $value['product']['attr'] = $attr; + $price = bcadd($price, bcadd($must_price,$maxPrice,2), 2); + if ($value['type'] == 1) { + array_unshift($data,$value); + }else { + $data[] = $value; + } + } + return compact('data', 'price'); + } +} + + +if (!function_exists('systemConfig')) { + /** + * 获取系统配置 + * + * @param string|string[] $key + * @return mixed + * @author xaboy + * @day 2020-05-08 + */ + function systemConfig($key) + { + return merchantConfig(0, $key); + } +} + +if (!function_exists('getDatesBetweenTwoDays')) { + function getDatesBetweenTwoDays($startDate, $endDate) + { + $dates = []; + if (strtotime($startDate) > strtotime($endDate)) { + //如果开始日期大于结束日期,直接return 防止下面的循环出现死循环 + return $dates; + } elseif ($startDate == $endDate) { + //开始日期与结束日期是同一天时 + array_push($dates, date('m-d', strtotime($startDate))); + return $dates; + } else { + array_push($dates, date('m-d', strtotime($startDate))); + $currentDate = $startDate; + do { + $nextDate = date('Y-m-d', strtotime($currentDate . ' +1 days')); + array_push($dates, date('m-d', strtotime($currentDate . ' +1 days'))); + $currentDate = $nextDate; + } while ($endDate != $currentDate); + return $dates; + } + } +} + +if (!function_exists('getStartModelTime')) { + function getStartModelTime(string $section) + { + switch ($section) { + case 'today': + case 'yesterday': + return date('Y-m-d', strtotime($section)); + case 'week': + return date('Y-m-d', strtotime('this week')); + case 'month': + return date('Y-m-d', strtotime('first Day of this month')); + case 'year': + return date('Y-m-d', strtotime('this year 1/1')); + case 'quarter': + list($startTime, $endTime) = getMonth(); + return $startTime; + case 'lately7': + return date('Y-m-d', strtotime("-7 day")); + case 'lately30': + return date('Y-m-d', strtotime("-30 day")); + default: + if (strstr($section, '-') !== false) { + list($startTime, $endTime) = explode('-', $section); + return date('Y-m-d H:i:s', strtotime($startTime)); + } + return date('Y-m-d H:i:s'); + } + } +} + +if (!function_exists('merchantConfig')) { + /** + * 获取商户配置 + * + * @param int $merId + * @param string|string[] $key + * @return mixed + * @author xaboy + * @day 2020-05-08 + */ + function merchantConfig(int $merId, $key) + { + $request = request(); + $make = app()->make(SystemConfigValue::class); + if (is_array($key)) { + $_key = []; + $cacheData = []; + foreach ($key as $v) { + if ($request->hasCache($merId, $v)) { + $cacheData[$v] = $request->getCache($merId, $v); + } else { + $_key[] = $v; + } + } + if (!count($_key)) return $cacheData; + $data = $make->more($_key, $merId); + $request->setCache($merId, $data); + $data += $cacheData; + } else { + if ($request->hasCache($merId, $key)) { + $data = $request->getCache($merId, $key); + } else { + $data = $make->get($key, $merId); + $request->setCache($merId, $key, $data); + } + } + return $data; + } +} + +if (!function_exists('filter_emoji')) { + + // 过滤掉emoji表情 + function filter_emoji($str) + { + $str = preg_replace_callback( //执行一个正则表达式搜索并且使用一个回调进行替换 + '/./u', + function (array $match) { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, + $str + ); + return $str; + } +} + +if (!function_exists('setHttpType')) { + + /** + * TODO 修改 https 和 http 移动到common + * @param $url $url 域名 + * @param int $type 0 返回https 1 返回 http + * @return string + */ + function setHttpType($url, $type = 0) + { + $domainTop = substr($url, 0, 5); + if ($type) { + if ($domainTop == 'https') $url = 'http' . substr($url, 5, strlen($url)); + } else { + if ($domainTop != 'https') $url = 'https:' . substr($url, 5, strlen($url)); + } + return $url; + } +} + +if (!function_exists('remoteImage')) { + + /** + * TODO 获取小程序二维码是否生成 + * @param $url + * @return array + */ + function remoteImage($url) + { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + $result = curl_exec($curl); + $result = json_decode($result, true); + if (is_array($result)) return ['status' => false, 'msg' => $result['errcode'] . '---' . $result['errmsg']]; + return ['status' => true]; + } +} + +if (!function_exists('image_to_base64')) { + /** + * 获取图片转为base64 + * @param string $avatar + * @return bool|string + */ + function image_to_base64($avatar = '', $timeout = 9) + { + try { + $url = parse_url($avatar); + $url = $url['host']; + $header = [ + 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0', + 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3', + 'Accept-Encoding: gzip, deflate, br', + 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', + 'Host:' . $url + ]; + $dir = pathinfo($url); + $host = $dir['dirname']; + $refer = $host . '/'; + $curl = curl_init(); + curl_setopt($curl, CURLOPT_REFERER, $refer); + curl_setopt($curl, CURLOPT_URL, $avatar); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($curl, CURLOPT_HTTPHEADER, $header); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); + $data = curl_exec($curl); + $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + curl_close($curl); + if ($code == 200) { + return "data:image/jpeg;base64," . base64_encode($data); + } else { + return false; + } + } catch (Exception $e) { + return false; + } + } +} + + +if (!function_exists('put_image')) { + /** + * 获取图片转为base64 + * @param string $avatar + * @return bool|string + */ + function put_image($url, $filename = '') + { + + if ($url == '') { + return false; + } + try { + if ($filename == '') { + + $ext = pathinfo($url); + if ($ext['extension'] != "jpg" && $ext['extension'] != "png" && $ext['extension'] != "jpeg") { + return false; + } + $filename = time() . "." . $ext['extension']; + } + + //文件保存路径 + ob_start(); + readfile($url); + $img = ob_get_contents(); + ob_end_clean(); + $path = 'public/uploads/qrcode'; + $fp2 = fopen($path . '/' . $filename, 'a'); + fwrite($fp2, $img); + fclose($fp2); + return $path . '/' . $filename; + } catch (Exception $e) { + return false; + } + } +} + +if (!function_exists('path_to_url')) { + /** + * 路径转url路径 + * @param $path + * @return string + */ + function path_to_url($path) + { + return trim(str_replace(DIRECTORY_SEPARATOR, '/', $path), '.'); + } +} + +if (!function_exists('tidy_url')) { + /** + * 路径转url路径 + * @param $url + * @param int $http + * @param string $site + * @return string + */ + function tidy_url($url, $http = null, $site = null) + { + if (!$site) { + $site = systemConfig('site_url'); + } + $url = path_to_url($url); + if (strpos($url, 'http') === false) + $url = rtrim($site, '/') . '/' . ltrim($url, '/'); + + if (is_null($http)) { + $http = (parse_url($site)['scheme'] ?? '') == 'https' ? 0 : 1; + } + $url = set_http_type($url, $http); + return $url; + } +} + + +if (!function_exists('curl_file_exist')) { + /** + * CURL 检测远程文件是否在 + * @param $url + * @return bool + */ + function curl_file_exist($url) + { + $ch = curl_init(); + try { + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + $contents = curl_exec($ch); + if (preg_match("/404/", $contents)) return false; + if (preg_match("/403/", $contents)) return false; + return true; + } catch (Exception $e) { + return false; + } + } +} + + +if (!function_exists('set_http_type')) { + /** + * 修改 https 和 http + * @param $url $url 域名 + * @param int $type 0 返回https 1 返回 http + * @return string + */ + function set_http_type($url, $type = 0) + { + $domainTop = substr($url, 0, 5); + if ($type) { + if ($domainTop == 'https') $url = 'http' . substr($url, 5, strlen($url)); + } else { + if ($domainTop != 'https') $url = 'https:' . substr($url, 5, strlen($url)); + } + return $url; + } +} + + +if (!function_exists('getTimes')) { + function getTimes() + { + $dates = []; + for ($i = 0; $i <= 24; $i++) { + for ($j = 0; $j < 60; $j++) { + $dates[] = sprintf('%02.d', $i) . ':' . sprintf('%02.d', $j); + } + } + return $dates; + } +} + +if (!function_exists('monday')) { + /** + * 获取周一 + * + * @param null $time + * @return false|string + * @author xaboy + * @day 2020/6/22 + */ + function monday($time = null) + { + return date('Y-m-d', strtotime('Sunday -6 day', $time ?: time())); + } +} + + +if (!function_exists('attr_format')) { + /** + * 格式化属性 + * @param $arr + * @return array + */ + function attr_format($arr) + { + $data = []; + $res = []; + $count = count($arr); + if ($count > 1) { + for ($i = 0; $i < $count - 1; $i++) { + if ($i == 0) $data = $arr[$i]['detail']; + //替代变量1 + $rep1 = []; + foreach ($data as $v) { + foreach ($arr[$i + 1]['detail'] as $g) { + //替代变量2 + $rep2 = ($i != 0 ? '' : $arr[$i]['value'] . '_$_') . $v . '-$-' . $arr[$i + 1]['value'] . '_$_' . $g; + $tmp[] = $rep2; + if ($i == $count - 2) { + foreach (explode('-$-', $rep2) as $k => $h) { + //替代变量3 + $rep3 = explode('_$_', $h); + //替代变量4 + $rep4['detail'][$rep3[0]] = isset($rep3[1]) ? $rep3[1] : ''; + } + if ($count == count($rep4['detail'])) + $res[] = $rep4; + } + } + } + $data = isset($tmp) ? $tmp : []; + } + } else { + $dataArr = []; + foreach ($arr as $k => $v) { + foreach ($v['detail'] as $kk => $vv) { + $dataArr[$kk] = $v['value'] . '_' . $vv; + $res[$kk]['detail'][$v['value']] = $vv; + } + } + $data[] = implode('-', $dataArr); + } + return [$data, $res]; + } +} + +if (!function_exists('filter_emoji')) { + //过滤掉emoji表情 + function filter_emoji($str) + { + $str = preg_replace_callback('/./u', function (array $match) { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, $str); + return $str; + } +} + +/** + * 高德经纬度改百度经纬度 + * @param $lng 经度 + * @param $lat 纬度 + * @return mixed + */ +if (!function_exists('bd_encrypt')) { + function bd_encrypt($lng, $lat) + { + $x_pi = 3.14159265358979324 * 3000.0 / 180.0; + $x = $lng; + $y = $lat; + $z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi); + $theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi); + + $data['lng'] = $z * cos($theta) + 0.0065; + $data['lat'] = $z * sin($theta) + 0.006; + return $data; + } +} + + +if (!function_exists('aj_captcha_check_one')) { + /** + * 验证滑块1次验证 + * @param string $token + * @param string $pointJson + * @return bool + */ + function aj_captcha_check_one(string $captchaType, string $token, string $pointJson) + { + aj_get_serevice($captchaType)->check($token, $pointJson); + return true; + } +} + +if (!function_exists('aj_captcha_check_two')) { + /** + * 验证滑块2次验证 + * @param string $token + * @param string $pointJson + * @return bool + */ + function aj_captcha_check_two(string $captchaType, string $captchaVerification ) + { + aj_get_serevice($captchaType)->verificationByEncryptCode($captchaVerification); + return true; + } +} + + +if (!function_exists('validateIDCard')) { + + function validateIDCard(string $idcard) + { + if(empty($idcard)){ + return false; + }else{ + $idcard = strtoupper($idcard); # 如果是小写x,转化为大写X + if(strlen($idcard) != 18 && strlen($idcard) != 15){ + return false; + } + # 如果是15位身份证,则转化为18位 + if(strlen($idcard) == 15){ + # 如果身份证顺序码是996 997 998 999,这些是为百岁以上老人的特殊编码 + if (array_search(substr($idcard, 12, 3), array('996', '997', '998', '999')) !== false) { + $idcard = substr($idcard, 0, 6) . '18' . substr($idcard, 6, 9); + } else { + $idcard = substr($idcard, 0, 6) . '19' . substr($idcard, 6, 9); + } + # 加权因子 + $factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); + # 校验码对应值 + $code = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); + $checksum = 0; + for ($i = 0; $i < strlen($idcard); $i++) { + $checksum += substr($idcard, $i, 1) * $factor[$i]; + } + $idcard = $idcard . $code[$checksum % 11]; + } + # 验证身份证开始 + $IDCardBody = substr($idcard, 0, 17); # 身份证主体 + $IDCardCode = strtoupper(substr($idcard, 17, 1)); # 身份证最后一位的验证码 + + # 加权因子 + $factor = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); + # 校验码对应值 + $code = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'); + $checksum = 0; + for ($i = 0; $i < strlen($IDCardBody); $i++) { + $checksum += substr($IDCardBody, $i, 1) * $factor[$i]; + } + $validateIdcard = $code[$checksum % 11]; # 判断身份证是否合理 + if($validateIdcard != $IDCardCode){ + return false; + }else{ + return true; + } + } + } +} + + diff --git a/app/common/model/merchant/store/ShippingTemplate.php b/app/common/model/merchant/store/ShippingTemplate.php new file mode 100644 index 0000000..6fdd5b3 --- /dev/null +++ b/app/common/model/merchant/store/ShippingTemplate.php @@ -0,0 +1,118 @@ + "默认模板", + "type" => 1, + "appoint" => 0, + "undelivery" => 0, + 'mer_id' => $merId, + "region" => [[ + "first" => 0, + "first_price" => 0, + "continue" => 0, + "continue_price" => 0, + "city_id" => 0 + ]] + ]; + return $this->createTemp($data); + } + + /** + * @Author:Qinii + * @Date: 2020/5/13 + * @param array $data + */ + public function createTemp(array $data) + { + Db::transaction(function()use ($data) { + $region = $data['region']; + $free = $data['free'] ?? ''; + $undelives = $data['undelives'] ?? ''; + unset($data['region'],$data['free'],$data['undelives'],$data['city_ids']); + $temp = self::create($data); + if($data['appoint']) { + $settlefree = $this->settleFree($free, $temp['shipping_template_id']); + (new ShippingTemplateFree)->insertAll($settlefree); + } + $settleRegion = $this->settleRegion($region, $temp['shipping_template_id']); + (new ShippingTemplateRegion)->insertAll($settleRegion); + if($data['undelivery'] == 1){ + $settleUndelives = $this->settleUndelives($undelives,$temp['shipping_template_id']); + (new ShippingTemplateUndelive)->create($settleUndelives); + } + }); + } + + /** + * @param $data + * @param $id + * @return array + * @author Qinii + */ + public function settleFree($data,$id) + { + foreach ($data as $v){ + if (isset($v['city_id']) && !is_array($v['city_id'])) throw new ValidateException('包邮参数类型错误'); + $city = '/'.implode('/',$v['city_id']).'/'; + $free[] = [ + 'temp_id' => $id, + 'city_id' => $city, + 'number' => $v['number'], + 'price' => $v['price'] + ]; + } + return $free; + } + + /** + * @Author:Qinii + * @Date: 2020/5/13 + * @param $data + * @param $id + * @return array + */ + public function settleRegion($data,$id) + { + $result = []; + foreach ($data as $k => $v){ + $result[] = [ + 'city_id' => ($k > 0 ) ? '/'.implode('/',$v['city_id']).'/' : 0, + 'temp_id' => $id, + 'first' => $v['first'], + 'first_price'=> $v['first_price'], + 'continue' => $v['continue'], + 'continue_price'=> $v['continue_price'], + ]; + } + return $result; + } + + /** + * @param $data + * @param $id + * @return array + * @author Qinii + */ + public function settleUndelives($data,$id) + { + if (isset($v['city_id']) && !is_array($data['city_id'])) throw new ValidateException('指定不配送参数类型错误'); + return ['temp_id' => $id, 'city_id' => $data['city_id']]; + } +} \ No newline at end of file diff --git a/app/common/model/merchant/store/ShippingTemplateFree.php b/app/common/model/merchant/store/ShippingTemplateFree.php new file mode 100644 index 0000000..e03f882 --- /dev/null +++ b/app/common/model/merchant/store/ShippingTemplateFree.php @@ -0,0 +1,23 @@ + 'sys', + 'num' => systemConfig('copy_product_defaul'), + 'message' => '赠送次数', + ]; + $this->add($data,$merId); + } + } + + + /** + * TODO 添加记录并修改数据 + * @param $data + * @param $merId + * @author Qinii + * @day 2020-08-06 + */ + public function add($data,$merId) + { + $make = app()->make(Merchant::class); + $getOne = $make->get($merId); + + switch ($data['type']) { + case 'mer_dump': + //nobreak; + case 'pay_dump': + $field = 'export_dump_num'; + break; + case 'sys': + //nobreak; + //nobreak; + case 'pay_copy': + //nobreak; + case 'copy': + //nobreak; + $field = 'copy_product_num'; + break; + default: + $field = 'copy_product_num'; + break; + } + + + $number = $getOne[$field] + $data['num']; + $arr = [ + 'type' => $data['type'], + 'num' => $data['num'], + 'info' => $data['info']??'' , + 'mer_id'=> $merId, + 'message' => $data['message'] ?? '', + 'number' => ($number < 0) ? 0 : $number, + ]; + Db::transaction(function()use($arr,$make,$field){ + self::create($arr); + if ($arr['num'] < 0) { + $make->sumFieldNum($arr['mer_id'],$arr['num'],$field); + } else { + $make->addFieldNum($arr['mer_id'],$arr['num'],$field); + } + }); + } +} diff --git a/app/common/model/merchant/system/config/SystemConfig.php b/app/common/model/merchant/system/config/SystemConfig.php new file mode 100644 index 0000000..96c08ff --- /dev/null +++ b/app/common/model/merchant/system/config/SystemConfig.php @@ -0,0 +1,15 @@ +make(ConfigRepository::class)->intersectionKey($cid, $keys); + if (!count($keys)) return; + foreach ($keys as $key => $info) { + if (!isset($formData[$key])) + unset($formData[$key]); + else { + if ($info['config_type'] == 'number') { + if ($formData[$key] === '' || $formData[$key] < 0) + throw new ValidateException($info['config_name'] . '不能小于0'); + $formData[$key] = floatval($formData[$key]); + } + $this->separate($key,$formData[$key],$merId); + } + } + $this->setFormData($formData, $merId); + } + + /** + * TODO 需要做特殊处理的配置参数 + * @param $key + * @author Qinii + * @day 2022/11/17 + */ + public function separate($key,$value,$merId) + { + switch($key) { + case 'mer_svip_status': + //修改商户的会员状态 + app()->make(ProductRepository::class)->getSearch([])->where(['mer_id' => $merId,'product_type' => 0])->update([$key => $value]); + break; + + //热卖排行 + case 'hot_ranking_switch': + if ($value) { + Queue::push(SyncProductTopJob::class, []); + } + break; + case 'svip_switch_status': + if ($value == 1) { + $groupDataRepository = app()->make(GroupDataRepository::class); + $groupRepository = app()->make(GroupRepository::class); + $group_id = $groupRepository->getSearch(['group_key' => 'svip_pay'])->value('group_id'); + $where['group_id'] = $group_id; + $where['status'] = 1; + $count = $groupDataRepository->getSearch($where)->field('group_data_id,value,sort,status')->count(); + if (!$count) + throw new ValidateException('请先添加会员类型'); + } + break; + default: + break; + } + return ; + } + + public function setFormData(array $formData, int $merId) + { + Db::transaction(function () use ($merId, $formData) { + foreach ($formData as $key => $value) { + if ($this->dao->merExists($key, $merId)) + $this->dao->merUpdate($merId, $key, ['value' => $value]); + else + $this->dao->create([ + 'mer_id' => $merId, + 'value' => $value, + 'config_key' => $key + ]); + } + }); + } + + + + // ------------------------------------------------- + + /** + * @param array $keys + * @param int $merId + * @return array + */ + protected function fields(array $keys, int $merId) + { + $result = SystemConfigValue::whereIn('config_key', $keys)->where('mer_id', $merId)->withAttr('value', function ($val, $data) { + return json_decode($val, true); + })->column('value', 'config_key'); + foreach ($result as $k => $val) { + $result[$k] = json_decode($val, true); + } + return $result; + } + + /** + * @param string $key + * @param int $merId + * @return mixed|null + */ + protected function value(string $key, int $merId) + { + $value = SystemConfigValue::where('config_key', $key)->where('mer_id', $merId)->value('value'); + $value = is_null($value) ? null : json_decode($value, true); + return $value; + } +} diff --git a/app/common/model/merchant/system/merchant/Merchant.php b/app/common/model/merchant/system/merchant/Merchant.php index 11d6f3e..1e1e2aa 100644 --- a/app/common/model/merchant/system/merchant/Merchant.php +++ b/app/common/model/merchant/system/merchant/Merchant.php @@ -12,7 +12,9 @@ namespace app\common\model\merchant\system\merchant; use think\Model; use app\common\model\merchant\user\UserBill as UserBillModel; +use app\common\model\merchant\store\ShippingTemplate; use think\exception\ValidateException; +use think\facade\Db; /** * @mixin \think\Model @@ -32,6 +34,49 @@ class Merchant extends Model return $this->merchantType()->bind(['type_name']); } + /** + * @param array $data + * @author xaboy + * @day 2020-04-17 + */ + public function createMerchant(array $data) + { + if ($this->fieldExists('mer_name', $data['mer_name'])) + throw new ValidateException('商户名已存在'); + if ($data['mer_phone'] && isPhone($data['mer_phone'])) + throw new ValidateException('请输入正确的手机号'); + $merchantCategory = app()->make(MerchantCategory::class); + $admin = app()->make(MerchantAdmin::class); + + if (!$data['category_id'] || !$merchantCategory->idIsExists($data['category_id'])) + throw new ValidateException('商户分类不存在'); + if ($admin->fieldExists('account', $data['mer_account'])) + throw new ValidateException('账号已存在'); + + /** @var MerchantAdmin $make */ + $make = app()->make(MerchantAdmin::class); + + $margin = app()->make(MerchantType::class)->get($data['type_id']); + $data['is_margin'] = $margin['is_margin'] ?? -1; + $data['margin'] = $margin['margin'] ?? 0; + + return Db::transaction(function () use ($data, $make) { + $account = $data['mer_account']; + $password = $data['mer_password']; + unset($data['mer_account'], $data['mer_password']); + + $merchant = $this->dao->create($data); + $make->createMerchantAccount($merchant, $account, $password); + $address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['geo_street']]); + if($data['area_id'] && $data['village_id']){ + Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); + } + app()->make(ShippingTemplate::class)->createDefault($merchant->mer_id); + app()->make(ProductCopy::class)->defaulCopyNum($merchant->mer_id); + return $merchant; + }); + } + /** * 扣除保证金 *@param array $data [mer_id] => 75 @@ -79,4 +124,26 @@ class Merchant extends Model return $merchant; } + + + //------------------------------------------------ + + public function addFieldNum(int $merId, int $num, string $field) + { + if ($num < 0) $num = -$num; + $merchant = $this->getModel()::getDB()->where('mer_id', $merId)->find(); + $number = $merchant[$field] + $num; + $merchant[$field] = $number; + $merchant->save(); + } + + public function sumFieldNum(int $merId, int $num, string $field) + { + if ($num < 0) $num = -$num; + $merchant = $this->getModel()::getDB()->where('mer_id', $merId)->find(); + $number = $merchant[$field] - $num; + $merchant[$field] = $number; + $merchant->save(); + } + } diff --git a/app/common/model/merchant/system/merchant/MerchantAdmin.php b/app/common/model/merchant/system/merchant/MerchantAdmin.php index 03ec84b..684f09b 100644 --- a/app/common/model/merchant/system/merchant/MerchantAdmin.php +++ b/app/common/model/merchant/system/merchant/MerchantAdmin.php @@ -11,4 +11,55 @@ use think\Model; class MerchantAdmin extends Model { // + protected $connection = 'shop'; + protected $table = 'eb_merchant_admin'; + + const PASSWORD_TYPE_ADMIN = 1; + const PASSWORD_TYPE_MERCHANT = 2; + const PASSWORD_TYPE_SELF = 3; + + + /** + * @param $field + * @param $value + * @param int|null $except + * @return bool + */ + public function fieldExists($field, $value, ?int $except = null): bool + { + $query = self::where($field, $value); + if (!is_null($except)) $query->where($this->getPk(), '<>', $except); + return $query->count() > 0; + } + + /** + * @param Merchant $merchant + * @param $account + * @param $pwd + * @return BaseDao|Model + * @author xaboy + * @day 2020-04-17 + */ + public function createMerchantAccount(Merchant $merchant, $account, $pwd) + { + $pwd = $this->passwordEncode($pwd); + $data = compact('pwd', 'account') + [ + 'mer_id' => $merchant->mer_id, + 'real_name' => $merchant->real_name, + 'phone' => $merchant->mer_phone, + 'level' => 0 + ]; + return $this->create($data); + } + + /** + * @param $password + * @return bool|string + * @author xaboy + * @day 2020-04-17 + */ + public function passwordEncode($password) + { + return password_hash($password, PASSWORD_BCRYPT); + } } diff --git a/app/common/model/merchant/system/merchant/MerchantCategory.php b/app/common/model/merchant/system/merchant/MerchantCategory.php index aece970..29a9865 100644 --- a/app/common/model/merchant/system/merchant/MerchantCategory.php +++ b/app/common/model/merchant/system/merchant/MerchantCategory.php @@ -12,4 +12,31 @@ class MerchantCategory extends Model { protected $connection = 'shop'; protected $table = 'eb_merchant_category'; + + + /** + * @param int $id + * @return bool + * @author xaboy + * @day 2020-03-27 + */ + public function idIsExists(int $id) + { + return $this->fieldExists($this->getPk(), $id); + } + + /** + * @param $field + * @param $value + * @param int|null $except + * @return bool + * @author xaboy + * @day 2020-03-30 + */ + public function fieldExists($field, $value, ?int $except = null): bool + { + $query = self::where($field, $value); + if (!is_null($except)) $query->where($this->getPk(), '<>', $except); + return $query->count() > 0; + } } diff --git a/app/common/model/merchant/system/merchant/MerchantIntention.php b/app/common/model/merchant/system/merchant/MerchantIntention.php index febcf25..d4a4d67 100644 --- a/app/common/model/merchant/system/merchant/MerchantIntention.php +++ b/app/common/model/merchant/system/merchant/MerchantIntention.php @@ -12,6 +12,7 @@ namespace app\common\model\merchant\system\merchant; use app\common\model\merchant\system\merchant\MerchantCategory; use think\Model; +use think\facade\Db; use think\exception\ValidateException; /** @@ -39,7 +40,6 @@ class MerchantIntention extends Model 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(); @@ -92,6 +92,17 @@ class MerchantIntention extends Model return $query; } + /** + * 修改审核状态 + */ + public function getStatusAttr($value) + { + $status = [0=>'待审核', 1=>'审核已通过',2=>'审核未通过']; + return $status[$value]; + } + + + public function Edit($id, $data) { $rows = self::where('mer_intention_id',$id)->update($data); @@ -108,7 +119,7 @@ class MerchantIntention extends Model */ public function GetWhereCount($mer_intention_id) { - echo $count = self::where(['mer_intention_id' => $mer_intention_id, 'is_del' => 0])->count(); + $count = self::where(['mer_intention_id' => $mer_intention_id, 'is_del' => 0])->count(); return $count; } @@ -122,16 +133,16 @@ class MerchantIntention extends Model $create = $data['create_mer'] == 1; unset($data['create_mer']); $intention = $this->search(['mer_intention_id' => $id])->find(); - $smsData = []; + // $smsData = []; if (!$intention) throw new ValidateException('信息不存在'); if ($intention->status) throw new ValidateException('状态有误,修改失败'); //TODO: 此处需开发为可配置字段 - $config = ['broadcast_room_type'=>0, 'broadcast_goods_type'=>0]; + $config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']); - $margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']); + $margin = app()->make(MerchantType::class)->get($intention['mer_type_id']); $data['is_margin'] = $margin['is_margin'] ?? -1; $data['margin'] = $margin['margin'] ?? 0; $merData = []; @@ -146,10 +157,8 @@ class MerchantIntention extends Model 'real_name' => $intention['name'], 'status' => 1, 'is_audit' => 1, - // 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, - // 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, - 'is_bro_room' => empty($config['broadcast_room_type']) ? 0 : 1, - 'is_bro_goods' => !empty($config['broadcast_goods_type']) ? 0 : 1, + 'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1, + 'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1, 'mer_password' => $password, 'is_margin' => $margin['is_margin'] ?? -1, 'margin' => $margin['margin'] ?? 0, @@ -181,7 +190,7 @@ class MerchantIntention extends Model self::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData) { if ($data['status'] == 1) { if ($create) { - $merchant = self::createMerchant($merData); + $merchant = app()->make(Merchant::class)->createMerchant($merData); $data['mer_id'] = $merchant->mer_id; // 暂不开通通知 // Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]); @@ -193,6 +202,10 @@ class MerchantIntention extends Model }); } + protected function isPhone($test) + { + return !preg_match("/^1[3456789]{1}\d{9}$/", $test); + } /** @@ -204,20 +217,20 @@ class MerchantIntention extends Model { if ($this->fieldExists('mer_name', $data['mer_name'])) throw new ValidateException('商户名已存在'); - if ($data['mer_phone'] && isPhone($data['mer_phone'])) + if ($data['mer_phone'] && self::isPhone($data['mer_phone'])) throw new ValidateException('请输入正确的手机号'); - $merchantCategoryRepository = app()->make(MerchantCategoryRepository::class); - $adminRepository = app()->make(MerchantAdminRepository::class); + $merchantCategory = new MerchantCategory; + $merchantAdmin = new MerchantAdmin; - if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) + if (!$data['category_id'] || !$merchantCategory->exists($data['category_id'])) throw new ValidateException('商户分类不存在'); - if ($adminRepository->fieldExists('account', $data['mer_account'])) + if ($merchantAdmin->fieldExists('account', $data['mer_account'])) throw new ValidateException('账号已存在'); - /** @var MerchantAdminRepository $make */ - $make = app()->make(MerchantAdminRepository::class); + /** @var MerchantAdmin $make */ + $make = new MerchantCategory; - $margin = app()->make(MerchantTypeRepository::class)->get($data['type_id']); + $margin = (new MerchantType)->get($data['type_id']); $data['is_margin'] = $margin['is_margin'] ?? -1; $data['margin'] = $margin['margin'] ?? 0; From ab6648dde8aa376fa45e240f9485a56f5d7cee86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Mon, 13 Mar 2023 17:05:47 +0800 Subject: [PATCH 16/38] 1 --- public/.htaccess | 8 ------- public/nginx.htaccess | 56 ++++--------------------------------------- runtime/.gitignore | 2 -- 3 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 runtime/.gitignore diff --git a/public/.htaccess b/public/.htaccess index cbc7868..e69de29 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,8 +0,0 @@ - - Options +FollowSymlinks -Multiviews - RewriteEngine On - - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] - diff --git a/public/nginx.htaccess b/public/nginx.htaccess index a9942c4..686c455 100644 --- a/public/nginx.htaccess +++ b/public/nginx.htaccess @@ -1,51 +1,5 @@ -#ļΪNginxα̬ļ PHPCUSTOMٷַhttp://www.phpcustom.com http://www.lccee.com - - - - - -# 301תãԶ޸Ϊ - if ($Host = 'xxx.com'){ - rewrite ^/(.*)$ http://www.phpcustom.com/$1 permanent; - } - - - - - - -#Ϊphpwind9.0α̬,ȥ#Ч -#------------------------------------------------------------------------------------------------ - -# if (-f $request_filename) { -# break; -# } -# if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") { -# break; -# } -# if (!-e $request_filename) { -# rewrite . /index.php last; -# } - - - - - -# ThinkPHP V5α̬ʾ ȥ´ǰߵ#żЧ - -#------------------------------------------------------------------------------------------------ -#if (!-e $request_filename) { -# rewrite ^(.*)$ /index.php?s=/$1 last; -# break; -# } - -#------------------------------------------------------------------------------------------------ - - - - - - - - - +location / { + if (!-e $request_filename){ + rewrite ^(.*)$ /index.php?s=$1 last; break; + } +} \ No newline at end of file diff --git a/runtime/.gitignore b/runtime/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/runtime/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file From f716bf8d0920f93a911481a74fdef69df4daad86 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 17:31:53 +0800 Subject: [PATCH 17/38] =?UTF-8?q?=E5=95=86=E6=88=B7=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=AE=A1=E6=A0=B8=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/route/merchant.php | 2 +- .../system/merchant/intention/lst.html | 23 +- .../system/merchant/intention/status.html | 2 +- app/common/model/merchant/common.php | 279 ++++++------------ .../model/merchant/store/ShippingTemplate.php | 14 +- .../merchant/store/ShippingTemplateFree.php | 3 +- .../merchant/store/ShippingTemplateRegion.php | 5 +- .../store/ShippingTemplateUndelive.php | 1 + .../merchant/store/product/ProductCopy.php | 25 +- .../merchant/system/merchant/Merchant.php | 65 +++- .../system/merchant/MerchantAddress.php | 15 + .../system/merchant/MerchantAdmin.php | 1 + .../system/merchant/MerchantCategory.php | 3 +- .../system/merchant/MerchantIntention.php | 79 +---- .../merchant/system/merchant/MerchantType.php | 14 + 15 files changed, 252 insertions(+), 279 deletions(-) create mode 100644 app/common/model/merchant/system/merchant/MerchantAddress.php diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index 9a13da9..b1d61e3 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -53,7 +53,7 @@ Route::group(function(){ Route::get('lst', '/lst')->name('systemMerchantIntentionLst')->option([ '_alias' => '列表', ]); - Route::post('status', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ + Route::get('status', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ '_alias' => '审核', ]); Route::delete('delete', '/delete')->name('systemMerchantIntentionDelete')->option([ diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html index 99b24ba..f89cc4d 100644 --- a/app/admin/view/merchant/system/merchant/intention/lst.html +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -124,7 +124,10 @@ +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_account/datalist.html b/app/admin/view/supply_account/datalist.html new file mode 100644 index 0000000..2c70e61 --- /dev/null +++ b/app/admin/view/supply_account/datalist.html @@ -0,0 +1,148 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_account/edit.html b/app/admin/view/supply_account/edit.html new file mode 100644 index 0000000..8ea5ed4 --- /dev/null +++ b/app/admin/view/supply_account/edit.html @@ -0,0 +1,62 @@ +{extend name="common/base"/} + +{block name="body"} +
+

编辑供应链团队角色提现账户信息

+ + + + + + + + + + + + + + +
账号*用户名*开户行*
已提现金额*账户余额*冻结余额*
所属后台供应链团队ID* + +
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_account/read.html b/app/admin/view/supply_account/read.html new file mode 100644 index 0000000..ccabd2f --- /dev/null +++ b/app/admin/view/supply_account/read.html @@ -0,0 +1,28 @@ +{extend name="common/base"/} + +{block name="body"} +
+

供应链团队角色提现账户信息详情

+ + + + + + + + + + + + +
账号{$detail.account}用户名{$detail.name}开户行{$detail.bank}
已提现金额{$detail.amount}账户余额{$detail.balance}冻结余额{$detail.free_balance}
所属后台供应链团队ID + +
+
+{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_brokerage/add.html b/app/admin/view/supply_brokerage/add.html new file mode 100644 index 0000000..cf2a7e7 --- /dev/null +++ b/app/admin/view/supply_brokerage/add.html @@ -0,0 +1,45 @@ +{extend name="common/base"/} + +{block name="body"} +
+

新建供应链团队佣金记录表

+ + + + +
供应链佣金流水号
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_brokerage/datalist.html b/app/admin/view/supply_brokerage/datalist.html new file mode 100644 index 0000000..d61742a --- /dev/null +++ b/app/admin/view/supply_brokerage/datalist.html @@ -0,0 +1,188 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_brokerage/edit.html b/app/admin/view/supply_brokerage/edit.html new file mode 100644 index 0000000..fdd80e2 --- /dev/null +++ b/app/admin/view/supply_brokerage/edit.html @@ -0,0 +1,45 @@ +{extend name="common/base"/} + +{block name="body"} +
+

编辑供应链团队佣金记录表

+ + + + +
供应链佣金流水号
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_brokerage/read.html b/app/admin/view/supply_brokerage/read.html new file mode 100644 index 0000000..ff45489 --- /dev/null +++ b/app/admin/view/supply_brokerage/read.html @@ -0,0 +1,31 @@ +{extend name="common/base"/} + +{block name="body"} +
+

供应链团队佣金记录表详情

+ + + + + + + + + + + + + + + + + + + + + + +
供应链佣金流水号{$detail.supply_sn}商户 id{$detail.mer_id}供应链团队id{$detail.fa_supply_chain_id}
订单编号{$detail.order_sn}订单ID{$detail.order_id}用户名{$detail.user_info}
小组服务用户ID{$detail.user_id}供应链用户ID{$detail.supply_userId}订单金额{$detail.pay_price}
佣金金额{$detail.brokerage_price}分佣比例{$detail.brokerage_rate}分佣状态{$detail.status}
分佣等级{$detail.supply_level_id}用户组{$detail.group_user}创建时间{$detail.create_time}
+
+{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_level/add.html b/app/admin/view/supply_level/add.html new file mode 100644 index 0000000..d48af93 --- /dev/null +++ b/app/admin/view/supply_level/add.html @@ -0,0 +1,46 @@ +{extend name="common/base"/} + +{block name="body"} +
+

新建供应链团队角色

+ + + + + +
角色名称*分佣比例*
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_level/datalist.html b/app/admin/view/supply_level/datalist.html new file mode 100644 index 0000000..44b94d6 --- /dev/null +++ b/app/admin/view/supply_level/datalist.html @@ -0,0 +1,123 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_level/edit.html b/app/admin/view/supply_level/edit.html new file mode 100644 index 0000000..a2cbaab --- /dev/null +++ b/app/admin/view/supply_level/edit.html @@ -0,0 +1,46 @@ +{extend name="common/base"/} + +{block name="body"} +
+

编辑供应链团队角色

+ + + + + +
角色名称*分佣比例*
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_level/read.html b/app/admin/view/supply_level/read.html new file mode 100644 index 0000000..20f6a27 --- /dev/null +++ b/app/admin/view/supply_level/read.html @@ -0,0 +1,14 @@ +{extend name="common/base"/} + +{block name="body"} +
+

供应链团队角色详情

+ + + + + +
角色名称{$detail.name}分佣比例{$detail.rate}
+
+{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_team/add.html b/app/admin/view/supply_team/add.html new file mode 100644 index 0000000..60c6d82 --- /dev/null +++ b/app/admin/view/supply_team/add.html @@ -0,0 +1,83 @@ +{extend name="common/base"/} + +{block name="body"} +
+

新建供应链分组

+ + + + + + + + + + + + + + + + + + + + +
后台供应链团队分组名称*经度*维度*
区县ID* + + 团队分佣金额*团队分佣已提现金额*
分佣冻结金额*团队所属等级* + + + 团队后台负责人ID* + +
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_team/datalist.html b/app/admin/view/supply_team/datalist.html new file mode 100644 index 0000000..beb1b15 --- /dev/null +++ b/app/admin/view/supply_team/datalist.html @@ -0,0 +1,158 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_team/edit.html b/app/admin/view/supply_team/edit.html new file mode 100644 index 0000000..a079d66 --- /dev/null +++ b/app/admin/view/supply_team/edit.html @@ -0,0 +1,79 @@ +{extend name="common/base"/} + +{block name="body"} +
+

编辑供应链分组

+ + + + + + + + + + + + + + + + + + + +
后台供应链团队分组名称*经度*维度*
区县ID* + + 团队分佣金额*团队分佣已提现金额*
分佣冻结金额*团队所属等级* + + 团队后台负责人ID* + +
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supply_team/read.html b/app/admin/view/supply_team/read.html new file mode 100644 index 0000000..1c68e7a --- /dev/null +++ b/app/admin/view/supply_team/read.html @@ -0,0 +1,44 @@ +{extend name="common/base"/} + +{block name="body"} +
+

供应链分组详情

+ + + + + + + + + + + + + + + + +
后台供应链团队分组名称{$detail.name}经度{$detail.lng}维度{$detail.lat}
区县ID + + 团队分佣金额{$detail.brokerage}团队分佣已提现金额{$detail.withdraw_brokerage}
分佣冻结金额{$detail.free_brokerage}团队所属等级 + + 团队后台负责人ID + +
+
+{/block} + \ No newline at end of file From 50d6fdef3b9a2f30b25314f134be9d822e539080 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Mon, 13 Mar 2023 18:55:46 +0800 Subject: [PATCH 19/38] =?UTF-8?q?=E5=95=86=E6=88=B7=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=97=B6=E9=97=B4=E9=80=89=E6=8B=A9=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/route/merchant.php | 2 +- .../system/merchant/intention/lst.html | 89 +++++++++++-------- .../system/merchant/intention/status.html | 4 +- 3 files changed, 57 insertions(+), 38 deletions(-) diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index b1d61e3..9a13da9 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -53,7 +53,7 @@ Route::group(function(){ Route::get('lst', '/lst')->name('systemMerchantIntentionLst')->option([ '_alias' => '列表', ]); - Route::get('status', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ + Route::post('status', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ '_alias' => '审核', ]); Route::delete('delete', '/delete')->name('systemMerchantIntentionDelete')->option([ diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html index f89cc4d..a8cb3b1 100644 --- a/app/admin/view/merchant/system/merchant/intention/lst.html +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -18,14 +18,14 @@
- - + + - - - - + + + +
@@ -53,11 +53,11 @@
- - - - - + + + + +
@@ -83,7 +83,6 @@
-
@@ -292,7 +291,7 @@ // var $ = layui.$, active = { reload: function(){ - let dataRload = getformdata();; + let dataRload = getformdata(); console.log(dataRload) //执行重载 table.reload('intention_list', { @@ -320,20 +319,41 @@ return false; }); + //选择时间 form.on('submit(chonse_date)', function(data){ - console.log(data.elem.name); - $('#chonse_date').val(data.elem.name); - layui.pageTable.reload({ - where: { - ...data.field - }, - page: { - curr: 1 - } - }); + var now = new Date().getTime(); //获取毫秒数 + + let value = ''; + let name = data.elem.name; + if (name =='today') { + value = now; + }else if(name == 'yeserday'){ + value = new Date(now - 1 * 86400 * 1000).getTime(); + }else if(name == 'week'){ + value = new Date(now - 7 * 86400 * 1000).getTime()+'-'+now; + }else if(name == '30day'){ + value = new Date(now - 30 * 86400 * 1000).getTime()+'-'+now; + }else if(name == 'month'){ + var day = now.getDate();//当前天份 + console.log(day); + var day = (new Date()).getMonth()+1;//当前月份 + value = new Date(now - day * 86400 * 1000).getTime() + }else if(name == 'year'){ + value = now.getFullYear();//获取当前年份 + } + $('#chonse_date').val(value); + active['reload'] ? active['reload'].call(this) : ''; + return false; }) + // 商户审核 + form.on('submit(statusform)', function(data) { + $('#status').val(data.elem.name); + active['reload'] ? active['reload'].call(this) : ''; + return false; + }); + //监听select提交 form.on('select(seleform)', function(data) { active['reload'] ? active['reload'].call(this) : ''; @@ -341,19 +361,18 @@ return false; }); - - - // 获取表单所有参数 - function getformdata() { - var form = $('#filterform').serializeArray(); - var data = new Array(); - for(let i=0;i {/block} diff --git a/app/admin/view/merchant/system/merchant/intention/status.html b/app/admin/view/merchant/system/merchant/intention/status.html index 7e2092d..0a8a71b 100644 --- a/app/admin/view/merchant/system/merchant/intention/status.html +++ b/app/admin/view/merchant/system/merchant/intention/status.html @@ -53,11 +53,11 @@ layer.msg(e.msg); if (e.code == 0) { setTimeout(function () { - // parent.location.reload(); + parent.location.reload(); }, 1000); } } - tool.get('/admin/merchant/intention/status', data.field, callback); + tool.post('/admin/merchant/intention/status', data.field, callback); return false; }); } From bc5ec1eee7546fd904b5964c3a33a0ebfa045366 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Tue, 14 Mar 2023 01:58:33 +0800 Subject: [PATCH 20/38] =?UTF-8?q?=E5=85=A5=E9=A9=BB=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2js=E7=AD=9B=E9=80=89=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/intention/lst.html | 120 +++++++++++++----- 1 file changed, 90 insertions(+), 30 deletions(-) diff --git a/app/admin/view/merchant/system/merchant/intention/lst.html b/app/admin/view/merchant/system/merchant/intention/lst.html index a8cb3b1..98a8b67 100644 --- a/app/admin/view/merchant/system/merchant/intention/lst.html +++ b/app/admin/view/merchant/system/merchant/intention/lst.html @@ -1,7 +1,12 @@ {extend name="common/base"/} {block name="body"} +
@@ -18,7 +23,8 @@
- + + @@ -34,13 +40,11 @@
- +
-
- +
@@ -48,22 +52,22 @@
-
+
- - - + + +
-
+
@@ -83,7 +87,7 @@
-
+
@@ -97,10 +101,10 @@
-
+
-
+
+ @@ -288,7 +288,9 @@ , range: ['#start-date', '#end-date'] ,done: function(value, date, endDate){ switchDateForm(true); - + + $('#both').removeClass('layui-btn-primary') + $('#both').siblings().addClass('layui-btn-primary') active['reload'] ? active['reload'].call(this) : ''; } }); From 1a5ad63673bab6b2f22cb9994bd7f554634a7455 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Wed, 15 Mar 2023 00:54:54 +0800 Subject: [PATCH 34/38] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2js=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/MerchantType.php | 32 ++- app/admin/route/merchant/menu.php | 82 ------ app/admin/route/merchant/merchant.php | 246 ------------------ .../merchant/system/merchant/type/add.html | 29 ++- .../merchant/system/merchant/type/edit.html | 31 ++- .../merchant/system/merchant/type/index.html | 1 - .../merchant/system/merchant/type/read.html | 72 ++++- .../model/merchant/system/Relevance.php | 4 +- .../merchant/system/merchant/MerchantType.php | 4 +- 9 files changed, 140 insertions(+), 361 deletions(-) delete mode 100644 app/admin/route/merchant/menu.php delete mode 100644 app/admin/route/merchant/merchant.php diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 5bdfa13..0cc3dc4 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace app\admin\controller\merchant\system\merchant; use app\admin\BaseController; +use app\admin\controller\merchant\system\auth\Menu; use app\common\model\merchant\system\merchant\MerchantType as MerchantTypeModel; use app\common\model\merchant\system\auth\Menu as MenuModel; use app\common\controller\FormatList; @@ -81,8 +82,12 @@ class MerchantType extends BaseController // 给菜单权限附加选中状态 foreach($data['list'] as $k=>$item) { - if (in_array($item['id'], $checked_list['list'][0]['auth_ids'])) { - $data['list'][$k]['checked'] = true; + foreach ($checked_list['list'] as $auth) { + if (in_array($item['id'], $auth['auth_ids'])) { + if ($item['pid']>0 && $item['title']!='权限') + $data['list'][$k]['checked'] = true; + $data['list'][$k]['spread'] = true; + } } } @@ -146,9 +151,30 @@ class MerchantType extends BaseController $param = get_params(); $id = isset($param['id']) ? (int)$param['id'] : 0; - $detail = $this->merchant->Find($id); + $detail = $this->merchant->getDetail($id); if (!empty($detail)) { + // 查出商户所有菜单数据权限 tree + $menu = app()->make(MenuModel::class); + $data = $menu->getList([],1); + + // 获取已有权限 + $checked_list = $this->merchant->getList(['mer_type_id'=>$id]); + + // 给菜单权限附加选中状态 + $list = []; + foreach($data['list'] as $k=>$item) { + foreach ($checked_list['list'] as $auth) { + if (in_array($item['id'], $auth['auth_ids'])) { + if ($item['pid']>0 && $item['title']!='权限') + $data['list'][$k]['checked'] = true; + $data['list'][$k]['spread'] = true; + array_push($list, $data['list'][$k]); + } + } + } + $format = app()->make(FormatList::class); + View::assign('dataTree', $format->FormatCategory($list)); View::assign('detail', $detail); return view($this->path['read']); } else { diff --git a/app/admin/route/merchant/menu.php b/app/admin/route/merchant/menu.php deleted file mode 100644 index c1ef28e..0000000 --- a/app/admin/route/merchant/menu.php +++ /dev/null @@ -1,82 +0,0 @@ - -// +---------------------------------------------------------------------- - -use think\facade\Route; -use app\common\middleware\AdminAuthMiddleware; -use app\common\middleware\AdminTokenMiddleware; -use app\common\middleware\AllowOriginMiddleware; -use app\common\middleware\LogMiddleware; - -Route::group(function () { - - //权限管理 - // Route::group('system/menu', function () { - // Route::get('lst', '/getList')->name('systemMenuGetLst')->option([ - // '_alias' => '平台菜单/权限列表', - // ]); - // Route::get('create/form', '/createForm')->name('systemMenuCreateForm')->option([ - // '_alias' => '平台菜单/权限添加表单', - // '_auth' => false, - // '_form' => 'systemMenuCreate', - // ]); - // Route::get('update/form/:id', '/updateForm')->name('systemMenuUpdateForm')->option([ - // '_alias' => '平台菜单/权限编辑表单', - // '_auth' => false, - // '_form' => 'systemMenuUpdate', - // ]); - // Route::post('create', '/create')->name('systemMenuCreate')->option([ - // '_alias' => '平台菜单/权限添加', - // ]); - // Route::post('update/:id', '/update')->name('systemMenuUpdate')->option([ - // '_alias' => '平台菜单/权限编辑', - // ]); - // Route::delete('delete/:id', '/delete')->name('systemMenuDelete')->option([ - // '_alias' => '平台菜单/权限删除', - // ]); - // })->prefix('admin.system.auth.Menu')->option([ - // '_path' => '/setting/menu', - // '_auth' => true, - // ]); - - //商户权限管理 - Route::group('merchant/menu', function () { - Route::get('lst', '/getList')->name('systemMerchantMenuGetLst')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限列表', - ]); - Route::get('create/form', '/createForm')->name('systemMerchantMenuCreateForm')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限添加表单', - '_auth' => false, - '_form' => 'systemMerchantMenuCreate', - ]); - Route::get('update/form/:id', '/updateForm')->name('systemMerchantMenuUpdateForm')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限编辑表单', - '_auth' => false, - '_form' => 'systemMerchantMenuUpdate', - ]); - Route::post('create', '/create')->name('systemMerchantMenuCreate')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限添加', - ]); - Route::post('update/:id', '/update')->name('systemMerchantMenuUpdate')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限编辑', - ]); - Route::delete('delete/:id', '/delete')->name('systemMerchantMenuDelete')->append(['merchant' => 1])->option([ - '_alias' => '商户菜单/权限删除', - ]); - })->prefix('admin.system.auth.Menu')->option([ - '_path' => '/merchant/system', - '_auth' => true, - ]); - -}); -// ->middleware(AllowOriginMiddleware::class) -// ->middleware(AdminTokenMiddleware::class, true) -// ->middleware(AdminAuthMiddleware::class) -// ->middleware(LogMiddleware::class); diff --git a/app/admin/route/merchant/merchant.php b/app/admin/route/merchant/merchant.php deleted file mode 100644 index 72a9505..0000000 --- a/app/admin/route/merchant/merchant.php +++ /dev/null @@ -1,246 +0,0 @@ - -// +---------------------------------------------------------------------- - -use think\facade\Route; - -Route::group(function () { - - //商户分类 - Route::group('system/merchant', function () { - Route::get('category/lst', '/lst')->name('systemMerchantCategoryLst')->option([ - '_alias' => '商户分类列表', - ]); - Route::get('category_lst', '/lst')->option([ - '_alias' => '商户分类列表', - '_auth' => false, - ]); - Route::post('category', '/create')->name('systemMerchantCategoryCreate')->option([ - '_alias' => '商户分类添加', - ]); - Route::get('category/form', '/createForm')->name('systemMerchantCategoryCreateForm')->option([ - '_alias' => '商户分类添加表单', - '_auth' => false, - '_form' => 'systemMerchantCategoryCreate', - ]); - Route::delete('category/:id', '/delete')->name('systemMerchantCategoryDelete')->option([ - '_alias' => '商户分类删除', - ]); - Route::post('category/:id', '/update')->name('systemMerchantCategoryUpdate')->option([ - '_alias' => '商户分类编辑', - ]); - Route::get('category/form/:id', '/updateForm')->name('systemMerchantCategoryUpdateForm')->option([ - '_alias' => '商户分类编辑表单', - '_auth' => false, - '_form' => 'systemMerchantCategoryUpdate', - ]); - Route::get('category/options', '/getOptions')->option([ - '_alias' => '商户分类筛选', - '_auth' => false, - ]); - })->prefix('admin.system.merchant.MerchantCategory')->option([ - '_path' => '/merchant/classify', - '_auth' => true, - ]); - - //申请列表 - Route::group('merchant/intention', function () { - Route::get('lst', '/lst')->name('systemMerchantIntentionLst')->option([ - '_alias' => '列表', - ]); - Route::post('status/:id', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ - '_alias' => '审核', - ]); - Route::delete('delete/:id', '/delete')->name('systemMerchantIntentionDelete')->option([ - '_alias' => '删除', - ]); - Route::get('mark/:id/form', '/form')->name('systemMerchantIntentionMarkForm')->option([ - '_alias' => '备注', - '_auth' => false, - '_form' => 'systemMerchantIntentionMark', - ]); - Route::get('status/:id/form', '/statusForm')->name('systemMerchantIntentionStatusForm')->option([ - '_alias' => '申请商户', - '_auth' => false, - '_form' => 'systemMerchantIntentionStatus', - ]); - - Route::post('mark/:id', '/mark')->name('systemMerchantIntentionMark')->option([ - '_alias' => '备注', - ]); - Route::get('excel', '/excel'); - })->prefix('admin.system.merchant.MerchantIntention')->option([ - '_path' => '/merchant/application', - '_auth' => true, - ]); - - //商户管理 - Route::group('system/merchant', function () { - Route::get('create/form', '.Merchant/createForm')->name('systemMerchantCreateForm')->option([ - '_alias' => '商户列表', - ]); - Route::get('count', '.Merchant/count')->name('systemMerchantCount')->option([ - '_alias' => '商户列表统计', - ]); - Route::get('lst', '.Merchant/lst')->name('systemMerchantLst')->option([ - '_alias' => '商户列表', - ]); - Route::post('create', '.Merchant/create')->name('systemMerchantCreate')->option([ - '_alias' => '商户添加', - ]); - Route::get('update/form/:id', '.Merchant/updateForm')->name('systemMerchantUpdateForm')->option([ - '_alias' => '商户编辑表单', - '_auth' => false, - '_form' => 'systemMerchantUpdate', - ]); - Route::post('update/:id', '.Merchant/update')->name('systemMerchantUpdate')->option([ - '_alias' => '商户编辑', - ]); - Route::post('status/:id', '.Merchant/switchStatus')->name('systemMerchantStatus')->option([ - '_alias' => '商户修改推荐', - ]); - Route::post('close/:id', '.Merchant/switchClose')->name('systemMerchantClose')->option([ - '_alias' => '商户开启/关闭', - ]); - Route::delete('delete/:id', '.Merchant/delete')->name('systemMerchantDelete')->option([ - '_alias' => '商户删除', - ]); - Route::post('password/:id', '.MerchantAdmin/password')->name('systemMerchantAdminPassword')->option([ - '_alias' => '商户修改密码', - ]); - Route::get('password/form/:id', '.MerchantAdmin/passwordForm')->name('systemMerchantAdminPasswordForm')->option([ - '_alias' => '商户修改密码表单', - '_auth' => false, - '_form' => 'systemMerchantAdminPassword', - ]); - Route::post('login/:id', '.Merchant/login')->name('systemMerchantLogin')->option([ - '_alias' => '商户登录', - ]); - Route::get('changecopy/:id/form', '.Merchant/changeCopyNumForm')->name('systemMerchantChangeCopyForm')->option([ - '_alias' => '修改采集商品次数表单', - '_auth' => false, - '_form' => 'systemMerchantChangeCopy', - ]); - Route::post('changecopy/:id', '.Merchant/changeCopyNum')->name('systemMerchantChangeCopy')->option([ - '_alias' => '修改采集商品次数', - ]); - })->prefix('admin.system.merchant')->option([ - '_path' => '/merchant/list', - '_auth' => true, - '_append'=> [ - [ - '_name' =>'uploadImage', - '_path' =>'/merchant/list', - '_alias' => '上传图片', - '_auth' => true, - ], - [ - '_name' =>'systemAttachmentLst', - '_path' =>'/merchant/list', - '_alias' => '图片列表', - '_auth' => true, - ], - ] - ]); - - // 店铺类型 - Route::group('merchant/type', function () { - Route::get('lst', '/lst')->name('systemMerchantTypeLst')->option([ - '_alias' => '列表', - ]); - Route::post('create', '/create')->name('systemMerchantTypeCreate')->option([ - '_alias' => '添加', - ]); - Route::post('update/:id', '/update')->name('systemMerchantTypeUpdate')->option([ - '_alias' => '编辑', - ]); - Route::delete('delete/:id', '/delete')->name('systemMerchantTypeDelete')->option([ - '_alias' => '删除', - ]); - Route::get('mark/:id', '/markForm')->name('systemMerchantTypeMarkForm')->option([ - '_alias' => '备注', - '_auth' => false, - '_form' => 'systemMerchantTypeMark', - ]); - Route::post('mark/:id', '/mark')->name('systemMerchantTypeMark')->option([ - '_alias' => '备注', - ]); - - Route::get('detail/:id', '/detail')->name('systemMerchantTypeDetail')->option([ - '_alias' => '备注', - ]); - - Route::get('options', '/options')->option([ - '_alias' => '筛选', - '_auth' => false, - ]); - Route::get('mer_auth', '/mer_auth')->option([ - '_alias' => '权限', - '_auth' => false, - ]); - })->prefix('admin.system.merchant.MerchantType')->option([ - '_path' => '/merchant/type', - '_auth' => true, - ]); - - //保证金 - Route::group('margin', function () { - //缴纳记录 - Route::get('lst', 'merchant.MerchantMargin/lst')->name('systemMerchantMarginLst')->option([ - '_alias' => '缴纳记录', - ]); - //扣费记录 - Route::get('list/:id', 'merchant.MerchantMargin/getMarginLst')->name('systemMarginList')->option([ - '_alias' => '扣费记录', - ]); - - //扣除保证金 - Route::get('set/:id/form', 'merchant.MerchantMargin/setMarginForm')->name('systemMarginSetForm')->option([ - '_alias' => '扣除保证金表单', - '_auth' => false, - '_form' => 'systemMarginSet', - ]); - Route::post('set', 'merchant.MerchantMargin/setMargin')->name('systemMarginSet')->option([ - '_alias' => '扣除保证金', - ]); - - //退款申请 - Route::get('refund/lst', 'financial.Financial/getMarginLst')->name('systemMarginRefundList')->option([ - '_alias' => '退款申请列表', - ]); - Route::get('refund/show/:id', 'financial.Financial/refundShow')->name('systemMarginRefundShow')->option([ - '_alias' => '退款申请详情', - ]); - - //审核 - Route::get('refund/status/:id/form', 'financial.Financial/statusForm')->name('systemMarginRefundSwitchStatusForm')->option([ - '_alias' => '审核表单', - '_auth' => false, - '_form' => 'systemMarginRefundSwitchStatus', - ]); - Route::post('refund/status/:id', 'financial.Financial/switchStatus')->name('systemMarginRefundSwitchStatus')->append(['type' => 1])->option([ - '_alias' => '审核', - ]); - - //备注 - Route::get('refund/mark/:id/form', 'financial.Financial/markMarginForm')->name('systemMarginRefundMarkForm')->option([ - '_alias' => '备注表单', - '_auth' => false, - '_form' => 'systemMarginRefundMark', - ]); - Route::post('refund/mark/:id', 'financial.Financial/mark')->name('systemMarginRefundMark')->option([ - '_alias' => '备注', - ]); - })->prefix('admin.system.')->option([ - '_path' => '/merchant/deposit_list', - '_auth' => true, - ]); - -}); diff --git a/app/admin/view/merchant/system/merchant/type/add.html b/app/admin/view/merchant/system/merchant/type/add.html index 1c3ab9d..c2721af 100644 --- a/app/admin/view/merchant/system/merchant/type/add.html +++ b/app/admin/view/merchant/system/merchant/type/add.html @@ -20,14 +20,14 @@ 店铺类型名称* + autocomplete="off" placeholder="请输入商品名称" class="layui-input" value=""> 店铺类型要求 - + @@ -38,15 +38,15 @@
- - + +
- + 单位:元 @@ -64,7 +64,7 @@ 其它说明 - + @@ -116,7 +116,6 @@ //监听提交 form.on('submit(webform)', function (data) { - console.log(data.field); // data.field.content = tinyMCE.editors['container_content'].getContent(); if (data.field == '') { layer.msg('请先完善店铺类型'); @@ -132,10 +131,18 @@ //获得选中的节点 var checkData = tree.getChecked('id'); - var list = new Array(); - list = getChecked_list(checkData); - data.field.auth = list - tool.post('/admin/merchant/type/add', data.field, callback); + var list = getChecked_list(checkData); + + var params = new Object(); + params.id = data.field.id + params.type_name = data.field.type_name + params.type_info = data.field.type_info + params.is_margin = data.field.is_margin + params.margin = data.field.margin + params.description = data.field.description + params.auth = list + + tool.post('/admin/merchant/type/add', params, callback); return true; }); diff --git a/app/admin/view/merchant/system/merchant/type/edit.html b/app/admin/view/merchant/system/merchant/type/edit.html index 4d26c5c..ca00224 100644 --- a/app/admin/view/merchant/system/merchant/type/edit.html +++ b/app/admin/view/merchant/system/merchant/type/edit.html @@ -56,7 +56,7 @@ 店铺权限*
-
+
@@ -103,8 +103,6 @@ var tree = layui.tree ,layer = layui.layer ,util = layui.util - ,spread = true - //模拟数据 ,data = getData(); //开启复选框 @@ -112,12 +110,15 @@ elem: '#test7' ,data: data ,showCheckbox: true - ,id:'id',//菜单id + ,id:'id'//菜单id + // ,click: function(obj){ + // var data = obj.data; //获取当前点击的节点数据 + // } }); + //监听提交 form.on('submit(webform)', function (data) { - console.log(data.field); // data.field.content = tinyMCE.editors['container_content'].getContent(); if (data.field == '') { layer.msg('请先完善店铺类型'); @@ -133,12 +134,20 @@ //获得选中的节点 var checkData = tree.getChecked('id'); - var list = new Array(); - list = getChecked_list(checkData); - data.field.auth = list - tool.put('/admin/merchant/type/edit', data.field, callback); + var list = getChecked_list(checkData); - return true; + var params = new Object(); + params.id = data.field.id + params.type_name = data.field.type_name + params.type_info = data.field.type_info + params.is_margin = data.field.is_margin + params.margin = data.field.margin + params.description = data.field.description + params.auth = list + + tool.put('/admin/merchant/type/edit', params, callback); + + return false; }); // 获取选中节点的id @@ -191,7 +200,7 @@ } //所有保存到数据节点的变量都成为`dataBox`对象的属性 - console.log(dataBox.admin); + // console.log(dataBox.admin) return dataBox.admin; } diff --git a/app/admin/view/merchant/system/merchant/type/index.html b/app/admin/view/merchant/system/merchant/type/index.html index 59a1285..bbf57da 100644 --- a/app/admin/view/merchant/system/merchant/type/index.html +++ b/app/admin/view/merchant/system/merchant/type/index.html @@ -104,7 +104,6 @@ //监听表格行工具事件 table.on('tool(store_product)', function(obj) { - console.log(obj.data); var data = obj.data; if (obj.event === 'read') { tool.side('/admin/merchant/type/read?id='+obj.data.id); diff --git a/app/admin/view/merchant/system/merchant/type/read.html b/app/admin/view/merchant/system/merchant/type/read.html index 1145f28..4d69900 100644 --- a/app/admin/view/merchant/system/merchant/type/read.html +++ b/app/admin/view/merchant/system/merchant/type/read.html @@ -32,15 +32,15 @@ 店铺权限 - - +
+
其它说明 - + @@ -60,4 +60,68 @@
{/block} - \ No newline at end of file + +{block name="script"} + + +{/block} \ No newline at end of file diff --git a/app/common/model/merchant/system/Relevance.php b/app/common/model/merchant/system/Relevance.php index af30c35..a3c3fc6 100644 --- a/app/common/model/merchant/system/Relevance.php +++ b/app/common/model/merchant/system/Relevance.php @@ -364,7 +364,9 @@ class Relevance extends Model */ public function batchInsert(array $data) { - return Relevance::insertAll($data); + $rows = Relevance::insertAll($data); + + return $rows; } diff --git a/app/common/model/merchant/system/merchant/MerchantType.php b/app/common/model/merchant/system/merchant/MerchantType.php index 0b3ba68..ce344ed 100644 --- a/app/common/model/merchant/system/merchant/MerchantType.php +++ b/app/common/model/merchant/system/merchant/MerchantType.php @@ -98,13 +98,13 @@ class MerchantType extends Model * * @return array|object */ - function Find(int $id) + function getDetail(int $id) { if (empty($id)) { throw new ValidateException('未传递参数'); return []; } - $row = self::where('mer_type_id', $id)->field('mer_type_id as id,type_name,margin,type_info,description,is_margin,create_time,update_time')->find(); + $row = self::search(['mer_type_id'=>$id])->find(); return $row; } From 4ffcbef5e08e0c4c057c709198be714b7af03ca8 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Wed, 15 Mar 2023 01:15:47 +0800 Subject: [PATCH 35/38] =?UTF-8?q?=E5=95=86=E6=88=B7=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=8D=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/merchant/system/auth/Menu.php | 6 +++--- app/admin/view/merchant/system/auth/menu/add.html | 2 +- app/common/controller/FormatList.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/admin/controller/merchant/system/auth/Menu.php b/app/admin/controller/merchant/system/auth/Menu.php index 24b50a9..3ec11a9 100644 --- a/app/admin/controller/merchant/system/auth/Menu.php +++ b/app/admin/controller/merchant/system/auth/Menu.php @@ -42,7 +42,7 @@ class Menu extends BaseController */ function Lst(){ // 查出商户所有菜单数据 - $data = $this->menu->Search([], 1); + $data = $this->menu->getList([], 1); to_assign(0,'',$data['list']); } @@ -62,9 +62,9 @@ class Menu extends BaseController View::assign('detail', $detail); } // 查出商户所有菜单数据 - $data = $this->menu->Search([], 1); + $data = $this->menu->getList([], 1); $menus = $format->DropDownMenu($data['list']); - + View::assign('id', $id); View::assign('pid', $pid); View::assign('menus',$menus); diff --git a/app/admin/view/merchant/system/auth/menu/add.html b/app/admin/view/merchant/system/auth/menu/add.html index 2b494c5..e1d2acc 100644 --- a/app/admin/view/merchant/system/auth/menu/add.html +++ b/app/admin/view/merchant/system/auth/menu/add.html @@ -11,7 +11,7 @@ diff --git a/app/common/controller/FormatList.php b/app/common/controller/FormatList.php index d7bd668..5fffb83 100644 --- a/app/common/controller/FormatList.php +++ b/app/common/controller/FormatList.php @@ -64,8 +64,8 @@ class FormatList $level++; foreach ($data as $k => $v) { if ($v['pid'] == $pid) { - $v['title'] = ''; if ($pid != 0) { + $v['title'] = isset($v['title'])?$v['title']:''; $v['title'] = $space[$level] . $v['title']; } /*将该类别的数据放入list中*/ From 67d225cb9e9c0f1da5b47f0b267b6b150e0fb068 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Wed, 15 Mar 2023 10:39:38 +0800 Subject: [PATCH 36/38] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=A1=B5=E6=89=80=E6=9C=89bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/MerchantType.php | 29 ++++++++++------- app/common/controller/FormatList.php | 8 +++++ .../merchant/system/merchant/Merchant.php | 8 +++++ .../merchant/system/merchant/MerchantType.php | 31 ++++++++++++++----- 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 0cc3dc4..cafe1de 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -59,6 +59,7 @@ class MerchantType extends BaseController // 进入编辑页,显示店铺数据 $detail = $this->merchant->Find($id); View::assign('id', $id); + } if (empty($detail)) { $detail = [ @@ -77,21 +78,26 @@ class MerchantType extends BaseController // 查出商户所有菜单数据权限 tree $data = $menu->getList([],1); - // 获取已有权限 - $checked_list = $this->merchant->getList(['mer_type_id'=>$id]); + $checked_list = []; + if (!empty($id) && $id>0) { + // 获取已有菜单权限 + $checked_list = $this->merchant->getList(['mer_type_id'=>$id]); - // 给菜单权限附加选中状态 - foreach($data['list'] as $k=>$item) { - foreach ($checked_list['list'] as $auth) { - if (in_array($item['id'], $auth['auth_ids'])) { - if ($item['pid']>0 && $item['title']!='权限') + // 给菜单权限附加选中状态 + foreach($data['list'] as $k=>$item) { + foreach ($checked_list['list'] as $auth) { + if (in_array($item['id'], $auth['auth_ids'])) { $data['list'][$k]['checked'] = true; $data['list'][$k]['spread'] = true; + } } } } - View::assign('dataTree', $format->FormatCategory($data['list'])); + // 递归分类, 顺便去掉所有父节点的 checked + $treelist = $format->FormatCategory($data['list']); + + View::assign('dataTree', $treelist); View::assign('detail', $detail); $path = empty($id)?'add':'edit'; @@ -111,7 +117,7 @@ class MerchantType extends BaseController $limit = empty($param['limit']) ? 10 : (int)$param['limit']; $data = $this->merchant->getList([], $page, $limit); - + return to_assign(0, '', $data); } @@ -173,6 +179,7 @@ class MerchantType extends BaseController } } } + $format = app()->make(FormatList::class); View::assign('dataTree', $format->FormatCategory($list)); View::assign('detail', $detail); @@ -239,9 +246,9 @@ class MerchantType extends BaseController return to_assign(1, '数据不存在'); } - $rows = $this->merchant->Del($id); + $res = $this->merchant->Del($id); - return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); + return $res['code']==0?to_assign(0, '操作成功'):to_assign(1, $res['msg']); } diff --git a/app/common/controller/FormatList.php b/app/common/controller/FormatList.php index 5fffb83..7478e4a 100644 --- a/app/common/controller/FormatList.php +++ b/app/common/controller/FormatList.php @@ -38,6 +38,14 @@ class FormatList foreach ($items as $item) { if (isset($items[$item[$parentId]])) { $items[$item[$parentId]][$childrenKey][] = &$items[$item[$idName]]; + + //--begin- + //因前端js Tree组件待性,父节点checked,其所属子孙节点会全部为checked状态, 所以此处去除所有父节点的checked + if (isset($items[$item[$parentId]]['checked'])&& $items[$item[$parentId]]['checked']) { + $items[$item[$parentId]]['checked'] = false; + } + //--end-- + } else if ($item[$parentId] == 0) { $result[] = &$items[$item[$idName]]; } diff --git a/app/common/model/merchant/system/merchant/Merchant.php b/app/common/model/merchant/system/merchant/Merchant.php index c08583f..16bae86 100644 --- a/app/common/model/merchant/system/merchant/Merchant.php +++ b/app/common/model/merchant/system/merchant/Merchant.php @@ -94,6 +94,14 @@ class Merchant extends Model }); } + /** + * 清除店铺类型 + */ + public function clearTypeId(int $typeId) + { + return Merchant::where('type_id', $typeId)->update(['type_id' => 0]); + } + /** * 扣除保证金 *@param array $data [mer_id] => 75 diff --git a/app/common/model/merchant/system/merchant/MerchantType.php b/app/common/model/merchant/system/merchant/MerchantType.php index ce344ed..918d5c3 100644 --- a/app/common/model/merchant/system/merchant/MerchantType.php +++ b/app/common/model/merchant/system/merchant/MerchantType.php @@ -215,15 +215,30 @@ class MerchantType extends Model return 0; } - // return Db::transaction(function () use ($id) { - // $this->dao->delete($id); - // app()->make(Merchant::class)->clearTypeId($id); - // app()->make(Relevance::class)->batchDelete($id, Relevance::TYPE_MERCHANT_AUTH); - // }); + Db::startTrans(); + try{ + $b1 = MerchantType::where($this->getPk(), $id)->delete(); + $b2 = app()->make(Merchant::class)->clearTypeId($id); + $b3 = app()->make(Relevance::class)->batchDelete($id, Relevance::TYPE_MERCHANT_AUTH); + if (empty($b1)) { + Db::rollback(); + throw new DbException('删除店铺类型失败'); + }else if($b2){ + Db::rollback(); + throw new DbException('清除商户店铺类型失败'); + }else if($b3){ + Db::rollback(); + throw new DbException('删除店铺权限失败'); + }else{ + Db::commit(); + } + $msg = ['code'=>0, 'msg'=>'success']; + }catch(DbException $e){ + Db::rollback(); + $msg = ['code'=>1, 'msg'=>$e->getMessage()]; + } - $rows = self::where('mer_type_id', $id)->delete(); - - return $rows; + return $msg; } /** From 1595573f52ab21cbfcc78ea88750095da2f9a117 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Wed, 15 Mar 2023 12:39:41 +0800 Subject: [PATCH 37/38] =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/merchant/system/Cache.php | 77 +++++ app/admin/route/system.php | 2 +- .../merchant/system/merchant/descr/index.html | 134 +++----- app/common/model/merchant/system/Cache.php | 309 ++++++++++++++++++ 4 files changed, 429 insertions(+), 93 deletions(-) create mode 100644 app/admin/controller/merchant/system/Cache.php create mode 100644 app/common/model/merchant/system/Cache.php diff --git a/app/admin/controller/merchant/system/Cache.php b/app/admin/controller/merchant/system/Cache.php new file mode 100644 index 0000000..f737077 --- /dev/null +++ b/app/admin/controller/merchant/system/Cache.php @@ -0,0 +1,77 @@ +cache = $cache; + } + + /** + * + */ + public function getKeyLst() + { + $type = $this->request->param('type',0); + $data = $this->cache->getAgreeList($type); + + return to_assign(0,'',$data); + } + + + /** + * @return mixed + */ + public function getAgree($key) + { + $allow = $this->cache->getAgreeKey(); + if (!in_array($key, $allow)) return app('json')->fail('数据不存在'); + $data = $this->cache->getResult($key); + + return to_assign(0,'success', $data); + } + + /** + * @return mixed + */ + public function saveAgree($key) + { + $allow = $this->cache->getAgreeKey(); + if (!in_array($key, $allow)) return app('json')->fail('KEY不存在'); + + $value = get_params('agree'); + $this->cache->saveCache($key, $value); + + if ($key == CacheModel::USER_PRIVACY) + $this->cache->setUserAgreement($value); + if ($key == CacheModel::USER_AGREE) + $this->cache->setUserRegister($value); + + return to_assign(0, '保存成功'); + } + + /** + * TODO 清除缓存 + * @return \think\response\Json + */ + public function clearCache() + { + return to_assign(0,'清除缓存成功'); + } +} \ No newline at end of file diff --git a/app/admin/route/system.php b/app/admin/route/system.php index 3c58937..297e051 100644 --- a/app/admin/route/system.php +++ b/app/admin/route/system.php @@ -20,7 +20,7 @@ Route::group('agreement', function () { '_init' => [ \crmeb\services\UpdateAuthInit::class,'agreement'], ]); -})->prefix('admin.system.Cache')->option([ +})->prefix('merchant.system.Cache')->option([ '_path' => '/setting/agreements', '_auth' => true, ]); \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/descr/index.html b/app/admin/view/merchant/system/merchant/descr/index.html index 7e86548..0058526 100644 --- a/app/admin/view/merchant/system/merchant/descr/index.html +++ b/app/admin/view/merchant/system/merchant/descr/index.html @@ -8,19 +8,21 @@ {block name="body"} - - +
店铺说明 +

店铺说明

+
- +
-
+
@@ -35,99 +37,47 @@ 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,laydate=layui.laydate; - laydate.render({ - elem: '#test1' //指定元素 + var form =layui.form, tool = layui.tool + // ,tagspicker = layui.tagpicker,laydate=layui.laydate; + + var editor = layui.tinymce; + var edit = editor.render({ + selector: "#container_content", + height: 500 }); - //上传缩略图 - var upload_thumb = layui.upload.render({ - elem: '#upload_btn_thumb', - url: '/admin/api/upload', - done: function (res) { - //如果上传失败 - if (res.code == 1) { - return layer.msg('上传失败'); + + $.ajax({ + url:'/admin/agreement/sys_merchant_type', + method:'get', + success: (data)=>{ + if (data.code==0){ + tinyMCE.editors['container_content'].setContent(data.data.sys_merchant_type); + }else{ + console.log(data) } - //上传成功 - $('#upload_box_thumb input').attr('value', res.data.filepath); - $('#upload_box_thumb img').attr('src', res.data.filepath); + }, + fail:(e)=>{ + console.log(e) } - }); + }) - street(); - village(); - form.on('select(area_id)', function (data) { - street(data.value) - }); - function street (id) { - var demo1 = xmSelect.render({ - name: 'township', - el: '#demo1', - initValue: [], - prop: { - name: 'name', - value: 'code', - }, - data: [], - radio: true, - disabled: group_access == 2 ||group_access == 4? true : false, - on: function (data) { - var arr = data.arr; - if(arr.length > 0){ - village(arr[0]['code']); - }else{ - village(); - } - }, - }) - $.get('/api/geo/street?pcode=' + id, function (result) { - demo1.update({ - data: result.data - }) - }); - } - function village (id) { - var demo2 = xmSelect.render({ - name: 'village', - el: '#demo2', - initValue: [], - prop: { - name: 'name', - value: 'id', - }, - data: [], - radio: true, - disabled: group_access == 2 ? true : false, - }) - $.get('/api/geo/village?pcode=' + id, function (result) { - demo2.update({ - data: result.data - }) - }); - } - - var editor = layui.tinymce; - var edit = editor.render({ - selector: "#container_content", - height: 500 - }); - //监听提交 - form.on('submit(webform)', function (data) { - data.field.content = tinyMCE.editors['container_content'].getContent(); - if (data.field.content == '') { - layer.msg('请先完善文章内容'); - return false; - } - let callback = function (e) { - layer.msg(e.msg); - if (e.code == 0) { - tool.tabRefresh(71); - tool.sideClose(1000); - } - } - tool.post('', data.field, callback); + //监听提交 + form.on('submit(webform)', function (data) { + data.field.agree = tinyMCE.editors['container_content'].getContent(); + if (data.field.content == '') { + 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/agreement/sys_merchant_type', data.field, callback); + return false; + }); } diff --git a/app/common/model/merchant/system/Cache.php b/app/common/model/merchant/system/Cache.php new file mode 100644 index 0000000..570a050 --- /dev/null +++ b/app/common/model/merchant/system/Cache.php @@ -0,0 +1,309 @@ + '用户协议', 'key' => self::USER_AGREE], + ['label' => '隐私政策', 'key' => self::USER_PRIVACY], + ['label' => '平台规则', 'key' => self::PLATFORM_RULE], + ['label' => '注销重要提示', 'key' => self::CANCELLATION_PROMPT], + ['label' => '商户入驻申请协议', 'key' => self::INTEGRAL_AGREE], + ]; + if (!$type) { + $data[] = ['label' => '注销声明', 'key' => self::CANCELLATION_MSG]; + $data[] = ['label' => '关于我们', 'key' => self::ABOUT_US]; + $data[] = ['label' => '资质证照', 'key' => self::SYS_CERTIFICATE]; + } + return $data; + } + + public function getAgreeKey(){ + return [ + self::INTEGRAL_RULE, + self::INTEGRAL_AGREE, + self::PRESELL_AGREE, + self::WECHAT_MENUS, + self::RECEIPT_AGREE, + self::EXTENSION_AGREE, + self::MERCHANT_TYPE, + self::SYS_BROKERAGE, + self::USER_AGREE, + self::USER_PRIVACY, + self::SYS_MEMBER, + self::ABOUT_US, + self::SYS_CERTIFICATE, + self::CANCELLATION_MSG, + self::CANCELLATION_PROMPT, + self::PLATFORM_RULE, + self::COUPON_AGREE, + self::SYS_SVIP, + ]; + } + + + /** + * @param string $key + * @param $result + * @param int $expire_time + * @throws DbException + */ + public function saveCache(string $key, $result, int $expire_time = 0) + { + if (!Cache::keyExist($key)) { + Cache::create(compact('key', 'result', 'expire_time')); + } else { + $this->keyUpdate($key, compact('result', 'expire_time')); + } + } + + public function getResult($key) + { + $data['title'] = ''; + foreach ($this->getAgreeList(1) as $item) { + if ($item['key'] == $key) { + $data['title'] = $item['label']; + } + } + $data[$key] = $this->getCache($key) ?? ''; + return $data; + } + + public function getResultByKey($key) + { + return $this->getCache($key); + } + + public function batchSaveCache(array $data) + { + foreach ($data as $k => $v) { + $this->saveCache($k, $v); + } + } + + + /** + * 设置用户协议内容 + * @return mixed + */ + public function setUserAgreement($content) + { + $html = << + + + + 隐私协议 + + + + + + + $content + + +HTML; + file_put_contents(public_path() . 'protocol.html', $html); + } + + public function setUserRegister($content) + { + $html = << + + + + 用户协议 + + + + + + + $content + + +HTML; + file_put_contents(public_path() . 'register.html', $html); + } + + + /* + * 整理城市数据用的方法 + */ + public function addres() + { + return []; + $re = (Cache::get('AAAAAA')); + //halt($re); + unset($re['省市编码']); + if (!$re) throw new ValidateException('无数据'); + $shen = []; + $shi = []; + $qu = []; + foreach ($re as $key => $value) { + $item = explode(',', $value); + $cout = count($item); + //省 + if ($cout == 2) { + $shen[$item[1]] = [ + 'value' => $key, + 'label' => $item[1], + ]; + } + //市 + if ($cout == 3) { + if ($item[1] == '') { + $shen[$item[2]] = [ + 'value' => $key, + 'label' => $item[2], + ]; + $item[1] = $item[2]; + } + $_v = [ + 'value' => $key, + 'label' => $item[2] + ]; + $shi[$item[1]][] = $_v; + } + //区 + if ($cout == 4) { + $_v = [ + 'value' => $key, + 'label' => $item[3] + ]; + $qu[$item[2]][] = $_v; + } + } + $data = []; + foreach ($shen as $s => $c) { + foreach ($shi as $i => $c_) { + if ($c['label'] == $i) { + if ($c['label'] == $i) { + $san = []; + foreach ($c_ as $key => $value) { + if (isset($qu[$value['label']])) { + $value['children'] = $qu[$value['label']]; + } + $san[] = $value; + } + } + $c['children'] = $san; + } + } + $zls[$s] = $c; + } + $data = array_values($zls); + file_put_contents('address.js', json_encode($data, JSON_UNESCAPED_UNICODE)); + //$this->save('applyments_addres',$data); + } + + + /** ----------- dao function ----------- */ + + /** + * @param $key + * @return mixed + * @author xaboy + * @day 2020-04-24 + */ + protected function getCache($key) + { + $val = Cache::where('key', $key)->value('result'); + return $val ? json_decode($val, true) : null; + } + + /** + * 判断是key是否存在 + */ + protected function keyExist($key) + { + return Cache::where('key', $key)->count(); + } + + /** + * @param string $key + * @param $data + * @throws DbException + * @author xaboy + * @day 2020-04-24 + */ + protected function keyUpdate(string $key, $data) + { + if (isset($data['result'])) + $data['result'] = json_encode($data['result'], JSON_UNESCAPED_UNICODE); + Cache::where('key', $key)->update($data); + } + + protected function search(array $keys) + { + $cache = Cache::whereIn('key',$keys)->column('result','key'); + $ret = []; + + foreach ($cache as $k => $v) { + $ret[$k] = json_decode($v); + } + return $ret; + } +} From b0ae2c70878ba6cb0cb9ed3cd45a81959ba2be8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Wed, 15 Mar 2023 16:26:36 +0800 Subject: [PATCH 38/38] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/UserExtract.php | 149 ++++++++++++ app/admin/controller/supplychain/Merchant.php | 6 +- app/admin/model/UserExtract.php | 102 ++++++++ app/admin/validate/UserExtractValidate.php | 20 ++ app/admin/view/supply_brokerage/datalist.html | 2 +- app/admin/view/supplychain/merchant/bill.html | 14 +- .../view/supplychain/merchant/index.html | 14 +- app/admin/view/user_extract/add.html | 45 ++++ app/admin/view/user_extract/datalist.html | 218 ++++++++++++++++++ app/admin/view/user_extract/edit.html | 45 ++++ app/admin/view/user_extract/read.html | 13 ++ 11 files changed, 611 insertions(+), 17 deletions(-) create mode 100644 app/admin/controller/UserExtract.php create mode 100644 app/admin/model/UserExtract.php create mode 100644 app/admin/validate/UserExtractValidate.php create mode 100644 app/admin/view/user_extract/add.html create mode 100644 app/admin/view/user_extract/datalist.html create mode 100644 app/admin/view/user_extract/edit.html create mode 100644 app/admin/view/user_extract/read.html diff --git a/app/admin/controller/UserExtract.php b/app/admin/controller/UserExtract.php new file mode 100644 index 0000000..1de0be5 --- /dev/null +++ b/app/admin/controller/UserExtract.php @@ -0,0 +1,149 @@ +model = new UserExtractModel(); + $this->uid = get_login_admin('id'); + } + /** + * 数据列表 + */ + public function datalist() + { + if (request()->isAjax()) { + $param = get_params(); + $where = []; + + $list = $this->model->getUserExtractList($where,$param); + foreach ($list as $k =>$v){ + $list[$k]['uid'] = Db::connect('shop')->table('eb_user')->where('uid',$v['uid'])->value('nickname'); + if($v['extract_type'] == 0){ + $list[$k]['extract_type'] = '银行卡'; + } + if($v['extract_type'] == 1){ + $list[$k]['extract_type'] = '支付宝'; + } + if($v['extract_type'] == 2){ + $list[$k]['extract_type'] = '微信'; + } + if($v['extract_type'] == 3){ + $list[$k]['extract_type'] = '零钱'; + } + + $list[$k]['admin_id'] = Db::connect('shop')->table('eb_system_admin')->where('admin_id',$v['admin_id'])->value('real_name'); + + } + return table_assign(0, '', $list); + } + else{ + return view(); + } + } + + /** + * 添加 + */ + public function add() + { + if (request()->isAjax()) { + $param = get_params(); + + // 检验完整性 + try { + validate(UserExtractValidate::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + + $this->model->addUserExtract($param); + }else{ + return view(); + } + } + + + /** + * 编辑 + */ + public function edit() + { + $param = get_params(); + + if (request()->isAjax()) { + // 检验完整性 + try { + validate(UserExtractValidate::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + + $this->model->editUserExtract($param); + }else{ + $extract_id = isset($param['extract_id']) ? $param['extract_id'] : 0; + $detail = $this->model->getUserExtractById($extract_id); + if (!empty($detail)) { + View::assign('detail', $detail); + return view(); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + } + + + /** + * 查看信息 + */ + public function read() + { + $param = get_params(); + $extract_id = isset($param['extract_id']) ? $param['extract_id'] : 0; + $detail = $this->model->getUserExtractById($extract_id); + if (!empty($detail)) { + View::assign('detail', $detail); + return view(); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + + /** + * 删除 + * type=0,逻辑删除,默认 + * type=1,物理删除 + */ + public function del() + { + $param = get_params(); + $extract_id = isset($param['extract_id']) ? $param['extract_id'] : 0; + $type = 1; + + $this->model->delUserExtractById($extract_id,$type); + } +} diff --git a/app/admin/controller/supplychain/Merchant.php b/app/admin/controller/supplychain/Merchant.php index d77e5f8..9e9e74e 100644 --- a/app/admin/controller/supplychain/Merchant.php +++ b/app/admin/controller/supplychain/Merchant.php @@ -129,8 +129,10 @@ class Merchant extends BaseController $total = StoreOrderModel::where($where)->count(); - $list = StoreOrderModel::with(['merchant'])->order('order_id desc')->select(); - + $list = StoreOrderModel::with(['merchant'])->order('order_id desc')->page($params['page'])->limit($params['limit'])->select(); + foreach ($list as $k =>$v){ + $list[$k]['uid'] = Db::connect('shop')->table('eb_user')->where('uid',$v['uid'])->value('nickname'); + } View::assign('url', $this->url); View::assign('list', $list); diff --git a/app/admin/model/UserExtract.php b/app/admin/model/UserExtract.php new file mode 100644 index 0000000..45883eb --- /dev/null +++ b/app/admin/model/UserExtract.php @@ -0,0 +1,102 @@ +field('extract_id,extract_id,uid,extract_sn,real_name,extract_type,bank_code,bank_address,alipay_code,wechat,extract_pic,extract_price,balance,mark,admin_id,fail_msg,status_time,create_time,status,bank_name')->order($order)->paginate($rows, false, ['query' => $param]); + return $list; + } + + /** + * 添加数据 + * @param $param + */ + public function addUserExtract($param) + { + $insertId = 0; + try { + $param['create_time'] = time(); + $insertId = self::strict(false)->field(true)->insertGetId($param); + add_log('add', $insertId, $param); + } catch(\Exception $e) { + return to_assign(1, '操作失败,原因:'.$e->getMessage()); + } + return to_assign(0,'操作成功',['aid'=>$insertId]); + } + + /** + * 编辑信息 + * @param $param + */ + public function editUserExtract($param) + { + try { + $param['update_time'] = time(); + self::where('extract_id', $param['extract_id'])->strict(false)->field(true)->update($param); + add_log('edit', $param['id'], $param); + } catch(\Exception $e) { + return to_assign(1, '操作失败,原因:'.$e->getMessage()); + } + return to_assign(); + } + + + /** + * 根据id获取信息 + * @param $id + */ + public function getUserExtractById($id) + { + $info = self::where('extract_id', $id)->find(); + return $info; + } + + /** + * 删除信息 + * @param $id + * @return array + */ + public function delUserExtractById($id,$type=0) + { + if($type==0){ + //逻辑删除 + try { + $param['delete_time'] = time(); + self::where('extract_id', $id)->update(['delete_time'=>time()]); + add_log('delete', $id); + } catch(\Exception $e) { + return to_assign(1, '操作失败,原因:'.$e->getMessage()); + } + } + else{ + //物理删除 + try { + self::where('extract_id', $id)->delete(); + add_log('delete', $id); + } catch(\Exception $e) { + return to_assign(1, '操作失败,原因:'.$e->getMessage()); + } + } + return to_assign(); + } +} + diff --git a/app/admin/validate/UserExtractValidate.php b/app/admin/validate/UserExtractValidate.php new file mode 100644 index 0000000..de6ec0f --- /dev/null +++ b/app/admin/validate/UserExtractValidate.php @@ -0,0 +1,20 @@ + 'require', +]; + + protected $message = [ + 'extract_id.require' => 'ID不能为空', +]; +} \ No newline at end of file diff --git a/app/admin/view/supply_brokerage/datalist.html b/app/admin/view/supply_brokerage/datalist.html index d61742a..efe1796 100644 --- a/app/admin/view/supply_brokerage/datalist.html +++ b/app/admin/view/supply_brokerage/datalist.html @@ -19,7 +19,7 @@ {/block} diff --git a/app/admin/view/supplychain/merchant/bill.html b/app/admin/view/supplychain/merchant/bill.html index d1e1ab5..404208c 100644 --- a/app/admin/view/supplychain/merchant/bill.html +++ b/app/admin/view/supplychain/merchant/bill.html @@ -21,13 +21,13 @@ - + + + + + + + - + + + + + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/user_extract/datalist.html b/app/admin/view/user_extract/datalist.html new file mode 100644 index 0000000..d326138 --- /dev/null +++ b/app/admin/view/user_extract/datalist.html @@ -0,0 +1,218 @@ +{extend name="common/base"/} + +{block name="body"} + +
+ +
+ +
+ + +
+
+ + + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/user_extract/edit.html b/app/admin/view/user_extract/edit.html new file mode 100644 index 0000000..b37f699 --- /dev/null +++ b/app/admin/view/user_extract/edit.html @@ -0,0 +1,45 @@ +{extend name="common/base"/} + +{block name="body"} +
+

编辑用户提现表

+ + + + +
ID*
+
+ + + +
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/user_extract/read.html b/app/admin/view/user_extract/read.html new file mode 100644 index 0000000..9099df0 --- /dev/null +++ b/app/admin/view/user_extract/read.html @@ -0,0 +1,13 @@ +{extend name="common/base"/} + +{block name="body"} +
+

用户提现表详情

+ + + + +
ID{$detail.extract_id}
+
+{/block} + \ No newline at end of file