Przeglądaj źródła

设备流量卡过期消息

李进 1 rok temu
rodzic
commit
3103d65e94

+ 34 - 20
device-api-service/src/main/java/com/xy/job/DeviceChargingJob.java

@@ -37,14 +37,28 @@ public class DeviceChargingJob {
         String now = DataTime.getSring();
         Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumMercCostMsgConfig.Code.CODE.getCode());
         String tel = stringSysDictRedisMap.get(EnumMercCostMsgConfig.CUSTOM_TEL.getCode()).toString();
+        String mmiTime = DataTime.getStringAround(0, -1, 0, 0, 0, 0, now);
         //即将过期
         FunctionUtils.NoParamsNoResult timeout1 = () -> {
             int day = Integer.valueOf(stringSysDictRedisMap.get(EnumMercCostMsgConfig.DEVICE_COST_DAY.getCode()).toString());
-            String end = DataTime.getStringAround(0, 0, day, 0, 0, 0);
-            deviceChargingTimeout1(now, end, 1, 1000, tel);
+            String end = DataTime.getStringAround(0, 0, day, 0, 0, 0, now);
+            JMap<String, Object> map = new JHashMap<String, Object>()
+                    .set("mmiTime", mmiTime)
+                    .set("workType", 1)
+                    .set("begin", now)
+                    .set("end", end);
+            deviceChargingTimeout1(map, 1, 100, tel);
         };
         //欠费
-        FunctionUtils.NoParamsNoResult timeout2 = () -> deviceChargingTimeout2(now, now, 1, 1000, tel);
+        FunctionUtils.NoParamsNoResult timeout2 = () -> {
+            int day = Integer.valueOf(stringSysDictRedisMap.get(EnumMercCostMsgConfig.ARREARAGE_DAY.getCode()).toString());
+            String time1 = DataTime.getStringAround(0, 0, day, 0, 0, 0, now);
+            JMap<String, Object> map = new JHashMap<String, Object>()
+                    .set("mmiTime", mmiTime)
+                    .set("workType", 2)
+                    .set("end", now);
+            deviceChargingTimeout2(map, now, time1, 1, 100, tel);
+        };
         timeout1.run();
         timeout2.run();
         return ReturnT.SUCCESS;
@@ -53,15 +67,14 @@ public class DeviceChargingJob {
     /**
      * 即将过期
      *
-     * @param begin
-     * @param end
-     * @param current
-     * @param size
-     * @param tel
+     * @param map     sql参数
+     * @param current 当前页码
+     * @param size    显示行数
+     * @param tel     客服手机
      */
-    private void deviceChargingTimeout1(String begin, String end, long current, long size, String tel) {
+    private void deviceChargingTimeout1(JMap<String, Object> map, long current, long size, String tel) {
         //查询数据
-        IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), begin, end);
+        IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), map);
         List<Long> mercIds = longIPage.getRecords();
         if (!Emptys.check(mercIds)) {
             return;
@@ -76,21 +89,22 @@ public class DeviceChargingJob {
                 .builder();
         //下一页
         current++;
-        deviceChargingTimeout1(begin, end, current, size, tel);
+        deviceChargingTimeout1(map, current, size, tel);
     }
 
     /**
      * 已欠费
      *
-     * @param end
-     * @param thisTime
-     * @param current
-     * @param size
-     * @param tel
+     * @param map      sql参数
+     * @param thisTime 当前时间
+     * @param time1    过期后可用时间
+     * @param current  当前页码
+     * @param size     显示行数
+     * @param tel      客服手机
      */
-    private void deviceChargingTimeout2(String end, String thisTime, long current, long size, String tel) {
+    private void deviceChargingTimeout2(JMap<String, Object> map, String thisTime, String time1, long current, long size, String tel) {
         //查询数据
-        IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), null, end);
+        IPage<Long> longIPage = deviceChargingMapper.deviceChargingTimeout(Page.of(current, size), map);
         List<Long> mercIds = longIPage.getRecords();
         if (!Emptys.check(mercIds)) {
             return;
@@ -99,7 +113,7 @@ public class DeviceChargingJob {
         JMap<String, Object> params = new JHashMap<String, Object>()
                 .set("time0", thisTime)
                 .set("type", "设备管理费")
-                .set("time1", "")
+                .set("time1", time1)
                 .set("phone", tel);
         MsgUtils.sendMsg(15L, mercIds)
                 .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), params))
