| | |
| | | package com.yeshi.location.app.controller.client.api; |
| | | |
| | | import com.github.qcloudsms.SmsSingleSenderResult; |
| | | import com.yeshi.location.app.entity.config.SystemConfigKey; |
| | | import com.yeshi.location.app.service.inter.config.SystemConfigService; |
| | | import com.yeshi.location.app.service.manager.VerifyCodeManager; |
| | |
| | | @ResponseBody |
| | | @RequestMapping("sendSMS") |
| | | public String sendSMS(AcceptData acceptData, String phone) { |
| | | if (StringUtil.isMobile(phone)) { |
| | | if (!StringUtil.isMobile(phone)) { |
| | | return JsonUtil.loadFalseResult("手机号格式错误"); |
| | | } |
| | | String key = "sendsms-" + phone; |
| | |
| | | String msg = systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.tencentVerifySMSTemplate); |
| | | String appId = systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.tencentSMSAppId); |
| | | String appKey = systemConfigService.getValueCache(acceptData.getSystem(), SystemConfigKey.tencentSMSAppKey); |
| | | // SmsSingleSenderResult result= |
| | | // TencentSMSUtil.sendSingleMsg(Integer.parseInt(appId), appKey, phone, msg.replace("{验证码}", code)); |
| | | verifyCodeManager.sendSMSSuccess(phone, code); |
| | | return JsonUtil.loadTrueResult(""); |
| | | SmsSingleSenderResult result = |
| | | TencentSMSUtil.sendSingleMsg(Integer.parseInt(appId), appKey, phone, msg.replace("{验证码}", code)); |
| | | if (result.result == 0) { |
| | | verifyCodeManager.sendSMSSuccess(phone, code); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } else { |
| | | return JsonUtil.loadFalseResult(result.errMsg); |
| | | } |
| | | } else { |
| | | return JsonUtil.loadFalseResult("服务器繁忙,请稍后再试"); |
| | | } |