| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aliyuncs.CommonResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Strings; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.utils.aliyun.ALiYunSmSUtil; |
| | | import com.doumee.core.utils.aliyun.AliSmsService; |
| | | import com.doumee.dao.business.SmsrecordMapper; |
| | | import com.doumee.dao.business.model.Smsrecord; |
| | | import com.doumee.service.business.SmsrecordService; |
| | |
| | | ); |
| | | String digits = Strings.randomNumeric(4); |
| | | //发送验证码 |
| | | Map<String,Object> map = new HashMap<String,Object>(); |
| | | map.put("code",digits); |
| | | CommonResponse response = ALiYunSmSUtil.sendMessage(phone,map); |
| | | if(response.getHttpResponse().isSuccess()){ |
| | | JSONObject data = JSONObject.parseObject(response.getData()); |
| | | String returnCode = data.getString("Code"); |
| | | if(!returnCode.equals("OK")){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"短信发送失败:" + data.getString("Message")); |
| | | } |
| | | String templateParam = "{\"code\":\"" + digits + "\"}"; |
| | | Boolean result = AliSmsService.sendSms(phone, "SMS_491325122", templateParam); |
| | | if (!result) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "短信发送失败,请稍后重试"); |
| | | } |
| | | //存储短信验证码 |
| | | Smsrecord smsrecord = new Smsrecord(); |