From d744adc7628bad2a5f296281f171f503a7e1322e Mon Sep 17 00:00:00 2001 From: 15090180611 <215509543@qq.com> Date: Fri, 29 Nov 2024 18:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A0=B7=E9=9D=92=E6=98=A5=E5=A4=9C?= =?UTF-8?q?=E6=A0=A1=201=E7=AB=99=E5=86=85=E4=BF=A1=E6=89=A9=E5=B1=95?= =?UTF-8?q?=EF=BC=9A=E6=94=AF=E6=8C=81=E5=A4=B4=E5=83=8F=E5=92=8C=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E6=97=B6=E9=97=B4=E6=9F=A5=E8=AF=A2=202=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=92=8C=E6=9C=BA=E6=9E=84=E5=90=8E=E5=8F=B0=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AF=BE=E6=97=B6=E5=92=8C=E8=AF=BE=E7=A8=8B=E5=9C=A8?= =?UTF-8?q?=E4=B8=80=E8=B5=B7=E7=AE=A1=E7=90=86=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E6=95=88=E7=8E=87=203=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=A1=A8=E6=8E=A5=E5=8F=A3=E4=BB=A5=E9=80=82?= =?UTF-8?q?=E9=85=8D=E6=9C=80=E6=96=B0=E7=9A=84ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/school/Message.php | 3 +- .../admin/controller/school/MessageConfig.php | 40 ++++++ .../controller/school/classes/ClassesLib.php | 39 +++++- .../controller/school/classes/ClassesSpec.php | 23 +++- .../admin/lang/zh-cn/school/message.php | 1 + .../lang/zh-cn/school/message_config.php | 30 ++++ application/admin/model/school/Message.php | 7 + .../admin/model/school/MessageConfig.php | 101 ++++++++++++++ .../admin/validate/school/MessageConfig.php | 27 ++++ .../school/classes/classes_lib/addnew.html | 4 +- .../view/school/classes/classes_lib/edit.html | 56 +++++++- .../school/classes/classes_lib/index.html | 4 +- .../admin/view/school/message/add.html | 11 ++ .../admin/view/school/message/edit.html | 8 ++ .../admin/view/school/message_config/add.html | 129 ++++++++++++++++++ .../view/school/message_config/edit.html | 129 ++++++++++++++++++ .../view/school/message_config/index.html | 46 +++++++ .../school/message_config/recyclebin.html | 25 ++++ application/api/controller/school/Message.php | 6 +- application/common/controller/Backend.php | 1 + .../common/controller/ManystoreBase.php | 1 + .../common/listener/classes/ClassesHook.php | 3 + .../listener/classeshourorder/OrderHook.php | 6 + .../listener/classesorder/OrderHook.php | 4 + .../common/listener/manystore/ShopHook.php | 3 + application/common/model/BaseModel.php | 5 +- application/common/model/school/Message.php | 21 ++- .../common/model/school/MessageConfig.php | 107 +++++++++++++++ .../model/school/classes/ClassesLib.php | 63 ++++++++- .../model/school/classes/ClassesSpec.php | 21 ++- .../controller/school/classes/ClassesLib.php | 35 +++++ .../controller/school/classes/ClassesSpec.php | 24 +++- .../school/classes/classes_lib/addnew.html | 4 +- .../view/school/classes/classes_lib/edit.html | 54 +++++++- .../school/classes/classes_lib/index.html | 4 +- .../js/backend/school/classes/classes_lib.js | 60 ++++++-- public/assets/js/backend/school/message.js | 14 +- .../js/backend/school/message_config.js | 126 +++++++++++++++++ .../manystore/school/classes/classes_lib.js | 85 ++++++++---- 39 files changed, 1240 insertions(+), 90 deletions(-) create mode 100644 application/admin/controller/school/MessageConfig.php create mode 100644 application/admin/lang/zh-cn/school/message_config.php create mode 100644 application/admin/model/school/MessageConfig.php create mode 100644 application/admin/validate/school/MessageConfig.php create mode 100644 application/admin/view/school/message_config/add.html create mode 100644 application/admin/view/school/message_config/edit.html create mode 100644 application/admin/view/school/message_config/index.html create mode 100644 application/admin/view/school/message_config/recyclebin.html create mode 100644 application/common/model/school/MessageConfig.php create mode 100644 public/assets/js/backend/school/message_config.js diff --git a/application/admin/controller/school/Message.php b/application/admin/controller/school/Message.php index fb6d67d..6c89041 100644 --- a/application/admin/controller/school/Message.php +++ b/application/admin/controller/school/Message.php @@ -56,7 +56,7 @@ class Message extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $as = $this->model->getWithAlisaName(); $list = $this->model - ->with(['admin','user']) + ->with(['admin','user','messageevent']) ->where($where) // ->order($sort, $order) ->order("{$as}.weigh DESC,{$as}.id DESC") @@ -66,6 +66,7 @@ class Message extends Backend $row->getRelation('admin')->visible(['nickname','avatar']); $row->getRelation('user')->visible(['nickname','avatar']); + $row->getRelation('messageevent')->visible(['logo_image']); } $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/application/admin/controller/school/MessageConfig.php b/application/admin/controller/school/MessageConfig.php new file mode 100644 index 0000000..e4e4ca8 --- /dev/null +++ b/application/admin/controller/school/MessageConfig.php @@ -0,0 +1,40 @@ +model = new \app\admin\model\school\MessageConfig; + $this->view->assign("statusList", $this->model->getStatusList()); + $this->view->assign("wechatWapList", $this->model->getWechatWapList()); + $this->view->assign("messageList", $this->model->getMessageList()); + $this->view->assign("selfmailList", $this->model->getSelfmailList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + +} diff --git a/application/admin/controller/school/classes/ClassesLib.php b/application/admin/controller/school/classes/ClassesLib.php index 7d3f27a..8566b55 100644 --- a/application/admin/controller/school/classes/ClassesLib.php +++ b/application/admin/controller/school/classes/ClassesLib.php @@ -216,7 +216,9 @@ class ClassesLib extends Backend $classesLib->no_auth_fields = $this->no_auth_fields; $classesLib->need_auth = $this->need_auth; $classesLib->have_auth = $this->have_auth; - $classesLib->classesCheck($params,$shop_id=null,$row); + + $classesLib->classesCheck($params,null,$row); + $this->need_auth = $classesLib->need_auth; $this->have_auth = $classesLib->have_auth; @@ -349,8 +351,17 @@ class ClassesLib extends Backend $this->model->validateFailException()->validate($validate); } $this->update_check($params,$row=null); + $spec = $params["spec"]; + unset($params["spec"]); $result = $this->model->allowField(true)->save($params); \app\common\model\school\classes\ClassesLib::add_virtual_init($this->model["id"]); + + //添加课程规格 + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $this->model["id"]; + \app\common\model\school\classes\ClassesSpec::create($v); + } + $this->update_classes($this->model["id"]); if($this->have_auth){ @@ -405,6 +416,11 @@ class ClassesLib extends Backend $this->error(__('You have no permission')); } if (false === $this->request->isPost()) { + $spec = \app\common\model\school\classes\ClassesSpec::where("classes_lib_id",$row["id"])->field("id,classes_lib_id,name,start_time,end_time,limit_num,status,weigh")->order('weigh desc,id desc')->select(); + foreach ($spec as $k=>&$v){ + $v["time"] = date("Y/m/d H:i",$v["start_time"])." - ".date("Y/m/d H:i",$v["end_time"]); + } + $row["spec"] = json_encode($spec); $this->view->assign('row', $row); return $this->view->fetch(); } @@ -422,8 +438,29 @@ class ClassesLib extends Backend $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; $row->validateFailException()->validate($validate); } + $this->update_check($params,$row); + $spec = $params["spec"] ?? []; + $delete_spec_ids = $params["delete_spec_ids"] ?? []; + unset($params["spec"]); + unset($params["delete_spec_ids"]); $result = $row->allowField(true)->save($params); + //添加课程规格 + foreach ($spec as $k=>$v){ + $v["classes_lib_id"] = $row["id"]; + //有id更新,否则新增 + if(isset($v["id"]) && $v["id"]){ + \app\common\model\school\classes\ClassesSpec::update((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + }else{ + \app\common\model\school\classes\ClassesSpec::create((new \app\common\model\school\classes\ClassesSpec)->checkAssemblyParameters($v)); + } + + } + //删除规格 + foreach ($delete_spec_ids as $k=>$delete_spec){ + $delete_spec->delete(); + } + $this->update_classes($row["id"]); if($this->have_auth){ //调用通过事件 diff --git a/application/admin/controller/school/classes/ClassesSpec.php b/application/admin/controller/school/classes/ClassesSpec.php index e64d9a0..755b242 100644 --- a/application/admin/controller/school/classes/ClassesSpec.php +++ b/application/admin/controller/school/classes/ClassesSpec.php @@ -135,14 +135,18 @@ class ClassesSpec extends Backend { //限定人数必须大于0 try { - (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,$shop_id=null,$row); - }catch (\Exception $e){ - $this->error($e->getMessage()); - } - //修改 + $classesLib = new \app\common\model\school\classes\ClassesSpec(); + $classesLib->no_auth_fields = $this->no_auth_fields; + $classesLib->need_auth = $this->need_auth; + $classesLib->have_auth = $this->have_auth; + $classesLib->specCheck($params,$shop_id=null,$row); + $this->need_auth = $classesLib->need_auth; + $this->have_auth = $classesLib->have_auth; + + //修改 if($row){ - $this->updateCheck($row->id,$params,$row); + $classesLib->updateCheck($row->id,$params,$row); }else{ //新增 @@ -150,6 +154,13 @@ class ClassesSpec extends Backend } +// (new \app\common\model\school\classes\ClassesSpec)->specCheck($params,$shop_id=null,$row); + }catch (\Exception $e){ + $this->error($e->getMessage()); + } + + + ; } diff --git a/application/admin/lang/zh-cn/school/message.php b/application/admin/lang/zh-cn/school/message.php index 82dcca1..556b1fd 100644 --- a/application/admin/lang/zh-cn/school/message.php +++ b/application/admin/lang/zh-cn/school/message.php @@ -5,6 +5,7 @@ return [ 'Type 1' => '未读', 'Type 2' => '已读', 'Weigh' => '权重', + 'Logo_image' => '事件消息logo', 'Platform' => '消息平台', 'Platform admin' => '总后台', 'Platform user' => '用户端', diff --git a/application/admin/lang/zh-cn/school/message_config.php b/application/admin/lang/zh-cn/school/message_config.php new file mode 100644 index 0000000..2a0460b --- /dev/null +++ b/application/admin/lang/zh-cn/school/message_config.php @@ -0,0 +1,30 @@ + '事件名', + 'Event' => '事件标识', + 'Logo_image' => '事件消息logo', + 'Status' => '事件类型', + 'Status 1' => '系统推送', + 'Set status to 1' => '设为系统推送', + 'Status 2' => '其他', + 'Set status to 2' => '设为其他', + 'Wechat_wap' => '微信公众号消息', + 'Wechat_wap 1' => '开启', + 'Wechat_wap 2' => '关闭', + 'Message' => '短信消息', + 'Message 1' => '开启', + 'Message 2' => '关闭', + 'Selfmail' => '站内行消息', + 'Selfmail 1' => '开启', + 'Selfmail 2' => '关闭', + 'Message_id' => '短信模板id', + 'Wechat_wap_id' => '公众号模板消息id', + 'Selfmail_title' => '站内信标题', + 'Selfmail_template_text' => '站内信模板', + 'Configjson' => '可用的模板字段变量', + 'Weigh' => '权重', + 'Createtime' => '创建时间', + 'Updatetime' => '修改时间', + 'Deletetime' => '删除时间' +]; diff --git a/application/admin/model/school/Message.php b/application/admin/model/school/Message.php index 32d46c1..59af4dc 100644 --- a/application/admin/model/school/Message.php +++ b/application/admin/model/school/Message.php @@ -144,4 +144,11 @@ class Message extends BaseModel { return $this->belongsTo('app\admin\model\User', 'to_id', 'id', [], 'LEFT')->setEagerlyType(0); } + + + public function messageevent() + { + return $this->belongsTo(MessageConfig::class, 'event', 'event', [], 'LEFT')->setEagerlyType(0); + } + } diff --git a/application/admin/model/school/MessageConfig.php b/application/admin/model/school/MessageConfig.php new file mode 100644 index 0000000..b38002b --- /dev/null +++ b/application/admin/model/school/MessageConfig.php @@ -0,0 +1,101 @@ +getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + } + }); + } + + + public function getStatusList() + { + return ['1' => __('Status 1'), '2' => __('Status 2')]; + } + + public function getWechatWapList() + { + return ['1' => __('Wechat_wap 1'), '2' => __('Wechat_wap 2')]; + } + + public function getMessageList() + { + return ['1' => __('Message 1'), '2' => __('Message 2')]; + } + + public function getSelfmailList() + { + return ['1' => __('Selfmail 1'), '2' => __('Selfmail 2')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getWechatWapTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['wechat_wap']) ? $data['wechat_wap'] : ''); + $list = $this->getWechatWapList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getMessageTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['message']) ? $data['message'] : ''); + $list = $this->getMessageList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + public function getSelfmailTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['selfmail']) ? $data['selfmail'] : ''); + $list = $this->getSelfmailList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + + +} diff --git a/application/admin/validate/school/MessageConfig.php b/application/admin/validate/school/MessageConfig.php new file mode 100644 index 0000000..18d5fb9 --- /dev/null +++ b/application/admin/validate/school/MessageConfig.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/school/classes/classes_lib/addnew.html b/application/admin/view/school/classes/classes_lib/addnew.html index d82d644..6c66719 100644 --- a/application/admin/view/school/classes/classes_lib/addnew.html +++ b/application/admin/view/school/classes/classes_lib/addnew.html @@ -169,9 +169,9 @@ + + + + + + + + +