Browse Source

后台消息推送

zhijiezhao 2 years ago
parent
commit
a27fb79d08

+ 3 - 4
src/main/java/com/caimei365/tools/mapper/MessageCenterMapper.java

@@ -1,10 +1,7 @@
 package com.caimei365.tools.mapper;
 
 import com.caimei365.tools.model.dto.message.InsideMessage;
-import com.caimei365.tools.model.po.CmCouponPo;
-import com.caimei365.tools.model.po.CmUserPo;
-import com.caimei365.tools.model.po.MessageCenterPo;
-import com.caimei365.tools.model.po.ShopReceiptVo;
+import com.caimei365.tools.model.po.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -98,4 +95,6 @@ public interface MessageCenterMapper {
     List<ShopReceiptVo> findExpireShopId(Integer day);
 
     List<CmCouponPo> findOutTimeCoupons(Integer day);
+
+    void addNotification(Notification notification);
 }

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

@@ -0,0 +1,40 @@
+package com.caimei365.tools.model.po;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+@Data
+@Accessors(fluent = true)
+public class Notification implements Serializable {
+    private String Id;
+    /**
+     * 通知主题
+     */
+    private String theme;
+    /**
+     * 通知时间
+     */
+    private String newTime;
+    /**
+     * 内容ID+名称
+     */
+    private String shopContent;
+    /**
+     * 商品ID
+     */
+    private String porductId;
+    /**
+     * 供应商ID
+     */
+    private String shopId;
+    /**
+     *     0.未读 , 1.已读
+     */
+    private Integer saved;
+    /**
+     * 隐藏状态0显示1隐藏
+     */
+    private Integer hide;
+}

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

@@ -17,5 +17,6 @@ public class ShopReceiptVo implements Serializable {
      */
     private String dateStrings;
     private Integer shopId;
+    private String shopName;
     private Double receiptAmount;
 }

+ 60 - 237
src/main/java/com/caimei365/tools/task/ShopMessTask.java

@@ -10,17 +10,13 @@ import com.caimei365.tools.model.dto.message.enums.MessageType;
 import com.caimei365.tools.model.po.*;
 import com.caimei365.tools.service.MessageSender;
 import com.caimei365.tools.service.WeChatService;
-import com.caimei365.tools.utils.InsideMessageUtil;
 import com.caimei365.tools.utils.SmsUtil;
 import lombok.RequiredArgsConstructor;
-import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
-import org.apache.juli.logging.Log;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
-import redis.clients.jedis.Jedis;
 
 import javax.annotation.Resource;
 import java.text.ParseException;
