1
0

NoticeController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. $params['data_rules'] = $this->adminInfo['data_rules']??[];
  74. if(isset($params['business_codes']) && !empty($params['business_codes'])){
  75. $result = NoticeLogic::getInformationBatch($params);
  76. }else{
  77. $result = NoticeLogic::getInformation($params);
  78. }
  79. if ($result) {
  80. return $this->success('获取成功', $result);
  81. }
  82. return $this->fail(NoticeLogic::getError());
  83. }
  84. /**
  85. * @notes 后台测试通知
  86. * http://api.weixiuloc.com:5175/adminapi/notice.notice/testNotice?scene_id=1&params={}
  87. */
  88. public function testNotice()
  89. {
  90. try {
  91. $params = $this->request->get();
  92. if(!isset($params['scene_id'])){
  93. throw new \Exception('scene_id不存在');
  94. }
  95. $noticeSetting = NoticeSetting::where('scene_id', $params['scene_id'])->findOrEmpty()->toArray();
  96. if(isset($noticeSetting['sms_notice']['status'])){
  97. $res = event('Notice', [
  98. 'scene_id' => $params['scene_id'],
  99. 'params' => json_decode($params['params'],true)
  100. /*[
  101. 'user_id' => $params['user_id'],
  102. ]*/
  103. ]);
  104. }
  105. if(isset($noticeSetting['oa_notice']['status'])){
  106. $res = event('Notice', [
  107. 'scene_id' => $params['scene_id'],
  108. 'params' => json_decode($params['params'],true)
  109. /*[
  110. 'user_id' => $params['user_id'],
  111. 'order_id' => $params['order_id']?:'',
  112. 'thing9' => '测试项目名称'.time(),
  113. 'time7' => date("Y-m-d H:i:s", time()),
  114. 'thing8' => '预约地址'.time(),
  115. 'phone_number6' => 18162757399,
  116. ]*/
  117. ]);
  118. }
  119. dd($params,json_decode($params['params'],true),$noticeSetting,$res??[]);
  120. } catch (\Exception $e) {
  121. dd($e->getMessage());
  122. }
  123. }
  124. }