@@ -107,7 +121,7 @@ public class DeviceChargingJob {
                 .builder();
         //下一页
         current++;
-        deviceChargingTimeout2(end, thisTime, current, size, tel);
+        deviceChargingTimeout2(map, thisTime, time1, current, size, tel);
     }
 
 }

+ 25 - 12
device-api-service/src/main/java/com/xy/job/DeviceSimJob.java

@@ -38,14 +38,28 @@ public class DeviceSimJob {
         String now = DataTime.getSring();
         Map<String, SysDictRedis> stringSysDictRedisMap = SysDictUtils.get(EnumMercCostMsgConfig.Code.CODE.getCode());
         String tel = stringSysDictRedisMap.get(EnumMercCostMsgConfig.CUSTOM_TEL.getCode()).toString();
+        String mmiTime = DataTime.getStringAround(0, -1, 0, 0, 0, 0, now);
         //即将过期
         FunctionUtils.NoParamsNoResult timeout1 = () -> {
             int day = SysDictUtils.getValue(EnumDeviceCharging.Code.CODE.getCode(), EnumDeviceCharging.N_200.getCode(), Integer.class);
             String end = DataTime.getStringAround(0, 0, day, 0, 0, 0);
-            deviceSimTimeout1(now, end, 1, 1000, tel);
+            JMap<String, Object> map = new JHashMap<String, Object>()
+                    .set("mmiTime", mmiTime)
+                    .set("workType", 1)
+                    .set("begin", now)
+                    .set("end", end);
+            deviceSimTimeout1(map, 1, 100, tel);
         };
         //欠费
-        FunctionUtils.NoParamsNoResult timeout2 = () -> deviceSimTimeout2(now, now, 1, 1000, tel);
+        FunctionUtils.NoParamsNoResult timeout2 = () -> {
+            int day = Integer.valueOf(stringSysDictRedisMap.get(EnumMercCostMsgConfig.ARREARAGE_DAY.getCode()).toString());
+            String time1 = DataTime.getStringAround(0, 0, day, 0, 0, 0, now);
+            JMap<String, Object> map = new JHashMap<String, Object>()
+                    .set("mmiTime", mmiTime)
+                    .set("workType", 2)
+                    .set("end", now);
+            deviceSimTimeout2(map, now, time1, 1, 100, tel);
+        };
         timeout1.run();
         timeout2.run();
         return ReturnT.SUCCESS;
@@ -54,15 +68,14 @@ public class DeviceSimJob {
     /**
      * 即将过期
      *
-     * @param begin
-     * @param end
+     * @param map
      * @param current
      * @param size
      * @param tel
      */
-    private void deviceSimTimeout1(String begin, String end, long current, long size, String tel) {
+    private void deviceSimTimeout1(JMap<String, Object> map, long current, long size, String tel) {
         //查询数据
-        IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, size), begin, end);
+        IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, size), map);
         List<Long> mercIds = longIPage.getRecords();
         if (!Emptys.check(mercIds)) {
             return;
@@ -77,21 +90,21 @@ public class DeviceSimJob {
                 .builder();
         //下一页
         current++;
-        deviceSimTimeout1(begin, end, current, size, tel);
+        deviceSimTimeout1(map, current, size, tel);
     }
 
     /**
      * 已欠费
      *
-     * @param end
+     * @param map
      * @param thisTime
      * @param current
      * @param size
      * @param tel
      */
-    private void deviceSimTimeout2(String end, String thisTime, long current, long size, String tel) {
+    private void deviceSimTimeout2(JMap<String, Object> map, String thisTime, String time1, long current, long size, String tel) {
         //查询数据
-        IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, size), null, end);
+        IPage<Long> longIPage = deviceSimMapper.deviceSimTimeout(Page.of(current, size), map);
         List<Long> mercIds = longIPage.getRecords();
         if (!Emptys.check(mercIds)) {
             return;
@@ -100,7 +113,7 @@ public class DeviceSimJob {
         JMap<String, Object> params = new JHashMap<String, Object>()
                 .set("time0", thisTime)
                 .set("type", "设备流量卡")
-                .set("time1", "")
+                .set("time1", time1)
                 .set("phone", tel);
         MsgUtils.sendMsg(15L, mercIds)
                 .official(userInfo -> new MsgUtils.MsgInfo(userInfo.getMpOpenid(), params))
@@ -108,6 +121,6 @@ public class DeviceSimJob {
                 .builder();
         //下一页
         current++;
-        deviceSimTimeout2(end, thisTime, current, size, tel);
+        deviceSimTimeout2(map, thisTime, time1, current, size, tel);
     }
 }

+ 3 - 3
device-api-service/src/main/java/com/xy/mapper/DeviceChargingMapper.java

@@ -6,6 +6,8 @@ import com.xy.dto.DeviceChargingDto;
 import com.xy.entity.DeviceCharging;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Map;
+
 /**
  * <p>
  * 设备计费表 Mapper 接口
@@ -29,9 +31,7 @@ public interface DeviceChargingMapper extends BaseMapper<DeviceCharging> {
      * 管理费过期
      *
      * @param page
-     * @param begin
-     * @param end
      * @return
      */
-    IPage<Long> deviceChargingTimeout(IPage page, @Param("begin") String begin, @Param("end") String end);
+    IPage<Long> deviceChargingTimeout(IPage page, @Param("query") Map<String, Object> map);
 }

+ 4 - 3
device-api-service/src/main/java/com/xy/mapper/DeviceSimMapper.java

@@ -6,6 +6,8 @@ import com.xy.dto.DeviceSimDto;
 import com.xy.entity.DeviceSim;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Map;
+
 /**
  * <p>
  * 设备流量卡 Mapper 接口
@@ -29,9 +31,8 @@ public interface DeviceSimMapper extends BaseMapper<DeviceSim> {
      * 管流量卡过期
      *
      * @param page
-     * @param begin
-     * @param end
+     * @param map
      * @return
      */
-    IPage<Long> deviceSimTimeout(IPage page, @Param("begin") String begin, @Param("end") String end);
+    IPage<Long> deviceSimTimeout(IPage page, @Param("query") Map<String, Object> map);
 }

