| | |
| | | import com.doumee.dao.business.dao.SmsConfigMapper; |
| | | import com.doumee.dao.business.dao.SmsEmailMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.dao.system.model.SystemUser; |
| | | import com.doumee.service.business.SmsEmailService; |
| | | import com.doumee.service.business.third.EmailService; |
| | | import com.doumee.service.business.third.EmayService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private EmayService emayService; |
| | | @Autowired |
| | | private SmsConfigMapper smsConfigMapper; |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | |
| | | @Value("${debug_model}") |
| | | private boolean debugModel; |
| | |
| | | if(StringUtils.isBlank(smsEmail.getPhone())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | //根据手机号查询用户 |
| | | if(systemUserMapper.selectCount(new QueryWrapper<SystemUser>().lambda().eq(SystemUser::getMobile,smsEmail.getPhone()))==Constants.ZERO){ |
| | | throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"对不起,手机号无效请检查后重试!"); |
| | | }; |
| | | String nowDate = DateUtil.getFomartDate(new Date(),"yyyy-MM-dd HH:mm:ss"); |
| | | if(smsEmailMapper.selectCount(new QueryWrapper<SmsEmail>().lambda() |
| | | .eq(SmsEmail::getPhone,smsEmail.getPhone()) |
| | |
| | | String code = Constants.getRandom6Num(); |
| | | SmsConfig smsConfig = smsConfigMapper.selectOne(new QueryWrapper<SmsConfig>().lambda().eq(SmsConfig::getObjType, |
| | | SmsConstants.inventCode).last(" limit 1 ")); |
| | | String comName = systemDictDataBiz.queryByCode(Constants.SMS,Constants.SMS_COMNAME).getCode(); |
| | | //开启短信通知 |
| | | if(Objects.nonNull(smsConfig) || Constants.equalsInteger(smsConfig.getStatus(),Constants.ZERO)){ |
| | | if(StringUtils.isNotBlank(smsConfig.getContent())){ |
| | | String content = smsConfig.getContent().replace("{验证码}",code); |
| | | emayService.sendSmsByHk(smsEmail.getPhone(),content); |
| | | String content = comName + smsConfig.getContent().replace("{验证码}",code); |
| | | emayService.sendSingleSms(smsEmail.getPhone(),content); |
| | | smsEmail.setRemark(code); |
| | | smsEmail.setIsdeleted(Constants.ZERO); |
| | | smsEmail.setCreateDate(new Date()); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Integer sendBillSms(String content,String mobile,Integer billId) { |
| | | boolean result = true; |
| | | if(StringUtils.isBlank(mobile)){ |
| | | result = false; |
| | | } |
| | | if(result){ |
| | | result = emayService.sendSingleSms(mobile,content); |
| | | } |
| | | SmsEmail smsEmail = new SmsEmail(); |
| | | smsEmail.setIsdeleted(Constants.ZERO); |
| | | smsEmail.setCreateDate(new Date()); |
| | | smsEmail.setStatus(result?Constants.ZERO:Constants.ONE); |
| | | smsEmail.setType(Constants.ZERO); |
| | | smsEmail.setRemark(result?"短信发送成功":"短信发送失败"); |
| | | smsEmail.setTitle("账单催费"); |
| | | smsEmail.setObjId(billId); |
| | | smsEmail.setObjType(Constants.ONE+""); |
| | | smsEmail.setContent(content); |
| | | smsEmailMapper.insert(smsEmail); |
| | | return smsEmail.getId(); |
| | | } |
| | | |
| | | @Autowired |
| | | private EmailService emailService; |
| | | |
| | | @Override |
| | | public Integer sendEmail(String email,String content,Integer billId) { |
| | | boolean result = true; |
| | | if(StringUtils.isBlank(email)){ |
| | | result = false; |
| | | } |
| | | if(result){ |
| | | result= emailService.sendEmail(email,"账单催费",content,null); |
| | | } |
| | | content = systemDictDataBiz.queryByCode(Constants.SMS,Constants.SMS_COMNAME).getCode() + content; |
| | | SmsEmail smsEmail = new SmsEmail(); |
| | | smsEmail.setRemark(result?"邮件发送成功":"邮件发送失败"); |
| | | smsEmail.setIsdeleted(Constants.ZERO); |
| | | smsEmail.setCreateDate(new Date()); |
| | | smsEmail.setStatus(result?Constants.ZERO:Constants.ONE); |
| | | smsEmail.setType(Constants.TWO); |
| | | smsEmail.setObjId(billId); |
| | | smsEmail.setObjType(Constants.TWO+""); |
| | | smsEmail.setContent(content); |
| | | smsEmailMapper.insert(smsEmail); |
| | | return smsEmail.getId(); |
| | | } |
| | | } |