Browse Source

优惠券到期推送

zhijiezhao 2 years ago
parent
commit
ed05c98bfb

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

@@ -96,4 +96,6 @@ public interface MessageCenterMapper {
     void sendInsideMessage(InsideMessage insideMessage);
 
     List<ShopReceiptVo> findExpireShopId(Integer day);
+
+    List<CmCouponPo> findOutTimeCoupons(Integer day);
 }

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

@@ -50,6 +50,8 @@ public class CmCouponPo implements Serializable {
     private Double moneyCouponPrice; //价值优惠券购买金额
     private List<Integer> productIdList;
     private Integer couponPayWay;  //购买方式 1.直接购买 2.采美豆抵扣
+    private Integer clubId; //领取人的clubId
+    private String bindMobile;//领取人手机号
 
     private Date receiveDate;   // 领取时间
     private Date useEndDate;    // 使用截止时间

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

@@ -1,6 +1,7 @@
 package com.caimei365.tools.model.po;
 
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 
@@ -8,6 +9,7 @@ import java.io.Serializable;
  * Description
  */
 @Data
+@Accessors(fluent = true)
 public class MessageCenterPo implements Serializable {
     /**
      * 消息id
@@ -46,7 +48,7 @@ public class MessageCenterPo implements Serializable {
      */
     private Integer accountType;
     /**
-     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     * 优惠券类型 0活动券 1品类券 2用户专享券 3店铺券 4新用户券
      */
     private Integer couponType;
     /**

+ 126 - 126
src/main/java/com/caimei365/tools/task/CouponTask.java

@@ -1,126 +1,126 @@
-package com.caimei365.tools.task;
-
-import com.caimei365.tools.mapper.BaseMapper;
-import com.caimei365.tools.model.bo.CouponDateBo;
-import com.caimei365.tools.utils.CodeUtil;
-import com.caimei365.tools.utils.DateUtils;
-import com.caimei365.tools.utils.SmsUtil;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 优惠券定时推送
- *
- * @author : Charles
- * @date : 2021/10/26
- */
-@Slf4j
-@Configuration
-@EnableScheduling
-@RequiredArgsConstructor
-public class CouponTask {
-    @Resource
-    private BaseMapper baseMapper;
-    @Value("${spring.cloud.config.profile}")
-    private String profile;
-
-    /**
-     * 优惠券即将到期推送,定时中午12点推送
-     */
-    @Scheduled(cron = "0 0 12 * * ?")
-    public void couponExpiring() {
-        // 查询所有优惠券用户Id
-        List<Integer> userIds = baseMapper.getCouponUserIds();
-        int a = 0;
-        int b = 0;
-        int c = 0;
-        Date date = new Date();
-        //测试环境手机号允许发短信
-        List<String> list = new ArrayList<>();
-        list.add("15917362709");
-        list.add("15814011616");
-        list.add("15113936829");
-        A:
-        for (Integer userId : userIds) {
-            String mobile = baseMapper.findMobile(userId);
-            if (StringUtils.isBlank(mobile) || mobile.length() != 11) {
-                log.info("机构手机号异常,userId>>>>>" + userId);
-                continue;
-            }
-            // 正式环境或指定手机号
-            if ("prod".equals(profile) || list.contains(mobile)) {
-                // 已领取优惠券
-                List<CouponDateBo> couponList = baseMapper.getReceivedCoupons(userId);
-                String content = null;
-                if (couponList != null && couponList.size() > 0) {
-                    for (CouponDateBo coupon : couponList) {
-                        if (DateUtils.differentDays(coupon.getStartDate(), coupon.getEndDate()) >= 15 && DateUtils.differentDays(date, coupon.getEndDate()) == 7) {
-                            //7天后优惠券即将过期推送
-                            String shortLink = getShortLink(8, 12, "https://www.caimei365.com/user/coupon-collection.html");
-                            content = "您有优惠券即将过期,快戳采美网站链接www.caimei365.com/t/" + shortLink +
-                                    " 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美365网”获取更多优惠和精彩资讯。退订回T";
-                            String result = SmsUtil.sendSms(3, mobile, content);
-                            a++;
-                            continue A;
-                        }
-                        if (DateUtils.differentDays(date, coupon.getEndDate()) == 0) {
-                            //当天优惠券即将过期推送
-                            String shortLink = getShortLink(8, 13, "https://www.caimei365.com/user/coupon-collection.html");
-                            content = "您有优惠券今日过期,快戳采美网站链接www.caimei365.com/t/" + shortLink +
-                                    "  或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美365网”获取更多优惠和精彩资讯。退订回T";
-                            String result = SmsUtil.sendSms(3, mobile, content);
-                            b++;
-                            continue A;
-                        }
-                    }
-                }
-                // 未领取优惠券
-                List<CouponDateBo> coupons = baseMapper.getUnclaimedCoupons(userId);
-                if (couponList != null && couponList.size() > 0) {
-                    for (CouponDateBo coupon : coupons) {
-                        if (DateUtils.differentDays(date, coupon.getEndDate()) == 7) {
-                            //7天后优惠券即将过期推送
-                            String shortLink = getShortLink(8, 14, "https://www.caimei365.com/user/coupon-collection.html");
-                            content = "您有优惠券尚未领取,优惠券即将失效,快戳采美网站链接www.caimei365.com/t/" + shortLink +
-                                    " 或微信搜索“采美采购商城”小程序登录采美平台领取使用吧。关注公众号“采美365网”获取更多优惠和精彩资讯。退订回T";
-                            String result = SmsUtil.sendSms(3, mobile, content);
-                            c++;
-                            continue A;
-                        }
-                    }
-                }
-            }
-        }
-        baseMapper.updateSmsSendCount(12, a);
-        baseMapper.updateSmsSendCount(13, b);
-        baseMapper.updateSmsSendCount(14, c);
-    }
-
-    /**
-     * 生成短链接
-     *
-     * @param length 链接长度
-     * @param markId 跳转类型
-     * @param url    跳转地址
-     */
-    private String getShortLink(int length, int markId, String url) {
-        String shortLink = CodeUtil.generateShortLink(length);
-        Integer id = baseMapper.findIdByShortLink(shortLink);
-        if (id != null && id > 0) {
-            getShortLink(length, markId, url);
-        }
-        baseMapper.insertShortLink(markId, shortLink, url);
-        return shortLink;
-    }
-
-}
+//package com.caimei365.tools.task;
+//
+//import com.caimei365.tools.mapper.BaseMapper;
+//import com.caimei365.tools.model.bo.CouponDateBo;
+//import com.caimei365.tools.utils.CodeUtil;
+//import com.caimei365.tools.utils.DateUtils;
+//import com.caimei365.tools.utils.SmsUtil;
+//import lombok.RequiredArgsConstructor;
+//import lombok.extern.slf4j.Slf4j;
+//import org.apache.commons.lang.StringUtils;
+//import org.springframework.beans.factory.annotation.Value;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.scheduling.annotation.EnableScheduling;
+//import org.springframework.scheduling.annotation.Scheduled;
+//
+//import javax.annotation.Resource;
+//import java.util.ArrayList;
+//import java.util.Date;
+//import java.util.List;
+//
+///**
+// * 优惠券定时推送
+// *
+// * @author : Charles
+// * @date : 2021/10/26
+// */
+//@Slf4j
+//@Configuration
+//@EnableScheduling
+//@RequiredArgsConstructor
+//public class CouponTask {
+//    @Resource
+//    private BaseMapper baseMapper;
+//    @Value("${spring.cloud.config.profile}")
+//    private String profile;
+//
+//    /**
+//     * 优惠券即将到期推送,定时中午12点推送
+//     */
+//    @Scheduled(cron = "0 0 12 * * ?")
+//    public void couponExpiring() {
+//        // 查询所有优惠券用户Id
+//        List<Integer> userIds = baseMapper.getCouponUserIds();
+//        int a = 0;
+//        int b = 0;
+//        int c = 0;
+//        Date date = new Date();
+//        //测试环境手机号允许发短信
+//        List<String> list = new ArrayList<>();
+//        list.add("15917362709");
+//        list.add("15814011616");
+//        list.add("15113936829");
+//        A:
+//        for (Integer userId : userIds) {
+//            String mobile = baseMapper.findMobile(userId);
+//            if (StringUtils.isBlank(mobile) || mobile.length() != 11) {
+//                log.info("机构手机号异常,userId>>>>>" + userId);
+//                continue;
+//            }
+//            // 正式环境或指定手机号
+//            if ("prod".equals(profile) || list.contains(mobile)) {
+//                // 已领取优惠券
+//                List<CouponDateBo> couponList = baseMapper.getReceivedCoupons(userId);
+//                String content = null;
+//                if (couponList != null && couponList.size() > 0) {
+//                    for (CouponDateBo coupon : couponList) {
+//                        if (DateUtils.differentDays(coupon.getStartDate(), coupon.getEndDate()) >= 15 && DateUtils.differentDays(date, coupon.getEndDate()) == 7) {
+//                            //7天后优惠券即将过期推送
+//                            String shortLink = getShortLink(8, 12, "https://www.caimei365.com/user/coupon-collection.html");
+//                            content = "您有优惠券即将过期,快戳采美网站链接www.caimei365.com/t/" + shortLink +
+//                                    " 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美365网”获取更多优惠和精彩资讯。退订回T";
+//                            String result = SmsUtil.sendSms(3, mobile, content);
+//                            a++;
+//                            continue A;
+//                        }
+//                        if (DateUtils.differentDays(date, coupon.getEndDate()) == 0) {
+//                            //当天优惠券即将过期推送
+//                            String shortLink = getShortLink(8, 13, "https://www.caimei365.com/user/coupon-collection.html");
+//                            content = "您有优惠券今日过期,快戳采美网站链接www.caimei365.com/t/" + shortLink +
+//                                    "  或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美365网”获取更多优惠和精彩资讯。退订回T";
+//                            String result = SmsUtil.sendSms(3, mobile, content);
+//                            b++;
+//                            continue A;
+//                        }
+//                    }
+//                }
+//                // 未领取优惠券
+//                List<CouponDateBo> coupons = baseMapper.getUnclaimedCoupons(userId);
+//                if (couponList != null && couponList.size() > 0) {
+//                    for (CouponDateBo coupon : coupons) {
+//                        if (DateUtils.differentDays(date, coupon.getEndDate()) == 7) {
+//                            //7天后优惠券即将过期推送
+//                            String shortLink = getShortLink(8, 14, "https://www.caimei365.com/user/coupon-collection.html");
+//                            content = "您有优惠券尚未领取,优惠券即将失效,快戳采美网站链接www.caimei365.com/t/" + shortLink +
+//                                    " 或微信搜索“采美采购商城”小程序登录采美平台领取使用吧。关注公众号“采美365网”获取更多优惠和精彩资讯。退订回T";
+//                            String result = SmsUtil.sendSms(3, mobile, content);
+//                            c++;
+//                            continue A;
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//        baseMapper.updateSmsSendCount(12, a);
+//        baseMapper.updateSmsSendCount(13, b);
+//        baseMapper.updateSmsSendCount(14, c);
+//    }
+//
+//    /**
+//     * 生成短链接
+//     *
+//     * @param length 链接长度
+//     * @param markId 跳转类型
+//     * @param url    跳转地址
+//     */
+//    private String getShortLink(int length, int markId, String url) {
+//        String shortLink = CodeUtil.generateShortLink(length);
+//        Integer id = baseMapper.findIdByShortLink(shortLink);
+//        if (id != null && id > 0) {
+//            getShortLink(length, markId, url);
+//        }
+//        baseMapper.insertShortLink(markId, shortLink, url);
+//        return shortLink;
+//    }
+//
+//}

+ 225 - 332
src/main/java/com/caimei365/tools/task/ShopMessTask.java

@@ -67,18 +67,17 @@ public class ShopMessTask {
         log.info("上架费过期推送结束");
     }
 
-    public void putawayFee(Integer day){
-        List<ShopReceiptVo> shopIds=messageCenterMapper.findExpireShopId(day);
-        String contentDay="今";
-        if(7==day){
-             contentDay="7";
+    public void putawayFee(Integer day) {
+        List<ShopReceiptVo> shopIds = messageCenterMapper.findExpireShopId(day);
+        String contentDay = "今";
+        if (7 == day) {
+            contentDay = "7";
+        } else if (30 == day) {
+            contentDay = "30";
         }
-        else if (30==day){
-            contentDay="30";
-        }
-        String  firsts = "尊敬的采美供应商用户,您的账号维护费用"+contentDay+"天后即将到期!";
-        String content = "您的供应商账号上架费将于"+contentDay+"日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365。退订回T";
-        shopIds.forEach(s->{
+        String firsts = "尊敬的采美供应商用户,您的账号维护费用" + contentDay + "天后即将到期!";
+        String content = "您的供应商账号上架费将于" + contentDay + "日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365。退订回T";
+        shopIds.forEach(s -> {
             //站内信
             MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
             insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE).info(new InsideMessage().shopId(s.getShopId()).userType(2)
@@ -141,349 +140,243 @@ public class ShopMessTask {
     }
 
 
-    @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++;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }));
-        });
-
-    }
+//    @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点推送给领取了该优惠券的用户(谁领的给谁发短信)
+     *
+     * 若优惠券有限期小于15天,则上述情况不推送
+     *
+     * 短信模板:【采美365】您有100元优惠券将于7日后过期,快戳采美网站链接www.caimei365.com
+     * 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。
      */
     @Scheduled(cron = "0 0 12 * * ?")
 //    @Scheduled(cron = "0 0/10 * * * ?")
     private void Timerw() {
-        log.info(">>>>>7天后下架");
-        List<Integer> userIds = messageCenterMapper.CouponUserId();
-        userIds.forEach(userId -> {
-            List<CmCouponPo> coupons = messageCenterMapper.CouponLists(userId);
-            coupons.forEach(coupon -> {
-                if (userId != null) {
-                    CmUserPo user = messageCenterMapper.clubLists(userId);
-                    String contractMobile = messageCenterMapper.contractMobile(userId);
-                    Date date = new Date();
-                    Date d = coupon.getStartDate();
-                    //1.日期格式
-                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-                    String endTime = sdf.format(coupon.getEndDate());
-                    //2.某天的日期
-                    Date da1 = null;
-                    try {
-                        da1 = sdf.parse(endTime);
-                    } catch (ParseException e) {
-                        e.printStackTrace();
-                    }
-                    Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
-                    Long t = (date.getTime() - da1.getTime()) / 24 / 60 / 60 / 1000;
-                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    String current = dateFormat.format(new Date());
-                    MessageCenterPo messageCenter = new MessageCenterPo();
-                    //推送信息中心-账户通知
-                    if (s > 15) {
-                        if (t == 7) {
-                            messageCenter.setShopId(null);
-                            messageCenter.setClubId(Integer.parseInt(user.getClubID()));
-                            messageCenter.setUserType(1);
-                            messageCenter.setMessageType(4);
-                            messageCenter.setCouponType(2);
-                            messageCenter.setCouponMessageType(3);
-                            messageCenter.setContent("7天");
-                            messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-                            messageCenter.setTime(current);
-                            messageCenterMapper.addMessageCenter(messageCenter);
-                            String content = "您有" + coupon.getCouponAmount() + "元优惠券将于7日后过期,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-                            String result = SmsUtil.sendSms(3, contractMobile, 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() + "发送失败");
-                            }
-                        }
-                    }
-                }
-            });
+        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);
+        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());
         });
     }
 