+ 8 - 7
device-api-service/src/main/java/com/xy/mapper/mapper/DeviceChargingMapper.xml

@@ -18,15 +18,16 @@
     <!-- 管理费过期 -->
     <select id="deviceChargingTimeout" resultType="java.lang.Long">
         select di.merc_id
-        from
-        device_charging dc join device_info di on(dc.device_id = di.device_id)
+        from device_charging dc
+        join device_info di on(dc.device_id = di.device_id)
+        left join merc_msg_info mmi on(di.merc_id = mmi.merc_id and mmi.create_time >= #{query.mmiTime})
         where
-        1 = 1
-        <if test="begin != null">
-            and dc.timeout >= #{begin}
+        mmi.id is null and mmi.type = 1 and mmi.work_type = #{query.workType}
+        <if test="query.begin != null">
+            and dc.timeout >= #{query.begin}
         </if>
-        <if test="end != null">
-            and dc.timeout &lt;= #{end}
+        <if test="query.end != null">
+            and dc.timeout &lt;= #{query.end}
         </if>
         GROUP BY di.merc_id
     </select>

+ 6 - 5
device-api-service/src/main/java/com/xy/mapper/mapper/DeviceSimMapper.xml

@@ -74,13 +74,14 @@
         from device_sysinfo dsi
         join device_info di on(dsi.device_id = di.device_id)
         join device_sim dsim on(dsi.sim_iccid = dsim.id)
+        left join merc_msg_info mmi on(di.merc_id = mmi.merc_id and mmi.create_time >= #{query.mmiTime})
         where
-        1 = 1
-        <if test="begin != null">
-            and dsim.timeout >= #{begin}
+        mmi.id is null and mmi.type = 2 and mmi.work_type = #{query.workType}
+        <if test="query.begin != null">
+            and dsim.timeout >= #{query.begin}
         </if>
-        <if test="end != null">
-            and dsim.timeout &lt;= #{end}
+        <if test="query.end != null">
+            and dsim.timeout &lt;= #{query.end}
         </if>
         GROUP BY di.merc_id
     </select>