| | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.SmsEmailMapper; |
| | | import com.doumee.dao.business.model.SmsEmail; |
| | |
| | | if(StringUtils.isBlank(smsEmail.getPhone())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | String nowDate = DateUtil.getFomartDate(new Date(),"yyyy-MM-dd HH:mm:ss"); |
| | | if(smsEmailMapper.selectCount(new QueryWrapper<SmsEmail>().lambda() |
| | | .eq(SmsEmail::getPhone,smsEmail.getPhone()) |
| | | .eq(SmsEmail::getType,Constants.ZERO) |
| | | .between(SmsEmail::getCreateDate, DateUtil.getFomartDate(DateUtil.afterMinutesDate(-5),"yyyy-MM-dd HH:mm:ss"),nowDate) |
| | | )>=3){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,超出发送次数,请稍后重试!"); |
| | | } |
| | | String code = Constants.getRandom6Num(); |
| | | boolean result= emayService.sendSingleSms(smsEmail.getPhone(),code); |
| | | if(!result){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,短信验证码发送失败,请稍后重试!"); |
| | | } |
| | | |
| | | smsEmail.setRemark(code); |
| | | smsEmail.setIsdeleted(Constants.ZERO); |
| | | smsEmail.setCreateDate(new Date()); |