Sms.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\system\serve;
  12. use app\validate\admin\CrmebServeValidata;
  13. use crmeb\basic\BaseController;
  14. use crmeb\services\CrmebServeServices;
  15. use think\App;
  16. /**
  17. * Class Sms
  18. * @package app\controller\admin\v1\serve
  19. */
  20. class Sms extends BaseController
  21. {
  22. protected $services;
  23. /**
  24. * Sms constructor.
  25. * @param App $app
  26. * @param ServeServices $services
  27. */
  28. public function __construct(App $app, CrmebServeServices $services)
  29. {
  30. parent::__construct($app);
  31. $this->services = $services;
  32. }
  33. /**
  34. * 修改短信签名
  35. * @param string $sign
  36. * @return mixed
  37. */
  38. public function changeSign(CrmebServeValidata $validata)
  39. {
  40. $data = $this->request->params(['phone', 'sign', 'verify_code']);
  41. $validata->scene('phone')->check(['phone' => $data['phone']]);
  42. if (!$data['sign']) {
  43. return app('json')->fail('请设置短信签名');
  44. }
  45. $this->services->sms()->modify($data['sign'], $data['phone'], $data['verify_code']);
  46. return app('json')->success('修改短信签名成功');
  47. }
  48. /**
  49. * 获取短信模板
  50. * @return mixed
  51. */
  52. public function temps()
  53. {
  54. [$page, $limit] = $this->getPage();
  55. $type = $this->request->param('type');
  56. return app('json')->success($this->services->getSmsTempsList((int)$page, (int)$limit, (int)$type));
  57. }
  58. /**
  59. * 申请模板
  60. * @return mixed
  61. */
  62. public function apply()
  63. {
  64. $data = $this->request->params(['title', 'type', 'content']);
  65. if (!$data['title'] || !$data['content'] || !$data['type']) {
  66. return app('json')->success('请填写申请模板内容');
  67. }
  68. $ret = $this->services->sms()->apply($data['title'], $data['content'], (int)$data['type']);
  69. return app('json')->success($ret);
  70. }
  71. /**
  72. * 获取申请记录
  73. * @return mixed
  74. */
  75. public function applyRecord()
  76. {
  77. [$page, $limit] = $this->getPage();
  78. $tempType = $this->request->param('temp_type', 0);
  79. if (is_null($tempType)) $tempType = 0;
  80. $ret = $this->services->sms()->applys((int)$tempType, $page, $limit);
  81. return app('json')->success($ret);
  82. }
  83. }