+
     /**
-     * 每天10点判断
+     * 优惠券领取后没有使用,在失效日当天,上午10推送给领取了该优惠券的用户(谁领的给谁发短信)
+     *
+     * 短信模板:【采美365】您有100元优惠券今日过期,快戳采美网站链接www.caimei365.com/M2Tr98CG
+     * 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。
      */
     @Scheduled(cron = "0 0 10 * * ?")
 //    @Scheduled(cron = "0 0/2 * * * ?")
     private void Timeto() {
-        log.info(">>>>>1天后下架");
-        List<Integer> userIds = messageCenterMapper.CouponUserId();
-        userIds.forEach(userId -> {
-            String contractMobile = messageCenterMapper.contractMobile(userId);
-            List<CmCouponPo> coupons = messageCenterMapper.CouponLists(userId);
-            coupons.forEach(coupon -> {
-                if (userId != null) {
-                    CmUserPo user = messageCenterMapper.clubLists(userId);
-                    Date d = new Date();
-                    //1.日期格式
-                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-                    String endTime = sdf.format(coupon.getEndDate());
-                    //2.某天的日期
-                    Date da1 = null;
-                    try {
-                        da1 = sdf.parse(endTime);
-                    } catch (ParseException e) {
-                        e.printStackTrace();
-                    }
-                    Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
-                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    String current = dateFormat.format(new Date());
-                    MessageCenterPo messageCenter = new MessageCenterPo();
-                    //推送信息中心-账户通知
-                    if (s == 1) {
-                        messageCenter.setShopId(null);
-                        messageCenter.setClubId(Integer.parseInt(user.getClubID()));
-                        messageCenter.setUserType(1);
-                        messageCenter.setMessageType(4);
-                        messageCenter.setCouponType(2);
-                        messageCenter.setCouponMessageType(3);
-                        messageCenter.setContent("今日");
-                        messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-                        messageCenter.setTime(current);
-                        messageCenterMapper.addMessageCenter(messageCenter);
-                        String content = "您有" + coupon.getCouponAmount() + "元优惠券今日过期,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-                        String result = SmsUtil.sendSms(3, contractMobile, 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() + "发送失败");
-                        }
-                    }
-
-                }
-            });
+        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);
+        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());
         });
     }
 
     //    @Scheduled(cron = "0 0/2 * * * ?")
     @Scheduled(cron = "0 0 15 * * ?")
     private void Timeth() {
-        log.info(">>>>>三天后下架");
-        List<Integer> userIds = messageCenterMapper.CouponUserId();
-        userIds.forEach(userId -> {
-            String contractMobile = messageCenterMapper.contractMobile(userId);
-            List<CmCouponPo> coupons = messageCenterMapper.CouponLists(userId);
-            coupons.forEach(coupon -> {
-                if (userId != null) {
-                    CmUserPo user = messageCenterMapper.clubLists(userId);
-                    Date date = new Date();
-                    Date d = coupon.getStartDate();
-                    //1.日期格式
-                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-                    String endTime = sdf.format(coupon.getEndDate());
-                    //2.某天的日期
-                    Date da1 = null;
-                    try {
-                        da1 = sdf.parse(endTime);
-                    } catch (ParseException e) {
-                        e.printStackTrace();
-                    }
-                    Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
-                    Long t = (date.getTime() - da1.getTime()) / 24 / 60 / 60 / 1000;
-                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    String current = dateFormat.format(new Date());
-                    MessageCenterPo messageCenter = new MessageCenterPo();
-                    //推送信息中心-账户通知
-                    if (t == 3) {
-                        messageCenter.setShopId(null);
-                        messageCenter.setClubId(Integer.parseInt(user.getClubID()));
-                        messageCenter.setUserType(1);
-                        messageCenter.setMessageType(4);
-                        messageCenter.setCouponType(2);
-                        messageCenter.setCouponMessageType(3);
-                        messageCenter.setContent("3天");
-                        messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
-                        messageCenter.setTime(current);
-                        messageCenterMapper.addMessageCenter(messageCenter);
-                        String content = "您有" + coupon.getCouponAmount() + "元优惠券3日后过期,快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
-                        String result = SmsUtil.sendSms(3, contractMobile, 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() + "发送失败");
-                        }
-                    }
-
-                }
-            });
+        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);
+        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());
         });
     }
 

