From 49080c9b0bc5dec728d47451d28d1e26bc276f06 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Wed, 1 Mar 2023 17:53:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E9=93=BE=E6=A8=A1=E5=9D=97=E5=88=9D=E5=A7=8B=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/supplychain/Index.php | 60 ++++++++++++++++ app/admin/controller/supplychain/Merchant.php | 71 +++++++++++++++++++ app/admin/view/supplychain/index/index.html | 0 app/admin/view/supplychain/merchant/bill.html | 0 .../view/supplychain/merchant/index.html | 0 5 files changed, 131 insertions(+) create mode 100644 app/admin/controller/supplychain/Index.php create mode 100644 app/admin/controller/supplychain/Merchant.php create mode 100644 app/admin/view/supplychain/index/index.html create mode 100644 app/admin/view/supplychain/merchant/bill.html create mode 100644 app/admin/view/supplychain/merchant/index.html diff --git a/app/admin/controller/supplychain/Index.php b/app/admin/controller/supplychain/Index.php new file mode 100644 index 0000000..236838e --- /dev/null +++ b/app/admin/controller/supplychain/Index.php @@ -0,0 +1,60 @@ +adminInfo = get_login_admin(); + } + + /** + * + * 供应链团队列表 + * + */ + public function Index() + { + return view(); + } + + /** + * + * 新增 + * + */ + public function add() + { + return view(); + } + + /** + * + * 编辑 + * + */ + public function edit() + { + return view(); + } + + /** + * + * 删除 + * + */ + public function delete() + { + return view(); + } + +} \ No newline at end of file diff --git a/app/admin/controller/supplychain/Merchant.php b/app/admin/controller/supplychain/Merchant.php new file mode 100644 index 0000000..c5891c4 --- /dev/null +++ b/app/admin/controller/supplychain/Merchant.php @@ -0,0 +1,71 @@ +adminInfo = get_login_admin(); + } + + /** + * + * 供应链团队列表 + * + */ + public function index() + { + return view(); + } + + /** + * + * 交易订单 + * + */ + public function bill() + { + return view(); + + } + + /** + * + * 新增 + * + */ + public function add() + { + return view(); + } + + /** + * + * 编辑 + * + */ + public function edit() + { + return view(); + } + + /** + * + * 删除 + * + */ + public function delete() + { + return view(); + } + +} \ No newline at end of file diff --git a/app/admin/view/supplychain/index/index.html b/app/admin/view/supplychain/index/index.html new file mode 100644 index 0000000..e69de29 diff --git a/app/admin/view/supplychain/merchant/bill.html b/app/admin/view/supplychain/merchant/bill.html new file mode 100644 index 0000000..e69de29 diff --git a/app/admin/view/supplychain/merchant/index.html b/app/admin/view/supplychain/merchant/index.html new file mode 100644 index 0000000..e69de29 From a6fd1e14f825a456579f2fb9eb6484b3892dfbb0 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Thu, 2 Mar 2023 13:37:31 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=A1=86=E6=9E=B6=EF=BC=8C=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/supplychain/Index.php | 96 +++++++++- app/admin/model/Merchant.php | 32 ++++ app/admin/model/SupplyChain.php | 29 +++ app/admin/model/SupplyChainLinkMerchant.php | 38 ++++ app/admin/view/supplychain/index/add.html | 150 +++++++++++++++ app/admin/view/supplychain/index/edit.html | 133 +++++++++++++ app/admin/view/supplychain/index/index.html | 174 ++++++++++++++++++ app/admin/view/supplychain/index/read.html | 67 +++++++ app/admin/view/supplychain/merchant/add.html | 138 ++++++++++++++ app/admin/view/supplychain/merchant/edit.html | 133 +++++++++++++ .../view/supplychain/merchant/index.html | 174 ++++++++++++++++++ app/admin/view/supplychain/merchant/read.html | 67 +++++++ 12 files changed, 1228 insertions(+), 3 deletions(-) create mode 100644 app/admin/model/Merchant.php create mode 100644 app/admin/model/SupplyChain.php create mode 100644 app/admin/model/SupplyChainLinkMerchant.php create mode 100644 app/admin/view/supplychain/index/add.html create mode 100644 app/admin/view/supplychain/index/edit.html create mode 100644 app/admin/view/supplychain/index/read.html create mode 100644 app/admin/view/supplychain/merchant/add.html create mode 100644 app/admin/view/supplychain/merchant/edit.html create mode 100644 app/admin/view/supplychain/merchant/read.html diff --git a/app/admin/controller/supplychain/Index.php b/app/admin/controller/supplychain/Index.php index 236838e..f2a78b6 100644 --- a/app/admin/controller/supplychain/Index.php +++ b/app/admin/controller/supplychain/Index.php @@ -9,12 +9,24 @@ namespace app\admin\controller\supplychain; use app\admin\BaseController; use think\facade\Db; use think\facade\View; +use app\admin\model\Merchant; // 商户模型 +use app\api\model\Area as AreaModel; // 市场区域模型 +use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型 class Index extends BaseController { public function __construct() { $this->adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/supplychain.index/index?category_id='.$this->category_id, + '/admin/supplychain.index/add', + '/admin/supplychain.index/edit', + '/admin/supplychain.index/delete', + '/admin/supplychain.merchant/index', + '/admin/supplychain.merchant/bill', + ]; } /** @@ -22,9 +34,53 @@ class Index extends BaseController * 供应链团队列表 * */ - public function Index() + public function index() { - return view(); + if (request()->isAjax()) { + + $params= get_params(); + + $where[]= ['status','=',0]; + + 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 = AreaManagerModel::where($where)->count(); + + // 负责人信息 + $list = AreaManagerModel::with('area') + ->where($where) + ->page($params['page']) + ->limit($params['limit']) + ->order('id desc') + ->select(); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + return view('nk/areamanager/index',['url'=>$this->url]); + } } /** @@ -34,7 +90,41 @@ class Index extends BaseController */ public function add() { - return view(); + if (request()->isAjax()) { + + $params= get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['avatar'] = $params['avatar']; // 头像 + $data['name'] = $params['name']; // 姓名 + $data['duty'] = $params['duty']; // 职务 + $data['phone'] = $params['phone']; // 手机号 + $data['area_id'] = $params['area_id']; // 区域ID + + $area = AreaModel::find($params['area_id']); + $data['farm_product_market_id'] = $area->id; // 市场ID + + $data['created_at'] = date('Y-m-d H:i:s'); + $res = AreaManagerModel::create($data); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $area = AreaModel::where('status', 0)->column('id, area_name'); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + View::assign('editor', get_system_config('other','editor')); + View::assign('area', $area); + View::assign('merchant', $merchant); + return view(); + } } /** diff --git a/app/admin/model/Merchant.php b/app/admin/model/Merchant.php new file mode 100644 index 0000000..0c56b58 --- /dev/null +++ b/app/admin/model/Merchant.php @@ -0,0 +1,32 @@ +hasOneThrough(SupplyChainLinkMerchant::class, SupplyChain::class); + } + + + } \ No newline at end of file diff --git a/app/admin/model/SupplyChain.php b/app/admin/model/SupplyChain.php new file mode 100644 index 0000000..87b0314 --- /dev/null +++ b/app/admin/model/SupplyChain.php @@ -0,0 +1,29 @@ +hasManyThrough(SupplyChainLinkMerchant::class, Merchant::class); + } + + + } \ No newline at end of file diff --git a/app/admin/model/SupplyChainLinkMerchant.php b/app/admin/model/SupplyChainLinkMerchant.php new file mode 100644 index 0000000..2c8e6af --- /dev/null +++ b/app/admin/model/SupplyChainLinkMerchant.php @@ -0,0 +1,38 @@ +hasOne(SupplyChain::class); + } + + /** + * + * 所属商户 + * 一对一 + * + */ + public function merchant() + { + return $this->hasOne(); + } + } \ No newline at end of file diff --git a/app/admin/view/supplychain/index/add.html b/app/admin/view/supplychain/index/add.html new file mode 100644 index 0000000..2b80b87 --- /dev/null +++ b/app/admin/view/supplychain/index/add.html @@ -0,0 +1,150 @@ +{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/supplychain/index/edit.html b/app/admin/view/supplychain/index/edit.html new file mode 100644 index 0000000..a27228d --- /dev/null +++ b/app/admin/view/supplychain/index/edit.html @@ -0,0 +1,133 @@ +{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/supplychain/index/index.html b/app/admin/view/supplychain/index/index.html index e69de29..acad52f 100644 --- a/app/admin/view/supplychain/index/index.html +++ b/app/admin/view/supplychain/index/index.html @@ -0,0 +1,174 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/index/read.html b/app/admin/view/supplychain/index/read.html new file mode 100644 index 0000000..3fffad9 --- /dev/null +++ b/app/admin/view/supplychain/index/read.html @@ -0,0 +1,67 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
标题*
简介* + +
内容 + +
坐标 +

