Pārlūkot izejas kodu

创米公众号消息推送调整

tanbin 7 mēneši atpakaļ
vecāks
revīzija
3412ac3d7f

+ 2 - 8
device-api-service-merc-mini/pom.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <artifactId>xy-device</artifactId>
@@ -29,12 +29,6 @@
             <version>1.0</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.xy</groupId>
-            <artifactId>merc-sdk</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
-        </dependency>
         <dependency>
             <groupId>com.xy</groupId>
             <artifactId>data-api</artifactId>

+ 9 - 2
device-api-service/pom.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
         <artifactId>xy-device</artifactId>
@@ -125,6 +125,13 @@
             <artifactId>msg-sdk</artifactId>
             <version>1.0</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.xy</groupId>
+            <artifactId>merc-sdk</artifactId>
+            <version>1.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 37 - 4
device-api-service/src/main/java/com/xy/job/DeviceChargingJob.java

@@ -1,5 +1,6 @@
 package com.xy.job;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,12 +12,15 @@ import com.xy.collections.map.JMap;
 import com.xy.device.EnumDeviceCharging;
 import com.xy.dto.MercArrearageConfigDto;
 import com.xy.dto.MercMsgInfoDto;
+import com.xy.dto.be.MercDto;
 import com.xy.entity.DeviceCharging;
 import com.xy.entity.DeviceInfo;
+import com.xy.enums.MsgConfigId;
 import com.xy.mapper.DeviceChargingMapper;
 import com.xy.service.DeviceInfoServiceImpl;
 import com.xy.service.MercArrearageConfigService;
 import com.xy.service.MercMsgInfoService;
+import com.xy.service.be.MercFeignService;
 import com.xy.sys.EnumMercCostMsgConfig;
 import com.xy.utils.*;
 import lombok.AllArgsConstructor;
