|  |  |  | 
|---|
|  |  |  | package com.doumee.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.SmsEmailMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.SmsEmail; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.doumee.service.business.third.EmayService; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 短信邮件信息表Service实现 | 
|---|
|  |  |  | * @author 江蹄蹄 | 
|---|
|  |  |  | * @date 2024/01/15 15:07 | 
|---|
|  |  |  | * @date 2024/01/16 10:03 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Service | 
|---|
|  |  |  | public class SmsEmailServiceImpl implements SmsEmailService { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SmsEmailMapper smsEmailMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SystemDictDataBiz systemDictDataBiz; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private EmayService emayService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void isCaptcheValide(SmsEmailMapper smsEmailMapper, String phone, String captche) { | 
|---|
|  |  |  | SmsEmail model = smsEmailMapper.selectOne(new QueryWrapper<SmsEmail>().lambda() | 
|---|
|  |  |  | .eq(SmsEmail::getType, Constants.ZERO) | 
|---|
|  |  |  | .eq(SmsEmail::getPhone, phone) | 
|---|
|  |  |  | .eq(SmsEmail::getRemark, captche) | 
|---|
|  |  |  | .eq(SmsEmail::getIsdeleted, Constants.ZERO) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(model == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码不正确,请重新发送再试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(model.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码已失效,请重新发送再试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(model.getCreateDate() !=null && System.currentTimeMillis() - model.getCreateDate().getTime() > 3*60*100){ | 
|---|
|  |  |  | model.setStatus(Constants.ONE); | 
|---|
|  |  |  | model.setEditDate(new Date()); | 
|---|
|  |  |  | smsEmailMapper.updateById(model); | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,验证码已失效,请重新发送再试~"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | model.setStatus(Constants.ONE); | 
|---|
|  |  |  | model.setEditDate(new Date()); | 
|---|
|  |  |  | smsEmailMapper.updateById(model); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(SmsEmail smsEmail) { | 
|---|
|  |  |  | smsEmailMapper.insert(smsEmail); | 
|---|
|  |  |  | return smsEmail.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer sendSms(SmsEmail smsEmail) { | 
|---|
|  |  |  | if(StringUtils.isBlank(smsEmail.getPhone())){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String code = Constants.getRandom6Num(); | 
|---|
|  |  |  | smsEmail.setRemark(code); | 
|---|
|  |  |  | smsEmail.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | smsEmail.setCreateDate(new Date()); | 
|---|
|  |  |  | smsEmail.setStatus(Constants.ZERO); | 
|---|
|  |  |  | smsEmail.setType(Constants.ZERO); | 
|---|
|  |  |  | smsEmail.setTitle("短信验证码"); | 
|---|
|  |  |  | smsEmail.setContent(systemDictDataBiz.queryByCode(Constants.SMS,Constants.SMS_COMNAME).getCode()+"验证码为:"+code+",此验证码有效为3分钟。请勿泄露"); | 
|---|
|  |  |  | smsEmailMapper.insert(smsEmail); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return smsEmail.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id) { | 
|---|