| @@ -43,7 +43,7 @@ public class MsgSendingSchedule { | |||
| /** | |||
| * 每小时第一分钟执行 | |||
| */ | |||
| @Scheduled(cron = "0 1 * * * ?") | |||
| @Scheduled(cron = "0 1 */1 * * ?") | |||
| public void sendmsgschedule() { | |||
| logger.info("sendmsg定时任务启动"); | |||
| String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:00:00"); | |||
| @@ -55,12 +55,19 @@ public class MsgSendingSchedule { | |||
| for (WxMsg msg : list) { | |||
| //sendmsg(msg); | |||
| msg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||
| if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){ | |||
| msg.setMsgType(EnumMsgRecordType.SMS_CALLBACK.getCode()); | |||
| msg.setReceiver(msg.getPhones()); | |||
| mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(),null); | |||
| }else if(msg.getWay() == EnumSendWay.APPINFOR.getCode()){ | |||
| if(EnumSendWay.TAG.getCode().equals(msg.getWay())){ | |||
| if (msg.getExpectSendNumber().intValue() > 1000) { | |||
| WxMsgService.batchSendMsg(msg, null, null); | |||
| } else { | |||
| msg.setMsgType(EnumMsgRecordType.SMS_CALLBACK.getCode()); | |||
| msg.setReceiver(msg.getPhones()); | |||
| mqBaseProducer.sendMessage(msg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(),null); | |||
| } | |||
| }else if(EnumSendWay.APPINFOR.getCode().equals(msg.getWay())){ | |||
| WxMsgService.batchSendAppinfo(msg); | |||
| }else{ | |||
| break; | |||
| } | |||
| wxMsgMapper.updateById(msg); | |||
| @@ -11,7 +11,7 @@ public interface WxLevelConfigMapper extends CommonMapper<WxLevelConfig, Long> { | |||
| int insertBatch(List<WxLevelConfig> list); | |||
| int batchUpdate(List<WxLevelConfig> list); | |||
| int batchUpdate(WxLevelConfig wxLevelConfig); | |||
| void deleteAll(@Param("tenantId")String tenantId); | |||
| @@ -25,18 +25,19 @@ public interface WxMsgModelService { | |||
| */ | |||
| WxMsgModel getById(Long id); | |||
| /** | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| ResultData saveOrUpdate(WxMsgModel record); | |||
| ResultData saveOrUpdate(WxMsgModel record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| @@ -41,4 +41,6 @@ public interface WxMsgService { | |||
| void addMsgCallback(WxMsg wxmsg, String batchNo); | |||
| void batchSendAppinfo(WxMsg wxMsg); | |||
| void batchSendMsg(WxMsg wxMsg, WxMsgConfig wxMsgConfig, WxCouponInject couponInject); | |||
| } | |||
| @@ -207,7 +207,10 @@ public class WxLevelConfigServiceImpl implements WxLevelConfigService { | |||
| levelConfigs.add(levelConfig); | |||
| } | |||
| } | |||
| wxLevelConfigMapper.batchUpdate(levelConfigs); | |||
| for (WxLevelConfig config:levelConfigs) { | |||
| wxLevelConfigMapper.batchUpdate(config); | |||
| } | |||
| this.deleteRedis(tenantEntity.getFinalTenantId()); | |||
| } | |||
| @@ -143,7 +143,7 @@ public class WxMallApplyServiceImpl implements WxMallApplyService { | |||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||
| wxMsgRecord.setModelType(wxMsgValidationcode.getType()); | |||
| wxMsgRecord.setReceiver(wxMsgValidationcode.getPhone()); | |||
| wxMsgRecord.setTenantId(wxMsgValidationcode.getTenantId()); | |||
| wxMsgRecord.updateTenantInfo(wxMsgValidationcode); | |||
| Map<String,String> map = new HashedMap(); | |||
| map.put("s6",String.valueOf(code)); | |||
| wxMsgRecord.setDynamicContentMap(map); | |||
| @@ -50,7 +50,7 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| //从短信配置中查询密钥 bid 等信息 | |||
| WxMsgConfig wxMsgConfig = new WxMsgConfig(); | |||
| wxMsgConfig.setTenantId(wxMsgModel.getTenantId()); | |||
| wxMsgConfig.updateTenantInfo(wxMsgModel); | |||
| List<WxMsgConfig> wxMsgConfigs = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if (wxMsgConfigs.size() == 0) | |||
| return new ResultData(ErrorCode.MSG_SERVER_NOT_FIND.getCode(), "您还未接入短信运营商,请联系平台管理员"); | |||
| @@ -82,7 +82,6 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| if (wxMsgModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgModel.setId(idWorker.nextId()); | |||
| wxMsgModel.updateTenantInfo(wxMsgModel); | |||
| if(jsonObjectResult.get("data") != null){ | |||
| String data = jsonObjectResult.get("data").toString(); | |||
| wxMsgModel.setModelId(Integer.valueOf(data)); | |||
| @@ -109,7 +108,6 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| if (wxMsgModel.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsgModel.setId(idWorker.nextId()); | |||
| wxMsgModel.updateTenantInfo(wxMsgModel); | |||
| wxMsgModel.setCreatetime(new Date()); | |||
| wxMsgModel.setStatus(1); | |||
| wxMsgModelMapper.insert(wxMsgModel); | |||
| @@ -141,6 +141,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| wxMsg.setSendtime(systemTime); | |||
| if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){ | |||
| if (wxMsg.getExpectSendNumber().intValue() > 1000) { | |||
| wxMsgMapper.insert(wxMsg); | |||
| batchSendMsg(wxMsg, wxMsgConfig, null); | |||
| } else { | |||
| //sendmsg(wxMsg, wxMsgConfig, null); | |||
| @@ -177,6 +178,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| wxMsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||
| if(wxMsg.getWay() == EnumSendWay.TAG.getCode()){ | |||
| if (wxMsg.getExpectSendNumber().intValue() > 1000) { | |||
| wxMsgMapper.updateById(wxMsg); | |||
| batchSendMsg(wxMsg, wxMsgConfig, null); | |||
| } else { | |||
| //sendmsg(wxMsg, wxMsgConfig, null); | |||
| @@ -211,9 +213,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| @Override | |||
| public ResultData add(WxMsg wxMsg){ | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.setTenantId(wxMsg.getTenantId()); | |||
| tenantEntity.setParentTenantId(wxMsg.getParentTenantId()); | |||
| TenantEntity tenantEntity = wxMsg.getTenantInfo(); | |||
| //不是草稿检验疲劳度 | |||
| if (!wxMsg.getStatus().equals(EnumMsgStatus.MSG_STATUS_DRAFT.getCode())) { | |||
| @@ -327,7 +328,7 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| batchSendMsg(wxmsg, wxMsgConfig, couponInject); | |||
| } | |||
| @Override | |||
| public void batchSendMsg(WxMsg wxMsg, WxMsgConfig wxMsgConfig, WxCouponInject couponInject) { | |||
| String[] split = wxMsg.getPhones().split(","); | |||
| @@ -335,27 +336,34 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| int extra = length % 1000; | |||
| int extracount = extra > 0 ? (length / 1000 + 1) : (length / 1000); | |||
| int index = extracount - 1; | |||
| for (int i = 0; i < extracount; i++) { | |||
| WxMsg wxMsg1 = new WxMsg(); | |||
| wxMsg1.setId(wxMsg.getId()); | |||
| wxMsg1.updateTenantInfo(wxMsg.getTenantInfo()); | |||
| wxMsg1.setSignature(wxMsg.getSignature()); | |||
| wxMsg1.setMsg(wxMsg.getMsg()); | |||
| wxMsg1.setModelId(wxMsg.getModelId()); | |||
| if (extra > 0 && i == index) { | |||
| List<String> phoneList = Arrays.asList(split).subList(i * 1000, length); | |||
| String phones = StringUtils.join(phoneList, ","); | |||
| wxMsg.setPhones(phones); | |||
| wxMsg.setExpectSendNumber(extra); | |||
| wxMsg.setWxMsgConfig(wxMsgConfig); | |||
| wxMsg.setCouponInject(couponInject); | |||
| wxMsg.setMsgType(EnumMsgRecordType.SMS_CALLBACK.getCode()); | |||
| wxMsg.setReceiver(wxMsg.getPhones()); | |||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| wxMsg1.setPhones(phones); | |||
| wxMsg1.setExpectSendNumber(extra); | |||
| wxMsg1.setWxMsgConfig(wxMsgConfig); | |||
| wxMsg1.setCouponInject(couponInject); | |||
| wxMsg1.setMsgType(EnumMsgRecordType.SMS_CALLBACK.getCode()); | |||
| wxMsg1.setReceiver(wxMsg1.getPhones()); | |||
| mqBaseProducer.sendMessage(wxMsg1, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| } else { | |||
| List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i + 1) * 1000); | |||
| String phones = StringUtils.join(phoneList, ","); | |||
| wxMsg.setExpectSendNumber(1000); | |||
| wxMsg.setPhones(phones); | |||
| wxMsg.setWxMsgConfig(wxMsgConfig); | |||
| wxMsg.setCouponInject(couponInject); | |||
| wxMsg.setMsgType(EnumMsgRecordType.SMS_CALLBACK.getCode()); | |||
| wxMsg.setReceiver(wxMsg.getPhones()); | |||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| wxMsg1.setExpectSendNumber(1000); | |||
| wxMsg1.setPhones(phones); | |||
| wxMsg1.setWxMsgConfig(wxMsgConfig); | |||
| wxMsg1.setCouponInject(couponInject); | |||
| wxMsg1.setMsgType(EnumMsgRecordType.SMS_CALLBACK.getCode()); | |||
| wxMsg1.setReceiver(wxMsg1.getPhones()); | |||
| mqBaseProducer.sendMessage(wxMsg1, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| } | |||
| } | |||
| } | |||
| @@ -75,16 +75,10 @@ public class SendCallBackSmsServiceImpl implements MsgSendService { | |||
| throw new MallinkException(ErrorCode.MSG_CONFIG_ACCOUNT); | |||
| } | |||
| } | |||
| WxCouponInject couponInject = record.getCouponInject(); | |||
| String secret = wxMsgConfig.getSecret(); | |||
| String bid = wxMsgConfig.getBid(); | |||
| String publickey = wxMsgConfig.getPublickey(); | |||
| String phone = record.getPhones(); | |||
| String signature = record.getSignature(); | |||
| String msg = record.getMsg(); | |||
| String notifyUrl = wxMsgConfig.getNotifyurl(); | |||
| WxMsgModel wxMsgModel = wxMsgModelMapper.selectById(record.getModelId()); | |||
| Integer modelId = null; | |||
| if (wxMsgModel != null) { | |||
| @@ -143,9 +137,11 @@ public class SendCallBackSmsServiceImpl implements MsgSendService { | |||
| wxMsgService.addMsgCallback(record, batchNo); | |||
| //wx_msg改为已发送 | |||
| record.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); | |||
| record.setExpectSendNumber(null); | |||
| wxMsgMapper.updateById(record); | |||
| } else { | |||
| logger.error("发送:{},运营商返回失败:{}",phone,result); | |||
| record.setExpectSendNumber(null); | |||
| wxMsgMapper.updateById(record); | |||
| throw new MallinkException(1001,"运营商返回失败:"+result); | |||
| } | |||
| @@ -87,21 +87,22 @@ | |||
| </foreach> | |||
| </insert> | |||
| <update id="batchUpdate" parameterType="java.util.List"> | |||
| <foreach collection="list" item="item" index="index" open="" close="" separator=";"> | |||
| <!-- <update id="batchUpdate" parameterType="java.util.List">--> | |||
| <update id="batchUpdate" parameterType="com.iformall.domain.po.WxLevelConfig"> | |||
| <!-- <foreach collection="list" item="item" index="index" open="" close="" separator=";">--> | |||
| update wx_level_config | |||
| <set> | |||
| <if test=" null != item.tenantId ">`tenant_id` = #{item.tenantId},</if> | |||
| <if test=" null != item.points ">`points` = #{item.points},</if> | |||
| <if test=" null != item.level ">`level` = #{item.level},</if> | |||
| <if test=" null != item.description ">`description` = #{item.description},</if> | |||
| <if test=" null != item.updateDate ">`update_date` = #{item.updateDate},</if> | |||
| <if test=" null != item.discountEnable ">`discount_enable` = #{item.discountEnable},</if> | |||
| <if test=" null != item.capability ">`capability` = #{item.capability},</if> | |||
| <if test=" null != item.scale ">`scale` = #{item.scale},</if> | |||
| <if test=" null != tenantId ">`tenant_id` = #{tenantId},</if> | |||
| <if test=" null != points ">`points` = #{points},</if> | |||
| <if test=" null != level ">`level` = #{level},</if> | |||
| <if test=" null != description ">`description` = #{description},</if> | |||
| <if test=" null != updateDate ">`update_date` = #{updateDate},</if> | |||
| <if test=" null != discountEnable ">`discount_enable` = #{discountEnable},</if> | |||
| <if test=" null != capability ">`capability` = #{capability},</if> | |||
| <if test=" null != scale ">`scale` = #{scale},</if> | |||
| </set> | |||
| where id = ${item.id}; | |||
| </foreach> | |||
| where id = ${id}; | |||
| <!-- </foreach>--> | |||
| </update> | |||
| <delete id="deleteAll" parameterType="com.iformall.domain.po.WxLevelConfig"> | |||