diff --git a/jsowell-pile/src/main/java/com/jsowell/wxpay/service/WxAppletRemoteService.java b/jsowell-pile/src/main/java/com/jsowell/wxpay/service/WxAppletRemoteService.java index 52fe1f4fd..cc7b5632e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/wxpay/service/WxAppletRemoteService.java +++ b/jsowell-pile/src/main/java/com/jsowell/wxpay/service/WxAppletRemoteService.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.redis.RedisCache; @@ -298,39 +299,34 @@ public class WxAppletRemoteService { // 判断是什么场景调用此方法(1-开始充电推送消息;2-充电结束推送消息) String type = dto.getType(); // 根据不同的场景set不同的对象 + Map map = Maps.newHashMap(); + String templateId = null; if (StringUtils.equals("1", type)) { // 开始充电 - String templateId = startChargingTmpId; - dto.setTemplate_id(templateId); - Map map = new HashMap<>(); + templateId = startChargingTmpId; map.put("thing5", ImmutableMap.of("value", dto.getStartChargingMessage().getStationName())); // 充电站名称 map.put("time2", ImmutableMap.of("value", dto.getStartChargingMessage().getStartTime())); // 开始时间 map.put("character_string11", ImmutableMap.of("value", dto.getStartChargingMessage().getOrderCode())); // 订单编号 map.put("thing7", ImmutableMap.of("value", dto.getStartChargingMessage().getPileConnectorCode())); // 充电插座 map.put("thing13", ImmutableMap.of("value", dto.getStartChargingMessage().getTotalPrice())); // 收费标准 - dto.setData(map); } else if (StringUtils.equals("2", type)) { // 结束充电 - String templateId = stopChargingTmpId; - dto.setTemplate_id(templateId); - Map map = new HashMap<>(); + templateId = stopChargingTmpId; map.put("character_string5", ImmutableMap.of("value", dto.getStopChargingMessage().getOrderCode())); // 充电金额 map.put("amount17", ImmutableMap.of("value", dto.getStopChargingMessage().getChargingAmount())); // 充电金额 map.put("thing7", ImmutableMap.of("value", dto.getStopChargingMessage().getEndReason())); // 结束原因 map.put("thing22", ImmutableMap.of("value", dto.getStopChargingMessage().getChargingTime())); // 充电时长 map.put("number13", ImmutableMap.of("value", dto.getStopChargingMessage().getChargingDegree())); // 充电度数 - dto.setData(map); } else if (StringUtils.equals("3", type)) { // 预约充电启动通知 - String templateId = stopChargingTmpId; - dto.setTemplate_id(templateId); - Map map = new HashMap<>(); + templateId = stopChargingTmpId; map.put("time2", ImmutableMap.of("value", dto.getStartUpResultMessage().getStartTime())); // 开始时间 map.put("time3", ImmutableMap.of("value", dto.getStartUpResultMessage().getEndTime())); // 结束时间 map.put("phrase20", ImmutableMap.of("value", dto.getStartUpResultMessage().getStartUpResult())); // 启动结果 map.put("thing21", ImmutableMap.of("value", dto.getStartUpResultMessage().getFailReason())); // 失败原因 - } + dto.setTemplate_id(templateId); + dto.setData(map); // 调用下面的发送消息接口 return uniformMessageSend(dto); }