@Test public void batchSendTest() { String mobile = "13302926050"; Integer templateId = 7; smsService.batchSend(Lists.newArrayList(mobile), templateId, ImmutableMap.of("code", "8888")); }
@Override public void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params) { SmsTemplateDO smsTemplateDO = smsTemplateMapper.selectOne( new QueryWrapper<SmsTemplateDO>().eq("id", smsTemplateId)); if (smsTemplateDO == null || smsTemplateDO.getDeleted().equals(DeletedStatusEnum.DELETED_YES.getValue())) { throw new ServiceException(AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getMessage()); } SmsSignDO smsSignDO = smsSignMapper.selectOne( new QueryWrapper<SmsSignDO>().eq("id", smsTemplateDO.getSmsSignId())); if (smsSignDO == null) { smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage("发送成功!") .setCreateTime(new Date()) ); throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getMessage()); } SmsClient smsClient = getSmsClient(smsTemplateDO.getPlatform()); SmsClient.SendResult sendResult = smsClient.batchSend(mobileList, smsSignDO.getSign(), smsTemplateDO.getTemplateCode(), smsTemplateDO.getTemplate(), params); smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage(sendResult.getMessage()) .setCreateTime(new Date()) ); }
SmsServiceImpl implements SmsService { @Override public void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params) { SmsTemplateDO smsTemplateDO = smsTemplateMapper.selectOne( new QueryWrapper<SmsTemplateDO>().eq("id", smsTemplateId)); if (smsTemplateDO == null || smsTemplateDO.getDeleted().equals(DeletedStatusEnum.DELETED_YES.getValue())) { throw new ServiceException(AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getMessage()); } SmsSignDO smsSignDO = smsSignMapper.selectOne( new QueryWrapper<SmsSignDO>().eq("id", smsTemplateDO.getSmsSignId())); if (smsSignDO == null) { smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage("发送成功!") .setCreateTime(new Date()) ); throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getMessage()); } SmsClient smsClient = getSmsClient(smsTemplateDO.getPlatform()); SmsClient.SendResult sendResult = smsClient.batchSend(mobileList, smsSignDO.getSign(), smsTemplateDO.getTemplateCode(), smsTemplateDO.getTemplate(), params); smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage(sendResult.getMessage()) .setCreateTime(new Date()) ); } }
SmsServiceImpl implements SmsService { @Override public void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params) { SmsTemplateDO smsTemplateDO = smsTemplateMapper.selectOne( new QueryWrapper<SmsTemplateDO>().eq("id", smsTemplateId)); if (smsTemplateDO == null || smsTemplateDO.getDeleted().equals(DeletedStatusEnum.DELETED_YES.getValue())) { throw new ServiceException(AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getMessage()); } SmsSignDO smsSignDO = smsSignMapper.selectOne( new QueryWrapper<SmsSignDO>().eq("id", smsTemplateDO.getSmsSignId())); if (smsSignDO == null) { smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage("发送成功!") .setCreateTime(new Date()) ); throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getMessage()); } SmsClient smsClient = getSmsClient(smsTemplateDO.getPlatform()); SmsClient.SendResult sendResult = smsClient.batchSend(mobileList, smsSignDO.getSign(), smsTemplateDO.getTemplateCode(), smsTemplateDO.getTemplate(), params); smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage(sendResult.getMessage()) .setCreateTime(new Date()) ); }  }
SmsServiceImpl implements SmsService { @Override public void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params) { SmsTemplateDO smsTemplateDO = smsTemplateMapper.selectOne( new QueryWrapper<SmsTemplateDO>().eq("id", smsTemplateId)); if (smsTemplateDO == null || smsTemplateDO.getDeleted().equals(DeletedStatusEnum.DELETED_YES.getValue())) { throw new ServiceException(AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getMessage()); } SmsSignDO smsSignDO = smsSignMapper.selectOne( new QueryWrapper<SmsSignDO>().eq("id", smsTemplateDO.getSmsSignId())); if (smsSignDO == null) { smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage("发送成功!") .setCreateTime(new Date()) ); throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getMessage()); } SmsClient smsClient = getSmsClient(smsTemplateDO.getPlatform()); SmsClient.SendResult sendResult = smsClient.batchSend(mobileList, smsSignDO.getSign(), smsTemplateDO.getTemplateCode(), smsTemplateDO.getTemplate(), params); smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage(sendResult.getMessage()) .setCreateTime(new Date()) ); }  @Override PageSmsSignBO pageSmsSign(PageQuerySmsSignDTO queryDTO); @Override PageSmsTemplateBO pageSmsTemplate(PageQuerySmsTemplateDTO queryDTO); @Override @Transactional void addSign(String sign, Integer platform); @Override SmsSignBO getSign(Integer signId); @Override @Transactional void updateSign(Integer id, String newSign, Integer platform); @Override void deleteSign(Integer id); @Override @Transactional void addTemplate(Integer smsSignId, String templateCode,
                            String template, Integer platform, Integer smsType); @Override SmsTemplateBO getTemplate(Integer id, Integer platform); @Override @Transactional void updateTemplate(Integer id, Integer smsSignId, String templateCode,
                               String template, Integer platform, Integer smsType); @Override @Transactional void deleteTemplate(Integer id); @Override void singleSend(String mobile, Integer smsTemplateId, Map<String, String> params); @Override void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params); }