经度:{$detail.lng}

+

纬度:{$detail.lat}

+ +
运输距离 + {volist name='farmers' id='vo'} +

距离 {$vo.title} {$vo.juli} 公里

+ {/volist} +
+
+{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/add.html b/app/admin/view/supplychain/merchant/add.html new file mode 100644 index 0000000..a408038 --- /dev/null +++ b/app/admin/view/supplychain/merchant/add.html @@ -0,0 +1,138 @@ +{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/supplychain/merchant/edit.html b/app/admin/view/supplychain/merchant/edit.html new file mode 100644 index 0000000..a27228d --- /dev/null +++ b/app/admin/view/supplychain/merchant/edit.html @@ -0,0 +1,133 @@ +{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/supplychain/merchant/index.html b/app/admin/view/supplychain/merchant/index.html index e69de29..acad52f 100644 --- a/app/admin/view/supplychain/merchant/index.html +++ b/app/admin/view/supplychain/merchant/index.html @@ -0,0 +1,174 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/read.html b/app/admin/view/supplychain/merchant/read.html new file mode 100644 index 0000000..3fffad9 --- /dev/null +++ b/app/admin/view/supplychain/merchant/read.html @@ -0,0 +1,67 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
标题*
简介* + +
内容 + +
坐标 +

经度:{$detail.lng}

+

纬度:{$detail.lat}

+ +
运输距离 + {volist name='farmers' id='vo'} +

距离 {$vo.title} {$vo.juli} 公里

+ {/volist} +
+
+{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file From 09048ec2e58ddfff07e709851fc2e2c73e3fe81e Mon Sep 17 00:00:00 2001 From: monanxiao Date: Thu, 2 Mar 2023 17:59:15 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E9=93=BE=E5=B9=B3=E5=8F=B0=E5=90=8E=E5=8F=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=8C=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/supplychain/Index.php | 89 +++++--- app/admin/model/GeoArea.php | 26 +++ app/admin/model/GeoCity.php | 19 ++ app/admin/model/GeoStreet.php | 27 +++ app/admin/model/Merchant.php | 1 + app/admin/model/SupplyChain.php | 30 ++- app/admin/model/SupplyChainLinkMerchant.php | 14 +- app/admin/view/supplychain/index/add.html | 169 +++++++++------ app/admin/view/supplychain/index/edit.html | 226 +++++++++++++------- app/admin/view/supplychain/index/index.html | 46 +++- 10 files changed, 473 insertions(+), 174 deletions(-) create mode 100644 app/admin/model/GeoArea.php create mode 100644 app/admin/model/GeoCity.php create mode 100644 app/admin/model/GeoStreet.php diff --git a/app/admin/controller/supplychain/Index.php b/app/admin/controller/supplychain/Index.php index f2a78b6..03caf01 100644 --- a/app/admin/controller/supplychain/Index.php +++ b/app/admin/controller/supplychain/Index.php @@ -10,6 +10,10 @@ use app\admin\BaseController; use think\facade\Db; use think\facade\View; use app\admin\model\Merchant; // 商户模型 +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; // 区域负责人模型 @@ -63,15 +67,12 @@ class Index extends BaseController } } - $total = AreaManagerModel::where($where)->count(); + $total = SupplyChain::where($where)->count(); - // 负责人信息 - $list = AreaManagerModel::with('area') - ->where($where) - ->page($params['page']) - ->limit($params['limit']) - ->order('id desc') - ->select(); + $list = SupplyChain::order('id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); $result = ['total' => $total, 'data' => $list]; @@ -79,7 +80,11 @@ class Index extends BaseController }else{ - return view('nk/areamanager/index',['url'=>$this->url]); + $list = SupplyChain::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); } } @@ -92,20 +97,37 @@ class Index extends BaseController { if (request()->isAjax()) { - $params= get_params(); - - $data['user_id'] = $this->adminInfo['id']; // 操作用户ID - $data['avatar'] = $params['avatar']; // 头像 - $data['name'] = $params['name']; // 姓名 - $data['duty'] = $params['duty']; // 职务 - $data['phone'] = $params['phone']; // 手机号 - $data['area_id'] = $params['area_id']; // 区域ID + $params = get_params(); - $area = AreaModel::find($params['area_id']); - $data['farm_product_market_id'] = $area->id; // 市场ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); - $data['created_at'] = date('Y-m-d H:i:s'); - $res = AreaManagerModel::create($data); + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'mer_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } if ($res){ return to_assign(0,'操作成功',['aid'=>$res]); @@ -115,14 +137,16 @@ class Index extends BaseController }else{ - $area = AreaModel::where('status', 0)->column('id, area_name'); - // 取出正常的商家 $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + View::assign('editor', get_system_config('other','editor')); - View::assign('area', $area); + View::assign('arealist', $arealist); View::assign('merchant', $merchant); + View::assign('url', $this->url); return view(); } } @@ -134,6 +158,21 @@ class Index extends BaseController */ public function edit() { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); return view(); } @@ -146,5 +185,5 @@ class Index extends BaseController { return view(); } - + } \ No newline at end of file diff --git a/app/admin/model/GeoArea.php b/app/admin/model/GeoArea.php new file mode 100644 index 0000000..3ac0060 --- /dev/null +++ b/app/admin/model/GeoArea.php @@ -0,0 +1,26 @@ +hasOne(GeoArea::class, 'area_code', 'area_code'); + } + } \ No newline at end of file diff --git a/app/admin/model/GeoCity.php b/app/admin/model/GeoCity.php new file mode 100644 index 0000000..ea24176 --- /dev/null +++ b/app/admin/model/GeoCity.php @@ -0,0 +1,19 @@ +hasOne(GeoArea::class, 'area_code', 'area_code'); + } + } \ No newline at end of file diff --git a/app/admin/model/Merchant.php b/app/admin/model/Merchant.php index 0c56b58..32cb06d 100644 --- a/app/admin/model/Merchant.php +++ b/app/admin/model/Merchant.php @@ -17,6 +17,7 @@ // 设置当前模型对应的完整数据表名称 protected $table = 'eb_merchant'; + protected $pk = 'mer_id'; /** * 所属供应链 diff --git a/app/admin/model/SupplyChain.php b/app/admin/model/SupplyChain.php index 87b0314..3bb4bd5 100644 --- a/app/admin/model/SupplyChain.php +++ b/app/admin/model/SupplyChain.php @@ -22,8 +22,36 @@ */ public function merchant() { - return $this->hasManyThrough(SupplyChainLinkMerchant::class, Merchant::class); + return $this->belongsToMany(Merchant::class, SupplyChainLinkMerchant::class, 'eb_merchant_id', 'fa_supply_chain_id'); } + /** + * + * 关联中间表 + * + */ + public function linkMerchant() + { + return $this->hasMany(SupplyChainLinkMerchant::class); + } + /** + * 关联街道 + * + * + */ + public function street() + { + return $this->hasOne(GeoStreet::class, 'street_id', 'street_id'); + } + + /** + * 关联区县 + * + * + */ + public function area() + { + return $this->hasOne(GeoArea::class, 'area_id', 'area_id'); + } } \ No newline at end of file diff --git a/app/admin/model/SupplyChainLinkMerchant.php b/app/admin/model/SupplyChainLinkMerchant.php index 2c8e6af..f778055 100644 --- a/app/admin/model/SupplyChainLinkMerchant.php +++ b/app/admin/model/SupplyChainLinkMerchant.php @@ -9,12 +9,18 @@ namespace app\admin\model; use think\Model; - - class SupplyChainLinkMerchant extends Model - { + use think\model\Pivot; + + class SupplyChainLinkMerchant extends Pivot + { + protected $autoWriteTimestamp = true; + + // 设置当前模型的数据库连接 + protected $connection = 'mysql'; + // 设置当前模型对应的完整数据表名称 protected $table = 'fa_supply_chain_link_merchant'; - + /** * 所属供应链 * 一对一 diff --git a/app/admin/view/supplychain/index/add.html b/app/admin/view/supplychain/index/add.html index 2b80b87..479d6ba 100644 --- a/app/admin/view/supplychain/index/add.html +++ b/app/admin/view/supplychain/index/add.html @@ -20,14 +20,14 @@ {/block} {block name="body"} -
+

关联商户

- - + - + + + + -
选择商户* -
+
选择商户 +
-
- +
+
+
@@ -50,13 +50,13 @@
-
+
-
- +
+
@@ -65,15 +65,33 @@
-
- +
+
- + +
+
+
请选择所在地址* +
+ +
+
+ +
+
@@ -86,64 +104,95 @@ {block name="script"} - - - + - {/block} diff --git a/app/admin/view/supplychain/index/edit.html b/app/admin/view/supplychain/index/edit.html index a27228d..2a6e0b3 100644 --- a/app/admin/view/supplychain/index/edit.html +++ b/app/admin/view/supplychain/index/edit.html @@ -22,49 +22,81 @@

编辑

- - + + + + + + + + + + + + - - - - + - - - - + @@ -83,51 +115,93 @@ {/block} \ No newline at end of file diff --git a/app/admin/view/supplychain/index/index.html b/app/admin/view/supplychain/index/index.html index acad52f..4457ce5 100644 --- a/app/admin/view/supplychain/index/index.html +++ b/app/admin/view/supplychain/index/index.html @@ -5,7 +5,7 @@
- +
@@ -69,30 +69,60 @@ width:80, },{ field: 'area', - title: '区域', + title: '地址', align: 'center', templet: function (d) { - var html = '【' + d['area']['area_name'] + '】' + var html = 11; return html; }, width:120, + },{ + field: 'mer_id', + title: '主商户', + align: 'center', + width:120, + templet: function (d) + { + var html = d.mer_id?d.mer_id:'待定'; + return html; + }, },{ field: 'name', title: '姓名', align: 'center', width:120, },{ - field: 'duty', - title: '职务', + field: 'tel', + title: '联系电话', align: 'center', width:150, },{ - field: 'phone', - title: '电话', + field: 'earnings_amount', + title: '净收益', align: 'center', width:150, },{ + field: 'bill_amount', + title: '流水', + align: 'center', + width:150, + },{ + field: 'brokerage', + title: '分销佣金', + align: 'center', + width:150, + },{ + field: 'order_number', + title: '支付订单数量', + align: 'center', + width:150, + },{ + field: 'cancel_order_number', + title: '取消支付订单数量', + align: 'center', + width:150, + },,{ field: 'status', title: '状态', align: 'center', @@ -105,7 +135,7 @@ return html; }, },{ - field: 'created_at', + field: 'create_time', title: '添加时间', align: 'center', width:150, From 85d6b9407abcf5e670f97bff3f7b64b5cb260eea Mon Sep 17 00:00:00 2001 From: monanxiao Date: Fri, 3 Mar 2023 18:03:28 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E9=93=BE=E5=9B=A2=E9=98=9F=E5=BB=BA=E8=AE=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/supplychain/Index.php | 98 +++++- app/admin/controller/supplychain/Merchant.php | 118 +++++++- app/admin/model/EbStoreProduct.php | 22 ++ app/admin/model/StoreCart.php | 40 +++ app/admin/model/StoreOrder.php | 64 ++++ app/admin/model/SupplyChain.php | 9 +- app/admin/model/SupplyChainLinkMerchant.php | 4 +- app/admin/view/supplychain/index/add.html | 3 +- app/admin/view/supplychain/index/edit.html | 18 +- app/admin/view/supplychain/index/index.html | 7 +- app/admin/view/supplychain/merchant/bill.html | 280 ++++++++++++++++++ .../view/supplychain/merchant/index.html | 147 +++++++-- 12 files changed, 744 insertions(+), 66 deletions(-) create mode 100644 app/admin/model/EbStoreProduct.php create mode 100644 app/admin/model/StoreCart.php create mode 100644 app/admin/model/StoreOrder.php diff --git a/app/admin/controller/supplychain/Index.php b/app/admin/controller/supplychain/Index.php index 03caf01..fe57dad 100644 --- a/app/admin/controller/supplychain/Index.php +++ b/app/admin/controller/supplychain/Index.php @@ -69,7 +69,7 @@ class Index extends BaseController $total = SupplyChain::where($where)->count(); - $list = SupplyChain::order('id desc')->select(); + $list = SupplyChain::with(['merchant', 'street', 'area'])->order('id desc')->select(); View::assign('url', $this->url); View::assign('list', $list); @@ -121,7 +121,7 @@ class Index extends BaseController foreach ($params['mer_id'] as $v) { $dataLink = [ - 'mer_id' => $v, // 商户ID + 'eb_merchant_id' => $v, // 商户ID 'user_id' => $data['user_id'], 'create_time' => $data['create_time'], ]; @@ -161,19 +161,75 @@ class Index extends BaseController $id = get_params("id"); if(!$id) return to_assign(1, '非法操作!'); - $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + if (request()->isAjax()) { + + $params = get_params(); + + $data['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } - View::assign('detail', $supplyChain); - - // 取出正常的商家 - $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); - // 区域模型 - $arealist = GeoArea::where('city_code', '510500')->select(); - - View::assign('arealist', $arealist); - View::assign('merchant', $merchant); - View::assign('url', $this->url); - return view(); } /** @@ -183,7 +239,19 @@ class Index extends BaseController */ public function delete() { - return view(); + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['linkMerchant'])->find($id); + // 删除关联模型 + $res = $supplyChain->together(['linkMerchant'])->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + } } \ No newline at end of file diff --git a/app/admin/controller/supplychain/Merchant.php b/app/admin/controller/supplychain/Merchant.php index c5891c4..d77e5f8 100644 --- a/app/admin/controller/supplychain/Merchant.php +++ b/app/admin/controller/supplychain/Merchant.php @@ -9,12 +9,30 @@ namespace app\admin\controller\supplychain; use app\admin\BaseController; use think\facade\Db; use think\facade\View; +use app\admin\model\Merchant as MerchantModel; // 商户模型 +use app\admin\model\StoreOrder as StoreOrderModel; // 商户订单模型 +use app\admin\model\GeoCity; // 省市模型 +use app\admin\model\GeoArea; // 区域模型 +use app\admin\model\GeoStreet; // 街道模型 +use app\admin\model\SupplyChain; // 供应链模型 +use app\admin\model\SupplyChainLinkMerchant; // 供应链关联商户模型 +use app\api\model\Area as AreaModel; // 市场区域模型 +use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型 class Merchant extends BaseController { public function __construct() { $this->adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/supplychain.index/index?category_id='.$this->category_id, + '/admin/supplychain.index/add', + '/admin/supplychain.index/edit', + '/admin/supplychain.index/delete', + '/admin/supplychain.merchant/index', + '/admin/supplychain.merchant/bill', + ]; } /** @@ -24,7 +42,55 @@ class Merchant extends BaseController */ public function index() { - return view(); + 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 = SupplyChainLinkMerchant::where($where)->count(); + + $list = SupplyChainLinkMerchant::with(['supplyChain', 'merchant'])->order('id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $total = SupplyChainLinkMerchant::count(); + $list = SupplyChainLinkMerchant::with(['merchant', 'supplyChain'])->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + return view(); + } } /** @@ -34,7 +100,55 @@ class Merchant extends BaseController */ public function bill() { - return view(); + 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 = StoreOrderModel::where($where)->count(); + + $list = StoreOrderModel::with(['merchant'])->order('order_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $total = StoreOrderModel::count(); + $list = StoreOrderModel::with(['merchant'])->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + return view(); + } } diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php new file mode 100644 index 0000000..28c3804 --- /dev/null +++ b/app/admin/model/EbStoreProduct.php @@ -0,0 +1,22 @@ +hasOne(EbStoreProduct::class, 'product_id', 'product_id'); + } + + /** + * + * 所属用户 + * + */ + public function user() + { + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/StoreOrder.php b/app/admin/model/StoreOrder.php new file mode 100644 index 0000000..0fbfa00 --- /dev/null +++ b/app/admin/model/StoreOrder.php @@ -0,0 +1,64 @@ +hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + + /** + * 所属商品 + * + */ + public function cart() + { + return $this->hasOne(StoreCart::class, 'cart_id', 'cart_id'); + } + + /** + * 获取购物车商品 + * + */ + public function getCartIdAttr($value) + { + // 分割为数组 + $cartId = explode(',', $value); + // 购物车ID + $scartList = StoreCart::whereIn('cart_id', $cartId)->with(['product'])->select(); + + return $scartList; + } + + /** + * + * 所属用户 + * + */ + public function user() + { + return $this->hasOne(Merchant::class, 'mer_id', 'mer_id'); + } + } \ No newline at end of file diff --git a/app/admin/model/SupplyChain.php b/app/admin/model/SupplyChain.php index 3bb4bd5..2b6762a 100644 --- a/app/admin/model/SupplyChain.php +++ b/app/admin/model/SupplyChain.php @@ -12,17 +12,20 @@ class SupplyChain extends Model { + // 设置当前模型的数据库连接 + protected $connection = 'mysql'; + // 设置当前模型对应的完整数据表名称 protected $table = 'fa_supply_chain'; /** * 关联拥有多个商户 * 远程一对多 - * + * 关联模型、中间模型 */ public function merchant() { - return $this->belongsToMany(Merchant::class, SupplyChainLinkMerchant::class, 'eb_merchant_id', 'fa_supply_chain_id'); + return $this->hasManyThrough(Merchant::class, SupplyChainLinkMerchant::class, 'fa_supply_chain_id', 'mer_id', 'id', 'eb_merchant_id'); } /** @@ -32,7 +35,7 @@ */ public function linkMerchant() { - return $this->hasMany(SupplyChainLinkMerchant::class); + return $this->hasMany(SupplyChainLinkMerchant::class, 'fa_supply_chain_id'); } /** diff --git a/app/admin/model/SupplyChainLinkMerchant.php b/app/admin/model/SupplyChainLinkMerchant.php index f778055..b2cf046 100644 --- a/app/admin/model/SupplyChainLinkMerchant.php +++ b/app/admin/model/SupplyChainLinkMerchant.php @@ -28,7 +28,7 @@ */ public function supplyChain() { - return $this->hasOne(SupplyChain::class); + return $this->hasOne(SupplyChain::class, 'id', 'fa_supply_chain_id'); } /** @@ -39,6 +39,6 @@ */ public function merchant() { - return $this->hasOne(); + return $this->hasOne(Merchant::class, 'mer_id', 'eb_merchant_id'); } } \ No newline at end of file diff --git a/app/admin/view/supplychain/index/add.html b/app/admin/view/supplychain/index/add.html index 479d6ba..b4b9888 100644 --- a/app/admin/view/supplychain/index/add.html +++ b/app/admin/view/supplychain/index/add.html @@ -180,7 +180,8 @@ data: [], radio: true, initValue: [], - disabled: group_access == 2 || group_access==4 ? true : false + disabled: group_access == 2 || group_access==4 ? true : false, + }); $.get('/api/geo/street?pcode=' + id, function (result) { diff --git a/app/admin/view/supplychain/index/edit.html b/app/admin/view/supplychain/index/edit.html index 2a6e0b3..dff1dd2 100644 --- a/app/admin/view/supplychain/index/edit.html +++ b/app/admin/view/supplychain/index/edit.html @@ -19,6 +19,7 @@ {block name="body"}
+

编辑

所属区域* -
-
选择商户 +
+ + +
+
+
+ +
+ {$detail} + {volist name='arealist' id='vo'} + {/volist} +
+
+
+
+
+
+ +
+ +
姓名* - + +
+ +
+ +
+
负责人头像 -
- -
- - -
-
-
职务* - - 电话* - + 请选择所在地址* +
+ +
+
+ +
+ {$detail.address} +
+
+
@@ -37,12 +38,12 @@ @@ -86,14 +87,12 @@ {else /} {/if} - {/volist}
- {$detail.address}
@@ -114,6 +113,7 @@ {block name="script"} + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/supplychain/merchant/index.html b/app/admin/view/supplychain/merchant/index.html index acad52f..0ec5f85 100644 --- a/app/admin/view/supplychain/merchant/index.html +++ b/app/admin/view/supplychain/merchant/index.html @@ -5,7 +5,7 @@
- +
@@ -56,7 +56,7 @@ elem: '#article', title: '列表', toolbar: '#toolbarDemo', - url: '{$url[0]}', + url: '{$url[4]}', page: true, limit: 20, cols: [ @@ -68,53 +68,138 @@ align: 'center', width:80, },{ - field: 'area', - title: '区域', + fixed: 'left', + field: 'supplyChain', + title: '供应链', align: 'center', templet: function (d) { - var html = '【' + d['area']['area_name'] + '】' + var html = d.supplyChain.name; return html; }, width:120, },{ - field: 'name', - title: '姓名', - align: 'center', - width:120, - },{ - field: 'duty', - title: '职务', - align: 'center', - width:150, - },{ - field: 'phone', - title: '电话', - align: 'center', - width:150, - },{ - field: 'status', - title: '状态', + field: 'brokerage', + title: '团队负责人', align: 'center', templet: function (d) { - var html = '禁用'; - if (d.status == '0') { + var html = d.principal ? '是': '否'; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '商户', + align: 'center', + templet: function (d) + { + var html = d.merchant.mer_name; + return html; + }, + width:120, + },{ + field: 'merchant', + title: '姓名', + align: 'center', + templet: function (d) + { + var html = d.merchant.real_name; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '联系电话', + align: 'center', + templet: function (d) + { + var html = d.merchant.mer_phone; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '店铺状态', + align: 'center', + templet: function (d) + { + var html = '锁定'; + if (d.merchant.status == 1) { html = '正常'; } return html; }, },{ - field: 'created_at', - title: '添加时间', + field: 'merchant', + title: '产品数量', + align: 'center', + templet: function (d) + { + var html = d.merchant.mer_phone; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '产品数量', + align: 'center', + templet: function (d) + { + var html = d.merchant.mer_phone; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '余额', + align: 'center', + templet: function (d) + { + var html = d.merchant.mer_money; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '保证金', + align: 'center', + templet: function (d) + { + var html = d.merchant.margin; + return html; + }, + width:150, + },{ + field: 'order_number', + title: '销量', + align: 'center', + templet: function (d) + { + var html = d.merchant.sales; + return html; + }, + width:150, + },{ + field: 'merchant', + title: '商户地址', + templet: function (d) + { + var html = d.merchant.mer_address; + return html; + }, align: 'center', width:150, },{ - fixed: 'right', - field: 'right', - title: '操作', - toolbar: '#barDemo', - align: 'center' + field: 'merchant', + title: '入驻时间', + align: 'center', + templet: function (d) + { + var html = d.merchant.create_time; + return html; + }, + width:150, } ] ] From 9b81c17b3963c5c59aab060019fc25777b3775de Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 4 Mar 2023 11:41:12 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=95=86=E5=93=81?= =?UTF-8?q?=E3=80=81=E5=95=86=E6=88=B7=E7=B1=BB=E5=9E=8B=E3=80=81=E5=95=86?= =?UTF-8?q?=E6=88=B7=E5=88=86=E7=B1=BB=E3=80=81=E5=95=86=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E3=80=81=E8=AF=84=E8=AE=BA=E6=A8=A1=E5=9E=8B=EF=BC=9B?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=95=86=E5=93=81=E3=80=81=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E3=80=81=E8=AF=84=E8=AE=BA=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=EF=BC=9B=E6=96=B0=E5=BB=BA=E5=95=86=E5=93=81=E3=80=81?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB=E3=80=81=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/product/Classify.php | 262 ++++++++++++++++++++ app/admin/controller/product/Comment.php | 263 +++++++++++++++++++++ app/admin/controller/product/Product.php | 262 ++++++++++++++++++++ app/admin/model/EbStoreProduct.php | 11 +- app/admin/model/Merchant.php | 19 ++ app/admin/model/MerchantCategory.php | 22 ++ app/admin/model/MerchantType.php | 22 ++ app/admin/model/StoreCategory.php | 22 ++ app/admin/model/StoreProductReply.php | 51 ++++ app/admin/view/product/classify/add.html | 200 ++++++++++++++++ app/admin/view/product/classify/edit.html | 188 +++++++++++++++ app/admin/view/product/classify/index.html | 185 +++++++++++++++ app/admin/view/product/comment/add.html | 200 ++++++++++++++++ app/admin/view/product/comment/edit.html | 188 +++++++++++++++ app/admin/view/product/comment/index.html | 200 ++++++++++++++++ app/admin/view/product/product/add.html | 200 ++++++++++++++++ app/admin/view/product/product/edit.html | 188 +++++++++++++++ app/admin/view/product/product/index.html | 236 ++++++++++++++++++ 18 files changed, 2718 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/product/Classify.php create mode 100644 app/admin/controller/product/Comment.php create mode 100644 app/admin/controller/product/Product.php create mode 100644 app/admin/model/MerchantCategory.php create mode 100644 app/admin/model/MerchantType.php create mode 100644 app/admin/model/StoreCategory.php create mode 100644 app/admin/model/StoreProductReply.php create mode 100644 app/admin/view/product/classify/add.html create mode 100644 app/admin/view/product/classify/edit.html create mode 100644 app/admin/view/product/classify/index.html create mode 100644 app/admin/view/product/comment/add.html create mode 100644 app/admin/view/product/comment/edit.html create mode 100644 app/admin/view/product/comment/index.html create mode 100644 app/admin/view/product/product/add.html create mode 100644 app/admin/view/product/product/edit.html create mode 100644 app/admin/view/product/product/index.html diff --git a/app/admin/controller/product/Classify.php b/app/admin/controller/product/Classify.php new file mode 100644 index 0000000..efd9cbb --- /dev/null +++ b/app/admin/controller/product/Classify.php @@ -0,0 +1,262 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.classify/index?category_id='.$this->category_id, + '/admin/product.classify/add', + '/admin/product.classify/edit', + '/admin/product.classify/delete' + ]; + } + + /** + * + * 商城分类列表 + * + */ + 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 = StoreCategory::where('level', 0)->where('mer_id', 0)->where($where)->count(); + + // $list = StoreCategory::with(['merchant', 'street', 'area'])->order('id desc')->select(); + $list = StoreCategory::where('level', 0)->where('mer_id', 0)->order('store_category_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreCategory::where('level', 0)->where('mer_id', 0)->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + 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['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $category = StoreCategory::find($id); // 取出当前供应链数据 + + View::assign('detail', $category); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function delete() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['linkMerchant'])->find($id); + // 删除关联模型 + $res = $supplyChain->together(['linkMerchant'])->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Comment.php b/app/admin/controller/product/Comment.php new file mode 100644 index 0000000..a4183ba --- /dev/null +++ b/app/admin/controller/product/Comment.php @@ -0,0 +1,263 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.comment/index?category_id='.$this->category_id, + '/admin/product.comment/add', + '/admin/product.comment/edit', + '/admin/product.comment/del', + '/admin/product.comment/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 = StoreProductReply::where($where)->count(); + + $list = StoreProductReply::with(['product'])->order('reply_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreProductReply::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + 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['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + $res = StoreProductReply::where('reply_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/controller/product/Product.php b/app/admin/controller/product/Product.php new file mode 100644 index 0000000..0d3466a --- /dev/null +++ b/app/admin/controller/product/Product.php @@ -0,0 +1,262 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.product/index?category_id='.$this->category_id, + '/admin/product.product/add', + '/admin/product.product/edit', + '/admin/product.product/delete', + '/admin/product.product/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 = EbStoreProduct::where($where)->count(); + + $list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = SupplyChain::with(['merchant' => ['merchantType', 'category']])->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + 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['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function delete() + { + $id = get_params("id"); + if(!$id) return to_assign(1, '非法操作!'); + + $supplyChain = SupplyChain::with(['linkMerchant'])->find($id); + // 删除关联模型 + $res = $supplyChain->together(['linkMerchant'])->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/model/EbStoreProduct.php b/app/admin/model/EbStoreProduct.php index 28c3804..b5a873b 100644 --- a/app/admin/model/EbStoreProduct.php +++ b/app/admin/model/EbStoreProduct.php @@ -1,6 +1,6 @@ hasOne(Merchant::class, 'mer_id', 'mer_id'); + } } \ No newline at end of file diff --git a/app/admin/model/Merchant.php b/app/admin/model/Merchant.php index 32cb06d..4368153 100644 --- a/app/admin/model/Merchant.php +++ b/app/admin/model/Merchant.php @@ -29,5 +29,24 @@ return $this->hasOneThrough(SupplyChainLinkMerchant::class, SupplyChain::class); } + /** + * + * 关联商户类型 + * + */ + public function merchantType() + { + return $this->hasOne(MerchantType::class, 'mer_type_id', 'type_id'); + } + + /** + * + * 关联商户类别 + * + */ + public function category() + { + return $this->hasOne(MerchantCategory::class, 'merchant_category_id', 'category_id'); + } } \ No newline at end of file diff --git a/app/admin/model/MerchantCategory.php b/app/admin/model/MerchantCategory.php new file mode 100644 index 0000000..b486efa --- /dev/null +++ b/app/admin/model/MerchantCategory.php @@ -0,0 +1,22 @@ +hasOne(EbStoreProduct::class, 'product_id', 'product_id'); + } + } \ No newline at end of file diff --git a/app/admin/view/product/classify/add.html b/app/admin/view/product/classify/add.html new file mode 100644 index 0000000..b4b9888 --- /dev/null +++ b/app/admin/view/product/classify/add.html @@ -0,0 +1,200 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

关联商户

+
-
+
- {$detail} - {volist name='arealist' id='vo'} - {/volist} + {volist name='detail.merchant' id='vo'} + + {/volist}
+ + + + + + + + + + + + + + + + + + + + + + + +
选择商户 +
+ +
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
请选择所在地址* +
+ +
+
+ +
+
+
+
+
+
+ + +
+ + +{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/product/classify/edit.html b/app/admin/view/product/classify/edit.html new file mode 100644 index 0000000..2ebf4e4 --- /dev/null +++ b/app/admin/view/product/classify/edit.html @@ -0,0 +1,188 @@ +{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/classify/index.html b/app/admin/view/product/classify/index.html new file mode 100644 index 0000000..ea8a104 --- /dev/null +++ b/app/admin/view/product/classify/index.html @@ -0,0 +1,185 @@ +{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/comment/add.html b/app/admin/view/product/comment/add.html new file mode 100644 index 0000000..b4b9888 --- /dev/null +++ b/app/admin/view/product/comment/add.html @@ -0,0 +1,200 @@ +{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/comment/edit.html b/app/admin/view/product/comment/edit.html new file mode 100644 index 0000000..2ebf4e4 --- /dev/null +++ b/app/admin/view/product/comment/edit.html @@ -0,0 +1,188 @@ +{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/comment/index.html b/app/admin/view/product/comment/index.html new file mode 100644 index 0000000..b369315 --- /dev/null +++ b/app/admin/view/product/comment/index.html @@ -0,0 +1,200 @@ +{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/add.html b/app/admin/view/product/product/add.html new file mode 100644 index 0000000..b4b9888 --- /dev/null +++ b/app/admin/view/product/product/add.html @@ -0,0 +1,200 @@ +{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/product/edit.html b/app/admin/view/product/product/edit.html new file mode 100644 index 0000000..2ebf4e4 --- /dev/null +++ b/app/admin/view/product/product/edit.html @@ -0,0 +1,188 @@ +{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/product/index.html b/app/admin/view/product/product/index.html new file mode 100644 index 0000000..57343c8 --- /dev/null +++ b/app/admin/view/product/product/index.html @@ -0,0 +1,236 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + + + + +{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file From 709c7f4ab7ab2ca530abc410cae7ea8623a98733 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 4 Mar 2023 17:33:04 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=97=E8=A1=A8=E3=80=81=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E3=80=81=E5=95=86=E5=93=81=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=9B=86=E6=88=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/common.php | 34 +++ app/admin/controller/product/Classify.php | 96 +++---- app/admin/controller/product/Label.php | 264 +++++++++++++++++ app/admin/model/StoreProductLabel.php | 51 ++++ app/admin/view/product/Label/add.html | 96 +++++++ app/admin/view/product/Label/edit.html | 188 ++++++++++++ app/admin/view/product/Label/index.html | 200 +++++++++++++ app/admin/view/product/classify/add.html | 319 +++++++++------------ app/admin/view/product/classify/index.html | 181 +++++------- 9 files changed, 1082 insertions(+), 347 deletions(-) create mode 100644 app/admin/controller/product/Label.php create mode 100644 app/admin/model/StoreProductLabel.php create mode 100644 app/admin/view/product/Label/add.html create mode 100644 app/admin/view/product/Label/edit.html create mode 100644 app/admin/view/product/Label/index.html diff --git a/app/admin/common.php b/app/admin/common.php index fd2aa8a..fae15ee 100644 --- a/app/admin/common.php +++ b/app/admin/common.php @@ -9,6 +9,8 @@ use think\facade\Config; use think\facade\Request; use think\facade\Cache; use think\facade\Db; +use app\admin\model\StoreCategory; // 商品分类模型 + //获取后台模块当前登录用户的信息 function get_login_admin($key = "") { @@ -93,6 +95,7 @@ function set_recursion($result, $pid = 0, $level=-1) static $list = array(); static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; $level++; + foreach ($result as $k => $v) { if ($v['pid'] == $pid) { if ($pid != 0) { @@ -103,9 +106,40 @@ function set_recursion($result, $pid = 0, $level=-1) set_recursion($result, $v['id'],$level); } } + return $list; } +//读取商品分类节点列表 +function get_product_calss() +{ + $result = StoreCategory::select()->toArray(); + return $result; +} + +//递归排序,用于分类选择 +function set_product_recursion($result, $pid = 0, $level=-1) +{ + /*记录排序后的类别数组*/ + static $list = array(); + static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; + $level++; + + foreach ($result as $k => $v) { + if ($v['pid'] == $pid) { + if ($pid != 0) { + $v['cate_name'] = $space[$level] . $v['cate_name']; + } + /*将该类别的数据放入list中*/ + $list[] = $v; + set_product_recursion($result, $v['store_category_id'],$level); + } + } + + return $list; +} + + /** * 根据id递归返回子数据 * @param $data 数据 diff --git a/app/admin/controller/product/Classify.php b/app/admin/controller/product/Classify.php index efd9cbb..cd8cf4c 100644 --- a/app/admin/controller/product/Classify.php +++ b/app/admin/controller/product/Classify.php @@ -71,10 +71,10 @@ class Classify extends BaseController } } - $total = StoreCategory::where('level', 0)->where('mer_id', 0)->where($where)->count(); + $total = StoreCategory::where('mer_id', 0)->where($where)->count(); // $list = StoreCategory::with(['merchant', 'street', 'area'])->order('id desc')->select(); - $list = StoreCategory::where('level', 0)->where('mer_id', 0)->order('store_category_id desc')->select(); + $list = StoreCategory::where('mer_id', 0)->order('store_category_id desc')->select(); View::assign('url', $this->url); View::assign('list', $list); @@ -85,7 +85,7 @@ class Classify extends BaseController }else{ - $list = StoreCategory::where('level', 0)->where('mer_id', 0)->select(); + $list = StoreCategory::where('mer_id', 0)->select(); View::assign('url', $this->url); View::assign('list', $list); @@ -100,59 +100,59 @@ class Classify extends BaseController */ public function add() { + $param = get_params(); + if (request()->isAjax()) { + $param['src'] = preg_replace('# #','',$param['src']); + if ($param['id'] > 0) { + try { + validate(RuleCheck::class)->scene('edit')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + Db::name('AdminRule')->strict(false)->field(true)->update($param); + add_log('edit', $param['id'], $param); + } else { + try { + validate(RuleCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + $rid = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($param); + //自动为系统所有者管理组分配新增的节点 + $group = Db::name('AdminGroup')->find(1); + if (!empty($group)) { + $newGroup['id'] = 1; + $newGroup['rules'] = $group['rules'] . ',' . $rid; + Db::name('AdminGroup')->strict(false)->field(true)->update($newGroup); + add_log('add', $rid, $param); + } + } + // 删除后台节点缓存 + clear_cache('adminRules'); + return to_assign(); + } else { - $params = get_params(); + $id = isset($param['id']) ? $param['id'] : 0; + $pid = isset($param['pid']) ? $param['pid'] : 0; - $data['user_id'] = $this->adminInfo['id']; // 操作用户ID - $data['name'] = $params['title']; // 团队名称 - $data['tel'] = $params['phone']; // 联系电话 - $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 - - $data['street_id'] = $params['street_id']; // 街道ID - $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 - $data['lng'] = $street['lng']; // 经度 - $data['lat'] = $street['lat']; // 纬度 - $area = $street->area; // 区数据 - $data['area_id'] = $area['area_id']; // 区县id - $city = $area->city; // 获取市级 - $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 - $data['create_time'] = date('Y-m-d H:i:s'); - - // 数据入库 - $res = SupplyChain::create($data); - - // 关联数据入库 - foreach ($params['mer_id'] as $v) { - - $dataLink = [ - 'eb_merchant_id' => $v, // 商户ID - 'user_id' => $data['user_id'], - 'create_time' => $data['create_time'], - ]; - - $res->linkMerchant()->save($dataLink); // 插入关联数据 + if($id > 0){ + $detail = StoreCategory::find($id); // 分类模型 + View::assign('detail', $detail); } - if ($res){ - return to_assign(0,'操作成功',['aid'=>$res]); - } + $storeCategoryList = StoreCategory::select(); - return to_assign(1, '操作失败,原因:'.$res); - - }else{ - - // 取出正常的商家 - $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); - - // 区域模型 - $arealist = GeoArea::where('city_code', '510500')->select(); - - View::assign('editor', get_system_config('other','editor')); - View::assign('arealist', $arealist); - View::assign('merchant', $merchant); + View::assign('storeCategoryList', $storeCategoryList); View::assign('url', $this->url); + + View::assign('id', $id); + View::assign('pid', $pid); return view(); + } } diff --git a/app/admin/controller/product/Label.php b/app/admin/controller/product/Label.php new file mode 100644 index 0000000..e2596d6 --- /dev/null +++ b/app/admin/controller/product/Label.php @@ -0,0 +1,264 @@ +adminInfo = get_login_admin(); + $this->category_id=354; + $this->url=[ + '/admin/product.label/index?category_id='.$this->category_id, + '/admin/product.label/add', + '/admin/product.label/edit', + '/admin/product.label/del', + '/admin/product.label/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 = StoreProductLabel::where($where)->count(); + + $list = StoreProductLabel::with(['product'])->order('product_label_id desc')->select(); + + View::assign('url', $this->url); + View::assign('list', $list); + + $result = ['total' => $total, 'data' => $list]; + + return table_assign(0, '', $result); + + }else{ + + $list = StoreProductLabel::select(); + + View::assign('url', $this->url); + View::assign('list', $list); + return view(); + } + } + + /** + * + * 新增 + * + */ + public function add() + { + if (request()->isAjax()) { + + $params = get_params(); + + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = json_encode($params['mer_id']); // 已选商户 + + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据入库 + $res = SupplyChain::create($data); + + // 关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $res->linkMerchant()->save($dataLink); // 插入关联数据 + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('editor', get_system_config('other','editor')); + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + 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['id'] = $params['id']; // 当前ID + $data['user_id'] = $this->adminInfo['id']; // 操作用户ID + $data['name'] = $params['title']; // 团队名称 + $data['tel'] = $params['phone']; // 联系电话 + $data['mer_id_list'] = isset($params['mer_id']) ? json_encode($params['mer_id']) : null; // 已选商户 + $data['street_id'] = $params['street_id']; // 街道ID + $street = GeoStreet::where('street_id', $data['street_id'])->find(); // 街道数据 + $data['lng'] = $street['lng']; // 经度 + $data['lat'] = $street['lat']; // 纬度 + $area = $street->area; // 区数据 + $data['area_id'] = $area['area_id']; // 区县id + $city = $area->city; // 获取市级 + $data['address'] = $city['city_name'] . $area['area_name'] . $street['street_name']; // 实际地址 + $data['create_time'] = date('Y-m-d H:i:s'); + + // 数据更新 + $supplyChain = SupplyChain::with(['linkMerchant'])->find($data['id']); + $res = $supplyChain->update($data); + + // 获取关联数据一对一---曲线救国 + $linkMerchant = $supplyChain['linkMerchant']; + // $linkMerchantArr = $linkMerchant->column('id'); + + // 先删除关联数据-- 曲线救国 + $linkMerchant->delete(); + + // 关联商户状态 + if($data['mer_id_list']) + { + // 再重新将关联数据入库 + foreach ($params['mer_id'] as $v) { + + $dataLink = [ + 'eb_merchant_id' => $v, // 商户ID + 'user_id' => $data['user_id'], + 'create_time' => $data['create_time'], + ]; + + $supplyChain->linkMerchant()->save($dataLink); + } + } + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + }else{ + + $supplyChain = SupplyChain::with(['merchant', 'street', 'area'])->find($id); // 取出当前供应链数据 + + View::assign('detail', $supplyChain); + + // 取出正常的商家 + $merchant = Merchant::where('status', 1)->column('mer_id, real_name'); + // 区域模型 + $arealist = GeoArea::where('city_code', '510500')->select(); + + View::assign('arealist', $arealist); + View::assign('merchant', $merchant); + View::assign('url', $this->url); + return view(); + } + + } + + /** + * + * 删除 + * + */ + public function del() + { + $id = get_params("id"); + + if(!$id) return to_assign(1, '非法操作!'); + + $res = StoreProductReply::where('reply_id', $id)->delete(); + + if ($res){ + return to_assign(0,'操作成功',['aid'=>$res]); + } + + return to_assign(1, '操作失败,原因:'.$res); + + } + +} \ No newline at end of file diff --git a/app/admin/model/StoreProductLabel.php b/app/admin/model/StoreProductLabel.php new file mode 100644 index 0000000..881f58a --- /dev/null +++ b/app/admin/model/StoreProductLabel.php @@ -0,0 +1,51 @@ +hasOne(EbStoreProduct::class, 'product_id', 'product_id'); + } + } \ No newline at end of file diff --git a/app/admin/view/product/Label/add.html b/app/admin/view/product/Label/add.html new file mode 100644 index 0000000..d5e2d1e --- /dev/null +++ b/app/admin/view/product/Label/add.html @@ -0,0 +1,96 @@ +{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/Label/edit.html b/app/admin/view/product/Label/edit.html new file mode 100644 index 0000000..2ebf4e4 --- /dev/null +++ b/app/admin/view/product/Label/edit.html @@ -0,0 +1,188 @@ +{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/Label/index.html b/app/admin/view/product/Label/index.html new file mode 100644 index 0000000..3bc5c51 --- /dev/null +++ b/app/admin/view/product/Label/index.html @@ -0,0 +1,200 @@ +{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/classify/add.html b/app/admin/view/product/classify/add.html index b4b9888..fcc0291 100644 --- a/app/admin/view/product/classify/add.html +++ b/app/admin/view/product/classify/add.html @@ -1,200 +1,147 @@ -{extend name="common/base"/} -{block name="style"} - -{/block} +{extend name="common/base" /} {block name="body"}
-

关联商户

- - - - - - - - - - - - - - - - - - - - - - - - -
选择商户 -
- -
-
-
- -
-
-
-
-
-
-
- -
- -
-
-
-
- -
- -
-
-
请选择所在地址* -
- -
-
- -
-
-
-
-
-
- - -
- +

添加分类

+ {if condition="$id eq 0"} + + + + + + + + + + + + + + + + + + + +
上级分类* + + +
分类名称* + + +
排序 + + +
+ +
+ +
+
+
分类图片 +
+ +
+ + +
+
+
+ {else/} + + + + + + + + + + + + + + + + + + + + + + + +
父级菜单/节点* + + + 左侧菜单显示* + + + +
菜单/节点名称* + + + 操作日志名称* + + +
菜单/节点URL + + 菜单排序 + +
菜单图标 + + [查看图标] +
+ {/if} +
+ + + +
{/block} {block name="script"} - - {/block} \ No newline at end of file diff --git a/app/admin/view/product/classify/index.html b/app/admin/view/product/classify/index.html index ea8a104..4ff66ac 100644 --- a/app/admin/view/product/classify/index.html +++ b/app/admin/view/product/classify/index.html @@ -9,7 +9,12 @@
-
+
+ +
+
+
+