Message.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * NiuShop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. */
  9. namespace addon\niusms\shop\controller;
  10. use addon\niusms\model\Config as ConfigModel;
  11. use addon\niusms\model\Sms as SmsModel;
  12. use addon\niusms\model\Template;
  13. use app\shop\controller\BaseShop;
  14. /**
  15. * 牛云短信消息管理
  16. */
  17. class Message extends BaseShop
  18. {
  19. /**
  20. * 编辑模板消息
  21. * @return array|mixed|string
  22. */
  23. public function edit()
  24. {
  25. $message_model = new Template();
  26. $sms_model = new SmsModel();
  27. $keywords = input("keywords", "");
  28. $info_result = $message_model->getTemplateInfo($this->site_id, $keywords);
  29. $info = $info_result[ "data" ];
  30. if (request()->isAjax()) {
  31. if (empty($info))
  32. return error("", "不存在的模板信息!");
  33. } else {
  34. if (empty($info))
  35. $this->error("不存在的模板信息!");
  36. $audit_status = $sms_model->getAuditStatus();
  37. $info[ 'audit_status_name' ] = $audit_status[ $info[ 'audit_status' ] ];
  38. $this->assign("info", $info);
  39. $this->assign("keywords", $keywords);
  40. $this->assign('sms_is_open', $info[ 'sms_is_open' ]);
  41. $template_info = $this->queryTemplate($info[ 'tem_id' ]);
  42. $this->assign('template_info', $template_info);
  43. return $this->fetch('message/edit');
  44. }
  45. }
  46. /**
  47. * 查询短信模板审核状态
  48. * @param string $tem_id
  49. * @return array|mixed
  50. */
  51. public function queryTemplate($tem_id = '')
  52. {
  53. $sms_model = new SmsModel();
  54. $config_model = new ConfigModel();
  55. $sms_config = $config_model->getSmsConfig($this->site_id, $this->app_module);
  56. $sms_config = $sms_config[ 'data' ][ 'value' ];
  57. $tKey = time();
  58. $data = [
  59. 'username' => $sms_config[ 'username' ],
  60. 'password' => md5(md5($sms_config[ 'password' ]) . $tKey),
  61. 'tKey' => $tKey,
  62. 'sign' => input('signature', $sms_config[ 'signature' ]),//短信签名
  63. 'temId' => input('tem_id', $tem_id)//模板id
  64. ];
  65. $res = $sms_model->queryTemplate($data);
  66. return $res;
  67. }
  68. }