ZjSMSServerService.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. namespace crmeb\services;
  3. use think\facade\Db;
  4. /**
  5. * 短信服务
  6. * Class SMSService
  7. * @package crmeb\services
  8. */
  9. class ZjSMSServerService
  10. {
  11. private static $userid = '15889';
  12. private static $username = "yflkj";
  13. private static $passwd = 'yfl831**';
  14. //验证码
  15. const VERIFICATION_CODE = 518076;
  16. //支付成功
  17. const PAY_SUCCESS_CODE = 520268;
  18. //发货提醒
  19. const DELIVER_GOODS_CODE = 520269;
  20. //确认收货提醒
  21. const TAKE_DELIVERY_CODE = 520271;
  22. //管理员下单提醒
  23. const ADMIN_PLACE_ORDER_CODE = 520272;
  24. //管理员退货提醒
  25. const ADMIN_RETURN_GOODS_CODE = 520274;
  26. //管理员支付成功提醒
  27. const ADMIN_PAY_SUCCESS_CODE = 520273;
  28. //管理员确认收货
  29. const ADMIN_TAKE_DELIVERY_CODE = 520422;
  30. /**
  31. * get: 发送短信验证码
  32. * path: sendSmsCode
  33. * method: sendSmsCode
  34. * param: phone - {string} 手机号
  35. */
  36. public static function send($phone, array $param, $template = "VERIFICATION_CODE")
  37. {
  38. $code = $param['code'];
  39. $target = "http://sms.izjun.cn/v2sms.aspx";
  40. // $company = Sys_config('site_name');
  41. $company = "星拼乐";
  42. switch ($template) {
  43. case 'PAY_SUCCESS_CODE':
  44. break;
  45. case 'DELIVER_GOODS_CODE':
  46. break;
  47. case 'TAKE_DELIVERY_CODE':
  48. break;
  49. case 'ADMIN_PLACE_ORDER_CODE':
  50. break;
  51. case 'ADMIN_RETURN_GOODS_CODE':
  52. break;
  53. case 'ADMIN_PAY_SUCCESS_CODE':
  54. break;
  55. case 'ADMIN_TAKE_DELIVERY_CODE':
  56. break;
  57. default:
  58. $content = sprintf('【%s】您的验证码为:%d 。验证码有效期为%d分钟,请尽快填写!', $company, $code, 5);
  59. }
  60. $time = date("YmdHis", time());
  61. $data = [
  62. 'action' => 'send',
  63. 'userid' => self::$userid,
  64. 'timestamp' => $time,
  65. 'sign' => md5(self::$username . self::$passwd . $time),
  66. 'mobile' => $phone,
  67. 'content' => $content,
  68. 'sendTime' => '',
  69. 'extno' => '',
  70. 'rt' => 'json',
  71. ];
  72. $gets = json_decode(HttpService::postRequest($target, $data), true);$target = "http://sms.izjun.cn/v2sms.aspx";
  73. // $company = Sys_config('site_name');
  74. $company = "星拼乐";
  75. switch ($template) {
  76. case 'PAY_SUCCESS_CODE':
  77. break;
  78. case 'DELIVER_GOODS_CODE':
  79. break;
  80. case 'TAKE_DELIVERY_CODE':
  81. break;
  82. case 'ADMIN_PLACE_ORDER_CODE':
  83. break;
  84. case 'ADMIN_RETURN_GOODS_CODE':
  85. break;
  86. case 'ADMIN_PAY_SUCCESS_CODE':
  87. break;
  88. case 'ADMIN_TAKE_DELIVERY_CODE':
  89. break;
  90. default:
  91. $content = sprintf('【%s】您的验证码为:%d 。验证码有效期为%d分钟,请尽快填写!', $company, $code, 5);
  92. }
  93. $time = date("YmdHis", time());
  94. $data = [
  95. 'action' => 'send',
  96. 'userid' => self::$userid,
  97. 'timestamp' => $time,
  98. 'sign' => md5(self::$username . self::$passwd . $time),
  99. 'mobile' => $phone,
  100. 'content' => $content,
  101. 'sendTime' => '',
  102. 'extno' => '',
  103. 'rt' => 'json',
  104. ];
  105. $gets = json_decode(HttpService::postRequest($target, $data), true);
  106. if ($gets) {
  107. return ['status' => 200, 'msg' => '短信发送成功'];
  108. } else {
  109. return ['status' => 400, 'msg' => '发送失败'];
  110. }
  111. }
  112. }