+ 20 - 35
src/main/java/com/caimei365/tools/task/SuperVipTask.java

@@ -52,36 +52,28 @@ public class SuperVipTask {
             MessageCenterPo messageCenter = new MessageCenterPo();
             SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             String current = dateFormat.format(new Date());
+            messageCenter.userType(1).messageType(2).accountType(3).time(current);
             //今日到期
-            String message = "您的超级会员将于今日后到期,到期后将无法享受专属会员权益,快戳采美网站链接www.caimei365.com 或微信搜索“采美采购商城”小程序登录采美平台续费吧。关注公众号“采美365网”可获取更多优惠和精彩资讯。退订回T";
+            String message = "您的超级会员将于今日后到期,到期后将无法享受专属会员权益,快戳采美网站链接www.caimei365.com 或微信" +
+                    "搜索“采美采购商城”小程序登录采美平台续费吧。关注公众号“采美365网”可获取更多优惠和精彩资讯。退订回T";
             List<SuperVipPo> vip = baseMapper.findVip(startTime, endTime);
             if (vip != null && vip.size() > 0) {
-                vip.forEach(
-                        v -> {
-                            String mobile = baseMapper.findMobile(v.getUserId());
-                            String result = SmsUtil.sendSms(3, mobile, message);
-                            JSONObject json = (JSONObject) JSONObject.parse(result);
-                            log.info("发送结果:" + result + ",短信内容:" + message);
-                            if (null != json && json.getInteger("code") == 0) {
-                                log.info(mobile + "发送成功");
-                            } else {
-                                log.error(mobile + "发送失败");
-                            }
-                            //推送信息中心-账户通知
-                            Integer clubId = messageCenterMapper.clubIdCule(v.getUserId());
-                            messageCenter.setShopId(null);
-                            messageCenter.setClubId(clubId);
-                            messageCenter.setUserType(1);
-                            messageCenter.setMessageType(2);
-                            messageCenter.setAccountType(3);
-                            messageCenter.setContent("今日后");
-                            messageCenter.setTime(current);
-                            messageCenterMapper.addMessageCenter(messageCenter);
-
-                        });
+                vip.forEach(v -> {
+                    String mobile = baseMapper.findMobile(v.getUserId());
+                    String result = SmsUtil.sendSms(3, mobile, message);
+                    JSONObject json = (JSONObject) JSONObject.parse(result);
+                    log.info("发送结果:" + result + ",短信内容:" + message);
+                    if (null != json && json.getInteger("code") == 0) {
+                        log.info(mobile + "发送成功");
+                    } else {
+                        log.error(mobile + "发送失败");
+                    }
+                    //推送信息中心-账户通知
+                    Integer clubId = messageCenterMapper.clubIdCule(v.getUserId());
+                    messageCenter.clubId(clubId).content("今日后");
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                });
             }
-
-
             //7天后到期
             Calendar cal = Calendar.getInstance();
             cal.setTime(startTime);
@@ -93,8 +85,7 @@ public class SuperVipTask {
             String mes = "您的超级会员将于7日后到期,到期后将无法享受专属会员权益,快戳采美网站链接www.caimei365.com或微信搜索“采美采购商城”小程序登录采美平台续费吧。关注公众号“采美365网”可获取更多优惠和精彩资讯。退订回T";
             List<SuperVipPo> vips = baseMapper.findVip(startTime7, endTime7);
             if (vips != null && vips.size() > 0) {
-                vips.forEach(
-                        v -> {
+                vips.forEach(v -> {
                             String mobile = baseMapper.findMobile(v.getUserId());
                             String result = SmsUtil.sendSms(3, mobile, mes);
                             JSONObject json = (JSONObject) JSONObject.parse(result);
@@ -105,13 +96,7 @@ public class SuperVipTask {
                                 log.error(mobile + "发送失败");
                             }
                             Integer clubId = messageCenterMapper.clubIdCule(v.getUserId());
-                            messageCenter.setShopId(null);
-                            messageCenter.setClubId(clubId);
-                            messageCenter.setUserType(1);
-                            messageCenter.setMessageType(2);
-                            messageCenter.setAccountType(3);
-                            messageCenter.setContent("7日后");
-                            messageCenter.setTime(current);
+                            messageCenter.clubId(clubId).content("7日后");
                             messageCenterMapper.addMessageCenter(messageCenter);
                         }
                 );

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

@@ -307,4 +307,12 @@
         LEFT JOIN cm_discern_receipt cdr ON cr.receiptId = cdr.id
         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
+        WHERE DATE_ADD(NOW(),INTERVAL 7 DAY) <![CDATA[  <  ]]> IF(cc.useTimeFlag=1,cc.endDate,DATE_ADD(ccc.createDate,INTERVAL cc.usePeriod DAY))
+    </select>
 </mapper>