NoticeController.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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\OnlineCustomerService;
  22. use app\common\service\wechat\WeChatOaService;
  23. /**
  24. * 通知控制器
  25. * Class NoticeController
  26. * @package app\adminapi\controller\notice
  27. */
  28. class NoticeController extends BaseAdminController
  29. {
  30. public array $notNeedLogin = ['testNotice'];
  31. /**
  32. * @notes 查看通知设置列表
  33. * @return \think\response\Json
  34. * @author 段誉
  35. * @date 2022/3/29 11:18
  36. */
  37. public function settingLists()
  38. {
  39. return $this->dataLists(new NoticeSettingLists());
  40. }
  41. /**
  42. * @notes 查看通知设置详情
  43. * @return \think\response\Json
  44. * @author 段誉
  45. * @date 2022/3/29 11:18
  46. */
  47. public function detail()
  48. {
  49. $params = (new NoticeValidate())->goCheck('detail');
  50. $result = NoticeLogic::detail($params);
  51. return $this->data($result);
  52. }
  53. /**
  54. * @notes 通知设置
  55. * @return \think\response\Json
  56. * @author 段誉
  57. * @date 2022/3/29 11:18
  58. */
  59. public function set()
  60. {
  61. $params = $this->request->post();
  62. $result = NoticeLogic::set($params);
  63. if ($result) {
  64. return $this->success('设置成功');
  65. }
  66. return $this->fail(NoticeLogic::getError());
  67. }
  68. /**
  69. * @notes 获取通知弹框信息
  70. */
  71. public function getInformation()
  72. {
  73. $params = $this->request->post();
  74. $params['data_rules'] = $this->adminInfo['data_rules']??[];
  75. if(isset($params['business_codes']) && !empty($params['business_codes'])){
  76. $result = NoticeLogic::getInformationBatch($params);
  77. }else{
  78. $result = NoticeLogic::getInformation($params);
  79. }
  80. if ($result) {
  81. return $this->success('获取成功', $result);
  82. }
  83. return $this->fail(NoticeLogic::getError());
  84. }
  85. public function getUnifiedNotific()
  86. {
  87. $params = $this->request->post();
  88. $params['admin_id'] = $this->adminId??0;
  89. $business_codes = [];
  90. isset($params['business_codes']) && $params['business_codes'] && $business_codes = explode(',',$params['business_codes']);
  91. $result = OnlineCustomerService::getAllNotificList($params['admin_id'],$business_codes,$params['prefix']??'',$params['is_test']??0);
  92. return $this->success('', $result?:[]);
  93. }
  94. /**
  95. * @notes 后台测试通知
  96. * http://api.weixiuloc.com:5175/adminapi/notice.notice/testNotice?scene_id=1&params={}
  97. */
  98. public function testNotice()
  99. {
  100. try {
  101. $params = $this->request->get();
  102. if(!isset($params['scene_id'])){
  103. throw new \Exception('scene_id不存在');
  104. }
  105. $noticeSetting = NoticeSetting::where('scene_id', $params['scene_id'])->findOrEmpty()->toArray();
  106. if(isset($noticeSetting['sms_notice']['status'])){
  107. $res = event('Notice', [
  108. 'scene_id' => $params['scene_id'],
  109. 'params' => json_decode($params['params'],true)
  110. /*[
  111. 'user_id' => $params['user_id'],
  112. ]*/
  113. ]);
  114. }
  115. if(isset($noticeSetting['oa_notice']['status'])){
  116. $res = event('Notice', [
  117. 'scene_id' => $params['scene_id'],
  118. 'params' => json_decode($params['params'],true)
  119. /*[
  120. 'user_id' => $params['user_id'],
  121. 'order_id' => $params['order_id']?:'',
  122. 'thing9' => '测试项目名称'.time(),
  123. 'time7' => date("Y-m-d H:i:s", time()),
  124. 'thing8' => '预约地址'.time(),
  125. 'phone_number6' => 18162757399,
  126. ]*/
  127. ]);
  128. }
  129. dd($params,json_decode($params['params'],true),$noticeSetting,$res??[]);
  130. } catch (\Exception $e) {
  131. dd($e->getMessage());
  132. }
  133. }
  134. }