@@ -29,10 +25,7 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Description
@@ -52,29 +45,23 @@ public class ShopMessTask {
     @Resource
     private OrderClubMapper orderClubMapper;
 
-    @Resource
-    private WeChatService weChatService;
-
     @Resource
     private MessageSender messageSender;
 
     @Scheduled(cron = "0 0 15 * * ?")
     public void Timesjf() {
-        log.info("上架费过期推送开始");
-        putawayFee(1);
-        putawayFee(7);
-        putawayFee(30);
-        log.info("上架费过期推送结束");
+        log.info("-------------------------------上架费过期推送开始-------------------------------");
+        putAwayFee(0);
+        putAwayFee(6);
+        putAwayFee(29);
+        log.info("-------------------------------上架费过期推送结束-------------------------------");
     }
 
-    public void putawayFee(Integer day) {
+    public void putAwayFee(Integer day) {
         List<ShopReceiptVo> shopIds = messageCenterMapper.findExpireShopId(day);
-        String contentDay = "今";
-        if (7 == day) {
-            contentDay = "7";
-        } else if (30 == day) {
-            contentDay = "30";
-        }
+        String contentDay = day > 6 ? "30" : 6 == day ? "7" : "今";
+        StringBuilder shopNames = new StringBuilder();
+        StringBuilder shopsId = new StringBuilder();
         String firsts = "尊敬的采美供应商用户,您的账号维护费用" + contentDay + "天后即将到期!";
         String content = "您的供应商账号上架费将于" + contentDay + "日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365。退订回T";
         shopIds.forEach(s -> {
@@ -102,9 +89,40 @@ public class ShopMessTask {
                     .templateId("jYUIq63wP6mGFvkgNHgTOXAgF7j6h_VZKgST_-2fqCo").remark("为了更好给您服务,请及时联系采美客服缴费!").appid("wx91c4152b60ca91a3").url(pagePath);
             MessageModel<WechatTemplateMessage> weChatMessage = wechatTemplateMessageMessageModel.code(MessageType.WECHAT_TEMPLATE_MESSAGE).info(weChat);
             messageSender.messageSend(weChatMessage);
+            shopNames.append(s.getShopName()).append(",");
+            shopsId.append(s.getShopId()).append(",");
         });
+        String s = shopNames.toString();
+        String sn = shopsId.toString();
+        String shopDay = 0 == day ? "今天" : 6 == 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);
     }
 
+    @Scheduled(cron = "0 0 15 * * ?")
+    public void putAwayFeeForManager() {
+        log.info("---------------------------上架费三个月过期推送开始-------------------------------");
+        //后台上架费三个月过期推送
+        List<ShopReceiptVo> shopIds = messageCenterMapper.findExpireShopId(90);
+        StringBuilder shopNames = new StringBuilder();
+        StringBuilder shopsId = new StringBuilder();
+        shopIds.forEach(s -> {
+            shopNames.append(s.getShopName()).append(",");
+            shopsId.append(s.getShopId()).append(",");
+        });
+        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);
+        log.info("---------------------------上架费三个月过期推送结束-------------------------------");
+    }
 
     @Scheduled(cron = "0 0 10 15 * ?")
     public void gwc() {
@@ -135,190 +153,15 @@ public class ShopMessTask {
                 }
             }
         });
-
         log.info("------------推送购物车相关短信-结束----------------------->");
     }
 
