ZjSMSServerService.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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);
  73. if ($gets) {
  74. return ['status' => 200, 'msg' => '短信发送成功'];
  75. } else {
  76. return ['status' => 400, 'msg' => '发送失败'];
  77. }
  78. }
  79. }