diff --git a/application/admin/controller/manystore/ShopApply.php b/application/admin/controller/manystore/ShopApply.php
index 6e046a3..d5a6d70 100644
--- a/application/admin/controller/manystore/ShopApply.php
+++ b/application/admin/controller/manystore/ShopApply.php
@@ -3,6 +3,10 @@
namespace app\admin\controller\manystore;
use app\common\controller\Backend;
+use think\Db;
+use think\exception\DbException;
+use think\exception\PDOException;
+use think\exception\ValidateException;
/**
* 机构申请
@@ -77,4 +81,101 @@ class ShopApply extends Backend
return $this->view->fetch();
}
+
+
+
+ /**
+ * 添加
+ *
+ * @return string
+ * @throws \think\Exception
+ */
+ public function add()
+ {
+ if (false === $this->request->isPost()) {
+ return $this->view->fetch();
+ }
+ $params = $this->request->post('row/a');
+ if (empty($params)) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $params = $this->preExcludeFields($params);
+
+ if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
+ $params[$this->dataLimitField] = $this->auth->id;
+ }
+ $result = false;
+ Db::startTrans();
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+ $this->model->validateFailException()->validate($validate);
+ }
+ $result = $this->model->allowField(true)->save($params);
+
+ //调用订单事件
+ $data = ['shop' => $this->model];
+ \think\Hook::listen('shop_apply_create_after', $data);
+
+ Db::commit();
+ } catch (ValidateException|PDOException|\Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if ($result === false) {
+ $this->error(__('No rows were inserted'));
+ }
+ $this->success();
+ }
+
+ /**
+ * 编辑
+ *
+ * @param $ids
+ * @return string
+ * @throws DbException
+ * @throws \think\Exception
+ */
+ public function edit($ids = null)
+ {
+ $row = $this->model->get($ids);
+ if (!$row) {
+ $this->error(__('No Results were found'));
+ }
+ $adminIds = $this->getDataLimitAdminIds();
+ if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
+ $this->error(__('You have no permission'));
+ }
+ if (false === $this->request->isPost()) {
+ $this->view->assign('row', $row);
+ return $this->view->fetch();
+ }
+ $params = $this->request->post('row/a');
+ if (empty($params)) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $params = $this->preExcludeFields($params);
+ $result = false;
+ Db::startTrans();
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+ $row->validateFailException()->validate($validate);
+ }
+ $result = $row->allowField(true)->save($params);
+ Db::commit();
+ } catch (ValidateException|PDOException|\Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if (false === $result) {
+ $this->error(__('No rows were updated'));
+ }
+ $this->success();
+ }
+
}
diff --git a/application/admin/controller/notice/Admin.php b/application/admin/controller/notice/Admin.php
new file mode 100644
index 0000000..17bbcf2
--- /dev/null
+++ b/application/admin/controller/notice/Admin.php
@@ -0,0 +1,113 @@
+auth->getUserInfo();
+ $list = \app\admin\model\notice\Notice::where('to_id', $user['id'])
+ ->where('platform', 'admin')
+ ->where('type','msg')
+ ->order('id', 'desc')
+ ->paginate(20);
+
+ $config = get_addon_config('notice');
+ // 是否有未读的
+ $haveUnread = false;
+ // 判断是否需要自动标记为已读
+ $auto_read = $config['auto_read'] ?? false;
+ if ($auto_read) {
+ \app\admin\model\notice\Notice::where('id', 'in',array_column($list->items(), 'id'))
+ ->update(['readtime' => time()]);
+ } else {
+ foreach ($list->items() as $item) {
+ if ($item['readtime'] === null) {
+ $haveUnread = true;
+ break;
+ }
+ }
+ }
+
+ $this->assign('haveUnread', $haveUnread);
+ $this->assign('list', $list);
+ $this->assign('title', '我的消息');
+
+ return $this->view->fetch();
+ }
+
+ // 标记为已读
+ public function mark()
+ {
+ $user = $this->auth->getUserInfo();
+
+ $where = [];
+ if (input('id')) {
+ $where['id'] = input('id');
+ }
+
+ $count = \app\admin\model\notice\Notice::where('to_id', $user['id'])
+ ->where('platform', 'admin')
+ ->where('type','msg')
+ ->where($where)
+ ->order('id', 'desc')
+ ->whereNull('readtime')
+ ->update(['readtime' => time()]);
+
+ $this->success('', $count);
+ }
+
+ // 统计
+ public function statistical()
+ {
+ AdminLog::setIgnoreRegex('/./');
+
+ $user = $this->auth->getUserInfo();
+ $statisticalTime = Cache::get('notice_admin_statistical_time_'.$user['id'], 0);
+ $new = \app\admin\model\notice\Notice::where('to_id', $user['id'])
+ ->where('platform', 'admin')
+ ->where('type','msg')
+ ->order('id', 'desc')
+ ->where('createtime','>', $statisticalTime)
+ ->whereNull('readtime')
+ ->find();
+ if ($new) {
+ Cache::set('notice_admin_statistical_time_'.$user['id'], time());
+ }
+
+ $noticeData = Service::getNoticeData();
+ $waitData = Service::getWaitData();
+
+ $data = [
+ 'num' => \app\admin\model\notice\Notice::where('to_id', $user['id'])
+ ->where('platform', 'admin')
+ ->where('type','msg')
+ ->order('id', 'desc')
+ ->whereNull('readtime')
+ ->count()
+ ,
+ 'new' => $new,
+
+ 'notice_data' => $noticeData,
+ 'wait_data' => $waitData,
+ ];
+
+ $this->success('', '', $data);
+ }
+}
\ No newline at end of file
diff --git a/application/admin/controller/notice/AdminMptemplate.php b/application/admin/controller/notice/AdminMptemplate.php
new file mode 100644
index 0000000..ca5ffc2
--- /dev/null
+++ b/application/admin/controller/notice/AdminMptemplate.php
@@ -0,0 +1,110 @@
+model = new \app\admin\model\notice\AdminMptemplate;
+
+ }
+
+ public function import()
+ {
+ parent::import();
+ }
+
+ /**
+ * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+ * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+ * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+ */
+
+
+ // 绑定模版消息(公众号)
+ public function bind()
+ {
+ $exist = \app\admin\model\notice\AdminMptemplate::where('admin_id', $this->auth->id)->find();
+
+ if ($this->request->isPost()) {
+ $exist->delete();
+ $this->success('解绑成功');
+ }
+
+ $this->assign('exist', $exist);
+
+ $url = '';
+ // 5分钟有效的绑定连接
+ if (!$exist){
+ $mark = 'notice_bmp'.uniqid();
+ Cache::set($mark, $this->auth->id, 60*5);
+ $url = addon_url('notice/index/mpauth', ['mark' => $mark], false, true);
+ }
+
+ $this->assignconfig('url', $url);
+ return $this->fetch();
+ }
+
+ /**
+ * 查看
+ */
+ public function index()
+ {
+ //当前是否为关联查询
+ $this->relationSearch = true;
+ //设置过滤方法
+ $this->request->filter(['strip_tags', 'trim']);
+ if ($this->request->isAjax())
+ {
+ //如果发送的来源是Selectpage,则转发到Selectpage
+ if ($this->request->request('keyField'))
+ {
+ return $this->selectpage();
+ }
+ list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+ $total = $this->model
+ ->with(['admin'])
+ ->where($where)
+ ->order($sort, $order)
+ ->count();
+
+ $list = $this->model
+ ->with(['admin'])
+ ->where($where)
+ ->order($sort, $order)
+ ->limit($offset, $limit)
+ ->select();
+
+ foreach ($list as $row) {
+
+ $row->getRelation('admin')->visible(['id','nickname']);
+ }
+ $list = collection($list)->toArray();
+ $result = array("total" => $total, "rows" => $list);
+
+ return json($result);
+ }
+ return $this->view->fetch();
+ }
+}
diff --git a/application/admin/controller/notice/Event.php b/application/admin/controller/notice/Event.php
new file mode 100644
index 0000000..60d71fb
--- /dev/null
+++ b/application/admin/controller/notice/Event.php
@@ -0,0 +1,106 @@
+model = new \app\admin\model\notice\NoticeEvent;
+ $this->view->assign("platformList", $this->model->getPlatformList());
+ $this->view->assign("typeList", $this->model->getTypeList());
+ $this->assignconfig("typeList", $this->model->getTypeList());
+ $this->view->assign("visibleSwitchList", $this->model->getVisibleSwitchList());
+ }
+
+ public function import()
+ {
+ parent::import();
+ }
+
+ /**
+ * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+ * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+ * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+ */
+
+
+ public function test($ids)
+ {
+ $row = $this->model->get($ids);
+ if (!$row) {
+ $this->error(__('No Results were found'));
+ }
+ if ($this->request->isAjax()) {
+ $params = input('row/a');
+ $params = $this->preExcludeFields($params);
+ $params = array_only($params, '*');
+ $params['field']['receiver_admin_ids'] = input('row.receiver_admin_ids');
+ $params['field']['receiver_admin_group_ids'] = input('row.receiver_admin_group_ids');
+ $params['field'] = array_filter($params['field'], function ($v) {
+ return $v != '';
+ });
+ if (!$params) {
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ Db::startTrans();
+ try{
+ // 函数发送
+// $is = NoticeClient::instance()->trigger($row['event'], $params['field']);
+ // 行为发送
+ $noticeParams = [
+ 'event' => $row['event'],
+ 'params' => $params['field']
+ ];
+ $is = Hook::listen('send_notice', $noticeParams, null, true);
+ Db::commit();
+ }catch (\Exception $e) {
+ $this->error($e->getMessage());
+ Db::rollback();
+ }
+ if ($is) {
+ $this->success('操作成功');
+ }
+ $this->error('发送失败:'.NoticeClient::instance()->getError());
+ }
+
+ $row->content_arr2 = array_merge(['receiver_admin_ids' => '', 'receiver_admin_group_ids' => '',], $row['content_arr']);
+ $this->assign('row', $row);
+
+ return $this->fetch();
+ }
+
+
+ public function edit($ids = null)
+ {
+ // copy数据
+ if ($this->request->isPost() && input('is_copy')) {
+ $params = $this->request->post("row/a");
+ $params = $this->preExcludeFields($params);
+ $this->model->save($params);
+ $this->success('添加成功');
+ }
+ return parent::edit($ids);
+ }
+
+}
diff --git a/application/admin/controller/notice/Notice.php b/application/admin/controller/notice/Notice.php
new file mode 100644
index 0000000..f2ff61c
--- /dev/null
+++ b/application/admin/controller/notice/Notice.php
@@ -0,0 +1,137 @@
+model = new \app\admin\model\notice\Notice;
+ $this->view->assign("typeList", $this->model->getTypeList());
+ $this->assignconfig("typeList", $this->model->getTypeList());
+ $this->view->assign("platformList", $this->model->getPlatformList());
+ }
+
+ public function import()
+ {
+ parent::import();
+ }
+
+ /**
+ * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+ * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+ * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+ */
+
+
+ /**
+ * 查看
+ */
+ public function index()
+ {
+ //当前是否为关联查询
+ $this->relationSearch = true;
+ //设置过滤方法
+ $this->request->filter(['strip_tags', 'trim']);
+ if ($this->request->isAjax()) {
+ //如果发送的来源是Selectpage,则转发到Selectpage
+ if ($this->request->request('keyField')) {
+ return $this->selectpage();
+ }
+ list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+ $list = $this->model
+ ->with(['noticetemplate'])
+ ->where($where)
+ ->order($sort, $order)
+ ->paginate($limit);
+
+ foreach ($list as $row) {
+
+ $row->getRelation('noticetemplate')->visible(['id']);
+ }
+
+ $result = array("total" => $list->total(), "rows" => $list->items());
+
+ return json($result);
+ }
+ return $this->view->fetch();
+ }
+
+
+ public function add()
+ {
+ if ($this->request->isPost()) {
+ $params = $this->request->post("row/a");
+ if ($params) {
+ $params = $this->preExcludeFields($params);
+
+ $toIds = '';
+ if (input('row.platform') == 'user') {
+ $toIds = input('row.id1');
+ } else {
+ $toIds = input('row.id2');
+ }
+ if (empty($toIds)) {
+ $this->error('请选择接收人');
+ }
+ $toIds = explode(',', $toIds);
+
+ if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
+ $params[$this->dataLimitField] = $this->auth->id;
+ }
+ $result = false;
+ Db::startTrans();
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+ $this->model->validateFailException(true)->validate($validate);
+ }
+ foreach ($toIds as $id) {
+ $params['to_id'] = $id;
+ $this->model::create($params, true);
+ }
+ $result = true;
+ Db::commit();
+ } catch (ValidateException $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ } catch (PDOException $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ } catch (Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if ($result !== false) {
+ $this->success();
+ } else {
+ $this->error(__('No rows were inserted'));
+ }
+ }
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ return $this->view->fetch();
+ }
+
+}
diff --git a/application/admin/controller/notice/Template.php b/application/admin/controller/notice/Template.php
new file mode 100644
index 0000000..81e992a
--- /dev/null
+++ b/application/admin/controller/notice/Template.php
@@ -0,0 +1,215 @@
+model = new \app\admin\model\notice\NoticeTemplate;
+ $this->view->assign("platformList", NoticeClient::instance()->getPlatformList());
+ $this->view->assign("typeList", NoticeClient::instance()->getTypeList());
+ $this->view->assign("visibleSwitchList", $this->model->getVisibleSwitchList());
+ }
+
+
+ public function add()
+ {
+ return false;
+ }
+
+
+ public function edit($ids = null)
+ {
+ $where = $this->request->only(['notice_event_id', 'platform', 'type']);
+ if (count($where) != 3) {
+ return_error('参数错误');
+ }
+
+ $event = NoticeEvent::get($where['notice_event_id']);
+ $this->assign('event', $event);
+ row_check($event);
+ $row = $this->model->get($where);
+ if (!$row) {
+ $row = $this->model;
+ $row->notice_event_id = $where['notice_event_id'];
+ $row->platform = $where['platform'];
+ $row->type = $where['type'];
+ $row->content = '';
+ $row->visible_switch = 1;
+ $row->mptemplate_id = '';
+ $row->mptemplate_json = '';
+ $row->url_type = 1;
+ $row->url_title = '';
+ $row->url = '';
+ }
+
+ $adminIds = $this->getDataLimitAdminIds();
+ if (is_array($adminIds)) {
+ if (!in_array($row[$this->dataLimitField], $adminIds)) {
+ $this->error(__('You have no permission'));
+ }
+ }
+ if ($this->request->isPost()) {
+ $params = $this->request->post("row/a");
+ if (isset($params['mptemplate_id'])) {
+ $params['mptemplate_id'] = trim($params['mptemplate_id']);
+ }
+ if ($params) {
+ $params = $this->preExcludeFields($params);
+ $result = false;
+ Db::startTrans();
+ try {
+ //是否采用模型验证
+ if ($this->modelValidate) {
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+ $row->validateFailException(true)->validate($validate);
+ }
+ $result = $row->allowField(true)->save($params);
+ Db::commit();
+ } catch (ValidateException $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ } catch (PDOException $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ } catch (\Exception $e) {
+ Db::rollback();
+ $this->error($e->getMessage());
+ }
+ if ($result !== false) {
+ $this->success();
+ } else {
+ $this->error(__('No rows were updated'));
+ }
+ }
+ $this->error(__('Parameter %s can not be empty', ''));
+ }
+ $this->view->assign("row", $row);
+
+ $this->view->assign('urlTypeList', $row->getUrlTypeList());
+ return $this->view->fetch();
+ }
+
+
+ /**
+ * 查看
+ */
+ public function index()
+ {
+ // 依据通知事件更新模板表
+ $eventList = NoticeEvent::scope('frontend')->select();
+ $templateList = [];
+ $noticeClient = new NoticeClient();
+
+ $default_params = [
+ // 默认平台
+ 'platform' => array_keys($noticeClient->getPlatformData())[0],
+ ];
+ $params = $this->request->only(['platform']);
+ $params = array_merge($default_params, $params);
+
+ // 当前平台支持的类型
+ $typeList = $noticeClient->getPlatformData()[$params['platform']]['type'] ?? [];
+ $typeList = array_combine($typeList, $typeList);
+ foreach ($typeList as $k=>$v) {
+ $typeList[$k] = $noticeClient->getTypeText($k);
+ }
+
+ foreach ($eventList as $item) {
+ $platformArr = explode(',', $item['platform']);
+ $typeArr = explode(',', $item['type']);
+ foreach ($platformArr as $v) {
+ if ($v != $params['platform']) {
+ continue;
+ }
+ $templateItem = [
+ 'noticeevent' => $item,
+ 'item' => []
+ ];
+ foreach ($typeList as $k2 => $v2) {
+ // 判断是否支持
+ $is = in_array($k2, $typeArr);
+ if ($is) {
+ $_item = [
+ 'notice_event_id' => $item['id'],
+ 'platform' => $v,
+ 'type' => $k2,
+ 'type_text' => $v2,
+ 'content' => null,
+ 'visible_switch' => 0,
+ 'id' => 0,
+ 'send_num' => '-',
+ 'send_fail_num' => '-',
+ 'error' => false
+ ];
+ // 判断是否有记录
+ $template = $noticeClient->getTemplateByPlatformAndType($item['id'],$v, $k2);
+ if ($template) {
+ $_item = array_merge($_item, $template->toArray());
+ }
+ $templateItem['item'][] = $_item;
+ } else {
+ $templateItem['item'][] = [
+ 'error' => '不支持'
+ ];
+ }
+ }
+ if ($templateItem['item']) {
+ $templateList[] = $templateItem;
+ }
+ }
+ }
+
+ $list = $templateList;
+ $this->assign('list', $list);
+ $this->assign('typeList', $typeList);
+ $this->assign('params', $params);
+ return $this->view->fetch();
+ }
+
+
+ /**
+ * 开关
+ */
+ public function visible()
+ {
+ $params = $this->request->only(['notice_event_id', 'platform', 'type', 'visible_switch']);
+ if (count($params) != 4) {
+ return_error('缺少参数');
+ }
+ $where = $params;
+ unset($where['visible_switch']);
+ $row = $this->model->where($where)->find();
+ if (!$row) {
+ $this->error('请先配置');
+ }
+ $row['visible_switch'] = $params['visible_switch'];
+ $row->save();
+ $this->success('操作成功');
+ }
+}
diff --git a/application/admin/lang/zh-cn/notice/admin_mptemplate.php b/application/admin/lang/zh-cn/notice/admin_mptemplate.php
new file mode 100644
index 0000000..4e5da81
--- /dev/null
+++ b/application/admin/lang/zh-cn/notice/admin_mptemplate.php
@@ -0,0 +1,12 @@
+ 'ID',
+ 'Admin_id' => '管理员',
+ 'Nickname' => '微信昵称',
+ 'Avatar' => '微信头像',
+ 'Createtime' => '创建时间',
+ 'Updatetime' => '更新时间',
+ 'Deletetime' => '删除时间',
+ 'Admin.nickname' => '昵称'
+];
diff --git a/application/admin/lang/zh-cn/notice/event.php b/application/admin/lang/zh-cn/notice/event.php
new file mode 100644
index 0000000..d466e17
--- /dev/null
+++ b/application/admin/lang/zh-cn/notice/event.php
@@ -0,0 +1,23 @@
+ 'ID',
+ 'Platform' => '支持平台',
+ 'Platform user' => '用户',
+ 'Platform admin' => '后台',
+ 'Type' => '支持类型',
+ 'Type msg' => '站内通知',
+ 'Type email' => '邮箱通知',
+ 'Type template' => '模版消息(公众号)',
+ 'Name' => '消息名称',
+ 'Event' => '消息事件',
+ 'Send_num' => '发送次数',
+ 'Send_fail_num' => '发送失败次数',
+ 'Content' => '参数',
+ 'Visible_switch' => '状态',
+ 'Visible_switch 0' => '关闭',
+ 'Visible_switch 1' => '启用',
+ 'Createtime' => '创建时间',
+ 'Updatetime' => '更新时间',
+ 'Deletetime' => '删除时间'
+];
diff --git a/application/admin/lang/zh-cn/notice/notice.php b/application/admin/lang/zh-cn/notice/notice.php
new file mode 100644
index 0000000..b96f8d3
--- /dev/null
+++ b/application/admin/lang/zh-cn/notice/notice.php
@@ -0,0 +1,23 @@
+ 'ID',
+ 'Name' => '消息名称',
+ 'Event' => '消息事件',
+ 'Type' => '消息类型',
+ 'Type msg' => '站内通知',
+ 'Type email' => '邮箱通知',
+ 'Type template' => '模版消息(公众号)',
+ 'Platform' => '平台',
+ 'Platform user' => '用户',
+ 'Platform admin' => '后台',
+ 'To_id' => '接收人id',
+ 'Content' => '内容',
+ 'Ext' => '扩展',
+ 'Notice_template_id' => '消息模板',
+ 'Readtime' => '是否已读',
+ 'Createtime' => '创建时间',
+ 'Updatetime' => '更新时间',
+ 'Deletetime' => '删除时间',
+ 'Noticetemplate.id' => 'ID',
+];
diff --git a/application/admin/lang/zh-cn/notice/template.php b/application/admin/lang/zh-cn/notice/template.php
new file mode 100644
index 0000000..e836a14
--- /dev/null
+++ b/application/admin/lang/zh-cn/notice/template.php
@@ -0,0 +1,30 @@
+ 'ID',
+ 'Notice_event_id' => '事件',
+ 'Platform' => '平台',
+ 'Platform user' => '用户',
+ 'Platform admin' => '后台',
+ 'Type' => '类型',
+ 'Type msg' => '站内通知',
+ 'Type email' => '邮箱通知',
+ 'Type template' => '模版消息(公众号)',
+ 'Content' => '消息内容',
+ 'Visible_switch' => '状态',
+ 'Visible_switch 0' => '关闭',
+ 'Visible_switch 1' => '启用',
+ 'Send_num' => '发送次数',
+ 'Send_fail_num' => '发送失败次数',
+ 'Ext' => '扩展数据',
+ 'Createtime' => '创建时间',
+ 'Updatetime' => '更新时间',
+ 'Noticeevent.id' => 'ID',
+ 'Noticeevent.name' => '消息名称',
+ 'mptemplate_id' => '模板id',
+ 'mptemplate_json' => '模版参数',
+
+ 'url' => 'url',
+ 'url_title' => 'url标题',
+ 'url_type' => 'url类型',
+];
diff --git a/application/admin/model/notice/AdminMptemplate.php b/application/admin/model/notice/AdminMptemplate.php
new file mode 100644
index 0000000..3d9cecc
--- /dev/null
+++ b/application/admin/model/notice/AdminMptemplate.php
@@ -0,0 +1,44 @@
+belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/admin/model/notice/Notice.php b/application/admin/model/notice/Notice.php
new file mode 100644
index 0000000..54f8316
--- /dev/null
+++ b/application/admin/model/notice/Notice.php
@@ -0,0 +1,106 @@
+ __('Type msg'), 'email' => __('Type email'), 'mptemplate' => '模版消息(公众号)', 'miniapp' => '小程序订阅消息', 'sms' => '短信通知'];
+ }
+
+ public function getPlatformList()
+ {
+ return ['user' => __('Platform user'), 'admin' => __('Platform admin')];
+ }
+
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $list = $this->getTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getPlatformTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
+ $list = $this->getPlatformList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getReadtimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['readtime']) ? $data['readtime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setReadtimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function noticetemplate()
+ {
+ return $this->belongsTo('NoticeTemplate', 'notice_template_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+ public function getExtArrAttr($value, $data)
+ {
+ $value = $data['ext'] ?? '';
+ $value = json_decode($value, true) ?? [];
+ if (!isset($value['url'])) {
+ $value['url'] = null;
+ }
+ if (!isset($value['url_type'])) {
+ $value['url_type'] = null;
+ }
+ if (!isset($value['url_title'])) {
+ $value['url_title'] = '';
+ }
+ if ($value['url']) {
+ if (0 === stripos($value['url'], 'http')) {
+
+ } else if (0 === stripos($value['url'], '/')) {
+
+ } else {
+ if (request()->module() != 'admin') {
+ $value['url'] = url($value['url']);
+ }
+ }
+ }
+
+ return $value;
+ }
+}
diff --git a/application/admin/model/notice/NoticeEvent.php b/application/admin/model/notice/NoticeEvent.php
new file mode 100644
index 0000000..93c1a65
--- /dev/null
+++ b/application/admin/model/notice/NoticeEvent.php
@@ -0,0 +1,99 @@
+ __('Platform user'), 'admin' => __('Platform admin')];
+ }
+
+ public function getTypeList()
+ {
+ return ['msg' => __('Type msg'), 'email' => __('Type email'), 'mptemplate' => '模版消息(公众号)', 'miniapp' => '小程序订阅消息', 'sms' => '短信通知'];
+ }
+
+ public function getVisibleSwitchList()
+ {
+ return ['0' => __('Visible_switch 0'), '1' => __('Visible_switch 1')];
+ }
+
+
+ public function getPlatformTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
+ $valueArr = explode(',', $value);
+ $list = $this->getPlatformList();
+ return implode(',', array_intersect_key($list, array_flip($valueArr)));
+ }
+
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $valueArr = explode(',', $value);
+ $list = $this->getTypeList();
+ return implode(',', array_intersect_key($list, array_flip($valueArr)));
+ }
+
+
+ public function getVisibleSwitchTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['visible_switch']) ? $data['visible_switch'] : '');
+ $list = $this->getVisibleSwitchList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+ protected function setPlatformAttr($value)
+ {
+ return is_array($value) ? implode(',', $value) : $value;
+ }
+
+ protected function setTypeAttr($value)
+ {
+ return is_array($value) ? implode(',', $value) : $value;
+ }
+
+
+ public function scopeFrontend(Query $query, $params = [])
+ {
+ $query->where('__TABLE__.visible_switch', 1)
+ ->order(['__TABLE__.id'=>'desc']);
+ }
+
+}
diff --git a/application/admin/model/notice/NoticeTemplate.php b/application/admin/model/notice/NoticeTemplate.php
new file mode 100644
index 0000000..325895f
--- /dev/null
+++ b/application/admin/model/notice/NoticeTemplate.php
@@ -0,0 +1,65 @@
+ __('Visible_switch 0'), '1' => __('Visible_switch 1')];
+ }
+
+
+ public function getVisibleSwitchTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['visible_switch']) ? $data['visible_switch'] : '');
+ $list = $this->getVisibleSwitchList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
+
+ public function noticeevent()
+ {
+ return $this->belongsTo('NoticeEvent', 'notice_event_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+ public function getUrlTypeList()
+ {
+ $type = $this['type'] ?? '';
+ if ($type == 'msg') {
+ return [1 => '链接', 2=>'弹窗', 3=>'新窗口'];
+ }
+ if ($type == 'mptemplate' || $type == 'miniapp') {
+ return [1 => '链接'];
+ }
+ return [1 => '链接', 2=>'弹窗', 3=>'新窗口'];
+ }
+}
diff --git a/application/admin/validate/notice/AdminMptemplate.php b/application/admin/validate/notice/AdminMptemplate.php
new file mode 100644
index 0000000..7b93cf2
--- /dev/null
+++ b/application/admin/validate/notice/AdminMptemplate.php
@@ -0,0 +1,27 @@
+ [],
+ 'edit' => [],
+ ];
+
+}
diff --git a/application/admin/validate/notice/Notice.php b/application/admin/validate/notice/Notice.php
new file mode 100644
index 0000000..90c336e
--- /dev/null
+++ b/application/admin/validate/notice/Notice.php
@@ -0,0 +1,27 @@
+ [],
+ 'edit' => [],
+ ];
+
+}
diff --git a/application/admin/validate/notice/NoticeEvent.php b/application/admin/validate/notice/NoticeEvent.php
new file mode 100644
index 0000000..bda2404
--- /dev/null
+++ b/application/admin/validate/notice/NoticeEvent.php
@@ -0,0 +1,27 @@
+ [],
+ 'edit' => [],
+ ];
+
+}
diff --git a/application/admin/validate/notice/NoticeTemplate.php b/application/admin/validate/notice/NoticeTemplate.php
new file mode 100644
index 0000000..ed5b99c
--- /dev/null
+++ b/application/admin/validate/notice/NoticeTemplate.php
@@ -0,0 +1,27 @@
+ [],
+ 'edit' => [],
+ ];
+
+}
diff --git a/application/admin/view/notice/admin/index.html b/application/admin/view/notice/admin/index.html
new file mode 100644
index 0000000..efdabb0
--- /dev/null
+++ b/application/admin/view/notice/admin/index.html
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {foreach $list as $v}
+
+ {$v.content|htmlentities} |
+ {$v.createtime|time_text} |
+
+ {if $v.readtime == null}
+
+ {else}
+ 已读
+ {/if}
+ |
+
+ {/foreach}
+
+
+
+ {if $list->count() == 0}
+
暂无消息
+ {/if}
+
+ {$list->render()}
+
+
+
+
+
\ No newline at end of file
diff --git a/application/admin/view/notice/admin_mptemplate/add.html b/application/admin/view/notice/admin_mptemplate/add.html
new file mode 100644
index 0000000..a42935f
--- /dev/null
+++ b/application/admin/view/notice/admin_mptemplate/add.html
@@ -0,0 +1,48 @@
+
diff --git a/application/admin/view/notice/admin_mptemplate/bind.html b/application/admin/view/notice/admin_mptemplate/bind.html
new file mode 100644
index 0000000..bec820a
--- /dev/null
+++ b/application/admin/view/notice/admin_mptemplate/bind.html
@@ -0,0 +1,42 @@
+
+
diff --git a/application/admin/view/notice/admin_mptemplate/edit.html b/application/admin/view/notice/admin_mptemplate/edit.html
new file mode 100644
index 0000000..f9848de
--- /dev/null
+++ b/application/admin/view/notice/admin_mptemplate/edit.html
@@ -0,0 +1,50 @@
+
diff --git a/application/admin/view/notice/admin_mptemplate/index.html b/application/admin/view/notice/admin_mptemplate/index.html
new file mode 100644
index 0000000..cc0a62a
--- /dev/null
+++ b/application/admin/view/notice/admin_mptemplate/index.html
@@ -0,0 +1,26 @@
+
+ {:build_heading()}
+
+
+
diff --git a/application/admin/view/notice/admin_mptemplate/recyclebin.html b/application/admin/view/notice/admin_mptemplate/recyclebin.html
new file mode 100644
index 0000000..192f34c
--- /dev/null
+++ b/application/admin/view/notice/admin_mptemplate/recyclebin.html
@@ -0,0 +1,25 @@
+
+ {:build_heading()}
+
+
+
diff --git a/application/admin/view/notice/event/add.html b/application/admin/view/notice/event/add.html
new file mode 100644
index 0000000..72e2b3f
--- /dev/null
+++ b/application/admin/view/notice/event/add.html
@@ -0,0 +1,88 @@
+
diff --git a/application/admin/view/notice/event/edit.html b/application/admin/view/notice/event/edit.html
new file mode 100644
index 0000000..f09dc6f
--- /dev/null
+++ b/application/admin/view/notice/event/edit.html
@@ -0,0 +1,87 @@
+
diff --git a/application/admin/view/notice/event/index.html b/application/admin/view/notice/event/index.html
new file mode 100644
index 0000000..d2e8f00
--- /dev/null
+++ b/application/admin/view/notice/event/index.html
@@ -0,0 +1,35 @@
+
+ {:build_heading()}
+
+
+
diff --git a/application/admin/view/notice/event/recyclebin.html b/application/admin/view/notice/event/recyclebin.html
new file mode 100644
index 0000000..747dc1e
--- /dev/null
+++ b/application/admin/view/notice/event/recyclebin.html
@@ -0,0 +1,25 @@
+
+ {:build_heading()}
+
+
+
diff --git a/application/admin/view/notice/event/test.html b/application/admin/view/notice/event/test.html
new file mode 100644
index 0000000..d9f4347
--- /dev/null
+++ b/application/admin/view/notice/event/test.html
@@ -0,0 +1,61 @@
+
diff --git a/application/admin/view/notice/notice/add.html b/application/admin/view/notice/notice/add.html
new file mode 100644
index 0000000..d11d27e
--- /dev/null
+++ b/application/admin/view/notice/notice/add.html
@@ -0,0 +1,85 @@
+
diff --git a/application/admin/view/notice/notice/edit.html b/application/admin/view/notice/notice/edit.html
new file mode 100644
index 0000000..ba0b674
--- /dev/null
+++ b/application/admin/view/notice/notice/edit.html
@@ -0,0 +1,76 @@
+
diff --git a/application/admin/view/notice/notice/index.html b/application/admin/view/notice/notice/index.html
new file mode 100644
index 0000000..748d4c1
--- /dev/null
+++ b/application/admin/view/notice/notice/index.html
@@ -0,0 +1,26 @@
+
+ {:build_heading()}
+
+
+
diff --git a/application/admin/view/notice/notice/recyclebin.html b/application/admin/view/notice/notice/recyclebin.html
new file mode 100644
index 0000000..a7cf784
--- /dev/null
+++ b/application/admin/view/notice/notice/recyclebin.html
@@ -0,0 +1,25 @@
+
+ {:build_heading()}
+
+
+
diff --git a/application/admin/view/notice/template/add.html b/application/admin/view/notice/template/add.html
new file mode 100644
index 0000000..8e14248
--- /dev/null
+++ b/application/admin/view/notice/template/add.html
@@ -0,0 +1,76 @@
+
diff --git a/application/admin/view/notice/template/edit.html b/application/admin/view/notice/template/edit.html
new file mode 100644
index 0000000..eed4d91
--- /dev/null
+++ b/application/admin/view/notice/template/edit.html
@@ -0,0 +1,158 @@
+
diff --git a/application/admin/view/notice/template/index.html b/application/admin/view/notice/template/index.html
new file mode 100644
index 0000000..78146d7
--- /dev/null
+++ b/application/admin/view/notice/template/index.html
@@ -0,0 +1,66 @@
+
+
+ {:build_heading(null,FALSE)}
+
+
+
+
diff --git a/application/common/hooks.php b/application/common/hooks.php
index 852d325..92b5d7a 100644
--- a/application/common/hooks.php
+++ b/application/common/hooks.php
@@ -76,6 +76,9 @@ $manystoreHooks = [
'shop_update_after' => [ // 机构数据变更
'app\\common\\listener\\manystore\\ShopHook'
],
+ 'shop_apply_create_after' => [ // 主理人申请提交
+ 'app\\common\\listener\\manystore\\ShopHook'
+ ],
];
diff --git a/application/common/listener/manystore/ShopHook.php b/application/common/listener/manystore/ShopHook.php
index f2c6bff..a8b1672 100644
--- a/application/common/listener/manystore/ShopHook.php
+++ b/application/common/listener/manystore/ShopHook.php
@@ -223,4 +223,57 @@ class ShopHook
}
+
+
+
+ // 主理人申请提交
+ public function shopApplyCreateAfter(&$params)
+ {
+ ["shop"=>$shop] = $params;
+
+ $user = User::where("id" ,$shop["user_id"])->find();
+ //记录订单日志
+
+ $desc = "您申请的认证{$shop['name']}已提交审核,审核时间为1-3日内,请耐心等待审核结果";
+
+ $title = "入驻申请提交";
+ $mini_type = "shop_apply";
+ $to_type="user";
+ $to_id = $shop["user_id"];
+ $status ="system";
+ $platform="user";
+ $oper_id=0;
+ $oper_type="system";
+ $params=[
+ "event"=>"shop_apply_create_after",
+ "shop_id"=>$shop["id"],
+ "name"=>$shop["name"],
+ ];
+
+
+
+
+ $param = [
+ "name" => $shop['name'],
+ "realname" => $shop["realname"],
+ "mobile" => $shop["mobile"],
+ "address" => $shop["address"],
+ ];
+
+ //发给用户
+ (new MessageConfig)
+ ->setTemplate($params["event"])
+ ->setTemplateData($param)
+ ->setToUid($to_id)
+ ->setMessageStatus($status)
+ ->setMessageMiniType($mini_type)
+ ->setMessageParams($params)
+ ->sendMessage();
+
+
+
+ }
+
+
+
}
\ No newline at end of file
diff --git a/application/common/model/manystore/ShopApply.php b/application/common/model/manystore/ShopApply.php
index c0adcbc..e7cf27c 100644
--- a/application/common/model/manystore/ShopApply.php
+++ b/application/common/model/manystore/ShopApply.php
@@ -159,6 +159,10 @@ class ShopApply extends BaseModel
// $res = false;
try{
$res = self::create($params);
+ //调用订单事件
+ $data = ['shop' => $res];
+ \think\Hook::listen('shop_apply_create_after', $data);
+
if($trans){
self::commitTrans();
diff --git a/application/common/model/notice/AdminMptemplate.php b/application/common/model/notice/AdminMptemplate.php
new file mode 100644
index 0000000..88241a7
--- /dev/null
+++ b/application/common/model/notice/AdminMptemplate.php
@@ -0,0 +1,44 @@
+belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+}
diff --git a/application/common/model/notice/Notice.php b/application/common/model/notice/Notice.php
new file mode 100644
index 0000000..98c4087
--- /dev/null
+++ b/application/common/model/notice/Notice.php
@@ -0,0 +1,106 @@
+ __('Type msg'), 'email' => __('Type email'), 'mptemplate' => '模版消息(公众号)', 'miniapp' => '小程序订阅消息', 'sms' => '短信通知'];
+ }
+
+ public function getPlatformList()
+ {
+ return ['user' => __('Platform user'), 'admin' => __('Platform admin')];
+ }
+
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $list = $this->getTypeList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getPlatformTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
+ $list = $this->getPlatformList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+ public function getReadtimeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['readtime']) ? $data['readtime'] : '');
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+ }
+
+ protected function setReadtimeAttr($value)
+ {
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+ }
+
+
+ public function noticetemplate()
+ {
+ return $this->belongsTo('NoticeTemplate', 'notice_template_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+ public function getExtArrAttr($value, $data)
+ {
+ $value = $data['ext'] ?? '';
+ $value = json_decode($value, true) ?? [];
+ if (!isset($value['url'])) {
+ $value['url'] = null;
+ }
+ if (!isset($value['url_type'])) {
+ $value['url_type'] = null;
+ }
+ if (!isset($value['url_title'])) {
+ $value['url_title'] = '';
+ }
+ if ($value['url']) {
+ if (0 === stripos($value['url'], 'http')) {
+
+ } else if (0 === stripos($value['url'], '/')) {
+
+ } else {
+ if (request()->module() != 'admin') {
+ $value['url'] = url($value['url']);
+ }
+ }
+ }
+
+ return $value;
+ }
+}
diff --git a/application/common/model/notice/NoticeEvent.php b/application/common/model/notice/NoticeEvent.php
new file mode 100644
index 0000000..bd7f3fb
--- /dev/null
+++ b/application/common/model/notice/NoticeEvent.php
@@ -0,0 +1,99 @@
+ __('Platform user'), 'admin' => __('Platform admin')];
+ }
+
+ public function getTypeList()
+ {
+ return ['msg' => __('Type msg'), 'email' => __('Type email'), 'mptemplate' => '模版消息(公众号)', 'miniapp' => '小程序订阅消息', 'sms' => '短信通知'];
+ }
+
+ public function getVisibleSwitchList()
+ {
+ return ['0' => __('Visible_switch 0'), '1' => __('Visible_switch 1')];
+ }
+
+
+ public function getPlatformTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['platform']) ? $data['platform'] : '');
+ $valueArr = explode(',', $value);
+ $list = $this->getPlatformList();
+ return implode(',', array_intersect_key($list, array_flip($valueArr)));
+ }
+
+
+ public function getTypeTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+ $valueArr = explode(',', $value);
+ $list = $this->getTypeList();
+ return implode(',', array_intersect_key($list, array_flip($valueArr)));
+ }
+
+
+ public function getVisibleSwitchTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['visible_switch']) ? $data['visible_switch'] : '');
+ $list = $this->getVisibleSwitchList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+ protected function setPlatformAttr($value)
+ {
+ return is_array($value) ? implode(',', $value) : $value;
+ }
+
+ protected function setTypeAttr($value)
+ {
+ return is_array($value) ? implode(',', $value) : $value;
+ }
+
+
+ public function scopeFrontend(Query $query, $params = [])
+ {
+ $query->where('__TABLE__.visible_switch', 1)
+ ->order(['__TABLE__.id'=>'desc']);
+ }
+
+}
diff --git a/application/common/model/notice/NoticeTemplate.php b/application/common/model/notice/NoticeTemplate.php
new file mode 100644
index 0000000..3eb72de
--- /dev/null
+++ b/application/common/model/notice/NoticeTemplate.php
@@ -0,0 +1,65 @@
+ __('Visible_switch 0'), '1' => __('Visible_switch 1')];
+ }
+
+
+ public function getVisibleSwitchTextAttr($value, $data)
+ {
+ $value = $value ? $value : (isset($data['visible_switch']) ? $data['visible_switch'] : '');
+ $list = $this->getVisibleSwitchList();
+ return isset($list[$value]) ? $list[$value] : '';
+ }
+
+
+
+
+ public function noticeevent()
+ {
+ return $this->belongsTo('NoticeEvent', 'notice_event_id', 'id', [], 'LEFT')->setEagerlyType(0);
+ }
+
+ public function getUrlTypeList()
+ {
+ $type = $this['type'] ?? '';
+ if ($type == 'msg') {
+ return [1 => '链接', 2=>'弹窗', 3=>'新窗口'];
+ }
+ if ($type == 'mptemplate' || $type == 'miniapp') {
+ return [1 => '链接'];
+ }
+ return [1 => '链接', 2=>'弹窗', 3=>'新窗口'];
+ }
+}
diff --git a/application/common/model/school/MessageConfig.php b/application/common/model/school/MessageConfig.php
index ea118a4..d1aa241 100644
--- a/application/common/model/school/MessageConfig.php
+++ b/application/common/model/school/MessageConfig.php
@@ -3,6 +3,7 @@
namespace app\common\model\school;
+use app\common\model\notice\NoticeEvent;
use bw\Common;
use think\Cache;
use think\Model;
@@ -276,10 +277,30 @@ class MessageConfig extends Model
return true;
}
}
+
+ public function sendBackendMessage($to_uid=0){
+ if($to_uid)$this->setToUid($to_uid);
+ $template = $this->messageTemplate;
+ if(!$template) return true;
+ $event = $template["event"];
+ $notice_event = NoticeEvent::where("event",$event)->where("visible_switch",1)->find();
+ if($notice_event){
+ //执行后台通知
+ // 发送通知-主理人申请通知
+ $noticeParams = [
+ 'event' => $event,
+ 'params' => array_merge( array (
+ 'receiver_admin_ids' => '',
+ 'receiver_admin_group_ids' => '',
+ ), $this->templateData)];
+ \Think\Hook::listen('send_notice', $noticeParams);
+ }
+ }
public function sendMessage($to_uid=0){
$this->sendSelfmail($to_uid);
$this->sendMobileMessage($to_uid);
$this->sendWechatWap($to_uid);
+ $this->sendBackendMessage($to_uid);
return $this;
}
diff --git a/application/common/model/school/activity/Join.php b/application/common/model/school/activity/Join.php
index 93d256e..ed40ac2 100644
--- a/application/common/model/school/activity/Join.php
+++ b/application/common/model/school/activity/Join.php
@@ -66,12 +66,20 @@ class Join extends BaseModel
}
+ if(config("site.activity_idcard_need")){
+ $rule = [
+ 'user_id'=>'require',
+ 'name'=>'require',
+ 'idnum'=>'require',
+ ];
+ }else{
+ $rule = [
+ 'user_id'=>'require',
+ 'name'=>'require',
+// 'idnum'=>'require',
+ ];
+ }
- $rule = [
- 'user_id'=>'require',
- 'name'=>'require',
- 'idnum'=>'require',
- ];
$rule_msg = [
"user_id.require"=>'用户必填',
@@ -130,11 +138,19 @@ class Join extends BaseModel
- $rule = [
- 'user_id'=>'require',
- 'name'=>'require',
- 'idnum'=>'require',
- ];
+ if(config("site.activity_idcard_need")){
+ $rule = [
+ 'user_id'=>'require',
+ 'name'=>'require',
+ 'idnum'=>'require',
+ ];
+ }else{
+ $rule = [
+ 'user_id'=>'require',
+ 'name'=>'require',
+// 'idnum'=>'require',
+ ];
+ }
$rule_msg = [
"user_id.require"=>'用户必填',
diff --git a/application/common/model/school/activity/order/Order.php b/application/common/model/school/activity/order/Order.php
index 1d1100e..0e30ed7 100644
--- a/application/common/model/school/activity/order/Order.php
+++ b/application/common/model/school/activity/order/Order.php
@@ -692,27 +692,31 @@ class Order extends BaseModel
throw new \Exception("报名人信息需要跟报名人数一致!");
}
- //$param["people"] = [{name:"小明",idnum:"410303199501220515"}]
- $people_idnums = [];
- foreach ($peoples as $people){
- $people_idnums[] = $people["idnum"];
- }
+
//当前活动已经报名的身份证无法重复报名
- $as = (new OrderCode)->getWithAlisaName();
- $orderCode = OrderCode::with("activityorder")
- ->where("{$as}.activity_id",$activity_id)
- ->where("activityorder.status","in",[ "0","2","3",'4',"7","9"])
- ->where("{$as}.idnum","in",$people_idnums)
- ->find();
- if($orderCode){
+ if(config("site.activity_idcard_need")){
+ //$param["people"] = [{name:"小明",idnum:"410303199501220515"}]
+ $people_idnums = [];
+ foreach ($peoples as $people){
+ $people_idnums[] = $people["idnum"];
+ }
+ $as = (new OrderCode)->getWithAlisaName();
+ $orderCode = OrderCode::with("activityorder")
+ ->where("{$as}.activity_id",$activity_id)
+ ->where("activityorder.status","in",[ "0","2","3",'4',"7","9"])
+ ->where("{$as}.idnum","in",$people_idnums)
+ ->find();
+ if($orderCode){
// throw new \Exception("{$orderCode['name']}已经报过名了!请勿重复报名!");
- throw new \Exception("该身份证号已报名!请勿重复报名!");
+ throw new \Exception("该身份证号已报名!请勿重复报名!");
+ }
}
+
}
@@ -956,7 +960,7 @@ class Order extends BaseModel
];
if($people && isset($people[$i])){
$params["name"] = $people[$i]["name"];
- $params["idnum"] = $people[$i]["idnum"];
+ $params["idnum"] = $people[$i]["idnum"] ?? "";
}
diff --git a/application/index/controller/notice/Index.php b/application/index/controller/notice/Index.php
new file mode 100644
index 0000000..3dfcd54
--- /dev/null
+++ b/application/index/controller/notice/Index.php
@@ -0,0 +1,51 @@
+auth->getUser();
+ $list = \app\admin\model\notice\Notice::where('to_id', $user['id'])
+ ->where('platform', 'user')
+ ->where('type','msg')
+ ->order('id', 'desc')
+ ->paginate(20);
+
+ $config = get_addon_config('notice');
+ // 是否有未读的
+ $haveUnread = false;
+ // 判断是否需要自动标记为已读
+ $auto_read = $config['auto_read'] ?? false;
+ if ($auto_read) {
+ \app\admin\model\notice\Notice::where('id', 'in',array_column($list->items(), 'id'))
+ ->update(['readtime' => time()]);
+ } else {
+ foreach ($list->items() as $item) {
+ if ($item['readtime'] === null) {
+ $haveUnread = true;
+ break;
+ }
+ }
+ }
+
+ $this->assign('haveUnread', $haveUnread);
+ $this->assign('list', $list);
+ $this->assign('title', '我的消息');
+
+ return $this->fetch();
+ }
+}
\ No newline at end of file
diff --git a/application/index/view/notice/index/index.html b/application/index/view/notice/index/index.html
new file mode 100644
index 0000000..c6484cc
--- /dev/null
+++ b/application/index/view/notice/index/index.html
@@ -0,0 +1,110 @@
+
+
+
+
+
+ {include file="common/sidenav" /}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {foreach $list as $v}
+
+ {$v.content|htmlentities} |
+ {$v.createtime|time_text} |
+
+ {if $v.readtime == null}
+
+ {else}
+ 已读
+ {/if}
+ |
+
+ {/foreach}
+
+
+
+ {if $list->count() == 0}
+
+ {/if}
+
+ {$list->render()}
+
+
+
+
+
\ No newline at end of file
diff --git a/public/assets/js/backend/notice/admin.js b/public/assets/js/backend/notice/admin.js
new file mode 100644
index 0000000..d7bfa48
--- /dev/null
+++ b/public/assets/js/backend/notice/admin.js
@@ -0,0 +1,32 @@
+define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) {
+ var Controller = {
+ index: function () {
+ // 标记为已读
+ $(document).on('click', '.mark-event', function () {
+ Fast.api.ajax($(this).data('url'), function () {
+ location.reload();
+ });
+ });
+
+ $(document).on('click','.btn-refresh', function () {
+ Layer.load();
+ location.reload();
+ });
+
+ // 重新获取左侧消息数量
+ Fast.api.ajax({
+ url: 'notice/admin/statistical',
+ loading: false,
+ method: 'post',
+ }, function (data, res) {
+ Backend.api.sidebar({
+ 'notice/admin': data.num,
+ });
+ return false;
+ }, function () {
+ return false;
+ });
+ }
+ };
+ return Controller;
+});
diff --git a/public/assets/js/backend/notice/admin_mptemplate.js b/public/assets/js/backend/notice/admin_mptemplate.js
new file mode 100644
index 0000000..77329c5
--- /dev/null
+++ b/public/assets/js/backend/notice/admin_mptemplate.js
@@ -0,0 +1,137 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+ var Controller = {
+ index: function () {
+ // 初始化表格参数配置
+ Table.api.init({
+ extend: {
+ index_url: 'notice/admin_mptemplate/index' + location.search,
+ add_url: 'notice/admin_mptemplate/add',
+ edit_url: 'notice/admin_mptemplate/edit',
+ del_url: 'notice/admin_mptemplate/del',
+ multi_url: 'notice/admin_mptemplate/multi',
+ import_url: 'notice/admin_mptemplate/import',
+ table: 'notice_admin_mptemplate',
+ }
+ });
+
+ var table = $("#table");
+
+ // 初始化表格
+ table.bootstrapTable({
+ url: $.fn.bootstrapTable.defaults.extend.index_url,
+ pk: 'id',
+ sortName: 'id',
+ columns: [
+ [
+ {checkbox: true},
+ {field: 'id', title: __('Id')},
+ // {field: 'admin_id', title: __('Admin_id')},
+ {field: 'admin.nickname', title: '管理员', operate: 'LIKE', formatter: Table.api.formatter.dialog, url: 'auth/admin/index?id={row.admin_id}&_t={ids}'},
+ {field: 'nickname', title: __('Nickname')},
+ {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
+ {field: 'openid', title: __('Openid')},
+ {field: 'unionid', title: __('Unionid')},
+ {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
+ // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
+ {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+ ]
+ ]
+ });
+
+ // 为表格绑定事件
+ Table.api.bindevent(table);
+ },
+ recyclebin: function () {
+ // 初始化表格参数配置
+ Table.api.init({
+ extend: {
+ 'dragsort_url': ''
+ }
+ });
+
+ var table = $("#table");
+
+ // 初始化表格
+ table.bootstrapTable({
+ url: 'notice/admin_mptemplate/recyclebin' + location.search,
+ pk: 'id',
+ sortName: 'id',
+ columns: [
+ [
+ {checkbox: true},
+ {field: 'id', title: __('Id')},
+ {
+ field: 'deletetime',
+ title: __('Deletetime'),
+ operate: 'RANGE',
+ addclass: 'datetimerange',
+ formatter: Table.api.formatter.datetime
+ },
+ {
+ field: 'operate',
+ width: '130px',
+ title: __('Operate'),
+ table: table,
+ events: Table.api.events.operate,
+ buttons: [
+ {
+ name: 'Restore',
+ text: __('Restore'),
+ classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
+ icon: 'fa fa-rotate-left',
+ url: 'notice/admin_mptemplate/restore',
+ refresh: true
+ },
+ {
+ name: 'Destroy',
+ text: __('Destroy'),
+ classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
+ icon: 'fa fa-times',
+ url: 'notice/admin_mptemplate/destroy',
+ refresh: true
+ }
+ ],
+ formatter: Table.api.formatter.operate
+ }
+ ]
+ ]
+ });
+
+ // 为表格绑定事件
+ Table.api.bindevent(table);
+ },
+ add: function () {
+ Controller.api.bindevent();
+ },
+ edit: function () {
+ Controller.api.bindevent();
+ },
+ bind: function () {
+ $(document).on('click', '.btn-refresh', function () {
+ location.reload();
+ });
+
+ $('#remove-event').data('success', function () {
+ location.reload();
+ });
+
+ require(['qrcode'], function () {
+ var qrcode = new QRCode("qrcode", {
+ text: Config.url,
+ width: 200,
+ height: 200,
+ colorDark : "#000000",
+ colorLight : "#ffffff",
+ correctLevel : QRCode.CorrectLevel.H
+ });
+ });
+ },
+ api: {
+ bindevent: function () {
+ Form.api.bindevent($("form[role=form]"));
+ }
+ }
+ };
+ return Controller;
+});
\ No newline at end of file
diff --git a/public/assets/js/backend/notice/event.js b/public/assets/js/backend/notice/event.js
new file mode 100644
index 0000000..85f528c
--- /dev/null
+++ b/public/assets/js/backend/notice/event.js
@@ -0,0 +1,139 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+ var Controller = {
+ index: function () {
+ // 初始化表格参数配置
+ Table.api.init({
+ extend: {
+ index_url: 'notice/event/index' + location.search,
+ add_url: 'notice/event/add',
+ edit_url: 'notice/event/edit',
+ del_url: 'notice/event/del',
+ multi_url: 'notice/event/multi',
+ import_url: 'notice/event/import',
+ table: 'notice_event',
+ }
+ });
+
+ var table = $("#table");
+
+ // 初始化表格
+ table.bootstrapTable({
+ url: $.fn.bootstrapTable.defaults.extend.index_url,
+ pk: 'id',
+ sortName: 'id',
+ fixedColumns: true,
+ fixedRightNumber: 1,
+ columns: [
+ [
+ {checkbox: true},
+ {field: 'id', title: __('Id')},
+ {field: 'platform', title: __('Platform'), searchList: {"user":__('Platform user'),"admin":__('Platform admin')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
+ {field: 'type', title: __('Type'), searchList: Config.typeList, operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
+ {field: 'name', title: __('Name'), operate: 'LIKE'},
+ {field: 'event', title: __('Event'), operate: 'LIKE'},
+ {field: 'send_num', title: __('Send_num')},
+ {field: 'send_fail_num', title: __('Send_fail_num')},
+ {field: 'visible_switch', title: __('Visible_switch'), searchList: {"0":__('Visible_switch 0'),"1":__('Visible_switch 1')}, table: table, formatter: Table.api.formatter.toggle},
+ {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+ {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false},
+ {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
+ buttons: [
+ {
+ name: 'test',
+ text: '测试',
+ url: 'notice/event/test',
+ classname: 'btn btn-xs btn-dialog btn-primary',
+ },
+ {
+ name: 'copy',
+ text: '复制',
+ url: 'notice/event/edit?is_copy=1',
+ classname: 'btn btn-xs btn-dialog btn-primary',
+ }
+ ]
+ }
+ ]
+ ]
+ });
+
+ // 为表格绑定事件
+ Table.api.bindevent(table);
+ },
+ recyclebin: function () {
+ // 初始化表格参数配置
+ Table.api.init({
+ extend: {
+ 'dragsort_url': ''
+ }
+ });
+
+ var table = $("#table");
+
+ // 初始化表格
+ table.bootstrapTable({
+ url: 'notice/event/recyclebin' + location.search,
+ pk: 'id',
+ sortName: 'id',
+ columns: [
+ [
+ {checkbox: true},
+ {field: 'id', title: __('Id')},
+ {field: 'name', title: __('Name'), align: 'left'},
+ {
+ field: 'deletetime',
+ title: __('Deletetime'),
+ operate: 'RANGE',
+ addclass: 'datetimerange',
+ formatter: Table.api.formatter.datetime
+ },
+ {
+ field: 'operate',
+ width: '130px',
+ title: __('Operate'),
+ table: table,
+ events: Table.api.events.operate,
+ buttons: [
+ {
+ name: 'Restore',
+ text: __('Restore'),
+ classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
+ icon: 'fa fa-rotate-left',
+ url: 'notice/event/restore',
+ refresh: true
+ },
+ {
+ name: 'Destroy',
+ text: __('Destroy'),
+ classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
+ icon: 'fa fa-times',
+ url: 'notice/event/destroy',
+ refresh: true
+ }
+ ],
+ formatter: Table.api.formatter.operate
+ }
+ ]
+ ]
+ });
+
+ // 为表格绑定事件
+ Table.api.bindevent(table);
+ },
+ add: function () {
+ Controller.api.bindevent();
+ },
+ edit: function () {
+ Controller.api.bindevent();
+ },
+ test: function () {
+ Form.api.bindevent($("form[role=form]"));
+ },
+ api: {
+ bindevent: function () {
+ Form.api.bindevent($("form[role=form]"));
+ }
+ }
+ };
+ return Controller;
+});
\ No newline at end of file
diff --git a/public/assets/js/backend/notice/notice.js b/public/assets/js/backend/notice/notice.js
new file mode 100644
index 0000000..2e049e5
--- /dev/null
+++ b/public/assets/js/backend/notice/notice.js
@@ -0,0 +1,119 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+ var Controller = {
+ index: function () {
+ // 初始化表格参数配置
+ Table.api.init({
+ extend: {
+ index_url: 'notice/notice/index' + location.search,
+ add_url: 'notice/notice/add',
+ edit_url: 'notice/notice/edit',
+ del_url: 'notice/notice/del',
+ multi_url: 'notice/notice/multi',
+ import_url: 'notice/notice/import',
+ table: 'notice',
+ }
+ });
+
+ var table = $("#table");
+
+ // 初始化表格
+ table.bootstrapTable({
+ url: $.fn.bootstrapTable.defaults.extend.index_url,
+ pk: 'id',
+ sortName: 'id',
+ columns: [
+ [
+ {checkbox: true},
+ {field: 'id', title: __('Id')},
+ {field: 'name', title: __('Name'), operate: 'LIKE'},
+ {field: 'event', title: __('Event'), operate: 'LIKE', visible: false},
+ {field: 'platform', title: __('Platform'), searchList: {"user":__('Platform user'),"admin":__('Platform admin')}, formatter: Table.api.formatter.normal},
+ {field: 'type', title: __('Type'), searchList: Config.typeList, formatter: Table.api.formatter.normal},
+ {field: 'to_id', title: __('To_id')},
+ {field: 'notice_template_id', title: __('Notice_template_id')},
+ {field: 'readtime', title: __('Readtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+ {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+ {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false},
+ {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+ ]
+ ]
+ });
+
+ // 为表格绑定事件
+ Table.api.bindevent(table);
+ },
+ recyclebin: function () {
+ // 初始化表格参数配置
+ Table.api.init({
+ extend: {
+ 'dragsort_url': ''
+ }
+ });
+
+ var table = $("#table");
+
+ // 初始化表格
+ table.bootstrapTable({
+ url: 'notice/notice/recyclebin' + location.search,
+ pk: 'id',
+ sortName: 'id',
+ columns: [
+ [
+ {checkbox: true},
+ {field: 'id', title: __('Id')},
+ {field: 'name', title: __('Name'), align: 'left'},
+ {
+ field: 'deletetime',
+ title: __('Deletetime'),
+ operate: 'RANGE',
+ addclass: 'datetimerange',
+ formatter: Table.api.formatter.datetime
+ },
+ {
+ field: 'operate',
+ width: '130px',
+ title: __('Operate'),
+ table: table,
+ events: Table.api.events.operate,
+ buttons: [
+ {
+ name: 'Restore',
+ text: __('Restore'),
+ classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
+ icon: 'fa fa-rotate-left',
+ url: 'notice/notice/restore',
+ refresh: true
+ },
+ {
+ name: 'Destroy',
+ text: __('Destroy'),
+ classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
+ icon: 'fa fa-times',
+ url: 'notice/notice/destroy',
+ refresh: true
+ }
+ ],
+ formatter: Table.api.formatter.operate
+ }
+ ]
+ ]
+ });
+
+ // 为表格绑定事件
+ Table.api.bindevent(table);
+ },
+ add: function () {
+ Controller.api.bindevent();
+ },
+ edit: function () {
+ Controller.api.bindevent();
+ },
+ api: {
+ bindevent: function () {
+ Form.api.bindevent($("form[role=form]"));
+ }
+ }
+ };
+ return Controller;
+});
\ No newline at end of file
diff --git a/public/assets/js/backend/notice/template.js b/public/assets/js/backend/notice/template.js
new file mode 100644
index 0000000..6940ee1
--- /dev/null
+++ b/public/assets/js/backend/notice/template.js
@@ -0,0 +1,45 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+ var Controller = {
+ index: function () {
+ Controller.api.bindevent();
+
+ $(document).on('change', '.switch-input', function () {
+ // ajax请求
+ var params = {
+ 'notice_event_id': $(this).parents('.parent').data('notice_event_id'),
+ 'platform': $(this).parents('.parent').data('platform'),
+ 'type': $(this).parents('.parent').data('type'),
+ 'visible_switch': $(this).val()
+ };
+ Fast.api.ajax({
+ url: 'notice/template/visible',
+ data: params,
+ loading: false
+ });
+ });
+
+ // tab自定义
+ $('.panel-heading [data-field] a[data-toggle="tab"]').unbind('shown.bs.tab');
+ $('.panel-heading [data-field] a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+ var platform = $(this).data('value');
+ var url = 'notice/template?platform='+platform;
+ url = Fast.api.fixurl(url);
+ Layer.load();
+ location.href = url;
+ });
+ },
+ add: function () {
+ Controller.api.bindevent();
+ },
+ edit: function () {
+ Controller.api.bindevent();
+ },
+ api: {
+ bindevent: function () {
+ Form.api.bindevent($("form[role=form]"));
+ }
+ }
+ };
+ return Controller;
+});
\ No newline at end of file
diff --git a/public/assets/js/frontend/notice/index.js b/public/assets/js/frontend/notice/index.js
new file mode 100644
index 0000000..5ff9928
--- /dev/null
+++ b/public/assets/js/frontend/notice/index.js
@@ -0,0 +1,36 @@
+define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) {
+ var Controller = {
+ index: function () {
+ // 标记为已读
+ $(document).on('click', '.mark-event', function () {
+ Fast.api.ajax($(this).data('url'), function () {
+ location.reload();
+ });
+ });
+
+
+ //点击包含.btn-dialog的元素时弹出dialog
+ $(document).on('click', '.btn-dialog,.dialogit', function (e) {
+ if(e.returnValue){
+ e.returnValue = false
+ }else{
+ e.preventDefault()
+ }
+ var that = this;
+ var options = $.extend({}, $(that).data() || {});
+ var url = $(that).data("url") || $(that).attr('href');
+ var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
+ if (typeof options.confirm !== 'undefined') {
+ Layer.confirm(options.confirm, function (index) {
+ Frontend.api.open(url, title, options);
+ Layer.close(index);
+ });
+ } else {
+ window[$(that).data("window") || 'self'].Frontend.api.open(url, title, options);
+ }
+ return false;
+ });
+ }
+ };
+ return Controller;
+});