Message.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\data\controller\user;
  3. use app\data\model\DataUserMessage;
  4. use app\data\service\MessageService;
  5. use think\admin\Controller;
  6. /**
  7. * 短信发送管理
  8. * Class Message
  9. * @package app\data\controller\user
  10. */
  11. class Message extends Controller
  12. {
  13. /**
  14. * 短信发送管理
  15. * @auth true
  16. * @menu true
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public function index()
  22. {
  23. $this->title = '短信发送管理';
  24. $query = $this->_query(DataUserMessage::mk());
  25. $query->equal('status')->like('phone,content');
  26. $query->dateBetween('create_at')->order('id desc')->page();
  27. }
  28. /**
  29. * 短信接口配置
  30. * @auth true
  31. * @menu true
  32. * @throws \think\db\exception\DataNotFoundException
  33. * @throws \think\db\exception\DbException
  34. * @throws \think\db\exception\ModelNotFoundException
  35. */
  36. public function config()
  37. {
  38. if ($this->request->isGet()) {
  39. $this->title = '短信接口配置';
  40. $this->result = MessageService::instance()->balance();
  41. $this->fetch();
  42. } else {
  43. $data = $this->request->post();
  44. foreach ($data as $k => $v) sysconf($k, $v);
  45. $this->success('配置保存成功!');
  46. }
  47. }
  48. /**
  49. * 删除短信记录
  50. * @auth true
  51. * @throws \think\db\exception\DbException
  52. */
  53. public function remove()
  54. {
  55. $this->_delete(DataUserMessage::mk());
  56. }
  57. }