NoticeController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller\notice;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\notice\NoticeSettingLists;
  17. use app\adminapi\logic\notice\NoticeLogic;
  18. use app\adminapi\validate\notice\NoticeValidate;
  19. use app\common\enum\notice\NoticeEnum;
  20. use app\common\model\notice\NoticeSetting;
  21. use app\common\service\wechat\WeChatOaService;
  22. /**
  23. * 通知控制器
  24. * Class NoticeController
  25. * @package app\adminapi\controller\notice
  26. */
  27. class NoticeController extends BaseAdminController
  28. {
  29. public array $notNeedLogin = ['testNotice'];
  30. /**
  31. * @notes 查看通知设置列表
  32. * @return \think\response\Json
  33. * @author 段誉
  34. * @date 2022/3/29 11:18
  35. */
  36. public function settingLists()
  37. {
  38. return $this->dataLists(new NoticeSettingLists());
  39. }
  40. /**
  41. * @notes 查看通知设置详情
  42. * @return \think\response\Json
  43. * @author 段誉
  44. * @date 2022/3/29 11:18
  45. */
  46. public function detail()
  47. {
  48. $params = (new NoticeValidate())->goCheck('detail');
  49. $result = NoticeLogic::detail($params);
  50. return $this->data($result);
  51. }
  52. /**
  53. * @notes 通知设置
  54. * @return \think\response\Json
  55. * @author 段誉
  56. * @date 2022/3/29 11:18
  57. */
  58. public function set()
  59. {
  60. $params = $this->request->post();
  61. $result = NoticeLogic::set($params);
  62. if ($result) {
  63. return $this->success('设置成功');
  64. }
  65. return $this->fail(NoticeLogic::getError());
  66. }
  67. /**
  68. * @notes 获取通知弹框信息
  69. */
  70. public function getInformation()
  71. {
  72. $params = $this->request->post();
  73. $result = NoticeLogic::getInformation($params);
  74. if ($result) {
  75. return $this->success('获取成功', $result);
  76. }
  77. return $this->fail(NoticeLogic::getError());
  78. }
  79. /**
  80. * @notes 后台测试通知
  81. */
  82. public function testNotice()
  83. {
  84. try {
  85. $params = $this->request->get();
  86. $noticeSetting = NoticeSetting::where('scene_id', $params['scene_id'])->findOrEmpty()->toArray();
  87. if(isset($noticeSetting['sms_notice']['status']) && $noticeSetting['sms_notice']['status'] == 1){
  88. $res = event('Notice', [
  89. 'scene_id' => $params['scene_id'],
  90. 'params' => [
  91. 'user_id' => $params['user_id'],
  92. ]
  93. ]);
  94. }
  95. if(isset($noticeSetting['oa_notice']['status']) && $noticeSetting['oa_notice']['status'] == 1){
  96. $res = event('Notice', [
  97. 'scene_id' => $params['scene_id'],
  98. 'params' => [
  99. 'user_id' => $params['user_id'],
  100. 'thing9' => $params['user_id'],
  101. 'time7' => $params['user_id'],
  102. 'thing8' => $params['user_id'],
  103. 'phone_number6' => $params['user_id'],
  104. ]
  105. ]);
  106. /*(new WeChatOaService())->sendTemplateMessage([
  107. 'scene_id' => NoticeEnum::WORKER_EXAMINE,
  108. 'params' => [
  109. 'user_id' => 0,
  110. 'openid' => $noticeSetting['oa_notice']['designated_user'],
  111. ]
  112. ]);*/
  113. }
  114. dd($res);
  115. } catch (\Exception $e) {
  116. dd($e->getMessage());
  117. }
  118. }
  119. }