-
-//    @Scheduled(cron = "0 0 15 * * ?")
-//    public void ConSumertime() {
-//        log.info("》》》》》》》》》》》开始检测优惠券是否生效");
-//        List<CmCouponPo> coupons = messageCenterMapper.couponTime();
-//        coupons.forEach(cmCoupon -> {
-//            List<Integer> clubIds = messageCenterMapper.ClubIds();
-//            new Thread(() -> clubIds.forEach(clubId -> {
-//                Jedis jedis = null;
-//                String constraint = "";
-//                if (clubId != null) {
-//                    MessageCenterPo messageCenter = new MessageCenterPo();
-//                    Date date = new Date();
-//                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-//                    CmUserPo user = messageCenterMapper.clubList(clubId);
-//                    int coumt = 0;//计数五种消息只推送一条
-//                    String catego = "";
-//                    Integer ts = (date.compareTo(cmCoupon.getStartDate()));
-//                    if (ts >= 0) {
-//                        if ("90".equals(user.getClubStatus()) && 0 == cmCoupon.getCouponType()) {
-//                            CmCouponPo coupon = messageCenterMapper.CouponList(0);//查询优惠券信息
-//                            if (coupon != null) {
-//                                String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-//                                messageCenter.setShopId(null);
-//                                messageCenter.setClubId(clubId);
-//                                messageCenter.setUserType(1);
-//                                messageCenter.setMessageType(4);
-//                                messageCenter.setContent(null);
-//                                messageCenter.setTime(curDateStr);
-//                                messageCenter.setCouponType(0);
-//                                messageCenter.setCouponMessageType(1);
-//                                messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-//                                messageCenterMapper.addMessageCenter(messageCenter);
-//                                String content = "采美平台送您" + coupon.getCouponAmount() + "元优惠券,众多大牌正品等着您,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取下单吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-//                                String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
-//                                JSONObject json = (JSONObject) JSONObject.parse(result);
-//                                log.info("发送结果:" + result + ",短信内容:" + content);
-//                                if (null != json && json.getInteger("code") == 0) {
-//                                    log.info(user.getBindMobile() + "发送成功");
-//                                } else {
-//                                    log.error(user.getBindMobile() + "发送失败");
-//                                }
-//                                coumt++;
-//                            }
-//                        }
-//                        if ("90".equals(user.getClubStatus()) && coumt == 0 && 1 == cmCoupon.getCouponType()) {
-//                            CmCouponPo coupon = messageCenterMapper.CouponList(1);//查询优惠券信息
-//                            if (coupon != null) {
-//                                String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-//                                messageCenter.setShopId(null);
-//                                messageCenter.setClubId(clubId);
-//                                messageCenter.setUserType(1);
-//                                messageCenter.setMessageType(4);
-//                                if (coupon != null && "1".equals(coupon.getCategoryType())) {
-//                                    catego = "产品";
-//                                }
-//                                if (coupon != null && "2".equals(coupon.getCategoryType())) {
-//                                    catego = "仪器";
-//                                }
-//                                messageCenter.setContent(catego);
-//                                messageCenter.setTime(curDateStr);
-//                                messageCenter.setCouponType(1);
-//                                messageCenter.setCouponMessageType(1);
-//                                messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-//                                messageCenterMapper.addMessageCenter(messageCenter);
-//                                String content = "采美平台" + catego + "类商品大优惠,采美平台送您" + coupon.getCouponAmount() + "元优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-//                                String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
-//                                JSONObject json = (JSONObject) JSONObject.parse(result);
-//                                log.info("发送结果:" + result + ",短信内容:" + content);
-//                                if (null != json && json.getInteger("code") == 0) {
-//                                    log.info(user.getBindMobile() + "发送成功");
-//                                } else {
-//                                    log.error(user.getBindMobile() + "发送失败");
-//                                }
-//                                coumt++;
-//                            }
-//                        }
-//                        if (coumt == 0 && 2 == cmCoupon.getCouponType()) {
-//                            CmCouponPo coupon = messageCenterMapper.CouponList(2);//查询优惠券信息
-//                            if (coupon != null) {
-//                                String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-//                                if (coupon != null && coupon.getUserId() != null) {
-//                                    messageCenter.setShopId(null);
-//                                    messageCenter.setClubId(clubId);
-//                                    messageCenter.setUserType(1);
-//                                    messageCenter.setMessageType(4);
-//                                    messageCenter.setContent(null);
-//                                    messageCenter.setTime(curDateStr);
-//                                    messageCenter.setCouponType(2);
-//                                    messageCenter.setCouponMessageType(1);
-//                                    messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-//                                    messageCenterMapper.addMessageCenter(messageCenter);
-//
-//                                    String content = "为了答谢您对采美平台的支持,采美平台送您" + coupon.getCouponAmount() + "元优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-//                                    String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
-//                                    JSONObject json = (JSONObject) JSONObject.parse(result);
-//                                    log.info("发送结果:" + result + ",短信内容:" + content);
-//                                    if (null != json && json.getInteger("code") == 0) {
-//                                        log.info(user.getBindMobile() + "发送成功");
-//                                    } else {
-//                                        log.error(user.getBindMobile() + "发送失败");
-//                                    }
-//                                    coumt++;
-//                                }
-//                            }
-//                        }
-//                        if ("90".equals(user.getClubStatus()) && coumt == 0 && 3 == cmCoupon.getCouponType()) {
-//                            CmCouponPo coupon = messageCenterMapper.CouponList(3);//查询优惠券信息
-//                            if (coupon != null) {
-//                                String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-//                                messageCenter.setShopId(null);
-//                                messageCenter.setClubId(clubId);
-//                                messageCenter.setUserType(1);
-//                                messageCenter.setMessageType(4);
-//                                messageCenter.setContent(user.getName());
-//                                messageCenter.setTime(curDateStr);
-//                                messageCenter.setCouponType(3);
-//                                messageCenter.setCouponMessageType(1);
-//                                messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-//                                messageCenterMapper.addMessageCenter(messageCenter);
-//
-//                                String content = "采美平台为了回馈客户,赠送您" + coupon.getCouponAmount() + "元的店铺专属优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-//                                String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
-//                                JSONObject json = (JSONObject) JSONObject.parse(result);
-//                                log.info("发送结果:" + result + ",短信内容:" + content);
-//                                if (null != json && json.getInteger("code") == 0) {
-//                                    log.info(user.getBindMobile() + "发送成功");
-//                                } else {
-//                                    log.error(user.getBindMobile() + "发送失败");
-//                                }
-//                                coumt++;
-//                            }
-//                        }
-//                        if (coumt == 0 && 4 == cmCoupon.getCouponType()) {
-//                            CmCouponPo coupon = messageCenterMapper.CouponList(4);//查询优惠券信息
-//                            if (coupon != null) {
-//                                String startDate = sdf.format(coupon.getStartDate());
-//                                int num = startDate.compareTo(user.getRegisterTime());
-//                                if (num > 0) {
-//                                    String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-//                                    if (coupon != null && coupon.getUserId() != null) {
-//                                        messageCenter.setShopId(null);
-//                                        messageCenter.setClubId(clubId);
-//                                        messageCenter.setUserType(1);
-//                                        messageCenter.setMessageType(4);
-//                                        messageCenter.setContent(null);
-//                                        messageCenter.setTime(curDateStr);
-//                                        messageCenter.setCouponType(4);
-//                                        messageCenter.setCouponMessageType(1);
-//                                        messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-//                                        messageCenterMapper.addMessageCenter(messageCenter);
-//
-//                                        String content = "恭喜成功注册采美平台。采美平台赠送您" + coupon.getCouponAmount() + "元新用户优惠券,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台领取吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-//                                        String result = SmsUtil.sendSms(3, user.getBindMobile(), content);
-//                                        JSONObject json = (JSONObject) JSONObject.parse(result);
-//                                        log.info("发送结果:" + result + ",短信内容:" + content);
-//                                        if (null != json && json.getInteger("code") == 0) {
-//                                            log.info(user.getBindMobile() + "发送成功");
-//                                        } else {
-//                                            log.error(user.getBindMobile() + "发送失败");
-//                                        }
-//                                        coumt++;
-//                                    }
-//                                }
-//                            }
-//                        }
-//                    }
-//                }
-//            }));
-//        });
-//
-//    }
-
-
     /**
      * 每天12点推送
-     *  优惠券领取后离失效日只剩7天还没使用,在当天中午12点推送给领取了该优惠券的用户(谁领的给谁发短信)
-     *
+     * 优惠券领取后离失效日只剩7天还没使用,在当天中午12点推送给领取了该优惠券的用户(谁领的给谁发短信)
+     * <p>
      * 若优惠券有限期小于15天,则上述情况不推送
-     *
+     * <p>
      * 短信模板:【采美365】您有100元优惠券将于7日后过期,快戳采美网站链接www.caimei365.com
      * 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。
      */
