From 842e365f8bba3b7a2c608e08459053d33f0bb9b6 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Fri, 3 Mar 2023 23:33:31 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=95=86=E6=88=B7=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E7=A7=BB=E5=8A=A8=E5=95=86=E6=88=B7?= =?UTF-8?q?model=E5=88=B0commom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/auth/Menu.php | 120 +++++++++++++++--- app/admin/route/menu.php | 48 ++----- app/admin/view/merchant/system/auth/add.html | 6 +- app/common/controller/FormatList.php | 34 ++++- app/common/model/merchant/system/Merchant.php | 51 ++++++++ .../merchant/system/MerchantApplyments.php | 22 ++++ .../model/merchant/system/auth/Menu.php | 108 ++++++++++++++++ .../model/merchant/system/auth/Role.php | 14 ++ .../merchant/system/merchant/MerchantType.php | 14 ++ 9 files changed, 353 insertions(+), 64 deletions(-) create mode 100644 app/common/model/merchant/system/Merchant.php create mode 100644 app/common/model/merchant/system/MerchantApplyments.php create mode 100644 app/common/model/merchant/system/auth/Menu.php create mode 100644 app/common/model/merchant/system/auth/Role.php create mode 100644 app/common/model/merchant/system/merchant/MerchantType.php diff --git a/app/admin/controller/merchant/system/merchant/auth/Menu.php b/app/admin/controller/merchant/system/merchant/auth/Menu.php index 1c4efe0..7e0398a 100644 --- a/app/admin/controller/merchant/system/merchant/auth/Menu.php +++ b/app/admin/controller/merchant/system/merchant/auth/Menu.php @@ -9,8 +9,10 @@ namespace app\admin\controller\merchant\system\merchant\auth; use app\admin\BaseController; -use app\admin\model\system\auth\Menu as MenuModel; +use app\common\model\merchant\system\auth\Menu as MenuModel; +use think\facade\View; use app\common\controller\FormatList; +use think\exception\ValidateException; /** * class Menu @@ -18,38 +20,114 @@ use app\common\controller\FormatList; class Menu extends BaseController { protected $menu; - protected $is_mer; - protected $url; - protected $category_id; + protected $params; function __construct(MenuModel $menu) { // $this->adminInfo = get_login_admin(); $this->menu = $menu; - // 模块,0 平台, 1商户 - $this->is_mer = get_params('is_m', 0) == 0 ? 2 : 2; - $this->category_id=354; - $this->url=[ - '/admin/nk.classroom/index?category_id='.$this->category_id, - '/admin/nk.classroom/add', - '/admin/nk.classroom/edit', - '/admin/nk.classroom/del', - '/admin/nk.classroom/read', - ]; + $this->params = get_params() ; } + /** + * 空白菜单页,由前端 ajax 获取数据 + */ function Index() { - return view('merchant/system/auth/index',['url'=>$this->url]); + return view('merchant/system/auth/index'); } - function Lst(FormatList $formatList){ + /** + * 菜单列表 + */ + function Lst(){ // 查出商户所有菜单数据 - $list = $this->menu->Search([], 1); + $data = $this->menu->Search([], 1); - // 格式化成多维数组 - // $data = $formatList->FormatCategory($list['list'], "menu_id"); - to_assign(0,'操作成功',$list); - // return view('merchant/system/auth/index',['url'=>$this->url]); + to_assign(0,'',$data['list']); + } + + /** + * 表单页 + * TODO: 操作日志要另建表做关联 + * 操作日志待开发 + * + */ + function AddForm(FormatList $format){ + $id = isset($this->params['id']) ? $this->params['id'] : 0; + $pid = isset($this->params['pid']) ? $this->params['pid'] : 0; + if($id>0){ + $detail = $this->menu->Find($id); + $detail['name'] = $detail['title']; + View::assign('detail', $detail); + } + // 查出商户所有菜单数据 + $data = $this->menu->Search([], 1); + $menus = $format->DropDownMenu($data['list']); + + View::assign('id', $id); + View::assign('pid', $pid); + View::assign('menus',$menus); + + return view('merchant/system/auth/add'); + } + + /** + * 添加菜单 + */ + function Add(){ + echo 'add'; + $this->params['src'] = preg_replace('# #','',$this->params['src']); + // if ($param['id'] == 0) { + try { + validate(RuleCheck::class)->scene('add')->check($this->params); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $this->params['create_time'] = time(); + $rid = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($this->params); + //自动为系统所有者管理组分配新增的节点 + $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, $this->params); + } + // } + // 删除后台节点缓存 + clear_cache('adminRules'); + return to_assign(); + } + + /** + * 编辑菜单 + */ + function Edit(){ + echo 'edit'; + if ($this->params['id'] > 0) { + try { + validate(RuleCheck::class)->scene('edit')->check($this->params); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + Db::name('AdminRule')->strict(false)->field(true)->update($this->params); + add_log('edit', $this->params['id'], $this->params); + } + } + + /** + * 删除菜单 + */ + function Del(){ + $id = get_params("id"); + try{ + $this->menu->Del($id); + return to_assign(0, "删除节点成功"); + }catch(ValidateException $e){ + return to_assign(1, $e->getMessage()); + } } } \ No newline at end of file diff --git a/app/admin/route/menu.php b/app/admin/route/menu.php index 7465915..5b15ac9 100644 --- a/app/admin/route/menu.php +++ b/app/admin/route/menu.php @@ -17,35 +17,6 @@ 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('index', '/index')->name('systemMerchantMenuIndex')->option([ @@ -56,23 +27,24 @@ Route::group(function () { Route::get('lst', '/lst')->name('systemMerchantMenuGetLst')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限列表', ]); - Route::get('create/form', '/createForm')->name('systemMerchantMenuCreateForm')->append(['merchant' => 1])->option([ + + Route::post('add', '/add')->name('systemMerchantMenuCreate')->append(['merchant' => 1])->option([ + '_alias' => '商户菜单/权限添加', + ]); + Route::post('edit/:id', '/edit')->name('systemMerchantMenuUpdate')->append(['merchant' => 1])->option([ + '_alias' => '商户菜单/权限编辑', + ]); + Route::get('addform', '/AddForm')->name('systemMerchantMenuCreateForm')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限添加表单', '_auth' => false, '_form' => 'systemMerchantMenuCreate', ]); - Route::get('update/form/:id', '/updateForm')->name('systemMerchantMenuUpdateForm')->append(['merchant' => 1])->option([ + Route::get('editform', '/editform')->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([ + Route::delete('del/:id', '/del')->name('systemMerchantMenuDelete')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限删除', ]); })->prefix('merchant.system.merchant.auth.Menu')->option([ diff --git a/app/admin/view/merchant/system/auth/add.html b/app/admin/view/merchant/system/auth/add.html index 49d2fca..2b494c5 100644 --- a/app/admin/view/merchant/system/auth/add.html +++ b/app/admin/view/merchant/system/auth/add.html @@ -11,7 +11,7 @@ @@ -65,8 +65,8 @@ diff --git a/app/common/controller/FormatList.php b/app/common/controller/FormatList.php index b7355ce..92eadef 100644 --- a/app/common/controller/FormatList.php +++ b/app/common/controller/FormatList.php @@ -4,7 +4,7 @@ * * @author:刘孝全 * @email:q8197264@126.com - * @date :2023年03月2日 + * @date :2023年03月3日 */ namespace app\common\controller; @@ -19,7 +19,7 @@ class FormatList * @param string $childrenKey 子级字段名 * @return array * - * @date 2020-03-27 + * @date 2023-03-3 */ function FormatCategory(array $data, string $idName = "id", string $fieldName = 'pid', $childrenKey = 'children') { @@ -37,4 +37,34 @@ class FormatList } return $result; } + + /** + * 递归排序,用于下拉分类选择菜单 + * + * @param array $data 数据源 + * @param string $idName 主键 + * @param string $fieldName 父级字段 + * @param string $childrenKey 子级字段名 + * @return array + * + * @date 2023-03-3 + */ + function DropDownMenu($result, $pid = 0, $level=-1) + { + /*记录排序后的类别数组*/ + static $list = array(); + static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─']; + $level++; + foreach ($result 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); + } + } + return $list; + } } \ No newline at end of file diff --git a/app/common/model/merchant/system/Merchant.php b/app/common/model/merchant/system/Merchant.php new file mode 100644 index 0000000..0078b08 --- /dev/null +++ b/app/common/model/merchant/system/Merchant.php @@ -0,0 +1,51 @@ +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 new file mode 100644 index 0000000..620fcb8 --- /dev/null +++ b/app/common/model/merchant/system/MerchantApplyments.php @@ -0,0 +1,22 @@ +select(); + + return $list; + } +} diff --git a/app/common/model/merchant/system/auth/Menu.php b/app/common/model/merchant/system/auth/Menu.php new file mode 100644 index 0000000..82aaff3 --- /dev/null +++ b/app/common/model/merchant/system/auth/Menu.php @@ -0,0 +1,108 @@ +field('menu_id as id,pid, sort, route as src,icon,menu_name as title,is_show as status, is_menu as menu') + ->order('sort DESC,menu_id ASC'); + if (isset($where['pid'])) $query->where('pid', (int)$where['pid']); + if (isset($where['keyword'])) $query->whereLike('menu_name|route', "%{$where['keyword']}%"); + if (isset($where['is_menu'])) $query->where('is_menu', (int)$where['is_menu']); + + // 查询记录总行数 + $count = $query->count(); + + if (isset($where['offset'])) $query->page($where['offset'])->limit($where['limit']); + + // 隐藏指定字段 + $list = $query->hidden(['update_time', 'path'])->select()->toArray(); + // 合并为一个数组并返回 + $data = compact('count', 'list'); + + return $data; + } + + /** + * 获取指定行数据 + * + * @return array $row + */ + function Find($id) { + $row = self::where('menu_id', $id) + ->field('menu_id as id,pid, sort, route as src,icon,menu_name as title,is_show as status, is_menu as menu') + ->find(); + + return $row; + } + + /** + * 添加 + */ + function Add() {} + + /** + * 更新 + */ + function modify() + { + return true; + } + + /** + * 删除指定菜单项 + * 由于有三种结果,建议用 try{}catch() 捕获 + * + * @return bool||throw Exception + */ + function Del($id) + { + $count = self::where(["pid" => $id])->count(); + if ($count > 0) { + throw new ValidateException('该节点下还有子节点,无法删除'); + return false; + } + if (self::delete($id) !== false) { + clear_cache('adminRules'); + add_log('delete', $id, []); + throw new ValidateException('删除节点成功'); + } else { + throw new ValidateException('删除失败'); + return false; + } + return true; + } + +} diff --git a/app/common/model/merchant/system/auth/Role.php b/app/common/model/merchant/system/auth/Role.php new file mode 100644 index 0000000..97c3196 --- /dev/null +++ b/app/common/model/merchant/system/auth/Role.php @@ -0,0 +1,14 @@ + Date: Sat, 4 Mar 2023 02:14:44 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=B1=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/merchant/system/Merchant.php | 26 ++ .../merchant/system/MerchantApplyments.php | 118 ++++++++ .../controller/merchant/system/auth/Menu.php | 133 +++++++++ .../system/merchant/MerchantMargin.php | 19 ++ .../merchant/system/merchant/MerchantType.php | 137 +++++++--- app/admin/route/menu.php | 2 +- app/admin/route/merchant.php | 5 +- .../view/merchant/system/auth/menu/add.html | 150 +++++++++++ .../merchant/system/merchant/type/add.html | 249 +++++++++++++++++ .../merchant/system/merchant/type/edit.html | 252 ++++++++++++++++++ .../merchant/system/merchant/type/read.html | 148 ++++++++++ .../system/merchant/MerchantMargin.php | 25 ++ .../merchant/system/merchant/MerchantType.php | 14 +- 13 files changed, 1245 insertions(+), 33 deletions(-) create mode 100644 app/admin/controller/merchant/system/Merchant.php create mode 100644 app/admin/controller/merchant/system/MerchantApplyments.php create mode 100644 app/admin/controller/merchant/system/auth/Menu.php create mode 100644 app/admin/view/merchant/system/auth/menu/add.html create mode 100644 app/admin/view/merchant/system/merchant/type/add.html create mode 100644 app/admin/view/merchant/system/merchant/type/edit.html create mode 100644 app/admin/view/merchant/system/merchant/type/read.html create 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 new file mode 100644 index 0000000..3b67d20 --- /dev/null +++ b/app/admin/controller/merchant/system/Merchant.php @@ -0,0 +1,26 @@ +model = $model; + } + + /** + * TODO 创建申请 + * @param MerchantApplymentsValidate $validate + * @return \think\response\Json + * @author Qinii + * @day 6/22/21 + */ + public function create(MerchantApplymentsValidate $validate) + { + // if(!systemConfig('open_wx_sub_mch')) return app('json')->fail('未开启子商户入驻'); + $data = $this->checkParams($validate); + + } + + /** + * TODO 创建申请 + * @param MerchantApplymentsValidate $validate + * @return \think\response\Json + * @author Qinii + * @day 6/22/21 + */ + public function detail() + {} + + /** + * TODO 编辑提交 + * @param MerchantApplymentsValidate $validate + * @return \think\response\Json + * @author Qinii + * @day 6/22/21 + */ + public function update($id,MerchantApplymentsValidate $validate) + {} + + /** + * TODO 查询更新状态 + * @param MerchantApplymentsValidate $validate + * @return \think\response\Json + * @author Qinii + * @day 6/22/21 + */ + public function check() + {} + + /** + * TODO 上传图片 + * @param MerchantApplymentsValidate $validate + * @return \think\response\Json + * @author Qinii + * @day 6/22/21 + */ + public function uploadImage($field) + {} + + /** + * TODO 检验参数 + * @param MerchantApplymentsValidate $validate + * @return \think\response\Json + * @author Qinii + * @day 6/22/21 + */ + public function checkParams(MerchantApplymentsValidate $validate) + { + //'organization_cert_info', + $data = $this->request->params([ + 'organization_type','business_license_info','id_doc_type','id_card_info','id_doc_info','need_account_info','account_info','contact_info','sales_scene_info','merchant_shortname','qualifications','business_addition_pics','business_addition_desc' + ]); + + if($data['id_doc_type'] == 1){ + unset($data['id_doc_info']); + }else{ + unset($data['id_card_info']); + } + + if(in_array($data['organization_type'],['2401','2500'])){ + unset($data['business_license_info']); + } + + if(isset($data['qualifications']) && !$data['qualifications']) unset($data['qualifications']); + + if(isset($data['business_addition_pics']) && !$data['business_addition_pics']) unset($data['business_addition_pics']); + if($data['organization_type'] !== 2 && isset($data['id_card_info']['id_card_address'])){ + unset($data['id_card_info']['id_card_address']); + } + $validate->check($data); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/controller/merchant/system/auth/Menu.php b/app/admin/controller/merchant/system/auth/Menu.php new file mode 100644 index 0000000..24b50a9 --- /dev/null +++ b/app/admin/controller/merchant/system/auth/Menu.php @@ -0,0 +1,133 @@ +adminInfo = get_login_admin(); + + $this->menu = $menu; + + $this->params = get_params() ; + } + + /** + * 空白菜单页,由前端 ajax 获取数据 + */ + function Index() { + return view('merchant/system/auth/menu/index'); + } + + /** + * 菜单列表 + */ + function Lst(){ + // 查出商户所有菜单数据 + $data = $this->menu->Search([], 1); + + to_assign(0,'',$data['list']); + } + + /** + * 表单页 + * TODO: 操作日志要另建表做关联 + * 操作日志待开发 + * + */ + function AddForm(FormatList $format){ + $id = isset($this->params['id']) ? $this->params['id'] : 0; + $pid = isset($this->params['pid']) ? $this->params['pid'] : 0; + if($id>0){ + $detail = $this->menu->Find($id); + $detail['name'] = $detail['title']; + View::assign('detail', $detail); + } + // 查出商户所有菜单数据 + $data = $this->menu->Search([], 1); + $menus = $format->DropDownMenu($data['list']); + + View::assign('id', $id); + View::assign('pid', $pid); + View::assign('menus',$menus); + + return view('merchant/system/auth/menu/add'); + } + + /** + * 添加菜单 + */ + function Add(){ + echo 'add'; + $this->params['src'] = preg_replace('# #','',$this->params['src']); + // if ($param['id'] == 0) { + try { + validate(RuleCheck::class)->scene('add')->check($this->params); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $this->params['create_time'] = time(); + $rid = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($this->params); + //自动为系统所有者管理组分配新增的节点 + $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, $this->params); + } + // } + // 删除后台节点缓存 + clear_cache('adminRules'); + return to_assign(); + } + + /** + * 编辑菜单 + */ + function Edit(){ + echo 'edit'; + if ($this->params['id'] > 0) { + try { + validate(RuleCheck::class)->scene('edit')->check($this->params); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + Db::name('AdminRule')->strict(false)->field(true)->update($this->params); + add_log('edit', $this->params['id'], $this->params); + } + } + + /** + * 删除菜单 + */ + function Del(){ + $id = get_params("id"); + try{ + $this->menu->Del($id); + return to_assign(0, "删除节点成功"); + }catch(ValidateException $e){ + return to_assign(1, $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/admin/controller/merchant/system/merchant/MerchantMargin.php b/app/admin/controller/merchant/system/merchant/MerchantMargin.php index 80c38a4..0f7f159 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantMargin.php +++ b/app/admin/controller/merchant/system/merchant/MerchantMargin.php @@ -1,13 +1,32 @@ margin = $margin; + } + /** * 显示资源列表 * diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 56a55d6..29ac1ce 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -1,13 +1,65 @@ mer_type = $mer_type; + } + + /** + * 空白菜单页,由前端 ajax 获取数据 + */ + function Index() + { + return View('merchant/system/merchant/type/index'); + } + + /** + * 添加/编辑 表单页 + */ + public function Form() + { + if ($param['mer_id']>0) { + $product_id = isset($param['product_id']) ? $param['product_id'] : 0; + $detail = $this->model->getStoreProductById($product_id); + if (!empty($detail)) { + $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); + $detail['slider_image_arr'] = explode(',',$detail['slider_image']); + // halt($detail['slider_image_arr']); + View::assign('detail', $detail); + $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) + ->select(); + View::assign('store_brand', $store_brand); + + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + return view(); + } + /** * 显示店铺类型列表 * @@ -16,6 +68,14 @@ class MerchantType extends BaseController public function Lst() { echo 1723; + $param = get_params(); + $where = []; + if (isset($param['keywords']) && !empty($param['keywords'])){ + $where[]=['store_name','like','%'.$param['keywords'].'%']; + } + $list = $this->model->getStoreProductList($where,$param); + + return table_assign(0, '', $list); } /** @@ -25,18 +85,9 @@ class MerchantType extends BaseController */ public function Add() { - // - } - - /** - * 保存新建的资源 - * - * @param \think\Request $request - * @return \think\Response - */ - public function save(Request $request) - { - // + $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) + ->select(); + return to_assign(0,'操作成功'); } /** @@ -47,7 +98,21 @@ class MerchantType extends BaseController */ public function Detail($id) { - // + $param = get_params(); + $product_id = isset($param['product_id']) ? $param['product_id'] : 0; + $detail = $this->model->getStoreProductById($product_id); + if (!empty($detail)) { + $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); + $detail['slider_image_arr'] = explode(',',$detail['slider_image']); + View::assign('detail', $detail); + $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) + ->select(); + View::assign('store_brand', $store_brand); + return view(); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } } /** @@ -58,19 +123,7 @@ class MerchantType extends BaseController */ public function edit($id) { - // - } - - /** - * 保存更新的资源 - * - * @param \think\Request $request - * @param int $id - * @return \think\Response - */ - public function update(Request $request, $id) - { - // + return to_assign(0,''); } /** @@ -79,12 +132,36 @@ class MerchantType extends BaseController * @param int $id * @return \think\Response */ - public function delete($id) + public function del($id) { - // + $param = get_params(); + $product_id = isset($param['product_id']) ? $param['product_id'] : 0; + $type = isset($param['type']) ? $param['type'] : 0; + + $this->model->delStoreProductById($product_id,1); } - public function Mark(){} + /** + * 备注表单页 + */ + public function MarkForm() + { + return View(''); + } - public function Description(){} + /** + * 店铺类型备注 + */ + public function Mark() + { + return to_assign(0, ''); + } + + /** + * 店铺类型说明 + */ + public function Description(){ + View::assign('detail',[]); + return View('merchant/system/merchant/descr/index',['id'=>1]); + } } diff --git a/app/admin/route/menu.php b/app/admin/route/menu.php index 5b15ac9..63c5290 100644 --- a/app/admin/route/menu.php +++ b/app/admin/route/menu.php @@ -47,7 +47,7 @@ Route::group(function () { Route::delete('del/:id', '/del')->name('systemMerchantMenuDelete')->append(['merchant' => 1])->option([ '_alias' => '商户菜单/权限删除', ]); - })->prefix('merchant.system.merchant.auth.Menu')->option([ + })->prefix('merchant.system.auth.Menu')->option([ '_path' => '/merchant/menu', '_auth' => true, ]); diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index 8b9e287..c65f134 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -46,6 +46,9 @@ Route::group(function(){ // 店铺类型 Route::group('/merchant/type',function(){ + Route::get('index', '/index')->name('systemMerchantTypeLst')->option([ + '_alias' => '列表', + ]); Route::get('lst', '/lst')->name('systemMerchantTypeLst')->option([ '_alias' => '列表', ]); @@ -70,7 +73,7 @@ Route::group(function(){ '_alias' => '备注', ]); - Route::get('description', '/description')->name('systemMerchantTypeDescrForm')->option([ + Route::get('descr', '/description')->name('systemMerchantTypeDescrForm')->option([ '_alias' => '店铺类型说明', ]); Route::post('description', '/description')->name('systemMerchantTypeDescr')->option([ diff --git a/app/admin/view/merchant/system/auth/menu/add.html b/app/admin/view/merchant/system/auth/menu/add.html new file mode 100644 index 0000000..2b494c5 --- /dev/null +++ b/app/admin/view/merchant/system/auth/menu/add.html @@ -0,0 +1,150 @@ +{extend name="common/base" /} + +{block name="body"} +
+

功能菜单/节点

+ {if condition="$id eq 0"} + + + + + + + + + + + + + + + + + + + + + + + +
父级菜单/节点* + + + 左侧菜单显示* + + + +
菜单/节点名称* + + + 操作日志名称* + + +
菜单/节点URL + + 菜单排序 + +
菜单图标 + + 如:bi-gear[查看图标] +
+ {else/} + + + + + + + + + + + + + + + + + + + + + + + +
父级菜单/节点* + + + 左侧菜单显示* + + + +
菜单/节点名称* + + + 操作日志名称* + + +
菜单/节点URL + + 菜单排序 + +
菜单图标 + + [查看图标] +
+ {/if} +
+ + + +
+
+{/block} + + + +{block name="script"} + +{/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 new file mode 100644 index 0000000..d5368fe --- /dev/null +++ b/app/admin/view/merchant/system/merchant/type/add.html @@ -0,0 +1,249 @@ +{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/type/edit.html b/app/admin/view/merchant/system/merchant/type/edit.html new file mode 100644 index 0000000..2ad9a35 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/type/edit.html @@ -0,0 +1,252 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑文章表

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商品名称*
平台商品分类* +
+ +
+
品牌选择* +
+ +
+
商品封面图 +
+ +
+ + +
+
+
商品轮播图 +
+ +
+ {volist name='detail.slider_image_arr' id='vo'} + {if $vo} + + {/if} + {/volist} + +
+
+
单位*
商品关键字*
售价*
成本价*
市场价*
库存*
商品简介 + +
商品详情 + +
+
+ + + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/merchant/system/merchant/type/read.html b/app/admin/view/merchant/system/merchant/type/read.html new file mode 100644 index 0000000..c3637d7 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/type/read.html @@ -0,0 +1,148 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

文章详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
商品名称*
商户商品分类* +
+ +
+
品牌选择* +
+ +
+
商品封面图 +
+ + + +
+ + +
+
+
商品轮播图 +
+ + + +
+ {volist name='detail.slider_image_arr' id='vo'} + {if $vo} + + {/if} + {/volist} + +
+
+
单位*
商品关键字*
售价*
成本价*
市场价*
库存*
商品简介 + +
商品详情 + +
+
+{/block} + \ No newline at end of file diff --git a/app/common/model/merchant/system/merchant/MerchantMargin.php b/app/common/model/merchant/system/merchant/MerchantMargin.php new file mode 100644 index 0000000..62e8eaa --- /dev/null +++ b/app/common/model/merchant/system/merchant/MerchantMargin.php @@ -0,0 +1,25 @@ + Date: Sat, 4 Mar 2023 02:19:17 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E8=A1=A5=E4=B8=8A=E9=81=97=E6=BC=8F?= =?UTF-8?q?=E7=9A=84index=E6=A8=A1=E6=9D=BF=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .../view/merchant/system/auth/menu/index.html | 93 ++++++++++ .../merchant/system/merchant/descr/index.html | 135 ++++++++++++++ .../merchant/system/merchant/type/index.html | 172 ++++++++++++++++++ 4 files changed, 401 insertions(+), 1 deletion(-) create mode 100644 app/admin/view/merchant/system/auth/menu/index.html create mode 100644 app/admin/view/merchant/system/merchant/descr/index.html create mode 100644 app/admin/view/merchant/system/merchant/type/index.html diff --git a/.gitignore b/.gitignore index 4f90f60..9be8bf4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ *.ini .htaccess 404.html -index.html +# index.html /runtime/* /public/storage/* /public/backup/* diff --git a/app/admin/view/merchant/system/auth/menu/index.html b/app/admin/view/merchant/system/auth/menu/index.html new file mode 100644 index 0000000..b47809f --- /dev/null +++ b/app/admin/view/merchant/system/auth/menu/index.html @@ -0,0 +1,93 @@ +{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/descr/index.html b/app/admin/view/merchant/system/merchant/descr/index.html new file mode 100644 index 0000000..7e86548 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/descr/index.html @@ -0,0 +1,135 @@ +{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/type/index.html b/app/admin/view/merchant/system/merchant/type/index.html new file mode 100644 index 0000000..a2bb254 --- /dev/null +++ b/app/admin/view/merchant/system/merchant/type/index.html @@ -0,0 +1,172 @@ +{extend name="common/base"/} + +{block name="body"} + +
+
+
+ +
+ +
+
+
+ + + + + +{/block} + + +{block name="script"} + +{/block} + \ No newline at end of file From 5bdf8b9975dc0ad6a09ca360cfc171d855a6347c Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Sat, 4 Mar 2023 02:31:56 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E5=95=86=E6=88=B7model?= =?UTF-8?q?=E5=88=B0common=E5=85=AC=E5=85=B1model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/Merchant.php | 26 --- .../system/merchant/MerchantApplyments.php | 118 -------------- .../merchant/system/merchant/auth/Menu.php | 133 ---------------- app/admin/model/system/Merchant.php | 51 ------ app/admin/model/system/MerchantApplyments.php | 22 --- app/admin/model/system/auth/Menu.php | 53 ------- app/admin/model/system/auth/Role.php | 14 -- .../model/system/merchant/MerchantType.php | 14 -- app/admin/view/merchant/system/auth/add.html | 150 ------------------ 9 files changed, 581 deletions(-) delete mode 100644 app/admin/controller/merchant/system/merchant/Merchant.php delete mode 100644 app/admin/controller/merchant/system/merchant/MerchantApplyments.php delete mode 100644 app/admin/controller/merchant/system/merchant/auth/Menu.php delete mode 100644 app/admin/model/system/Merchant.php delete mode 100644 app/admin/model/system/MerchantApplyments.php delete mode 100644 app/admin/model/system/auth/Menu.php delete mode 100644 app/admin/model/system/auth/Role.php delete mode 100644 app/admin/model/system/merchant/MerchantType.php delete mode 100644 app/admin/view/merchant/system/auth/add.html diff --git a/app/admin/controller/merchant/system/merchant/Merchant.php b/app/admin/controller/merchant/system/merchant/Merchant.php deleted file mode 100644 index 620f30a..0000000 --- a/app/admin/controller/merchant/system/merchant/Merchant.php +++ /dev/null @@ -1,26 +0,0 @@ -model = $model; - } - - /** - * TODO 创建申请 - * @param MerchantApplymentsValidate $validate - * @return \think\response\Json - * @author Qinii - * @day 6/22/21 - */ - public function create(MerchantApplymentsValidate $validate) - { - // if(!systemConfig('open_wx_sub_mch')) return app('json')->fail('未开启子商户入驻'); - $data = $this->checkParams($validate); - - } - - /** - * TODO 创建申请 - * @param MerchantApplymentsValidate $validate - * @return \think\response\Json - * @author Qinii - * @day 6/22/21 - */ - public function detail() - {} - - /** - * TODO 编辑提交 - * @param MerchantApplymentsValidate $validate - * @return \think\response\Json - * @author Qinii - * @day 6/22/21 - */ - public function update($id,MerchantApplymentsValidate $validate) - {} - - /** - * TODO 查询更新状态 - * @param MerchantApplymentsValidate $validate - * @return \think\response\Json - * @author Qinii - * @day 6/22/21 - */ - public function check() - {} - - /** - * TODO 上传图片 - * @param MerchantApplymentsValidate $validate - * @return \think\response\Json - * @author Qinii - * @day 6/22/21 - */ - public function uploadImage($field) - {} - - /** - * TODO 检验参数 - * @param MerchantApplymentsValidate $validate - * @return \think\response\Json - * @author Qinii - * @day 6/22/21 - */ - public function checkParams(MerchantApplymentsValidate $validate) - { - //'organization_cert_info', - $data = $this->request->params([ - 'organization_type','business_license_info','id_doc_type','id_card_info','id_doc_info','need_account_info','account_info','contact_info','sales_scene_info','merchant_shortname','qualifications','business_addition_pics','business_addition_desc' - ]); - - if($data['id_doc_type'] == 1){ - unset($data['id_doc_info']); - }else{ - unset($data['id_card_info']); - } - - if(in_array($data['organization_type'],['2401','2500'])){ - unset($data['business_license_info']); - } - - if(isset($data['qualifications']) && !$data['qualifications']) unset($data['qualifications']); - - if(isset($data['business_addition_pics']) && !$data['business_addition_pics']) unset($data['business_addition_pics']); - if($data['organization_type'] !== 2 && isset($data['id_card_info']['id_card_address'])){ - unset($data['id_card_info']['id_card_address']); - } - $validate->check($data); - return $data; - } -} \ No newline at end of file diff --git a/app/admin/controller/merchant/system/merchant/auth/Menu.php b/app/admin/controller/merchant/system/merchant/auth/Menu.php deleted file mode 100644 index 7e0398a..0000000 --- a/app/admin/controller/merchant/system/merchant/auth/Menu.php +++ /dev/null @@ -1,133 +0,0 @@ -adminInfo = get_login_admin(); - - $this->menu = $menu; - - $this->params = get_params() ; - } - - /** - * 空白菜单页,由前端 ajax 获取数据 - */ - function Index() { - return view('merchant/system/auth/index'); - } - - /** - * 菜单列表 - */ - function Lst(){ - // 查出商户所有菜单数据 - $data = $this->menu->Search([], 1); - - to_assign(0,'',$data['list']); - } - - /** - * 表单页 - * TODO: 操作日志要另建表做关联 - * 操作日志待开发 - * - */ - function AddForm(FormatList $format){ - $id = isset($this->params['id']) ? $this->params['id'] : 0; - $pid = isset($this->params['pid']) ? $this->params['pid'] : 0; - if($id>0){ - $detail = $this->menu->Find($id); - $detail['name'] = $detail['title']; - View::assign('detail', $detail); - } - // 查出商户所有菜单数据 - $data = $this->menu->Search([], 1); - $menus = $format->DropDownMenu($data['list']); - - View::assign('id', $id); - View::assign('pid', $pid); - View::assign('menus',$menus); - - return view('merchant/system/auth/add'); - } - - /** - * 添加菜单 - */ - function Add(){ - echo 'add'; - $this->params['src'] = preg_replace('# #','',$this->params['src']); - // if ($param['id'] == 0) { - try { - validate(RuleCheck::class)->scene('add')->check($this->params); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - $this->params['create_time'] = time(); - $rid = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($this->params); - //自动为系统所有者管理组分配新增的节点 - $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, $this->params); - } - // } - // 删除后台节点缓存 - clear_cache('adminRules'); - return to_assign(); - } - - /** - * 编辑菜单 - */ - function Edit(){ - echo 'edit'; - if ($this->params['id'] > 0) { - try { - validate(RuleCheck::class)->scene('edit')->check($this->params); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - Db::name('AdminRule')->strict(false)->field(true)->update($this->params); - add_log('edit', $this->params['id'], $this->params); - } - } - - /** - * 删除菜单 - */ - function Del(){ - $id = get_params("id"); - try{ - $this->menu->Del($id); - return to_assign(0, "删除节点成功"); - }catch(ValidateException $e){ - return to_assign(1, $e->getMessage()); - } - } -} \ No newline at end of file diff --git a/app/admin/model/system/Merchant.php b/app/admin/model/system/Merchant.php deleted file mode 100644 index 7687c90..0000000 --- a/app/admin/model/system/Merchant.php +++ /dev/null @@ -1,51 +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/admin/model/system/MerchantApplyments.php b/app/admin/model/system/MerchantApplyments.php deleted file mode 100644 index e623c12..0000000 --- a/app/admin/model/system/MerchantApplyments.php +++ /dev/null @@ -1,22 +0,0 @@ -select(); - - return $list; - } -} diff --git a/app/admin/model/system/auth/Menu.php b/app/admin/model/system/auth/Menu.php deleted file mode 100644 index a1843ed..0000000 --- a/app/admin/model/system/auth/Menu.php +++ /dev/null @@ -1,53 +0,0 @@ -order('sort DESC,menu_id ASC'); - if (isset($where['pid'])) $query->where('pid', (int)$where['pid']); - if (isset($where['keyword'])) $query->whereLike('menu_name|route', "%{$where['keyword']}%"); - if (isset($where['is_menu'])) $query->where('is_menu', (int)$where['is_menu']); - - // 查询记录总行数 - // $count = $query->count(); - - // 隐藏指定字段 - $list = $query->hidden(['update_time', 'path'])->select()->toArray(); - - // 合并为一个数组并返回 - // compact('count', 'list'); - - return $list; - } -} diff --git a/app/admin/model/system/auth/Role.php b/app/admin/model/system/auth/Role.php deleted file mode 100644 index 60cfe62..0000000 --- a/app/admin/model/system/auth/Role.php +++ /dev/null @@ -1,14 +0,0 @@ - -{block name="body"} -
-

功能菜单/节点

- {if condition="$id eq 0"} - - - - - - - - - - - - - - - - - - - - - - - -
父级菜单/节点* - - - 左侧菜单显示* - - - -
菜单/节点名称* - - - 操作日志名称* - - -
菜单/节点URL - - 菜单排序 - -
菜单图标 - - 如:bi-gear[查看图标] -
- {else/} - - - - - - - - - - - - - - - - - - - - - - - -
父级菜单/节点* - - - 左侧菜单显示* - - - -
菜单/节点名称* - - - 操作日志名称* - - -
菜单/节点URL - - 菜单排序 - -
菜单图标 - - [查看图标] -
- {/if} -
- - - -
-
-{/block} - - - -{block name="script"} - -{/block} - \ No newline at end of file From 5e4491d0b5539dffa4ce9cfe32fe665ea38cf8a0 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Sat, 4 Mar 2023 17:50:17 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=B1=BB=E5=9E=8B,?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/MerchantType.php | 182 +++++---- app/admin/route/merchant.php | 11 +- .../merchant/system/merchant/type/add.html | 354 ++++++++---------- .../merchant/system/merchant/type/index.html | 126 +++---- .../merchant/system/merchant/type/read.html | 137 ++----- .../system/merchant/MerchantMargin.php | 12 +- .../merchant/system/merchant/MerchantType.php | 133 ++++++- 7 files changed, 481 insertions(+), 474 deletions(-) diff --git a/app/admin/controller/merchant/system/merchant/MerchantType.php b/app/admin/controller/merchant/system/merchant/MerchantType.php index 29ac1ce..1a3dff9 100644 --- a/app/admin/controller/merchant/system/merchant/MerchantType.php +++ b/app/admin/controller/merchant/system/merchant/MerchantType.php @@ -1,18 +1,21 @@ mer_type = $mer_type; + $this->merchant = $merchant; + $this->path = [ + 'index' => 'merchant/system/merchant/type/index', + 'read' => 'merchant/system/merchant/type/read', + 'add' => 'merchant/system/merchant/type/add' + ]; } - /** + /** * 空白菜单页,由前端 ajax 获取数据 */ - function Index() + public function Index() { - return View('merchant/system/merchant/type/index'); + return View($this->path['index']); } /** * 添加/编辑 表单页 */ - public function Form() + public function Form(MenuModel $menu, FormatList $format) { - if ($param['mer_id']>0) { - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $detail = $this->model->getStoreProductById($product_id); - if (!empty($detail)) { - $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); - $detail['slider_image_arr'] = explode(',',$detail['slider_image']); - // halt($detail['slider_image_arr']); - View::assign('detail', $detail); - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - View::assign('store_brand', $store_brand); - - } - else{ - throw new \think\exception\HttpException(404, '找不到页面'); - } + $param = get_params(); + $id = isset($param['id']) ? (int)$param['id'] : 0; + + if (!empty($id)) { + // 进入编辑页,显示店铺数据 + $detail = $this->merchant->Find($id); } - return view(); + if (empty($detail)) { + $detail = [ + "create_time" => '', + "description" => '', + "id" => '', + "margin" => 0, + "is_margin" => 0, + "type_info" => '', + "description" => '', + "type_name" => '', + "update_time" => '' + ]; + } + + // 查出商户所有菜单数据 + $data = $menu->Search([], 1); + View::assign('dataTree', $format->FormatCategory($data['list'])); + View::assign('detail', $detail); + + return view($this->path['add']); } /** - * 显示店铺类型列表 + * 输出店铺类型列表数据 * * @return \think\Response */ public function Lst() { - echo 1723; $param = get_params(); - $where = []; - if (isset($param['keywords']) && !empty($param['keywords'])){ - $where[]=['store_name','like','%'.$param['keywords'].'%']; - } - $list = $this->model->getStoreProductList($where,$param); + $page = empty($param['page']) ? 1 : (int)$param['page']; + $limit = empty($param['limit']) ? 10 : (int)$param['limit']; - return table_assign(0, '', $list); + $data = $this->merchant->GetList($page, $limit); + + return table_assign(0, '', $data); } /** + * TODO: 关联权限待完成 + * * 添加店铺类型. * * @return \think\Response */ public function Add() { - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - return to_assign(0,'操作成功'); + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** - * 显示指定的店铺详情 + * 查看指定的店铺详情 * - * @param int $id * @return \think\Response */ - public function Detail($id) + public function Read() { $param = get_params(); - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $detail = $this->model->getStoreProductById($product_id); - if (!empty($detail)) { - $detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content'); - $detail['slider_image_arr'] = explode(',',$detail['slider_image']); - View::assign('detail', $detail); - $store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1]) - ->select(); - View::assign('store_brand', $store_brand); - return view(); - } - else{ - throw new \think\exception\HttpException(404, '找不到页面'); - } + $id = isset($param['id']) ? (int)$param['id'] : 0; + + $detail = $this->merchant->Find($id); + + if (!empty($detail)) { + View::assign('detail', $detail); + return view($this->path['read']); + } else { + throw new \think\exception\HttpException(404, '找不到页面'); + } } /** - * 显示编辑资源表单页. + * TODO: 关联权限待完成 + * 编辑指定菜单. * * @param int $id * @return \think\Response */ - public function edit($id) + public function Edit() { - return to_assign(0,''); + $params = get_params(); + + $batch['type_name'] = $params['type_name']; + $batch['description'] = $params['description']; + $batch['is_margin'] = $params['is_margin']; + $batch['margin'] = $params['margin']; + $batch['type_info'] = $params['type_info']; + $menu_ids = $params['auth']; + + // 更新权限 + // $this->menu->update($menu_ids); + + $rows = $this->merchant->Add($batch); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } /** @@ -132,36 +173,39 @@ class MerchantType extends BaseController * @param int $id * @return \think\Response */ - public function del($id) + public function Del() { $param = get_params(); - $product_id = isset($param['product_id']) ? $param['product_id'] : 0; - $type = isset($param['type']) ? $param['type'] : 0; + if (empty($param['id'])) { + return 0; + } + $id = (int)$param['id']; - $this->model->delStoreProductById($product_id,1); + $rows = $this->merchant->Del($id); + + return $rows>0?to_assign(0, '操作成功'):to_assign(1, '操作失败'); } + /** * 备注表单页 */ - public function MarkForm() - { - return View(''); - } /** * 店铺类型备注 */ public function Mark() { + $params = get_params(); return to_assign(0, ''); } /** * 店铺类型说明 */ - public function Description(){ - View::assign('detail',[]); - return View('merchant/system/merchant/descr/index',['id'=>1]); + public function Description() + { + View::assign('detail', []); + return View('merchant/system/merchant/descr/index', ['id' => 1]); } } diff --git a/app/admin/route/merchant.php b/app/admin/route/merchant.php index c65f134..1432f04 100644 --- a/app/admin/route/merchant.php +++ b/app/admin/route/merchant.php @@ -52,16 +52,19 @@ Route::group(function(){ Route::get('lst', '/lst')->name('systemMerchantTypeLst')->option([ '_alias' => '列表', ]); - Route::get('detail/:id', '/detail')->name('systemMerchantTypeDetail')->option([ + Route::get('read', '/read')->name('systemMerchantTypeDetail')->option([ '_alias' => '详情', ]); + Route::get('form', '/form')->name('systemMerchantTypeAdd')->option([ + '_alias' => '添加/编辑页', + ]); Route::post('add', '/add')->name('systemMerchantTypeAdd')->option([ '_alias' => '添加', ]); - Route::put('edit/:id', '/edit')->name('systemMerchantTypeUpdate')->option([ + Route::put('edit', '/edit')->name('systemMerchantTypeUpdate')->option([ '_alias' => '编辑', ]); - Route::delete('del/:id', '/del')->name('systemMerchantTypeDelete')->option([ + Route::delete('del', '/del')->name('systemMerchantTypeDelete')->option([ '_alias' => '删除', ]); Route::get('mark/:id', '/markForm')->name('systemMerchantTypeMarkForm')->option([ @@ -69,7 +72,7 @@ Route::group(function(){ '_auth' => false, '_form' => 'systemMerchantTypeMark', ]); - Route::post('mark/:id', '/mark')->name('systemMerchantTypeMark')->option([ + Route::post('mark', '/mark')->name('systemMerchantTypeMark')->option([ '_alias' => '备注', ]); diff --git a/app/admin/view/merchant/system/merchant/type/add.html b/app/admin/view/merchant/system/merchant/type/add.html index d5368fe..25d57e3 100644 --- a/app/admin/view/merchant/system/merchant/type/add.html +++ b/app/admin/view/merchant/system/merchant/type/add.html @@ -13,139 +13,64 @@ {block name="body"}
-

添加

+

添加店铺类型

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + +
商品名称*
平台商品分类* -
- -
-
品牌选择* -
- -
-
商品封面图 -
- -
- - -
-
-
商品轮播图 -
- - -
- -
-
-
单位*
商品关键字*
售价*
成本价*
市场价*
库存*
商品简介店铺类型名称* - + +
店铺类型要求 +
商品详情店铺保证金 - + + + + + + + + + +
+
+ + +
+
+ + 单位:元
+
店铺权限* +
+
其它说明 + +
+
- +
@@ -155,95 +80,130 @@ {block name="script"} + {/block} - \ No newline at end of file + diff --git a/app/admin/view/merchant/system/merchant/type/index.html b/app/admin/view/merchant/system/merchant/type/index.html index a2bb254..c5a0624 100644 --- a/app/admin/view/merchant/system/merchant/type/index.html +++ b/app/admin/view/merchant/system/merchant/type/index.html @@ -3,23 +3,21 @@ {block name="body"}
-
-
- -
- -
{/block} @@ -34,107 +32,75 @@ elem: '#store_product', title: '商品表列表', toolbar: '#toolbarDemo', - url: '/admin/store_product/datalist', + url: '/admin/merchant/type/lst', page: true, limit: 20, cellMinWidth: 300, cols: [ [ { - fixed: 'left', - field: 'product_id', + fixed: 'ID', + field: 'id', title: '编号', align: 'center', width: 80 - },{ - field: 'image', - title: '商品图片', + }, + { + field: 'type_name', + title: '店铺类型名称', align: 'center', - width: 100, - templet: '
', + width: 200 },{ - field: 'store_name', - title: '商品名称', + field: 'margin', + title: '店铺保证金', align: 'center', width: 100 },{ - field: 'store_info', - title: '商品简介', + field: 'type_info', + title: '店铺类型要求', align: 'center', - width: 100 + width: 220 },{ - field: 'keyword', - title: '关键字', + field: 'create_time', + title: '创建时间', align: 'center', - width: 100 + width: 150 },{ - field: 'brand_id', - title: '品牌 id', + field: 'update_time', + title: '最近修改时问', align: 'center', - width: 100 - },{ - field: 'cate_id', - title: '分类', - align: 'center', - width: 100 - },{ - field: 'unit_name', - title: '单位名', - align: 'center', - width: 100 - },{ - field: 'sales', - title: '销量', - align: 'center', - width: 100 - },{ - field: 'price', - title: '最低价格', - align: 'center', - width: 100 - },{ - field: 'cost', - title: '成本价', - align: 'center', - width: 100 - },{ - field: 'ot_price', - title: '原价', - align: 'center', - width: 100 - },{ - field: 'stock', - title: '总库存', - align: 'center', - width: 100 - }, { + width: 150 + }, + { fixed: 'right', field: 'right', title: '操作', toolbar: '#barDemo', - width: 136, + width: 190, align: 'center' - } + } ] ] + }); //监听表头工具栏事件 table.on('toolbar(store_product)', function(obj){ if (obj.event === 'add') { - tool.side("/admin/store_product/add"); + tool.side("/admin/merchant/type/form"); return false; } }); //监听表格行工具事件 table.on('tool(store_product)', function(obj) { + console.log(obj.data); var data = obj.data; if (obj.event === 'read') { - tool.side('/admin/store_product/read?product_id='+obj.data.product_id); + tool.side('/admin/merchant/type/read?id='+obj.data.id); } else if (obj.event === 'edit') { - tool.side('/admin/store_product/edit?product_id='+obj.data.product_id); + tool.side('/admin/merchant/type/form?id='+obj.data.id); } else if (obj.event === 'del') { layer.confirm('确定要删除该记录吗?', { @@ -147,7 +113,7 @@ obj.del(); } } - tool.delete("/admin/store_product/del", { product_id: data.product_id }, callback); + tool.delete("/admin/merchant/type/del", { id: data.id }, callback); layer.close(index); }); } @@ -155,17 +121,17 @@ }); //监听搜索提交 - 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; + // }); } {/block} diff --git a/app/admin/view/merchant/system/merchant/type/read.html b/app/admin/view/merchant/system/merchant/type/read.html index c3637d7..16d33e0 100644 --- a/app/admin/view/merchant/system/merchant/type/read.html +++ b/app/admin/view/merchant/system/merchant/type/read.html @@ -10,135 +10,50 @@

文章详情

- + + autocomplete="off" placeholder="请输入商品名称" class="layui-input" value="{$detail.type_name}" readonly> - - - - - - - - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - + autocomplete="off" placeholder="请输入商品关键字" class="layui-input" value="{$detail.margin}" readonly> - + + + + + + - + + + + + diff --git a/app/common/model/merchant/system/merchant/MerchantMargin.php b/app/common/model/merchant/system/merchant/MerchantMargin.php index 62e8eaa..3860102 100644 --- a/app/common/model/merchant/system/merchant/MerchantMargin.php +++ b/app/common/model/merchant/system/merchant/MerchantMargin.php @@ -15,11 +15,11 @@ class MerchantMargin extends Model protected $connection = 'shop'; protected $table = ''; - - function __construct() + function GetList() { - - } + $list = self::select(); + + return $list; + } +} - -} \ No newline at end of file diff --git a/app/common/model/merchant/system/merchant/MerchantType.php b/app/common/model/merchant/system/merchant/MerchantType.php index f6a4b64..d62f57d 100644 --- a/app/common/model/merchant/system/merchant/MerchantType.php +++ b/app/common/model/merchant/system/merchant/MerchantType.php @@ -1,9 +1,18 @@ order('mer_type_id DESC') + ->page($page) + ->limit($limit) + ->order('mer_type_id DESC')->paginate($rows, false,[ + 'query' => [], //url额外参数 + // 'total' => '', //最大数量 + // 'fragment' => '', //url锚点 + // 'var_page' => 'page', //分页变量 + ]); + + return $data; + } + + /** + * 查询指定店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Find(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(); + + return $row; + } + + /** + * 新增店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Add(array $set_data) { + if (empty($set_data['type_name'])) { + return 0; + } + $batch['type_name'] = $set_data['type_name']; + $batch['description'] = empty($set_data['description'])?"":$set_data['description']; + $batch['is_margin'] = empty($set_data['is_margin']); + if (!empty($set_data['is_margin'])) { + $batch['margin'] = empty($set_data['margin'])?0:$set_data['margin']; + } + $batch['type_info'] = empty($set_data['type_info'])?'':$set_data['type_info']; + $batch['create_time'] = date('Y-m-d H:i:s',time()); + $batch['update_time'] = date('Y-m-d H:i:s',time()); + + $rows = self::insert($batch); + + return $rows; + } + + /** + * 更新指定店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Edit(int $id, array $set_data) { + if (empty($id) || empty($set_data['type_name'])) { + throw new ValidateException('未传递参数'); + return 0; + } + + $batch['type_name'] = $set_data['type_name']; + $batch['description'] = empty($set_data['description'])?"":$set_data['description']; + $batch['is_margin'] = empty($set_data['is_margin']); + if (!empty($set_data['is_margin'])) { + $batch['margin'] = empty($set_data['margin'])?0:$set_data['margin']; + } + $batch['type_info'] = empty($set_data['type_info'])?'':$set_data['type_info']; + $batch['update_time'] = date('Y-m-d H:i:s',time()); + + $rows = self::update($batch)->where('mer_type_id', $id)->limit(1); + + return $rows; + } + + /** + * 删除指定店铺类型数据 + * + * @param int $page 过滤字段条件 + * @param int $limit 菜单类型: 0商城平台菜单 1商户菜单 + * + * @return array|object + */ + function Del(int $id) { + if (empty($id)) { + throw new ValidateException('未传递参数'); + return 0; + } + $rows = self::where('mer_type_id', $id)->delete(); + + return $rows; } - function List() - {} - function Find() - {} } From f80b8b753829bbce0f6e6aac983993101596ecf4 Mon Sep 17 00:00:00 2001 From: liuxiaoquan Date: Sat, 4 Mar 2023 17:53:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=B1=BB=E5=9E=8B,?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../merchant/system/merchant/type/edit.html | 252 ------------------ 1 file changed, 252 deletions(-) delete mode 100644 app/admin/view/merchant/system/merchant/type/edit.html diff --git a/app/admin/view/merchant/system/merchant/type/edit.html b/app/admin/view/merchant/system/merchant/type/edit.html deleted file mode 100644 index 2ad9a35..0000000 --- a/app/admin/view/merchant/system/merchant/type/edit.html +++ /dev/null @@ -1,252 +0,0 @@ -{extend name="common/base"/} -{block name="style"} - -{/block} - -{block name="body"} -
-

编辑文章表

-
商品名称*店铺类型名称
商户商品分类* -
- -
+
店铺类型要求 +
品牌选择* -
- -
-
商品封面图 -
- - - -
- - -
-
-
商品轮播图 -
- - - -
- {volist name='detail.slider_image_arr' id='vo'} - {if $vo} - - {/if} - {/volist} - -
-
-
单位*
商品关键字*
售价*店铺保证金
成本价*
市场价*
库存*
商品简介店铺权限 + + +
其它说明
商品详情创建时间 - + {$detail.create_time} +
修改时间 + {$detail.update_time}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
商品名称*
平台商品分类* -
- -
-
品牌选择* -
- -
-
商品封面图 -
- -
- - -
-
-
商品轮播图 -
- -
- {volist name='detail.slider_image_arr' id='vo'} - {if $vo} - - {/if} - {/volist} - -
-
-
单位*
商品关键字*
售价*
成本价*
市场价*
库存*
商品简介 - -
商品详情 - -
-
- - - -
- -{/block} - - - -{block name="script"} - - -{/block} - \ No newline at end of file