12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\api\controller;
- use crmeb\services\HttpService;
- use think\facade\Db;
- /**
- * 短信服务
- * Class SMSService
- * @package crmeb\services
- */
- class ZjSMSServerService
- {
- private static $userid = '15889';
- private static $username = "yflkj";
- private static $passwd = 'yfl831**';
- //验证码
- const VERIFICATION_CODE = 518076;
- //支付成功
- const PAY_SUCCESS_CODE = 520268;
- //发货提醒
- const DELIVER_GOODS_CODE = 520269;
- //确认收货提醒
- const TAKE_DELIVERY_CODE = 520271;
- //管理员下单提醒
- const ADMIN_PLACE_ORDER_CODE = 520272;
- //管理员退货提醒
- const ADMIN_RETURN_GOODS_CODE = 520274;
- //管理员支付成功提醒
- const ADMIN_PAY_SUCCESS_CODE = 520273;
- //管理员确认收货
- const ADMIN_TAKE_DELIVERY_CODE = 520422;
- /**
- * get: 发送短信验证码
- * path: sendSmsCode
- * method: sendSmsCode
- * param: phone - {string} 手机号
- */
- public static function send($phone, array $param, $template = "VERIFICATION_CODE")
- {
- $code = $param['code'];
- $target = "http://sms.izjun.cn/v2sms.aspx";
- $company = sys_config('site_name', '', true);
- // $company = "星拼乐";
- switch ($template) {
- case 'PAY_SUCCESS_CODE':
- break;
- case 'DELIVER_GOODS_CODE':
- break;
- case 'TAKE_DELIVERY_CODE':
- break;
- case 'ADMIN_PLACE_ORDER_CODE':
- break;
- case 'ADMIN_RETURN_GOODS_CODE':
- break;
- case 'ADMIN_PAY_SUCCESS_CODE':
- break;
- case 'ADMIN_TAKE_DELIVERY_CODE':
- break;
- default:
- $content = sprintf('【%s】您的验证码为:%d 。验证码有效期为%d分钟,请尽快填写!', $company, $code, 5);
- }
- $time = date("YmdHis", time());
- $data = [
- 'action' => 'send',
- 'userid' => self::$userid,
- 'timestamp' => $time,
- 'sign' => md5(self::$username . self::$passwd . $time),
- 'mobile' => $phone,
- 'content' => $content,
- 'sendTime' => '',
- 'extno' => '',
- 'rt' => 'json',
- ];
- $gets = json_decode(HttpService::postRequest($target, $data), true);
- if ($gets) {
- return ['status' => 200, 'msg' => '短信发送成功'];
- } else {
- return ['status' => 400, 'msg' => '发送失败'];
- }
- }
- }
|