Sms.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace app\controller\admin\system\serve;
  3. use app\validate\admin\CrmebServeValidata;
  4. use ln\basic\BaseController;
  5. use ln\services\CrmebServeServices;
  6. use think\App;
  7. /**
  8. * Class Sms
  9. * @package app\controller\admin\v1\serve
  10. */
  11. class Sms extends BaseController
  12. {
  13. protected $services;
  14. /**
  15. * Sms constructor.
  16. * @param App $app
  17. * @param ServeServices $services
  18. */
  19. public function __construct(App $app, CrmebServeServices $services)
  20. {
  21. parent::__construct($app);
  22. $this->services = $services;
  23. }
  24. /**
  25. * 修改短信签名
  26. * @param string $sign
  27. * @return mixed
  28. */
  29. public function changeSign(CrmebServeValidata $validata)
  30. {
  31. $data = $this->request->params(['phone','sign','verify_code']);
  32. $validata->scene('phone')->check(['phone' => $data['phone']]);
  33. if (!$data['sign']) {
  34. return app('json')->fail('请设置短信签名');
  35. }
  36. $this->services->sms()->modify($data['sign'], $data['phone'], $data['verify_code']);
  37. return app('json')->success('修改短信签名成功');
  38. }
  39. /**
  40. * 获取短信模板
  41. * @return mixed
  42. */
  43. public function temps()
  44. {
  45. [$page, $limit] = $this->getPage();
  46. $type = $this->request->param('type');
  47. return app('json')->success($this->services->getSmsTempsList((int)$page, (int)$limit, (int)$type));
  48. }
  49. /**
  50. * 申请模板
  51. * @return mixed
  52. */
  53. public function apply()
  54. {
  55. $data = $this->request->params(['title','type','content']);
  56. if (!$data['title'] || !$data['content'] || !$data['type']) {
  57. return app('json')->success('请填写申请模板内容');
  58. }
  59. $ret = $this->services->sms()->apply($data['title'], $data['content'], (int)$data['type']);
  60. return app('json')->success($ret);
  61. }
  62. /**
  63. * 获取申请记录
  64. * @return mixed
  65. */
  66. public function applyRecord()
  67. {
  68. [$page, $limit] = $this->getPage();
  69. $tempType = $this->request->param('temp_type');
  70. if (!$tempType) return app('json')->fail('缺少类型');
  71. $ret = $this->services->sms()->applys($tempType, $page, $limit);
  72. return app('json')->success($ret);
  73. }
  74. }