@@ -326,23 +169,23 @@ public class ShopMessTask {
 //    @Scheduled(cron = "0 0/10 * * * ?")
     private void Timerw() {
         log.info("----------------------------优惠券七天后过期---------------------------------");
-        List<CmCouponPo> coupons=messageCenterMapper.findOutTimeCoupons(7);
+        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);
-        coupons.forEach(c->{
+        coupons.forEach(c -> {
             messageCenter.clubId(c.getClubId()).couponFee(c.getCouponAmount().doubleValue()).couponType(c.getCouponType());
             messageCenterMapper.addMessageCenter(messageCenter);
             String content = "您有" + c.getCouponAmount() + "元优惠券将于7日后过期," +
                     "快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-            SmsUtil.sendSms(3,content,c.getBindMobile());
+            SmsUtil.sendSms(3, content, c.getBindMobile());
         });
     }
 
 
     /**
      * 优惠券领取后没有使用,在失效日当天,上午10推送给领取了该优惠券的用户(谁领的给谁发短信)
-     *
+     * <p>
      * 短信模板:【采美365】您有100元优惠券今日过期,快戳采美网站链接www.caimei365.com/M2Tr98CG
      * 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。
      */
@@ -350,16 +193,16 @@ public class ShopMessTask {
 //    @Scheduled(cron = "0 0/2 * * * ?")
     private void Timeto() {
         log.info("----------------------------优惠券一天后过期---------------------------------");
-        List<CmCouponPo> coupons=messageCenterMapper.findOutTimeCoupons(1);
+        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);
-        coupons.forEach(c->{
+        coupons.forEach(c -> {
             messageCenter.clubId(c.getClubId()).couponFee(c.getCouponAmount().doubleValue()).couponType(c.getCouponType());
             messageCenterMapper.addMessageCenter(messageCenter);
             String content = "您有" + c.getCouponAmount() + "元优惠券将于7日后过期," +
                     "快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-            SmsUtil.sendSms(3,content,c.getBindMobile());
+            SmsUtil.sendSms(3, content, c.getBindMobile());
         });
     }
 
@@ -367,16 +210,16 @@ public class ShopMessTask {
     @Scheduled(cron = "0 0 15 * * ?")
     private void Timeth() {
         log.info("----------------------------优惠券三天后过期---------------------------------");
-        List<CmCouponPo> coupons=messageCenterMapper.findOutTimeCoupons(3);
+        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);
-        coupons.forEach(c->{
+        coupons.forEach(c -> {
             messageCenter.clubId(c.getClubId()).couponFee(c.getCouponAmount().doubleValue()).couponType(c.getCouponType());
             messageCenterMapper.addMessageCenter(messageCenter);
             String content = "您有" + c.getCouponAmount() + "元优惠券将于3日后过期," +
                     "快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-            SmsUtil.sendSms(3,content,c.getBindMobile());
+            SmsUtil.sendSms(3, content, c.getBindMobile());
         });
     }
 
@@ -412,14 +255,8 @@ public class ShopMessTask {
             if (num == 0) {
                 MessageCenterPo messageCenter = new MessageCenterPo();
                 //推送信息中心-交易物流-待确认超时
-                messageCenter.setShopId(null);
-                messageCenter.setClubId(order.getClubId());
-                messageCenter.setUserType(1);
-                messageCenter.setMessageType(1);
-                messageCenter.setOrderId(order.getOrderId());
-                messageCenter.setOrderMessageType(4);
-                messageCenter.setContent("您的订单因超时未付款,系统已自动取消订单!");
-                messageCenter.setTime(current);
+                messageCenter.clubId(order.getClubId()).userType(1).messageType(1).orderId(order.getOrderId()).orderMessageType(4)
+                        .content("您的订单因超时未付款,系统已自动取消订单!").time(current);
                 messageCenterMapper.addMessageCenter(messageCenter);
             }
         });
@@ -444,14 +281,8 @@ public class ShopMessTask {
             if (num == 0) {
                 MessageCenterPo messageCenter = new MessageCenterPo();
                 //推送信息中心-账户通知
-                messageCenter.setShopId(null);
-                messageCenter.setClubId(order.getClubId());
-                messageCenter.setUserType(1);
-                messageCenter.setMessageType(1);
-                messageCenter.setOrderId(order.getOrderId());
-                messageCenter.setOrderMessageType(6);
-                messageCenter.setContent(null);
-                messageCenter.setTime(current);
+                messageCenter.clubId(order.getClubId()).userType(1).messageType(1).orderId(order.getOrderId()).
+                        orderMessageType(6).time(current);
                 messageCenterMapper.addMessageCenter(messageCenter);
             }
         });
@@ -475,18 +306,10 @@ public class ShopMessTask {
             if (num == 0) {
                 MessageCenterPo messageCenter = new MessageCenterPo();
                 //推送信息中心-账户通知
-                messageCenter.setShopId(null);
-                messageCenter.setClubId(order.getClubId());
-                messageCenter.setUserType(1);
-                messageCenter.setMessageType(1);
-                messageCenter.setOrderId(order.getOrderId());
-                messageCenter.setOrderMessageType(6);
-                messageCenter.setContent("您的订单因超时已被系统自动确认收货!");
-                messageCenter.setTime(current);
+                messageCenter.clubId(order.getClubId()).userType(1).messageType(1).orderId(order.getOrderId())
+                        .orderMessageType(6).content("您的订单因超时已被系统自动确认收货!").time(current);
                 messageCenterMapper.addMessageCenter(messageCenter);
             }
-
         });
     }
-
 }

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

@@ -15,7 +15,10 @@
                 #{couponMessageType}, #{couponFee}, #{content}, now(), 0, #{shopMessType},
                 #{shopTieredType}, #{couponType}, #{productId})
     </insert>
-
+    <insert id="addNotification">
+        INSERT INTO notification(theme, newTime, shopContent, porductID, shopID)
+        VALUES (#{theme}, NOW(), #{shopContent}, #{porductId}, #{shopId})
+    </insert>
     <select id="clubIdCule" resultType="java.lang.Integer">
         SELECT clubID
         FROM `user`
@@ -99,7 +102,7 @@
         WHERE unionId = (
             SELECT unionID
             FROM cm_order co
-            LEFT JOIN shop s ON co.userId = s.userId
+                     LEFT JOIN shop s ON co.userId = s.userId
             WHERE s.shopId = #{shopId}
               AND unionID IS NOT NULL
             ORDER BY orderID DESC
@@ -169,8 +172,8 @@
     <select id="receiptDate" resultType="java.lang.String">
         SELECT c.dateStrings
         FROM cm_receipt c
-        LEFT JOIN cm_discern_receipt a ON c.receiptID = a.id
-        LEFT JOIN shop s ON s.shopID = a.shopID
+                 LEFT JOIN cm_discern_receipt a ON c.receiptID = a.id
+                 LEFT JOIN shop s ON s.shopID = a.shopID
         WHERE a.shopID = 10324
           AND a.newReceiptType = 1
         ORDER BY a.id DESC
@@ -180,7 +183,7 @@
     <select id="receiptAmount" resultType="java.lang.Double">
         SELECT a.receiptAmount
         FROM cm_discern_receipt a
-        LEFT JOIN shop s ON s.shopID = a.shopID
+                 LEFT JOIN shop s ON s.shopID = a.shopID
         where a.shopID = #{shopID}
           AND a.newReceiptType = 1
         LIMIT 1
@@ -189,7 +192,7 @@
     <select id="newReceiptType" resultType="java.lang.Integer">
         SELECT a.newReceiptType
         FROM cm_discern_receipt a
-        LEFT JOIN shop s ON s.shopID = a.shopID
+                 LEFT JOIN shop s ON s.shopID = a.shopID
         where a.shopID = #{shopID}
         LIMIT 1
     </select>
@@ -293,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()
@@ -302,17 +305,18 @@
     </select>
 
     <select id="findExpireShopId" resultType="com.caimei365.tools.model.po.ShopReceiptVo">
-        SELECT cr.dateStrings,cdr.shopId,cdr.receiptAmount,cr.validityDate
+        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 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
+        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
-        WHERE DATE_ADD(NOW(),INTERVAL 7 DAY) <![CDATA[  <  ]]> IF(cc.useTimeFlag=1,cc.endDate,DATE_ADD(ccc.createDate,INTERVAL cc.usePeriod DAY))
+                 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>
 </mapper>