Browse Source

推送时间修改

zhijiezhao 2 years ago
parent
commit
52d55ce3d1

+ 2 - 0
src/main/java/com/caimei365/tools/model/po/CmCouponPo.java

@@ -1,5 +1,6 @@
 package com.caimei365.tools.model.po;
 import lombok.Data;
+import lombok.ToString;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -13,6 +14,7 @@ import java.util.List;
  * @version 2021-08-02
  */
 @Data
+@ToString
 public class CmCouponPo implements Serializable {
 
     private static final long serialVersionUID = 1L;

+ 2 - 0
src/main/java/com/caimei365/tools/model/po/QualificationPo.java

@@ -1,6 +1,7 @@
 package com.caimei365.tools.model.po;
 
 import lombok.Data;
+import lombok.ToString;
 import lombok.experimental.Accessors;
 
 import java.io.Serializable;
@@ -10,6 +11,7 @@ import java.io.Serializable;
  */
 @Data
 @Accessors(fluent = true)
+@ToString
 public class QualificationPo implements Serializable {
     private Integer shopId;
     private Integer productId;

+ 44 - 32
src/main/java/com/caimei365/tools/task/ShopMessTask.java

@@ -48,7 +48,7 @@ public class ShopMessTask {
     @Resource
     private MessageSender messageSender;
 
-    @Scheduled(cron = "0 0 15 * * ?")
+        @Scheduled(cron = "0 0 15 * * ?")
     public void outTimePutAwayFee() {
         log.info("-------------------------------上架费过期推送开始-------------------------------");
         putAwayFee(0);
@@ -57,8 +57,8 @@ public class ShopMessTask {
         log.info("-------------------------------上架费过期推送结束-------------------------------");
     }
 
+//        @Scheduled(cron = "0 0/2 * * * ?")
     @Scheduled(cron = "0 0 11 * * ?")
-//@Scheduled(cron = "0 0/1 * * * ?")
     public void outTimeQualification() {
         log.info("---------------------------开始检测商品资质证书是否过期-------------------------------");
         //1,7,30,90
@@ -73,6 +73,7 @@ public class ShopMessTask {
         StringBuilder productNames = new StringBuilder();
         StringBuilder productIds = new StringBuilder();
         List<QualificationPo> pro = messageCenterMapper.findOutTimeQualification(day);
+        log.info(day+"天证书过期的有-------------------》"+pro.toString());
         String contentDay = 0 == day ? "今天" : 7 == day ? "7天" : 30 == day ? "一个月" : "三个月";
         String content = "该商品的资质证书将于" + contentDay + "后失效,请及时登录采美网站上传新证书。";
         String theme = "以下械字号商品的资质证书将于" + contentDay + "后失效,请及时提醒供应商更换证书。";
@@ -96,18 +97,21 @@ public class ShopMessTask {
             wechat.remark(p.productName()).openId(openid).keyWords(strings);
             MessageModel<WechatTemplateMessage> we = new MessageModel<>();
             messageSender.messageSend(we.code(MessageType.WECHAT_TEMPLATE_MESSAGE).info(wechat));
+            log.info("资质证书" + day + "天-----productNames------------>" + productNames + "productIds----------->" + productIds);
         });
-        String names = productNames.toString();
-        String ids = productIds.toString();
-        names = names.endsWith(",") ? names.substring(0, names.lastIndexOf(",") - 1) : names;
-        ids = ids.endsWith(",") ? ids.substring(0, ids.lastIndexOf(",") - 1) : ids;
-        if (names.length() > 10) {
-            names = StringUtils.strip(names.substring(0, 11));
-            names += "...";
+        if (null != pro && pro.size() > 0) {
+            String names = productNames.toString();
+            String ids = productIds.toString();
+            names = names.endsWith(",") ? names.substring(0, names.lastIndexOf(",")) : names;
+            ids = ids.endsWith(",") ? ids.substring(0, ids.lastIndexOf(",")) : ids;
+            if (names.length() > 10) {
+                names = StringUtils.strip(names.substring(0, 11));
+                names += "...";
+            }
+            Notification notification = new Notification();
+            notification.theme(theme).shopContent(names).productId(ids);
+            messageCenterMapper.addNotification(notification);
         }
-        Notification notification = new Notification();
-        notification.theme(theme).shopContent(names).productId(ids);
-        messageCenterMapper.addNotification(notification);
     }
 
     public void putAwayFee(Integer day) {
@@ -144,16 +148,19 @@ public class ShopMessTask {
             messageSender.messageSend(weChatMessage);
             shopNames.append(s.getShopName()).append(",");
             shopsId.append(s.getShopId()).append(",");
+            log.info("上架费" + day + "天--shopName---------------->" + shopNames + "shopIds---------------->" + shopIds);
         });
-        String s = shopNames.toString();
-        String sn = shopsId.toString();
-        String shopDay = 0 == day ? "今天" : 7 == day ? "7天" : "一个月";
-        String theme = "以下供应商的上架费将于" + shopDay + "后到期,请及时提醒供应商续费。";
-        s = s.endsWith(",") ? s.substring(0, s.lastIndexOf(",") - 1) : s;
-        sn = sn.endsWith(",") ? sn.substring(0, sn.lastIndexOf(",") - 1) : sn;
-        Notification notification = new Notification();
-        notification.theme(theme).shopContent(s).shopId(sn);
-        messageCenterMapper.addNotification(notification);
+        if (null != shopIds && shopIds.size() > 0) {
+            String s = shopNames.toString();
+            String sn = shopsId.toString();
+            String shopDay = 0 == day ? "今天" : 7 == day ? "7天" : "一个月";
+            String theme = "以下供应商的上架费将于" + shopDay + "后到期,请及时提醒供应商续费。";
+            s = s.endsWith(",") ? s.substring(0, s.lastIndexOf(",")) : s;
+            sn = sn.endsWith(",") ? sn.substring(0, sn.lastIndexOf(",")) : sn;
+            Notification notification = new Notification();
+            notification.theme(theme).shopContent(s).shopId(sn);
+            messageCenterMapper.addNotification(notification);
+        }
     }
 
     @Scheduled(cron = "0 0 15 * * ?")
@@ -161,19 +168,23 @@ public class ShopMessTask {
         log.info("---------------------------上架费三个月过期推送开始-------------------------------");
         //后台上架费三个月过期推送
         List<ShopReceiptVo> shopIds = messageCenterMapper.findExpireShopId(90);
+        log.info("上架费三个月过期的有----------------》" + shopIds.toString());
         StringBuilder shopNames = new StringBuilder();
         StringBuilder shopsId = new StringBuilder();
         shopIds.forEach(s -> {
             shopNames.append(s.getShopName()).append(",");
             shopsId.append(s.getShopId()).append(",");
+            log.info("上架费三个月----------------->shopName---------------->" + shopNames + "shopIds---------------->" + shopIds);
         });
-        String s = shopNames.toString();
-        String sn = shopsId.toString();
-        s = s.endsWith(",") ? s.substring(0, s.lastIndexOf(",") - 1) : s;
-        sn = sn.endsWith(",") ? sn.substring(0, sn.lastIndexOf(",") - 1) : sn;
-        Notification notification = new Notification();
-        notification.theme("以下供应商的上架费将于3个月后到期,请及时提醒供应商续费。").shopContent(s).shopId(sn);
-        messageCenterMapper.addNotification(notification);
+        if (null != shopIds && shopIds.size() > 0) {
+            String s = shopNames.toString();
+            String sn = shopsId.toString();
+            s = s.endsWith(",") ? s.substring(0, s.lastIndexOf(",")) : s;
+            sn = sn.endsWith(",") ? sn.substring(0, sn.lastIndexOf(",")) : sn;
+            Notification notification = new Notification();
+            notification.theme("以下供应商的上架费将于3个月后到期,请及时提醒供应商续费。").shopContent(s).shopId(sn);
+            messageCenterMapper.addNotification(notification);
+        }
         log.info("---------------------------上架费三个月过期推送结束-------------------------------");
     }
 
@@ -219,10 +230,10 @@ public class ShopMessTask {
      * 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。
      */
     @Scheduled(cron = "0 0 12 * * ?")
-//    @Scheduled(cron = "0 0/10 * * * ?")
     private void Timerw() {
         log.info("----------------------------优惠券七天后过期---------------------------------");
         List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(7);
+        log.info("优惠券七天过期的有----------------》" + coupons.toString());
         MessageCenterPo messageCenter = new MessageCenterPo();
         messageCenter.userType(1).messageType(4).couponMessageType(3).content("7天");
         coupons.forEach(c -> {
@@ -242,10 +253,10 @@ public class ShopMessTask {
      * 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。
      */
     @Scheduled(cron = "0 0 10 * * ?")
-//    @Scheduled(cron = "0 0/2 * * * ?")
     private void Timeto() {
         log.info("----------------------------优惠券一天后过期---------------------------------");
         List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(1);
+        log.info("优惠券一天过期的有-----------------》" + coupons.toString());
         MessageCenterPo messageCenter = new MessageCenterPo();
         messageCenter.userType(1).messageType(4).couponMessageType(3).content("7天");
         coupons.forEach(c -> {
@@ -257,11 +268,12 @@ public class ShopMessTask {
         });
     }
 
-    //    @Scheduled(cron = "0 0/2 * * * ?")
-    @Scheduled(cron = "0 0 15 * * ?")
+
+//    @Scheduled(cron = "0 0 15 * * ?")
     private void Timeth() {
         log.info("----------------------------优惠券三天后过期---------------------------------");
         List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(3);
+        log.info("优惠券三天过期的有-------------------》" + coupons.toString());
         MessageCenterPo messageCenter = new MessageCenterPo();
         messageCenter.userType(1).messageType(4).couponMessageType(3).content("3天");
         coupons.forEach(c -> {

+ 2 - 1
src/main/resources/mapper/MessageCenter.xml

@@ -317,7 +317,8 @@
         LEFT JOIN cm_coupon cc ON ccc.couponId = cc.id
         LEFT JOIN club c ON ccc.userId = c.userId
         LEFT JOIN USER u ON ccc.userId = u.userId
-        WHERE DATE_ADD(NOW(), INTERVAL 7 DAY) <![CDATA[  <  ]]> IF(cc.useTimeFlag = 1, cc.endDate, DATE_ADD(ccc.createDate, INTERVAL cc.usePeriod DAY))
+        WHERE DATE_FORMAT(DATE_ADD(NOW(), INTERVAL #{day} DAY),'%y-%m-%d') =
+              DATE_FORMAT(IF(cc.useTimeFlag = 1, cc.endDate, DATE_ADD(ccc.createDate, INTERVAL cc.usePeriod DAY)),'%y-%m-%d')
     </select>
     <select id="findOutTimeQualification" resultType="com.caimei365.tools.model.po.QualificationPo">
         SELECT p.productId, p.name AS productName, p.shopId, p.qualificationNo, u.userId, s.name AS shopName