SmsServiceImpl implements SmsService { @Override public void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params) { SmsTemplateDO smsTemplateDO = smsTemplateMapper.selectOne( new QueryWrapper<SmsTemplateDO>().eq("id", smsTemplateId)); if (smsTemplateDO == null || smsTemplateDO.getDeleted().equals(DeletedStatusEnum.DELETED_YES.getValue())) { throw new ServiceException(AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_TEMPLATE_NOT_EXISTENT.getMessage()); } SmsSignDO smsSignDO = smsSignMapper.selectOne( new QueryWrapper<SmsSignDO>().eq("id", smsTemplateDO.getSmsSignId())); if (smsSignDO == null) { smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage("发送成功!") .setCreateTime(new Date()) ); throw new ServiceException(AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getCode(), AdminErrorCodeEnum.SMS_SIGN_NOT_EXISTENT.getMessage()); } SmsClient smsClient = getSmsClient(smsTemplateDO.getPlatform()); SmsClient.SendResult sendResult = smsClient.batchSend(mobileList, smsSignDO.getSign(), smsTemplateDO.getTemplateCode(), smsTemplateDO.getTemplate(), params); smsSendMapper.insert( (SmsSendLogDO) new SmsSendLogDO() .setTemplateId(smsTemplateDO.getId()) .setTemplate(smsTemplateDO.getTemplate()) .setMessage(sendResult.getMessage()) .setCreateTime(new Date()) ); }  @Override PageSmsSignBO pageSmsSign(PageQuerySmsSignDTO queryDTO); @Override PageSmsTemplateBO pageSmsTemplate(PageQuerySmsTemplateDTO queryDTO); @Override @Transactional void addSign(String sign, Integer platform); @Override SmsSignBO getSign(Integer signId); @Override @Transactional void updateSign(Integer id, String newSign, Integer platform); @Override void deleteSign(Integer id); @Override @Transactional void addTemplate(Integer smsSignId, String templateCode,
                            String template, Integer platform, Integer smsType); @Override SmsTemplateBO getTemplate(Integer id, Integer platform); @Override @Transactional void updateTemplate(Integer id, Integer smsSignId, String templateCode,
                               String template, Integer platform, Integer smsType); @Override @Transactional void deleteTemplate(Integer id); @Override void singleSend(String mobile, Integer smsTemplateId, Map<String, String> params); @Override void batchSend(List<String> mobileList, Integer smsTemplateId, Map<String, String> params);  }