Browse Source

商品资质证书推送

zhijiezhao 2 years ago
parent
commit
6a0515a581

+ 2 - 0
src/main/java/com/caimei365/tools/mapper/MessageCenterMapper.java

@@ -97,4 +97,6 @@ public interface MessageCenterMapper {
     List<CmCouponPo> findOutTimeCoupons(Integer day);
 
     void addNotification(Notification notification);
+
+    List<QualificationPo> findOutTimeQualification(Integer day);
 }

+ 2 - 1
src/main/java/com/caimei365/tools/model/po/MessageCenterPo.java

@@ -6,7 +6,8 @@ import lombok.experimental.Accessors;
 import java.io.Serializable;
 
 /**
- * Description
+ *
+ * @author zzj
  */
 @Data
 @Accessors(fluent = true)

+ 1 - 1
src/main/java/com/caimei365/tools/model/po/Notification.java

@@ -24,7 +24,7 @@ public class Notification implements Serializable {
     /**
      * 商品ID
      */
-    private String porductId;
+    private String productId;
     /**
      * 供应商ID
      */

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

@@ -0,0 +1,20 @@
+package com.caimei365.tools.model.po;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author zzj
+ */
+@Data
+@Accessors(fluent = true)
+public class QualificationPo implements Serializable {
+    private Integer shopId;
+    private Integer productId;
+    private Integer userId;
+    private String shopName;
+    private String qualificationNo;
+    private String productName;
+}

+ 48 - 11
src/main/java/com/caimei365/tools/task/ShopMessTask.java

@@ -49,17 +49,57 @@ public class ShopMessTask {
     private MessageSender messageSender;
 
     @Scheduled(cron = "0 0 15 * * ?")
-    public void Timesjf() {
+    public void outTimePutAwayFee() {
         log.info("-------------------------------上架费过期推送开始-------------------------------");
         putAwayFee(0);
-        putAwayFee(6);
-        putAwayFee(29);
+        putAwayFee(7);
+        putAwayFee(30);
         log.info("-------------------------------上架费过期推送结束-------------------------------");
     }
 
+    @Scheduled(cron = "0 0 11 * * ?")
+//@Scheduled(cron = "0 0/1 * * * ?")
+    public void outTimeQualification() {
+        log.info("---------------------------开始检测商品资质证书是否过期-------------------------------");
+        //1,7,30,90
+        qualification(0);
+        qualification(7);
+        qualification(30);
+        qualification(91);
+        log.info("---------------------------检测商品资质证书是否过期结束-------------------------------");
+    }
+
+    public void qualification(Integer day) {
+        StringBuilder productNames = new StringBuilder();
+        StringBuilder productIds = new StringBuilder();
+        List<QualificationPo> pro = messageCenterMapper.findOutTimeQualification(day);
+        String contentDay = 0 == day ? "今天" : 7 == day ? "7天" : 30 == day ? "一个月" : "三个月";
+        String content = "该商品的资质证书将于" + contentDay + "后失效,请及时登录采美网站上传新证书。";
+        String theme = "以下械字号商品的资质证书将于" + contentDay + "后失效,请及时提醒供应商更换证书。";
+        MessageCenterPo messageCenter = new MessageCenterPo();
+        messageCenter.userType(2).messageType(2).shopMessType(5).content(content);
+        pro.forEach(p -> {
+            productNames.append("(").append(p.productId()).append(")").append(p.productName());
+            productIds.append(p.productId()).append(",");
+            messageCenter.productId(p.productId());
+            messageCenterMapper.addMessageCenter(messageCenter);
+        });
+        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 += "...";
+        }
+        Notification notification = new Notification();
+        notification.theme(theme).shopContent(names).productId(ids);
+        messageCenterMapper.addNotification(notification);
+    }
+
     public void putAwayFee(Integer day) {
         List<ShopReceiptVo> shopIds = messageCenterMapper.findExpireShopId(day);
-        String contentDay = day > 6 ? "30" : 6 == day ? "7" : "今";
+        String contentDay = day > 7 ? "30" : 7 == day ? "7" : "今";
         StringBuilder shopNames = new StringBuilder();
         StringBuilder shopsId = new StringBuilder();
         String firsts = "尊敬的采美供应商用户,您的账号维护费用" + contentDay + "天后即将到期!";
@@ -94,7 +134,7 @@ public class ShopMessTask {
         });
         String s = shopNames.toString();
         String sn = shopsId.toString();
-        String shopDay = 0 == day ? "今天" : 6 == day ? "7天" : "一个月";
+        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;
@@ -171,8 +211,7 @@ public class ShopMessTask {
         log.info("----------------------------优惠券七天后过期---------------------------------");
         List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(7);
         MessageCenterPo messageCenter = new MessageCenterPo();
-        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
-        messageCenter.userType(1).messageType(4).couponMessageType(3).content("7天").time(format);
+        messageCenter.userType(1).messageType(4).couponMessageType(3).content("7天");
         coupons.forEach(c -> {
             messageCenter.clubId(c.getClubId()).couponFee(c.getCouponAmount().doubleValue()).couponType(c.getCouponType());
             messageCenterMapper.addMessageCenter(messageCenter);
@@ -195,8 +234,7 @@ public class ShopMessTask {
         log.info("----------------------------优惠券一天后过期---------------------------------");
         List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(1);
         MessageCenterPo messageCenter = new MessageCenterPo();
-        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
-        messageCenter.userType(1).messageType(4).couponMessageType(3).content("7天").time(format);
+        messageCenter.userType(1).messageType(4).couponMessageType(3).content("7天");
         coupons.forEach(c -> {
             messageCenter.clubId(c.getClubId()).couponFee(c.getCouponAmount().doubleValue()).couponType(c.getCouponType());
             messageCenterMapper.addMessageCenter(messageCenter);
@@ -212,8 +250,7 @@ public class ShopMessTask {
         log.info("----------------------------优惠券三天后过期---------------------------------");
         List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(3);
         MessageCenterPo messageCenter = new MessageCenterPo();
-        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
-        messageCenter.userType(1).messageType(4).couponMessageType(3).content("3天").time(format);
+        messageCenter.userType(1).messageType(4).couponMessageType(3).content("3天");
         coupons.forEach(c -> {
             messageCenter.clubId(c.getClubId()).couponFee(c.getCouponAmount().doubleValue()).couponType(c.getCouponType());
             messageCenterMapper.addMessageCenter(messageCenter);

+ 18 - 8
src/main/resources/mapper/MessageCenter.xml

@@ -4,7 +4,7 @@
     <insert id="addMessageCenter">
         INSERT INTO message_center (shopID, clubID, userType, messageType, content, time, accountType, couponType,
                                     couponFee, couponMessageType, ShopMessType, ShopTieredType)
-        VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, #{time}, #{accountType}, #{couponType},
+        VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, now(), #{accountType}, #{couponType},
                 #{couponFee}, #{couponMessageType}, #{shopMessType}, #{shopTieredType})
     </insert>
     <insert id="sendInsideMessage">
@@ -17,7 +17,7 @@
     </insert>
     <insert id="addNotification">
         INSERT INTO notification(theme, newTime, shopContent, porductID, shopID)
-        VALUES (#{theme}, NOW(), #{shopContent}, #{porductId}, #{shopId})
+        VALUES (#{theme}, NOW(), #{shopContent}, #{productId}, #{shopId})
     </insert>
     <select id="clubIdCule" resultType="java.lang.Integer">
         SELECT clubID
@@ -296,7 +296,7 @@
     <select id="CouponLists" resultType="com.caimei365.tools.model.po.CmCouponPo">
         SELECT *
         FROM cm_coupon a
-                 LEFT JOIN cm_coupon_club s ON s.couponId = a.id
+        LEFT JOIN cm_coupon_club s ON s.couponId = a.id
         WHERE s.userId = #{userID}
           AND NOW() >= a.startDate
           AND a.endDate >= NOW()
@@ -307,16 +307,26 @@
     <select id="findExpireShopId" resultType="com.caimei365.tools.model.po.ShopReceiptVo">
         SELECT cr.dateStrings, cdr.shopId, cdr.receiptAmount, cr.validityDate, p.name as shopName
         FROM cm_receipt cr
-                 LEFT JOIN cm_discern_receipt cdr ON cr.receiptId = cdr.id
-                 LEFT JOIN shop p on cdr.shopId = p.shopId
+        LEFT JOIN cm_discern_receipt cdr ON cr.receiptId = cdr.id
+        LEFT JOIN shop p on cdr.shopId = p.shopId
         WHERE DATE_FORMAT(cr.dateStrings, '%y-%m-%d') = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL #{day} DAY), '%y-%m-%d')
     </select>
     <select id="findOutTimeCoupons" resultType="com.caimei365.tools.model.po.CmCouponPo">
         SELECT ccc.couponId, ccc.userId, c.clubId, cc.couponAmount, u.bindMobile, cc.couponType
         FROM cm_coupon_club ccc
-                 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
+        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))
     </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
+        FROM product p
+        LEFT JOIN shop s ON p.shopId = s.shopId
+        LEFT JOIN USER u ON s.userId = u.userId
+        WHERE p.productType = 2
+          AND p.qualificationTime IS NOT NULL
+          AND DATE_FORMAT(p.qualificationTime, '%y-%m-%d') =
+              DATE_FORMAT(DATE_ADD(NOW(), INTERVAL #{day} DAY), '%y-%m-%d')
+    </select>
 </mapper>