@@ -26,6 +30,8 @@ import org.springframework.stereotype.Component;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 设备管理费job
@@ -43,6 +49,8 @@ public class DeviceChargingJob {
 
     private MercArrearageConfigService mercArrearageConfigService;
 
+    private MercFeignService mercFeignService;
+
     /**
      * 管理费设备停机
      *
@@ -128,11 +136,36 @@ public class DeviceChargingJob {
             if (!Emptys.check(mercIds)) {
                 return false;
             }
+
+            List<MercDto.Vo> mercList = R.feignCheckData(mercFeignService.listMerc(new MercDto.ListDTO().setIds(mercIds)));
+            Map<Long, MercDto.Vo> mercMap = mercList.stream().collect(Collectors.toMap(MercDto.Vo::getId, m -> m));
+            List<Long> cmMercIds = new ArrayList<>();
+            List<Long> mxrMercIds = new ArrayList<>();
+            //遍历mercMap 区分喵星人、创米商户
+            for (Map.Entry<Long, MercDto.Vo> entry : mercMap.entrySet()) {
+                Long mercId = entry.getKey();
+                String mercCode = entry.getValue().getMercCode();
+                if (MercAuthUtils.sendMsgToCM(mercCode)) {
+                    cmMercIds.add(mercId);
+                } else {
+                    mxrMercIds.add(mercId);
+                }
+            }
             //发送消息
-            MsgUtils.sendMsg(17L, mercIds)
-                    .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
-                    .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
-                    .builder();
+            if (CollUtil.isNotEmpty(mxrMercIds)) {
+                MsgUtils.sendMsg(MsgConfigId.FEE_NOTIFY.getId(), mercIds)
+                        .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
+                        .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
+                        .builder();
+            }
+            //创米商户
+            if (CollUtil.isNotEmpty(cmMercIds)) {
+                MsgUtils.sendMsg(MsgConfigId.CM_FEE_NOTIFY.getId(), mercIds)
+                        .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
+                        .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
+                        .builder();
+            }
+
             //写入记录
             mercMsgInfoService.save(new MercMsgInfoDto.Save()
                     .setMercId(mercIds)

+ 39 - 5
device-api-service/src/main/java/com/xy/job/DeviceSimJob.java

@@ -1,5 +1,6 @@
 package com.xy.job;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -10,9 +11,12 @@ import com.xy.collections.map.JHashMap;
 import com.xy.collections.map.JMap;
 import com.xy.device.EnumSimConfig;
 import com.xy.dto.MercMsgInfoDto;
+import com.xy.dto.be.MercDto;
 import com.xy.entity.DeviceSim;
+import com.xy.enums.MsgConfigId;
 import com.xy.mapper.DeviceSimMapper;
 import com.xy.service.MercMsgInfoService;
+import com.xy.service.be.MercFeignService;
 import com.xy.sys.EnumMercCostMsgConfig;
 import com.xy.utils.*;
 import lombok.AllArgsConstructor;
@@ -20,8 +24,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.GetMapping;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 设备流量卡job
@@ -36,6 +43,9 @@ public class DeviceSimJob {
 
     private MercMsgInfoService mercMsgInfoService;
 
+    private MercFeignService mercFeignService;
+
+
     /**
      * 设备流量卡过期消息
      *
@@ -58,11 +68,35 @@ public class DeviceSimJob {
             if (!Emptys.check(mercIds)) {
                 return false;
             }
+            List<MercDto.Vo> mercList = R.feignCheckData(mercFeignService.listMerc(new MercDto.ListDTO().setIds(mercIds)));
+            Map<Long, MercDto.Vo> mercMap = mercList.stream().collect(Collectors.toMap(MercDto.Vo::getId, m -> m));
+            List<Long> cmMercIds = new ArrayList<>();
+            List<Long> mxrMercIds = new ArrayList<>();
+            //遍历mercMap 区分喵星人、创米商户
+            for (Map.Entry<Long, MercDto.Vo> entry : mercMap.entrySet()) {
+                Long mercId = entry.getKey();
+                String mercCode = entry.getValue().getMercCode();
+                if (MercAuthUtils.sendMsgToCM(mercCode)) {
+                    cmMercIds.add(mercId);
+                } else {
+                    mxrMercIds.add(mercId);
+                }
+            }
             //发送消息
-            MsgUtils.sendMsg(17L, mercIds)
-                    .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
-                    .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
-                    .builder();
+            if (CollUtil.isNotEmpty(mxrMercIds)) {
+                MsgUtils.sendMsg(MsgConfigId.FEE_NOTIFY.getId(), mercIds)
+                        .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
+                        .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
+                        .builder();
+            }
+            //创米商户
+            if (CollUtil.isNotEmpty(cmMercIds)) {
+                MsgUtils.sendMsg(MsgConfigId.CM_FEE_NOTIFY.getId(), mercIds)
+                        .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), msg))
+                        .mxr(userInfo -> new MsgUtils.MsgInfo(String.valueOf(userInfo.getAuthorizeUserId()), msg))
+                        .builder();
+            }
+
             //写入记录
             mercMsgInfoService.save(new MercMsgInfoDto.Save()
                     .setMercId(mercIds)
@@ -109,7 +143,7 @@ public class DeviceSimJob {
     public ReturnT<String> deviceSimWaitHandle() {
         Long count = deviceSimMapper.selectCount(new LambdaQueryWrapper<DeviceSim>().eq(DeviceSim::getWaitHandle, true));
         if (count > 0) {
-            MsgUtils.sendMsg(19L)
+            MsgUtils.sendMsg(MsgConfigId.SIM_CARD_TO_PAY_NOTIFY.getId())
                     .official(() -> {
                         JMap<String, Object> map = new JHashMap<String, Object>()
                                 .set("thing1", "有需要缴费的流量卡")

+ 7 - 1
device-api-service/src/main/java/com/xy/service/DeviceMqttConsumerImpl.java

@@ -21,6 +21,7 @@ import com.xy.enums.ChannelType;
 import com.xy.enums.MsgConfigId;
 import com.xy.enums.MsgType;
 import com.xy.service.be.MercFeignService;
+import com.xy.utils.MercAuthUtils;
 import com.xy.utils.R;
 import com.xy.utils.SysCodeConfigureUtils;
 import com.xy.utils.SysDictUtils;
@@ -82,6 +83,9 @@ public class DeviceMqttConsumerImpl implements DeviceMqttConsumer {
         if (deviceEventMsg != null) {
             Long deviceId = deviceEventMsg.getDeviceId();
             Long mercId = deviceEventMsg.getMercId();
+
+            MercDto.Vo merc = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setId(mercId)));
+            String mercCode = merc.getMercCode();
             LocalDateTime createTime = deviceEventMsg.getCreateTime();
             String msg = deviceEventMsg.getMsg();
             String code = deviceEventMsg.getCode();
@@ -101,6 +105,9 @@ public class DeviceMqttConsumerImpl implements DeviceMqttConsumer {
             //是否推送时间段
             boolean expCanPush = SysCodeConfigureUtils.getExpCanPush(expand);
             Long configId = MsgConfigId.DEVICE_EXCEPTION.getId();
+            if (MercAuthUtils.sendMsgToCM(mercCode)) {
+                configId = MsgConfigId.CM_DEVICE_EXCEPTION.getId();
+            }
             MsgConfigDto.Vo msgConfig = R.feignCheckData(msgSendApiService.getMsgConfig(new MsgConfigDto.Vo().setId(configId)));
             List<MsgConfigTestDto.BizParam> bizParams = R.feignCheckData(msgSendApiService.getBizParamByMsgConfig(new MsgConfigTestDto.MsgConfig().setConfigId(configId)));
             if (CollUtil.isNotEmpty(bizParams) && msgConfig != null) {
@@ -121,7 +128,6 @@ public class DeviceMqttConsumerImpl implements DeviceMqttConsumer {
                 } else {
                     deviceName = deviceName + "(" + deviceId + ")";
                 }
-                MercDto.Vo merc = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setId(mercId)));
                 Long userInfoId = merc.getUserInfoId();
                 List<Long> userInfoIdList = new ArrayList<>();
                 userInfoIdList.add(userInfoId);