Browse Source

Merge remote-tracking branch 'origin/developerA' into developer

zhijiezhao 2 years ago
parent
commit
f95690b8e6
31 changed files with 2021 additions and 972 deletions
  1. 11 0
      pom.xml
  2. 81 0
      src/main/java/com/caimei365/tools/controller/MessageApi.java
  3. 12 12
      src/main/java/com/caimei365/tools/controller/RocketMqApi.java
  4. 34 0
      src/main/java/com/caimei365/tools/listener/MessageLIne.java
  5. 13 10
      src/main/java/com/caimei365/tools/mapper/MessageCenterMapper.java
  6. 57 0
      src/main/java/com/caimei365/tools/model/dto/MessageDto.java
  7. 74 0
      src/main/java/com/caimei365/tools/model/dto/message/EmailMessage.java
  8. 306 0
      src/main/java/com/caimei365/tools/model/dto/message/InsideMessage.java
  9. 44 0
      src/main/java/com/caimei365/tools/model/dto/message/MessageModel.java
  10. 66 0
      src/main/java/com/caimei365/tools/model/dto/message/MqInfo.java
  11. 53 0
      src/main/java/com/caimei365/tools/model/dto/message/SmsMessage.java
  12. 232 0
      src/main/java/com/caimei365/tools/model/dto/message/WechatTemplateMessage.java
  13. 42 0
      src/main/java/com/caimei365/tools/model/dto/message/enums/MessageType.java
  14. 37 0
      src/main/java/com/caimei365/tools/model/dto/message/enums/SmsMessageType.java
  15. 4 0
      src/main/java/com/caimei365/tools/model/po/CmCouponPo.java
  16. 5 2
      src/main/java/com/caimei365/tools/model/po/MessageCenterPo.java
  17. 40 0
      src/main/java/com/caimei365/tools/model/po/Notification.java
  18. 22 0
      src/main/java/com/caimei365/tools/model/po/QualificationPo.java
  19. 22 0
      src/main/java/com/caimei365/tools/model/po/ShopReceiptVo.java
  20. 8 0
      src/main/java/com/caimei365/tools/service/MessageSender.java
  21. 100 0
      src/main/java/com/caimei365/tools/service/impl/MessageSenderImpl.java
  22. 10 10
      src/main/java/com/caimei365/tools/service/impl/RocketMqServiceImpl.java
  23. 126 126
      src/main/java/com/caimei365/tools/task/CouponTask.java
  24. 196 531
      src/main/java/com/caimei365/tools/task/ShopMessTask.java
  25. 20 35
      src/main/java/com/caimei365/tools/task/SuperVipTask.java
  26. 40 0
      src/main/java/com/caimei365/tools/utils/EmailUtil.java
  27. 20 0
      src/main/java/com/caimei365/tools/utils/InsideMessageUtil.java
  28. 39 0
      src/main/java/com/caimei365/tools/utils/WeChatUtil.java
  29. 12 0
      src/main/resources/bootstrap.yml
  30. 175 126
      src/main/resources/mapper/MessageCenter.xml
  31. 120 120
      src/test/java/com/caimei365/tools/ToolsApplicationTests.java

+ 11 - 0
pom.xml

@@ -30,6 +30,17 @@
     </dependencyManagement>
 
     <dependencies>
+        <!--实体类校验注解-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+        <!--邮件依赖-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-mail</artifactId>
+        </dependency>
+
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>

+ 81 - 0
src/main/java/com/caimei365/tools/controller/MessageApi.java

@@ -0,0 +1,81 @@
+package com.caimei365.tools.controller;
+
+import com.caimei365.tools.model.ResponseJson;
+import com.caimei365.tools.model.dto.message.*;
+import com.caimei365.tools.model.dto.message.enums.MessageType;
+import com.caimei365.tools.service.MessageSender;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+
+@Api(tags = "消息工具")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/tools")
+public class MessageApi {
+
+    private final MessageSender messageSender;
+
+    /**
+     * 发送消息
+     *
+     * @param messageModel {
+     *                     信息类型枚举类  code;
+     *                     mq消息参数     mqInfo;
+     *                     消息体        info;
+     *                     }
+     * @return
+     */
+    @ApiOperation("综合消息工具")
+    @PostMapping("/message/send")
+    public ResponseJson sendCommonMessage(MessageModel messageModel) {
+        messageSender.messageSend(messageModel);
+        return ResponseJson.success();
+    }
+
+    @ApiOperation("综合消息工具测试")
+    @GetMapping("/message/send/try")
+    public ResponseJson sendCommonMessagetry(Integer status) {
+        //    WECHAT_TEMPLATE_MESSAGE(1, "微信模板消息"),
+        //    WEB_INSIDE_MESSAGE(2, "站内消息"),
+        //    EMAILS(3, "邮件"),
+        //    SYS_MESSAGE(4, "短信");
+        MessageModel messageModel = new MessageModel();
+        if (4 == status) {
+            MqInfo messageLine = new MqInfo().topic("MessageLine").async(1).delay(4);
+            SmsMessage smsMessage = new SmsMessage().type(3).mobile("15827317748").smsMessageContent("亲,好久没登陆采美了," +
+                    "近期在找新项目吗?采美新品橱窗有多款院线产品和仪器,现在登陆采美https://www.caimei365.com/,可获一张包邮券!退订回T");
+            messageModel = messageModel.code(MessageType.SYS_MESSAGE).mqInfo(messageLine).info(smsMessage);
+        }
+        if (3 == status) {
+            EmailMessage subject = new EmailMessage().emailMessageContent("测试接口").cc("z525282777@163.com").receiverAddress("525282777@qq.com").subject("接口测试");
+            messageModel = new MessageModel().code(MessageType.EMAILS).info(subject);
+        }
+        if (2 == status) {
+            InsideMessage sud = new InsideMessage().content("测工具").clubId(1111).productId(1111);
+            MqInfo messageLine = new MqInfo().topic("MessageLine").delay(3).async(0);
+            messageModel = messageModel.code(MessageType.WEB_INSIDE_MESSAGE).mqInfo(messageLine).info(sud);
+        }
+        if (1 == status) {
+            WechatTemplateMessage wechatTemplateMessage = new WechatTemplateMessage();
+            ArrayList<String> keyWords = new ArrayList<>();
+            keyWords.add("我测一下");
+            keyWords.add("110");
+            keyWords.add("北京天安门广场");
+            keyWords.add("2022-10-20");
+            wechatTemplateMessage = wechatTemplateMessage.url("https://www.caimei365.com/").templateId("o1nMAIsHAFr0VOu0qEbI1rEFDS14hl40UXbt52I5row")
+                    .openId("o9nzn5wFDZ_WjNo1-SfhqbKNXr4A").appid("wxf3cd4ae0cdd11c36").pagePath("pages/seller/club/list?type=wechat")
+                    .keyWords(keyWords).first("你有一个新机构用户,请及时跟进").remark("点击查看详情,了解更多客户信息。");
+            MqInfo messageLine = new MqInfo().topic("MessageLine").delay(3).async(0);
+            messageModel = messageModel.code(MessageType.WECHAT_TEMPLATE_MESSAGE).info(wechatTemplateMessage).mqInfo(messageLine);
+        }
+        messageSender.messageSend(messageModel);
+        return ResponseJson.success();
+    }
+}

+ 12 - 12
src/main/java/com/caimei365/tools/controller/RocketMqApi.java

@@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author : Charles
  * @date : 2021/6/17
  */
-@Api(tags="MQ消息中间件API")
+@Api(tags = "MQ消息中间件API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/tools")
@@ -33,23 +33,23 @@ public class RocketMqApi {
      * 发送消息
      *
      * @param messageDto {
-     *                    topic    消息主题
-     *                    content  消息内容
-     *                    tag      消息标签(可选)
-     *                    sort     有序消息(可选):1是,0否
-     *                    async    异步消息(可选):1是,0否
-     *                    oneway   单向消息(可选):1是,0否
-     *                    delay    延时消息等级(可选):1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
-     *                  }
-     Posteturn SendResult
+     *                   topic    消息主题
+     *                   content  消息内容
+     *                   tag      消息标签(可选)
+     *                   sort     有序消息(可选):1是,0否
+     *                   async    异步消息(可选):1是,0否
+     *                   oneway   单向消息(可选):1是,0否
+     *                   delay    延时消息等级(可选):1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
+     *                   }
+     *                   Posteturn SendResult
      */
     @ApiOperation("发送消息")
     @PostMapping("/mq/send")
     public ResponseJson<SendResult> sendCommonMessage(MessageDto messageDto) {
-        if (StringUtils.isEmpty(messageDto.getTopic())) {
+        if (StringUtils.isEmpty(messageDto.topic())) {
             return ResponseJson.error("消息主题不能为空!", null);
         }
-        if (StringUtils.isEmpty(messageDto.getContent())) {
+        if (StringUtils.isEmpty(messageDto.content())) {
             return ResponseJson.error("消息内容不能为空!", null);
         }
         SendResult sendResult = rocketMqService.sendCommonMessage(messageDto);

+ 34 - 0
src/main/java/com/caimei365/tools/listener/MessageLIne.java

@@ -0,0 +1,34 @@
+package com.caimei365.tools.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei365.tools.model.dto.message.MessageModel;
+import com.caimei365.tools.model.dto.message.MqInfo;
+import com.caimei365.tools.service.MessageSender;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
+import org.apache.rocketmq.spring.core.RocketMQListener;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Component
+@RocketMQMessageListener(
+        topic = "MessageLine",
+        // messageModel = MessageModel.BROADCASTING,//指定为广播消费
+        // consumeMode = ConsumeMode.ORDERLY, // 指定消费模式为顺序消费,消费的顺序也和发送顺序一致
+        // selectorType = SelectorType.TAG,// 如果我们的生产者指定了Tag,但是消费者的selectorExpression没有设置,即用默认的“*”,那么这个消费者也会消费到
+        // selectorExpression = "tag",     // 指定了tag后,发送的消息如果不带tag,将会消费不到
+        consumerGroup = "message_group")
+public class MessageLIne implements RocketMQListener<String> {
+    @Resource
+    private MessageSender messageSender;
+
+    @Override
+    public void onMessage(String model) {
+        MessageModel mod = JSONObject.parseObject(model,MessageModel.class);
+        //重置mq参数
+        mod.mqInfo(new MqInfo());
+        messageSender.messageSend(mod);
+    }
+}

+ 13 - 10
src/main/java/com/caimei365/tools/mapper/MessageCenterMapper.java

@@ -1,8 +1,7 @@
 package com.caimei365.tools.mapper;
 
-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.dto.message.InsideMessage;
+import com.caimei365.tools.model.po.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -26,10 +25,6 @@ public interface MessageCenterMapper {
 
     List<Integer> receiptShopID();
 
-//    UserVo clubList(Integer userId);
-//
-//    CouponVo CouponList(Integer couponType);
-
     Integer MessageCount(Integer userType,Integer messageType,Integer commonId);
 
     /**
@@ -49,13 +44,11 @@ public interface MessageCenterMapper {
      */
     Integer listingfeeExpire(Integer shopID);
 
-//    List<MessageCenter> MessageList(Integer userType,Integer messageType,Integer commonId);
-
     String contractMobile(Integer clubID);
 
     String contractMobiles(Integer ShopID);
 
-    String getOpenidListByPermission(String unionId);
+    String getOpenidListByPermission(Integer shopId);
 
     String FromUnionId(Integer userID);
 
@@ -96,4 +89,14 @@ public interface MessageCenterMapper {
     List<CmCouponPo> CouponLists(Integer userID);
 
     List<Integer> CouponUserId();
+
+    void sendInsideMessage(InsideMessage insideMessage);
+
+    List<ShopReceiptVo> findExpireShopId(Integer day);
+
+    List<CmCouponPo> findOutTimeCoupons(Integer day);
+
+    void addNotification(Notification notification);
+
+    List<QualificationPo> findOutTimeQualification(Integer day);
 }

+ 57 - 0
src/main/java/com/caimei365/tools/model/dto/MessageDto.java

@@ -3,6 +3,7 @@ package com.caimei365.tools.model.dto;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.experimental.Accessors;
 
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
@@ -15,6 +16,7 @@ import java.io.Serializable;
  */
 @ApiModel("发送消息接收参数")
 @Data
+@Accessors(fluent = true)
 public class MessageDto implements Serializable {
     private static final long serialVersionUID = 1L;
     /**
@@ -55,4 +57,59 @@ public class MessageDto implements Serializable {
     @ApiModelProperty("延时消息(可选),延时等级:1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h")
     private Integer delay;
 
+    public String getTopic() {
+        return topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public Integer getAsync() {
+        return async;
+    }
+
+    public void setAsync(Integer async) {
+        this.async = async;
+    }
+
+    public Integer getOneway() {
+        return oneway;
+    }
+
+    public void setOneway(Integer oneway) {
+        this.oneway = oneway;
+    }
+
+    public Integer getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Integer delay) {
+        this.delay = delay;
+    }
 }

+ 74 - 0
src/main/java/com/caimei365/tools/model/dto/message/EmailMessage.java

@@ -0,0 +1,74 @@
+package com.caimei365.tools.model.dto.message;
+
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+@ToString
+public class EmailMessage {
+    /**
+     * 邮件主题
+     */
+    @NotNull
+    private String subject;
+    /**
+     * 收件人地址
+     */
+    @NotNull
+    @Email
+    private String receiverAddress;
+    /**
+     * 内容
+     */
+    @NotNull
+    private String emailMessageContent;
+    /**
+     * 抄送地址
+     */
+    private String[] cc;
+
+    public EmailMessage cc(String cc) {
+        this.cc = new String[]{cc};
+        return this;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+    public String getReceiverAddress() {
+        return receiverAddress;
+    }
+
+    public void setReceiverAddress(String receiverAddress) {
+        this.receiverAddress = receiverAddress;
+    }
+
+    public String getEmailMessageContent() {
+        return emailMessageContent;
+    }
+
+    public void setEmailMessageContent(String emailMessageContent) {
+        this.emailMessageContent = emailMessageContent;
+    }
+
+    public String[] getCc() {
+        return cc;
+    }
+
+    public void setCc(String[] cc) {
+        this.cc = cc;
+    }
+}

+ 306 - 0
src/main/java/com/caimei365/tools/model/dto/message/InsideMessage.java

@@ -0,0 +1,306 @@
+package com.caimei365.tools.model.dto.message;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @author Administrator
+ * 站内信model
+ */
+@Data
+@Accessors(fluent = true)
+public class InsideMessage implements Serializable {
+
+    /**
+     * 消息id
+     */
+    private Integer id;
+    /**
+     * 供应商id
+     */
+    private Integer shopId;
+    /**
+     * 机构id
+     */
+    private Integer clubId;
+    /**
+     * 订单ID
+     */
+    private Integer orderId;
+    /**
+     * 用户类型1.机构2.供应商
+     */
+    private Integer userType;
+    /**
+     * 消息类型1.交易物流2.账户通知3.服务通知4.优惠促销
+     */
+    private Integer messageType;
+    /**
+     * 消息内容
+     */
+    private String content;
+    /**
+     * 操作完成时间
+     */
+    private String time;
+    /**
+     * 账户通知类型 1.注册成功通知 2.购买超级会员成功 3.超级会员到期提醒 4.超级会员到期提醒 5.升级资质机构成功 6.升级资质机构失败 7.成为机构运营人员通知
+     */
+    private Integer accountType;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponType;
+    /**
+     * 优惠券金额
+     */
+    private Double couponFee;
+    /**
+     * 主图
+     */
+    private String mainImage;
+    /**
+     * 是否能走线上支付 0可以 1不可以 只能线下
+     */
+    private Integer onlinePayFlag;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 供应商消息类型 1,账号审核通知,2.成为公司运营人员通知,3.商品上架审核通知,4.新品展示审核通知,5.上架费到期通知 6.商品资质到期通知
+     */
+    private Integer shopMessType;
+    /**
+     * 供应商服务消息类型 1.上架费
+     */
+    private Integer shopTieredType;
+    /**
+     * 交易物流1.下单成功通知  2.订单支付完成 3.退款/货成功通知 4.订单取消通知 5.订单发货通知 6.自动收货通知
+     */
+    private Integer orderMessageType;
+    /**
+     * 0.未读 , 1.已读
+     */
+    private Integer saved;
+    /**
+     * 优惠券类型 1.优惠券待领取通知 2.优惠券过期通知
+     */
+    private Integer couponMessageType;
+    /**
+     * 商品记录数
+     */
+    private Integer productCount;
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private Integer refundType;
+
+    /**
+     * 订单状态
+     */
+    private Integer status;
+    /**
+     * 商品ID
+     */
+    private Integer productId;
+
+    /**
+     * 供应商公司名称
+     */
+    private String shopName;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getClubId() {
+        return clubId;
+    }
+
+    public void setClubId(Integer clubId) {
+        this.clubId = clubId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public Integer getMessageType() {
+        return messageType;
+    }
+
+    public void setMessageType(Integer messageType) {
+        this.messageType = messageType;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getTime() {
+        return time;
+    }
+
+    public void setTime(String time) {
+        this.time = time;
+    }
+
+    public Integer getAccountType() {
+        return accountType;
+    }
+
+    public void setAccountType(Integer accountType) {
+        this.accountType = accountType;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public Double getCouponFee() {
+        return couponFee;
+    }
+
+    public void setCouponFee(Double couponFee) {
+        this.couponFee = couponFee;
+    }
+
+    public String getMainImage() {
+        return mainImage;
+    }
+
+    public void setMainImage(String mainImage) {
+        this.mainImage = mainImage;
+    }
+
+    public Integer getOnlinePayFlag() {
+        return onlinePayFlag;
+    }
+
+    public void setOnlinePayFlag(Integer onlinePayFlag) {
+        this.onlinePayFlag = onlinePayFlag;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public Integer getShopMessType() {
+        return shopMessType;
+    }
+
+    public void setShopMessType(Integer shopMessType) {
+        this.shopMessType = shopMessType;
+    }
+
+    public Integer getShopTieredType() {
+        return shopTieredType;
+    }
+
+    public void setShopTieredType(Integer shopTieredType) {
+        this.shopTieredType = shopTieredType;
+    }
+
+    public Integer getOrderMessageType() {
+        return orderMessageType;
+    }
+
+    public void setOrderMessageType(Integer orderMessageType) {
+        this.orderMessageType = orderMessageType;
+    }
+
+    public Integer getSaved() {
+        return saved;
+    }
+
+    public void setSaved(Integer saved) {
+        this.saved = saved;
+    }
+
+    public Integer getCouponMessageType() {
+        return couponMessageType;
+    }
+
+    public void setCouponMessageType(Integer couponMessageType) {
+        this.couponMessageType = couponMessageType;
+    }
+
+    public Integer getProductCount() {
+        return productCount;
+    }
+
+    public void setProductCount(Integer productCount) {
+        this.productCount = productCount;
+    }
+
+    public Integer getRefundType() {
+        return refundType;
+    }
+
+    public void setRefundType(Integer refundType) {
+        this.refundType = refundType;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+}

+ 44 - 0
src/main/java/com/caimei365/tools/model/dto/message/MessageModel.java

@@ -0,0 +1,44 @@
+package com.caimei365.tools.model.dto.message;
+
+import com.caimei365.tools.model.dto.message.enums.MessageType;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * @author Administrator
+ */
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class MessageModel<T> {
+    private MessageType code;
+
+    private MqInfo mqInfo;
+
+    private T info;
+
+    public MessageType getCode() {
+        return code;
+    }
+
+    public void setCode(MessageType code) {
+        this.code = code;
+    }
+
+    public MqInfo getMqInfo() {
+        return mqInfo;
+    }
+
+    public void setMqInfo(MqInfo mqInfo) {
+        this.mqInfo = mqInfo;
+    }
+
+    public T getInfo() {
+        return info;
+    }
+
+    public void setInfo(T info) {
+        this.info = info;
+    }
+}

+ 66 - 0
src/main/java/com/caimei365/tools/model/dto/message/MqInfo.java

@@ -0,0 +1,66 @@
+package com.caimei365.tools.model.dto.message;
+
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.hibernate.validator.constraints.Range;
+
+
+
+@Data
+@Accessors(fluent = true)
+public class MqInfo {
+    /**
+     * 异步消息(可选):1是,0否
+     */
+    @Range(min = 0, max = 1)
+    private Integer async;
+
+    /**
+     * 1-18,0否,对应时间依次:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h
+     */
+    @Range(min = 0, max = 18)
+    private Integer delay;
+
+    /**
+     * 消息主题
+     */
+    private String topic;
+
+    /**
+     * 消息标签(可选)
+     */
+    private String tag;
+
+    public Integer getAsync() {
+        return async;
+    }
+
+    public void setAsync(Integer async) {
+        this.async = async;
+    }
+
+    public Integer getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Integer delay) {
+        this.delay = delay;
+    }
+
+    public String getTopic() {
+        return topic;
+    }
+
+    public void setTopic(String topic) {
+        this.topic = topic;
+    }
+
+    public String getTag() {
+        return tag;
+    }
+
+    public void setTag(String tag) {
+        this.tag = tag;
+    }
+}

+ 53 - 0
src/main/java/com/caimei365/tools/model/dto/message/SmsMessage.java

@@ -0,0 +1,53 @@
+package com.caimei365.tools.model.dto.message;
+
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@Accessors(fluent = true)
+@NoArgsConstructor
+public class SmsMessage {
+    /**
+     * 短信类型:1通知短信,2验证码短信,3营销短信
+     */
+    @NotNull
+    private Integer type;
+    /**
+     *  手机号   接收的手机号;多个手机号使用英文逗号间隔,一次不要超过1000个;
+     */
+    @NotNull
+    private String mobile ;
+    /**
+     * 短信内容
+     */
+    @NotNull
+    private String smsMessageContent;
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getSmsMessageContent() {
+        return smsMessageContent;
+    }
+
+    public void setSmsMessageContent(String smsMessageContent) {
+        this.smsMessageContent = smsMessageContent;
+    }
+}

+ 232 - 0
src/main/java/com/caimei365/tools/model/dto/message/WechatTemplateMessage.java

@@ -0,0 +1,232 @@
+package com.caimei365.tools.model.dto.message;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@Accessors(fluent = true)
+@AllArgsConstructor
+@NoArgsConstructor
+public class WechatTemplateMessage {
+    /**
+     *  {
+     *            "touser":"OPENID",
+     *            "template_id":"ngqIpbwh8bUfcSsECmogfXcV14J0tQlEpBO27izEYtY",
+     *            "url":"http://weixin.qq.com/download",
+     *            "miniprogram":{
+     *              "appid":"xiaochengxuappid12345",
+     *              "pagepath":"index?foo=bar"
+     *            },
+     *            "client_msg_id":"MSG_000001",
+     *            "data":{
+     *                    "first": {
+     *                        "value":"恭喜你购买成功!",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword1":{
+     *                        "value":"巧克力",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword2": {
+     *                        "value":"39.8元",
+     *                        "color":"#173177"
+     *                    },
+     *                    "keyword3": {
+     *                        "value":"2014年9月22日",
+     *                        "color":"#173177"
+     *                    },
+     *                    "remark":{
+     *                        "value":"欢迎再次购买!",
+     *                        "color":"#173177"
+     *                    }
+     *            }
+     *        }
+     */
+
+    /**
+     * 推送内容抬头
+     */
+    @NotNull
+    private JSONObject first;
+    /**
+     * 推送内容
+     */
+    @NotNull
+    private List<JSONObject> keyWords;
+    /**
+     * 推送内容页尾
+     */
+    @NotNull
+    private JSONObject remark;
+    /**
+     * 所需跳转到的小程序appid(该小程序 appid 必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏)
+     */
+    private String appid;
+
+    /**
+     * 接收者openid
+     */
+    @NotNull
+    private String openId;
+    /**
+     * 模板ID
+     */
+    @NotNull
+    private String templateId;
+    /**
+     * 模板跳转链接
+     */
+    private String url;
+    /**
+     * 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏
+     */
+    private String pagePath;
+
+
+    /**
+     * 跳小程序所需数据,不需跳小程序可不用传该数据
+     */
+    private JSONObject miniProgram;
+    /**
+     * 模板数据
+     */
+    private JSONObject data;
+    private JSONObject json;
+
+    public JSONObject getFirst() {
+        return first;
+    }
+
+    public void setFirst(JSONObject first) {
+        this.first = first;
+    }
+
+    public List<JSONObject> getKeyWords() {
+        return keyWords;
+    }
+
+
+    public JSONObject getRemark() {
+        return remark;
+    }
+
+    public void setRemark(JSONObject remark) {
+        this.remark = remark;
+    }
+
+    public String getAppid() {
+        return appid;
+    }
+
+    public void setAppid(String appid) {
+        this.appid = appid;
+    }
+
+    public String getOpenId() {
+        return openId;
+    }
+
+    public void setOpenId(String openId) {
+        this.openId = openId;
+    }
+
+    public String getTemplateId() {
+        return templateId;
+    }
+
+    public void setTemplateId(String templateId) {
+        this.templateId = templateId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getPagePath() {
+        return pagePath;
+    }
+
+    public void setPagePath(String pagePath) {
+        this.pagePath = pagePath;
+    }
+
+    public WechatTemplateMessage first(String title) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("value", title);
+        this.setFirst(jsonObject);
+        return this;
+    }
+
+    public WechatTemplateMessage keyWords(List<String> words) {
+        List<JSONObject> collect = new ArrayList<>();
+        words.forEach(w -> {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("value", w);
+            collect.add(jsonObject);
+        });
+        this.setKeyWords(collect);
+        return this;
+    }
+
+    public void setKeyWords(List<JSONObject> keyWords) {
+        this.keyWords = keyWords;
+    }
+
+    public WechatTemplateMessage remark(String r) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("value", r);
+        this.setRemark(jsonObject);
+        return this;
+    }
+
+    public JSONObject getMiniProgram() {
+        return miniProgram;
+    }
+
+    private void setMiniProgram(JSONObject miniProgram) {
+        this.miniProgram = miniProgram;
+    }
+
+    private JSONObject getData() {
+        return data;
+    }
+
+    private void setData(JSONObject data) {
+        this.data = data;
+    }
+
+    public String getJson() {
+        JSONObject json = new JSONObject();
+        json.put("touser", openId);
+        json.put("template_id", templateId);
+        json.put("url", url);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", appid);
+        miniProgram.put("pagepath", pagePath);
+        json.put("miniprogram", miniProgram);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        if (!keyWords.isEmpty()) {
+            for (int i = 0; i < keyWords.size(); i++) {
+                String key = "keyword" + (i + 1);
+                data.put(key, keyWords.get(i));
+            }
+        }
+        data.put("remark", remark);
+        json.put("data", data);
+        return json.toJSONString();
+    }
+}

+ 42 - 0
src/main/java/com/caimei365/tools/model/dto/message/enums/MessageType.java

@@ -0,0 +1,42 @@
+package com.caimei365.tools.model.dto.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.ToString;
+
+/**
+ * @author Administrator
+ */
+
+@ToString
+@AllArgsConstructor
+public enum MessageType {
+    /**
+     * 1.微信模板消息
+     * 2.站内消息
+     * 3.邮件
+     * 4.短信
+     */
+    WECHAT_TEMPLATE_MESSAGE(1, "微信模板消息"),
+    WEB_INSIDE_MESSAGE(2, "站内消息"),
+    EMAILS(3, "邮件"),
+    SYS_MESSAGE(4, "短信");
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

+ 37 - 0
src/main/java/com/caimei365/tools/model/dto/message/enums/SmsMessageType.java

@@ -0,0 +1,37 @@
+package com.caimei365.tools.model.dto.message.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.ToString;
+
+@ToString
+@AllArgsConstructor
+public enum SmsMessageType {
+    /**
+     * 1通知短信
+     * 2验证码短信
+     * 3营销短信
+     */
+    NOTIFICATION_SMS(1, "通知短信"),
+    CHECK_CODE_SMS(2, "验证码短信"),
+    SALES_SMS(3, "营销短信");
+
+    private Integer code;
+    private String description;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}

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

@@ -1,5 +1,6 @@
 package com.caimei365.tools.model.po;
 import lombok.Data;
+import lombok.ToString;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
@@ -13,6 +14,7 @@ import java.util.List;
  * @version 2021-08-02
  */
 @Data
+@ToString
 public class CmCouponPo implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -50,6 +52,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;    // 使用截止时间

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

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

+ 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 productId;
+    /**
+     * 供应商ID
+     */
+    private String shopId;
+    /**
+     *     0.未读 , 1.已读
+     */
+    private Integer saved;
+    /**
+     * 隐藏状态0显示1隐藏
+     */
+    private Integer hide;
+}

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

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

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

@@ -0,0 +1,22 @@
+package com.caimei365.tools.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class ShopReceiptVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 生效时间
+     */
+    private String validityDate;
+    /**
+     * 到期时间
+     */
+    private String dateStrings;
+    private Integer shopId;
+    private String shopName;
+    private Double receiptAmount;
+}

+ 8 - 0
src/main/java/com/caimei365/tools/service/MessageSender.java

@@ -0,0 +1,8 @@
+package com.caimei365.tools.service;
+
+
+import com.caimei365.tools.model.dto.message.MessageModel;
+
+public interface MessageSender {
+    void messageSend(MessageModel model);
+}

+ 100 - 0
src/main/java/com/caimei365/tools/service/impl/MessageSenderImpl.java

@@ -0,0 +1,100 @@
+package com.caimei365.tools.service.impl;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei365.tools.model.dto.MessageDto;
+import com.caimei365.tools.model.dto.message.*;
+import com.caimei365.tools.model.dto.message.enums.MessageType;
+import com.caimei365.tools.service.MessageSender;
+import com.caimei365.tools.service.RocketMqService;
+import com.caimei365.tools.utils.EmailUtil;
+import com.caimei365.tools.utils.InsideMessageUtil;
+import com.caimei365.tools.utils.SmsUtil;
+import com.caimei365.tools.utils.WeChatUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+@Slf4j
+public class MessageSenderImpl implements MessageSender {
+    @Resource
+    private EmailUtil emailSender;
+    @Resource
+    private WeChatUtil weChatSender;
+    @Resource
+    private InsideMessageUtil messageUtil;
+    @Resource
+    private RocketMqService mqService;
+
+    @Override
+    public void messageSend(MessageModel model) {
+        MessageType code = model.code();
+        switch (code) {
+            case SYS_MESSAGE:
+                sendSMS(model);
+                break;
+            case EMAILS:
+                sendEmail(model);
+                break;
+            case WEB_INSIDE_MESSAGE:
+                sendInside(model);
+                break;
+            case WECHAT_TEMPLATE_MESSAGE:
+                sendWechat(model);
+                break;
+            default:
+                throw new IllegalStateException("Unexpected value: " + code);
+        }
+    }
+
+    public void sendSMS(MessageModel model) {
+        String info = JSONObject.toJSONString(model.info());
+        SmsMessage smsMessage = JSONObject.parseObject(info, SmsMessage.class);
+        if (null != model.mqInfo() && StringUtils.isNotBlank(model.mqInfo().topic())) {
+            mqService.sendCommonMessage(setMessageDto(model));
+        } else {
+            SmsUtil.sendSms(smsMessage.type(), smsMessage.mobile(), smsMessage.smsMessageContent());
+        }
+    }
+
+    public void sendEmail(MessageModel model) {
+        if (null != model.mqInfo() && StringUtils.isNotBlank(model.mqInfo().topic())) {
+            mqService.sendCommonMessage(setMessageDto(model));
+        } else {
+            String info = JSONObject.toJSONString(model.info());
+            EmailMessage emailMessage = JSONObject.parseObject(info, EmailMessage.class);
+            emailSender.sendSimpleMail(emailMessage);
+        }
+    }
+
+    public void sendInside(MessageModel model) {
+        if (null != model.mqInfo() && StringUtils.isNotBlank(model.mqInfo().topic())) {
+            mqService.sendCommonMessage(setMessageDto(model));
+        } else {
+            String info = JSONObject.toJSONString(model.info());
+            InsideMessage insideMessage = JSONObject.parseObject(info, InsideMessage.class);
+            messageUtil.sendInsideMessage(insideMessage);
+        }
+    }
+
+    public void sendWechat(MessageModel model) {
+        if (null != model.mqInfo() && StringUtils.isNotBlank(model.mqInfo().topic())) {
+            mqService.sendCommonMessage(setMessageDto(model));
+        } else {
+            String info = JSONObject.toJSONString(model.info());
+            WechatTemplateMessage wechatTemplateMessage = JSONObject.parseObject(info, WechatTemplateMessage.class);
+            weChatSender.sendMessage(wechatTemplateMessage);
+        }
+    }
+
+    private MessageDto setMessageDto(MessageModel model) {
+        MessageDto messageDto = new MessageDto();
+        MqInfo mqInfo = model.mqInfo();
+        messageDto = messageDto.async(mqInfo.async()).tag(mqInfo.tag()).topic(mqInfo.topic()).
+                delay(mqInfo.delay()).content(JSONObject.toJSONString(model));
+        return messageDto;
+    }
+}

+ 10 - 10
src/main/java/com/caimei365/tools/service/impl/RocketMqServiceImpl.java

@@ -46,21 +46,21 @@ public class RocketMqServiceImpl implements RocketMqService {
      */
     @Override
     public SendResult sendCommonMessage(MessageDto messageDto) {
-        String destination = messageDto.getTopic();
-        if (StringUtils.isNotEmpty(messageDto.getTag())) {
-            destination += ":" + messageDto.getTag();
+        String destination = messageDto.topic();
+        if (StringUtils.isNotEmpty(messageDto.tag())) {
+            destination += ":" + messageDto.tag();
         }
-        Message<String> message = MessageBuilder.withPayload(messageDto.getContent()).build();
+        Message<String> message = MessageBuilder.withPayload(messageDto.content()).build();
         SendResult returnResult = null;
-        boolean isAsync = (messageDto.getAsync() != null && messageDto.getAsync() == 1);
-        boolean isSort = (messageDto.getSort() != null && messageDto.getSort() == 1);
-        boolean isOneway = (messageDto.getOneway() != null && messageDto.getOneway() == 1);
-        boolean isDelay = (messageDto.getDelay() != null && messageDto.getDelay() > 0);
+        boolean isAsync = (messageDto.async() != null && messageDto.async() == 1);
+        boolean isSort = (messageDto.sort() != null && messageDto.sort() == 1);
+        boolean isOneway = (messageDto.oneway() != null && messageDto.oneway() == 1);
+        boolean isDelay = (messageDto.delay() != null && messageDto.delay() > 0);
         if (!isAsync) {
             // 同步消息
             if (isDelay) {
                 // 延时
-                returnResult = rocketMQTemplate.syncSend(destination, message, timeout, messageDto.getDelay());
+                returnResult = rocketMQTemplate.syncSend(destination, message, timeout, messageDto.delay());
             } else {
                 if (isSort && isOneway) {
                     // 单向有序
@@ -91,7 +91,7 @@ public class RocketMqServiceImpl implements RocketMqService {
                         //可以处理相应的业务
                         log.info("异步消息发送失败:{}", JSON.toJSONString(throwable));
                     }
-                }, timeout, messageDto.getDelay());
+                }, timeout, messageDto.delay());
             } else {
                 if (isSort) {
                     // 异步有序

+ 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;
+//    }
+//
+//}

+ 196 - 531
src/main/java/com/caimei365/tools/task/ShopMessTask.java

@@ -3,31 +3,29 @@ package com.caimei365.tools.task;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.tools.mapper.MessageCenterMapper;
 import com.caimei365.tools.mapper.OrderClubMapper;
-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.OrderVo;
+import com.caimei365.tools.model.dto.message.InsideMessage;
+import com.caimei365.tools.model.dto.message.MessageModel;
+import com.caimei365.tools.model.dto.message.WechatTemplateMessage;
+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.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;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Description
@@ -46,181 +44,151 @@ public class ShopMessTask {
 
     @Resource
     private OrderClubMapper orderClubMapper;
-    @Resource
-    private WeChatService weChatService;
-
-//    @SneakyThrows
-//    public static void main(String[] args) {
-//        Calendar calendar = Calendar.getInstance();
-//
-//        Date d = new Date();
-//        Date time=new Date();
-//        //1.日期格式
-//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
-//        String receiptDate="2022-08-02 19:07:46";
-////        if(!receiptDate.contains(":")){
-////            receiptDate+=" 00:00:01";
-////        }
-//
-//           Date s= sdf.parse(receiptDate);
-//
-//        calendar.setTime(time);
-//        calendar.add(Calendar.HOUR, -1);
-//       String hTime= sdf.format(calendar.getTime());
-//      Integer i=  hTime.compareTo(sdf.format(s));
-//      System.out.println(i);
-//        System.out.println(hTime);
-//        System.out.println(s);
-////if(i==0){
-////
-////}
-////        time = sdf.parse(receiptDate);
-////
-////        calendar.setTime(time);
-//////        calendar.add(Calendar.YEAR, 1);
-////        String dateStrings = sdf.format(calendar.getTime());
-////        //2.到期时间
-////
-////                Date da1 =    da1 = sdf.parse(dateStrings);
-////        //到期时间-当前时间=还剩多少天
-////        Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
-////        System.out.println(da1);
-////        System.out.println(d);
-////        System.out.println(s);
-//    }
-
-    @Scheduled(cron = "0 0 15 * * ?")
-//    @Scheduled(cron = "0 0/15 * * * ?")
-    public void Timesjf() {
-        log.info("上架费过期推送开始");
-        //1.获取下午3点的时间
-        List<Integer> shopIDs = messageCenterMapper.receiptShopID();
-        shopIDs.forEach(shopID -> {
-            if (shopID != null) {
-                String receiptDate = messageCenterMapper.receiptDate(shopID);
-                Double receiptAmount = messageCenterMapper.receiptAmount(shopID);
-                Calendar calendar = Calendar.getInstance();
 
-                String firsts = "";
+    @Resource
+    private MessageSender messageSender;
+
+        @Scheduled(cron = "0 0 15 * * ?")
+    public void outTimePutAwayFee() {
+        log.info("-------------------------------上架费过期推送开始-------------------------------");
+        putAwayFee(0);
+        putAwayFee(7);
+        putAwayFee(30);
+        log.info("-------------------------------上架费过期推送结束-------------------------------");
+    }
 
-                Date d = new Date();
-                Date time = new Date();
-                //1.日期格式
-                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
-                if (!receiptDate.contains(":")) {
-                    receiptDate += " 00:00:01";
-                }
-                try {
-                    time = sdf.parse(receiptDate);
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                }
-                calendar.setTime(time);
-                calendar.add(Calendar.YEAR, 1);
-                String dateStrings = sdf.format(calendar.getTime());
-                //2.到期时间
-                Date da1 = new Date();
-                try {
-                    da1 = sdf.parse(dateStrings);
-                } catch (ParseException e) {
-                    e.printStackTrace();
-                }
-                //到期时间-当前时间=还剩多少天
-                Long s = (da1.getTime() - d.getTime()) / 24 / 60 / 60 / 1000;
-                //3.输出间隔天数         getTime获取的是毫秒
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                String current = dateFormat.format(new Date());
-                MessageCenterPo messageCenter = new MessageCenterPo();
-                //推送信息中心-上架费服务通知
-                if (s <= 0) {
-                    messageCenter.setShopId(shopID);
-                    messageCenter.setClubId(null);
-                    messageCenter.setUserType(2);
-                    messageCenter.setMessageType(3);
-                    messageCenter.setShopTieredType(1);
-                    messageCenter.setContent("已过期");
-                    messageCenter.setTime(current);
-                    messageCenterMapper.addMessageCenter(messageCenter);
-                } else if (s == 1) {
-                    messageCenter.setShopId(shopID);
-                    messageCenter.setClubId(null);
-                    messageCenter.setUserType(2);
-                    messageCenter.setMessageType(3);
-                    messageCenter.setShopTieredType(1);
-                    messageCenter.setContent("今日后到期");
-                    messageCenter.setTime(current);
-                    messageCenterMapper.addMessageCenter(messageCenter);
-                    String mobile = messageCenterMapper.contractMobiles(shopID);
-                    String content = "您的供应商账号上架费将于今日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365。退订回T";
-                    String result = SmsUtil.sendSms(3, mobile, content);
-                    JSONObject json = (JSONObject) JSONObject.parse(result);
-                    log.info("发送结果:" + result + ",短信内容:" + content);
-                    if (null != json && json.getInteger("code") == 0) {
-                        log.info(mobile + "发送成功");
-                    } else {
-                        log.error(mobile + "发送失败");
-                    }
-                    firsts = "尊敬的采美供应商用户,您的账号维护费用今天后即将到期!";
-                } else if (s == 7) {
-                    messageCenter.setShopId(shopID);
-                    messageCenter.setClubId(null);
-                    messageCenter.setUserType(2);
-                    messageCenter.setMessageType(3);
-                    messageCenter.setShopTieredType(1);
-                    messageCenter.setContent("7日后到期");
-                    messageCenter.setTime(current);
-                    messageCenterMapper.addMessageCenter(messageCenter);
-                    String mobile = messageCenterMapper.contractMobiles(shopID);
-                    String content = "您的供应商账号上架费将于7日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365。退订回T";
-                    String result = SmsUtil.sendSms(3, mobile, content);
-                    JSONObject json = (JSONObject) JSONObject.parse(result);
-                    log.info("发送结果:" + result + ",短信内容:" + content);
-                    if (null != json && json.getInteger("code") == 0) {
-                        log.info(mobile + "发送成功");
-                    } else {
-                        log.error(mobile + "发送失败");
-                    }
-                    firsts = "尊敬的采美供应商用户,您的账号维护费用7天后即将到期!";
-                } else if (s == 30) {
-                    messageCenter.setShopId(shopID);
-                    messageCenter.setClubId(null);
-                    messageCenter.setUserType(2);
-                    messageCenter.setMessageType(3);
-                    messageCenter.setShopTieredType(1);
-                    messageCenter.setContent("30日后到期");
-                    messageCenter.setTime(current);
-                    messageCenterMapper.addMessageCenter(messageCenter);
-                    String mobile = messageCenterMapper.contractMobiles(shopID);
-                    String content = "您的供应商账号上架费将于30日后到期,到期后将无法发布和编辑商品,同时也会影响到其他采美提供的支持服务。请联系采美工作人员进行续费,联系电话0755-22907771 或15338851365。退订回T";
-                    String result = SmsUtil.sendSms(3, mobile, content);
-                    JSONObject json = (JSONObject) JSONObject.parse(result);
-                    log.info("发送结果:" + result + ",短信内容:" + content);
-                    if (null != json && json.getInteger("code") == 0) {
-                        log.info(mobile + "发送成功");
-                    } else {
-                        log.error(mobile + "发送失败");
-                    }
-                    firsts = "尊敬的采美供应商用户,您的账号维护费用30天后即将到期!";
-                }
-                try {
-                    Integer userId = messageCenterMapper.userIds(shopID);
-                    String accessToken = weChatService.getAccessToken();
-                    String openid = messageCenterMapper.getOpenidListByPermission(messageCenterMapper.FromUnionId(userId));
-                    // 跳转到【小程序付款-选择支付方式页面】
-                    String pagePath = "https://www.caimei365.com/";
-                    // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
-                    weChatService.messtemes(accessToken, openid, firsts, receiptDate, sdf.format(da1), receiptAmount, pagePath);
-                } catch (Exception e) {
+//        @Scheduled(cron = "0 0/2 * * * ?")
+    @Scheduled(cron = "0 0 11 * * ?")
+    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);
+        log.info(day+"天证书过期的有-------------------》"+pro.toString());
+        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);
+        WechatTemplateMessage wechat = new WechatTemplateMessage();
+        wechat.templateId("gpD9TqBpkgaw3YSM_JPk4WSTwKZY0hxrBCH0SjzNKY4").url("https://www.caimei365.com/").appid("wxf3cd4ae0cdd11c36")
+                .first("您好,您有商品资质证书即将到期。").pagePath("");
+        pro.forEach(p -> {
+            productNames.append("(").append(p.productId()).append(")").append(p.productName());
+            productIds.append(p.productId()).append(",");
+            messageCenter.productId(p.productId());
+            messageCenterMapper.addMessageCenter(messageCenter);
+            ArrayList<String> strings = new ArrayList<>();
+            strings.add(p.shopName());
+            strings.add("医疗器械注册证");
+            strings.add(p.qualificationNo());
+            strings.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+            //todo 傻逼写法,拿不到值,有空再改
+            String openid = messageCenterMapper.getOpenidListByPermission(p.shopId());
+            wechat.remark(p.productName()).openId(openid).keyWords(strings);
+            MessageModel<WechatTemplateMessage> we = new MessageModel<>();
+            messageSender.messageSend(we.code(MessageType.WECHAT_TEMPLATE_MESSAGE).info(wechat));
+            log.info("资质证书" + day + "天-----productNames------------>" + productNames + "productIds----------->" + productIds);
+        });
+        if (null != pro && pro.size() > 0) {
+            String names = productNames.toString();
+            String ids = productIds.toString();
+            names = names.endsWith(",") ? names.substring(0, names.lastIndexOf(",")) : names;
+            ids = ids.endsWith(",") ? ids.substring(0, ids.lastIndexOf(",")) : ids;
+            if (names.length() > 10) {
+                names = StringUtils.strip(names.substring(0, 11));
+                names += "...";
             }
-            log.info("上架费过期推送结束");
+            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 > 7 ? "30" : 7 == day ? "7" : "今";
+        StringBuilder shopNames = new StringBuilder();
+        StringBuilder shopsId = new StringBuilder();
+        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)
+                    .messageType(3).shopTieredType(1).content("今日后到期"));
+            messageSender.messageSend(insideMessageMessageModel);
+            //短信
+            String mobile = messageCenterMapper.contractMobiles(s.getShopId());
+            String result = SmsUtil.sendSms(3, mobile, content);
+            log.info("发送结果:" + result + ",短信内容:" + content);
+            //微信模板消息
+            MessageModel<WechatTemplateMessage> wechatTemplateMessageMessageModel = new MessageModel<>();
+            String pagePath = "https://www.caimei365.com/";
+            //todo 傻逼写法,拿不到值,有空再改
+            String openid = messageCenterMapper.getOpenidListByPermission(s.getShopId());
+            ArrayList<String> strings = new ArrayList<>();
+            strings.add("维护费");
+            strings.add("年付");
+            strings.add(s.getValidityDate());
+            strings.add(s.getDateStrings());
+            strings.add(s.getReceiptAmount().toString());
+            WechatTemplateMessage weChat = new WechatTemplateMessage().first(firsts).openId(openid).pagePath(pagePath).keyWords(strings)
+                    .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(",");
+            log.info("上架费" + day + "天--shopName---------------->" + shopNames + "shopIds---------------->" + shopIds);
         });
+        if (null != shopIds && shopIds.size() > 0) {
+            String s = shopNames.toString();
+            String sn = shopsId.toString();
+            String shopDay = 0 == day ? "今天" : 7 == day ? "7天" : "一个月";
+            String theme = "以下供应商的上架费将于" + shopDay + "后到期,请及时提醒供应商续费。";
+            s = s.endsWith(",") ? s.substring(0, s.lastIndexOf(",")) : s;
+            sn = sn.endsWith(",") ? sn.substring(0, sn.lastIndexOf(",")) : sn;
+            Notification notification = new Notification();
+            notification.theme(theme).shopContent(s).shopId(sn);
+            messageCenterMapper.addNotification(notification);
+        }
     }
 
+    @Scheduled(cron = "0 0 15 * * ?")
+    public void putAwayFeeForManager() {
+        log.info("---------------------------上架费三个月过期推送开始-------------------------------");
+        //后台上架费三个月过期推送
+        List<ShopReceiptVo> shopIds = messageCenterMapper.findExpireShopId(90);
+        log.info("上架费三个月过期的有----------------》" + shopIds.toString());
+        StringBuilder shopNames = new StringBuilder();
+        StringBuilder shopsId = new StringBuilder();
+        shopIds.forEach(s -> {
+            shopNames.append(s.getShopName()).append(",");
+            shopsId.append(s.getShopId()).append(",");
+            log.info("上架费三个月----------------->shopName---------------->" + shopNames + "shopIds---------------->" + shopIds);
+        });
+        if (null != shopIds && shopIds.size() > 0) {
+            String s = shopNames.toString();
+            String sn = shopsId.toString();
+            s = s.endsWith(",") ? s.substring(0, s.lastIndexOf(",")) : s;
+            sn = sn.endsWith(",") ? sn.substring(0, sn.lastIndexOf(",")) : sn;
+            Notification notification = new Notification();
+            notification.theme("以下供应商的上架费将于3个月后到期,请及时提醒供应商续费。").shopContent(s).shopId(sn);
+            messageCenterMapper.addNotification(notification);
+        }
+        log.info("---------------------------上架费三个月过期推送结束-------------------------------");
+    }
 
     @Scheduled(cron = "0 0 10 15 * ?")
-//@Scheduled(cron = "0 0/10 * * * ?")
     public void gwc() {
         log.info("------------开始推送购物车相关短信------------------------>");
         List<Integer> userId = orderClubMapper.userIds();
@@ -249,354 +217,71 @@ 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点推送给领取了该优惠券的用户(谁领的给谁发短信)
+     * <p>
+     * 若优惠券有限期小于15天,则上述情况不推送
+     * <p>
+     * 短信模板:【采美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);
+        log.info("优惠券七天过期的有----------------》" + coupons.toString());
+        MessageCenterPo messageCenter = new MessageCenterPo();
+        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);
+            String content = "您有" + c.getCouponAmount() + "元优惠券将于7日后过期," +
+                    "快戳采美网站链接www.caimei365.com/M2Tr98CG 或微信搜索“采美采购商城”小程序登录采美平台查看使用吧。关注公众号“采美网”获取更多优惠和精彩资讯。退订回T";
+            SmsUtil.sendSms(3, content, c.getBindMobile());
         });
     }
 
+
     /**
-     * 每天10点判断
+     * 优惠券领取后没有使用,在失效日当天,上午10推送给领取了该优惠券的用户(谁领的给谁发短信)
+     * <p>
+     * 短信模板:【采美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);
+        log.info("优惠券一天过期的有-----------------》" + coupons.toString());
+        MessageCenterPo messageCenter = new MessageCenterPo();
+        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);
+            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() + "发送失败");
-                        }
-                    }
 
-                }
-            });
+//    @Scheduled(cron = "0 0 15 * * ?")
+    private void Timeth() {
+        log.info("----------------------------优惠券三天后过期---------------------------------");
+        List<CmCouponPo> coupons = messageCenterMapper.findOutTimeCoupons(3);
+        log.info("优惠券三天过期的有-------------------》" + coupons.toString());
+        MessageCenterPo messageCenter = new MessageCenterPo();
+        messageCenter.userType(1).messageType(4).couponMessageType(3).content("3天");
+        coupons.forEach(c -> {
+            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());
         });
     }
 
@@ -632,14 +317,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);
             }
         });
@@ -664,14 +343,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);
             }
         });
@@ -695,18 +368,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);
             }
-
         });
     }
-
 }

+ 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);
                         }
                 );

+ 40 - 0
src/main/java/com/caimei365/tools/utils/EmailUtil.java

@@ -0,0 +1,40 @@
+package com.caimei365.tools.utils;
+
+
+import com.caimei365.tools.model.dto.message.EmailMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.mail.SimpleMailMessage;
+import org.springframework.mail.javamail.JavaMailSender;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Slf4j
+public class EmailUtil {
+    @Autowired
+    private JavaMailSender mailSender;
+
+    @Value("${spring.mail.username}")
+    private String from;
+
+    /**
+     * 发送文本邮件
+     *
+     * @param receiverAddress 收件人地址
+     * @param subject         邮件主题
+     * @param content         邮件内容
+     * @param cc              抄送地址
+     */
+    public void sendSimpleMail(EmailMessage emailMessage) {
+        SimpleMailMessage message = new SimpleMailMessage();
+        message.setFrom(from);
+        message.setTo(emailMessage.receiverAddress());
+        message.setSubject(emailMessage.subject());
+        message.setText(emailMessage.emailMessageContent());
+        message.setCc(emailMessage.cc());
+        log.info("邮件发送参数---------------------->" + message);
+        mailSender.send(message);
+    }
+}

+ 20 - 0
src/main/java/com/caimei365/tools/utils/InsideMessageUtil.java

@@ -0,0 +1,20 @@
+package com.caimei365.tools.utils;
+
+import com.caimei365.tools.mapper.MessageCenterMapper;
+import com.caimei365.tools.model.dto.message.InsideMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Component
+public class InsideMessageUtil {
+    @Resource
+    private MessageCenterMapper messageCenterMapper;
+
+    public void sendInsideMessage(InsideMessage insideMessage){
+        log.info("站内消息收到参数------------------->"+insideMessage.toString());
+        messageCenterMapper.sendInsideMessage(insideMessage);
+    }
+}

+ 39 - 0
src/main/java/com/caimei365/tools/utils/WeChatUtil.java

@@ -0,0 +1,39 @@
+package com.caimei365.tools.utils;
+
+import com.alibaba.fastjson.JSONObject;
+
+import com.caimei365.tools.model.dto.message.WechatTemplateMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+
+import java.util.Map;
+
+@Component
+@Slf4j
+public class WeChatUtil {
+    public void sendMessage(WechatTemplateMessage wechatTemplateMessage){
+        try {
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + getAccessToken();
+            // 发送请求
+            String json = wechatTemplateMessage.getJson();
+            log.info("微信发消息的-------------------------->"+json);
+            String result = RequestUtil.httpRequest(requestUrl, "POST", json);
+            log.info(">>>>>>>>微信模板消息推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:" + e);
+        }
+    }
+
+    public String getAccessToken() throws Exception {
+        String link = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
+        link = link.replace("APPID", "wx91c4152b60ca91a3");
+        link = link.replace("APPSECRET", "a563dd2c07c9c815a4e697c8b6cb73dc");
+        String result = RequestUtil.sendGet(link);
+        log.info("微信公众号获取access_token>>>" + result);
+        Map<String, Object> map = JSONObject.parseObject(result, Map.class);
+        String access_token = (String) map.get("access_token");
+        return access_token;
+    }
+
+}

+ 12 - 0
src/main/resources/bootstrap.yml

@@ -18,3 +18,15 @@ spring:
     multipart:
       max-file-size: 20MB
       max-request-size: 100MB
+  #邮件设置
+  mail:
+    host: smtp.qq.com
+    username: 525282777@qq.com
+    password: uvgkjjlusyczcagg #*****  //授权码
+    default-encoding: UTF-8
+    properties:
+      mail.smtp.auth: true
+      mail.smtp.starttls.enable: true
+      mail.smtp.starttls.required: true
+      mail.smtp.ssl.enable: true
+      mail.display.sendmail: spring-boot-demo

+ 175 - 126
src/main/resources/mapper/MessageCenter.xml

@@ -2,43 +2,43 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.tools.mapper.MessageCenterMapper">
     <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},#{couponFee},#{couponMessageType},#{shopMessType},#{shopTieredType})
+        INSERT INTO message_center (shopID, clubID, userType, messageType, content, time, accountType, couponType,
+                                    couponFee, couponMessageType, ShopMessType, ShopTieredType)
+        VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content}, now(), #{accountType}, #{couponType},
+                #{couponFee}, #{couponMessageType}, #{shopMessType}, #{shopTieredType})
+    </insert>
+    <insert id="sendInsideMessage">
+        INSERT INTO message_center (shopID, clubID, orderID, userType, messageType, accountType, orderMessageType,
+                                    couponMessageType, couponFee, content, time, saved, shopMessType,
+                                    shopTieredType, couponType, productID)
+        VALUES (#{shopId}, #{clubId}, #{orderId}, #{userType}, #{messageType}, #{accountType}, #{orderMessageType},
+                #{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}, #{productId}, #{shopId})
     </insert>
-
     <select id="clubIdCule" resultType="java.lang.Integer">
-        SELECT clubID FROM `user` WHERE userId=#{userId}
+        SELECT clubID
+        FROM `user`
+        WHERE userId = #{userId}
     </select>
 
     <select id="shopID" resultType="java.lang.Integer">
-        SELECT shopID FROM `shop` WHERE userId=#{userId}
+        SELECT shopID
+        FROM `shop`
+        WHERE userId = #{userId}
     </select>
 
-<!--    <select id="shopID" resultType="java.lang.Integer">-->
-<!--        SELECT shopID FROM `shop` WHERE userId=#{userId}-->
-<!--    </select>-->
-
-<!--    <select id="clubList" resultType="com.caimei365.user.model.vo.UserVo">-->
-<!--        SELECT * FROM `user` WHERE userId=#{userId}-->
-<!--    </select>-->
-
-<!--    <select id="CouponList" resultType="com.caimei365.user.model.vo.CouponVo">-->
-<!--        SELECT * FROM cm_coupon WHERE couponType=#{couponType}-->
-<!--         AND NOW() >= startDate-->
-<!--         AND endDate >= NOW()-->
-<!--         AND status=1-->
-<!--         AND delFlag=0-->
-<!--        LIMIT 1-->
-<!--    </select>-->
-
     <select id="MessageCount" resultType="java.lang.Integer">
         SELECT COUNT(1) FROM `message_center`
         <where>
             <if test="userType == 1">
-                and  clubID=#{commonId}
+                and clubID=#{commonId}
             </if>
             <if test="userType == 2">
-                and  shopID=#{commonId}
+                and shopID=#{commonId}
             </if>
             AND messageType=#{messageType}
             and userType=#{userType}
@@ -50,10 +50,10 @@
         SELECT COUNT(1) FROM `message_center`
         <where>
             <if test="userType == 1">
-                and  clubID=#{commonId}
+                and clubID=#{commonId}
             </if>
             <if test="userType == 2">
-                and  shopID=#{commonId}
+                and shopID=#{commonId}
             </if>
             and userType=#{userType}
             AND saved=0
@@ -62,75 +62,88 @@
 
 
     <select id="receStatct" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND receStatct=2
+        SELECT COUNT(*)
+        FROM `cm_discern_receipt`
+        WHERE newReceiptType = 1
+          AND shopID = #{shopID}
+          AND receStatct = 2
     </select>
 
     <select id="listingFee" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID}
+        SELECT COUNT(*)
+        FROM `cm_discern_receipt`
+        WHERE newReceiptType = 1
+          AND shopID = #{shopID}
     </select>
 
     <select id="listingfeeExpire" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND NOW()> DATE_ADD(receiptDate, INTERVAL 1 YEAR)
+        SELECT COUNT(*)
+        FROM `cm_discern_receipt`
+        WHERE newReceiptType = 1
+          AND shopID = #{shopID}
+          AND NOW() > DATE_ADD(receiptDate, INTERVAL 1 YEAR)
     </select>
 
-<!--    <select id="MessageList" resultType="com.caimei365.user.model.vo.MessageCenter">-->
-<!--        SELECT * FROM `message_center`-->
-<!--        <where>-->
-<!--            <if test="messageType !=null">-->
-<!--            AND messageType=#{messageType}-->
-<!--           </if>-->
-<!--            <if test="userType == 1">-->
-<!--                and  clubID=#{commonId}-->
-<!--            </if>-->
-<!--            <if test="userType == 2">-->
-<!--                and  shopID=#{commonId}-->
-<!--            </if>-->
-<!--           and userType=#{userType}-->
-<!--        </where>-->
-<!--        ORDER BY id DESC-->
-<!--    </select>-->
-
     <select id="contractMobile" resultType="java.lang.String">
-        SELECT contractMobile FROM club WHERE clubID=#{clubID}
+        SELECT contractMobile
+        FROM club
+        WHERE clubID = #{clubID}
     </select>
 
     <select id="contractMobiles" resultType="java.lang.String">
-        SELECT contractMobile FROM shop WHERE shopID=#{shopID}
+        SELECT contractMobile
+        FROM shop
+        WHERE shopID = #{shopID}
     </select>
 
     <select id="getOpenidListByPermission" resultType="java.lang.String">
-        SELECT openid FROM `wechat_user` WHERE unionId= #{unionId}
+        SELECT openid
+        FROM wechat_user
+        WHERE unionId = (
+            SELECT unionID
+            FROM cm_order co
+                     LEFT JOIN shop s ON co.userId = s.userId
+            WHERE s.shopId = #{shopId}
+              AND unionID IS NOT NULL
+            ORDER BY orderID DESC
+            LIMIT 1)
     </select>
 
     <select id="FromUnionId" resultType="java.lang.String">
-        SELECT unionID FROM `cm_order` WHERE userID=#{userID} AND unionID IS NOT NULL  ORDER BY orderID DESC LIMIT 1
+        SELECT unionID
+        FROM `cm_order`
+        WHERE userID = #{userID}
+          AND unionID IS NOT NULL
+        ORDER BY orderID DESC
+        LIMIT 1
     </select>
 
     <select id="getVipHistoryCount" resultType="java.lang.Integer">
         SELECT count(1)
         FROM cm_svip_history
-        WHERE  userId = #{userId}
+        WHERE userId = #{userId}
     </select>
 
     <select id="MainImage" resultType="com.caimei365.tools.model.po.MessageCenterPo">
-        SELECT co.refundType,COUNT(p.productID)AS productCount ,p.mainImage,co.onlinePayFlag,ifnull(p.name,'') as productName,co.orderID as orderID,co.status as status
+        SELECT co.refundType,COUNT(p.productID)AS productCount ,p.mainImage,co.onlinePayFlag,ifnull(p.name,'') as
+        productName,co.orderID as orderID,co.status as status
         FROM cm_order co
-                 LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
-                 LEFT JOIN USER u ON u.userID = co.userID
-                 LEFT JOIN club c ON u.userID = c.userID
-                 LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID AND sp.status = 90
-                 LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
-                 LEFT JOIN product p ON cop.productID = p.productID
-                 LEFT JOIN cm_shop_order cso ON co.orderid=cso.orderID
+        LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
+        LEFT JOIN USER u ON u.userID = co.userID
+        LEFT JOIN club c ON u.userID = c.userID
+        LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID AND sp.status = 90
+        LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
+        LEFT JOIN product p ON cop.productID = p.productID
+        LEFT JOIN cm_shop_order cso ON co.orderid=cso.orderID
         <where>
 
             <if test="userType == 1">
-              and  c.clubID=#{commonId}
+                and c.clubID=#{commonId}
             </if>
             <if test="userType == 2">
-              and  p.shopID=#{commonId}
+                and p.shopID=#{commonId}
             </if>
-        and co.orderID=#{orderID}
+            and co.orderID=#{orderID}
         </where>
         LIMIT 1
     </select>
@@ -144,123 +157,132 @@
             <if test="productID != null">
                 and p.productID=#{productID}
             </if>
-                and p.shopID=#{shopID}
+            and p.shopID=#{shopID}
         </where>
         LIMIT 1
     </select>
 
     <select id="productCount" resultType="java.lang.Integer">
-        SELECT COUNT(productID) FROM cm_order_product
-        WHERE orderID=#{orderID}
+        SELECT COUNT(productID)
+        FROM cm_order_product
+        WHERE orderID = #{orderID}
     </select>
 
 
     <select id="receiptDate" resultType="java.lang.String">
-        SELECT
-            c.dateStrings
+        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
-        WHERE
-            a.shopID=10324
-          AND a.newReceiptType=1
+        WHERE a.shopID = 10324
+          AND a.newReceiptType = 1
         ORDER BY a.id DESC
         LIMIT 1
     </select>
 
     <select id="receiptAmount" resultType="java.lang.Double">
-        SELECT
-            a.receiptAmount
+        SELECT a.receiptAmount
         FROM cm_discern_receipt a
                  LEFT JOIN shop s ON s.shopID = a.shopID
-        where
-            a.shopID=#{shopID}
-          AND a.newReceiptType=1
+        where a.shopID = #{shopID}
+          AND a.newReceiptType = 1
         LIMIT 1
     </select>
 
-<select id="newReceiptType" resultType="java.lang.Integer">
-    SELECT
-        a.newReceiptType
-    FROM cm_discern_receipt a
-             LEFT JOIN shop s ON s.shopID = a.shopID
-    where
-        a.shopID=#{shopID}
-    LIMIT 1
-</select>
+    <select id="newReceiptType" resultType="java.lang.Integer">
+        SELECT a.newReceiptType
+        FROM cm_discern_receipt a
+                 LEFT JOIN shop s ON s.shopID = a.shopID
+        where a.shopID = #{shopID}
+        LIMIT 1
+    </select>
     <update id="updateMessageAsRead">
         UPDATE message_center SET saved = 1
         <where>
-      <if test="userType == 1">
-          and  clubID=#{commonId}
-      </if>
-      <if test="userType == 2">
-          and  shopID=#{commonId}
-      </if>
-        <if test="messageType !=null">
-           and messageType = #{messageType}
-        </if>
-          and userType=#{userType}
+            <if test="userType == 1">
+                and clubID=#{commonId}
+            </if>
+            <if test="userType == 2">
+                and shopID=#{commonId}
+            </if>
+            <if test="messageType !=null">
+                and messageType = #{messageType}
+            </if>
+            and userType=#{userType}
         </where>
     </update>
 
     <select id="userId" resultType="java.lang.Integer">
-        SELECT userID FROM `cm_mall_operation_user` WHERE openid=#{openid}  LIMIT 1
+        SELECT userID
+        FROM `cm_mall_operation_user`
+        WHERE openid = #{openid}
+        LIMIT 1
     </select>
 
- <delete id="deleteMessage">
-        DELETE FROM message_center WHERE id = #{id}
+    <delete id="deleteMessage">
+        DELETE
+        FROM message_center
+        WHERE id = #{id}
     </delete>
 
     <update id="updateRead">
-        UPDATE message_center SET saved = 1
-        where userType=#{userType} and id=#{Id}
+        UPDATE message_center
+        SET saved = 1
+        where userType = #{userType}
+          and id = #{Id}
     </update>
 
     <select id="receiptShopID" resultType="java.lang.Integer">
-        SELECT DISTINCT
-            a.shopID
-        FROM cm_discern_receipt a
-                 LEFT JOIN shop s ON s.shopID = a.shopID
-        WHERE
-            a.newReceiptType=1
+        SELECT DISTINCT shopID
+        FROM cm_discern_receipt
+        WHERE newReceiptType = 1
     </select>
 
     <select id="userIds" resultType="java.lang.Integer">
-        SELECT DISTINCT
-            a.userID
+        SELECT DISTINCT a.userID
         FROM shop a
-        WHERE
-            a.shopOD=#{shopID}
+        WHERE a.shopOD = #{shopID}
     </select>
 
     <select id="ClubIds" resultType="java.lang.Integer">
-        SELECT clubID FROM `user` WHERE YEAR(loginTime)>YEAR(NOW())-3 AND clubID IS NOT NULL
+        SELECT clubID
+        FROM `user`
+        WHERE YEAR(loginTime) > YEAR(NOW()) - 3
+          AND clubID IS NOT NULL
 #         ORDER BY clubID DESC
     </select>
 
     <select id="couponTime" resultType="com.caimei365.tools.model.po.CmCouponPo">
-        SELECT * FROM `cm_coupon` WHERE
-            NOW() >= startDate
-             AND endDate >= NOW()
-             AND STATUS = 1
-             AND delFlag=0
+        SELECT *
+        FROM `cm_coupon`
+        WHERE NOW() >= startDate
+          AND endDate >= NOW()
+          AND STATUS = 1
+          AND delFlag = 0
     </select>
 
     <select id="clubList" resultType="com.caimei365.tools.model.po.CmUserPo">
-        SELECT * FROM `user` WHERE clubId=#{clubId}  LIMIT 1
+        SELECT *
+        FROM `user`
+        WHERE clubId = #{clubId}
+        LIMIT 1
     </select>
 
     <select id="clubLists" resultType="com.caimei365.tools.model.po.CmUserPo">
-        SELECT * FROM `user` WHERE userId=#{userId}  LIMIT 1
+        SELECT *
+        FROM `user`
+        WHERE userId = #{userId}
+        LIMIT 1
     </select>
 
     <select id="CouponList" resultType="com.caimei365.tools.model.po.CmCouponPo">
-        SELECT * FROM cm_coupon WHERE couponType=#{couponType}
-        AND NOW() >= startDate
-        AND endDate >= NOW()
-        AND status=1
-        AND delFlag=0
+        SELECT *
+        FROM cm_coupon
+        WHERE couponType = #{couponType}
+          AND NOW() >= startDate
+          AND endDate >= NOW()
+          AND status = 1
+          AND delFlag = 0
         ORDER BY id DESC
         LIMIT 1
     </select>
@@ -272,13 +294,40 @@
     </select>
 
     <select id="CouponLists" resultType="com.caimei365.tools.model.po.CmCouponPo">
-        SELECT * FROM cm_coupon a
+        SELECT *
+        FROM cm_coupon a
         LEFT JOIN cm_coupon_club s ON s.couponId = a.id
-        WHERE  s.userId=#{userID}
+        WHERE s.userId = #{userID}
           AND NOW() >= a.startDate
           AND a.endDate >= NOW()
-          AND a.status=1
-          AND a.delFlag=0
+          AND a.status = 1
+          AND a.delFlag = 0
     </select>
 
+    <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
+        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_FORMAT(DATE_ADD(NOW(), INTERVAL #{day} DAY),'%y-%m-%d') =
+              DATE_FORMAT(IF(cc.useTimeFlag = 1, cc.endDate, DATE_ADD(ccc.createDate, INTERVAL cc.usePeriod DAY)),'%y-%m-%d')
+    </select>
+    <select id="findOutTimeQualification" resultType="com.caimei365.tools.model.po.QualificationPo">
+        SELECT p.productId, p.name AS productName, p.shopId, p.qualificationNo, u.userId, s.name AS shopName
+        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>

+ 120 - 120
src/test/java/com/caimei365/tools/ToolsApplicationTests.java

@@ -1,131 +1,131 @@
-package com.caimei365.tools;
-
-import com.caimei365.tools.utils.SmsUtil;
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.yaml.snakeyaml.scanner.ScannerImpl;
-
-import java.util.Calendar;
-import java.util.Date;
-
-@SpringBootTest
-class ToolsApplicationTests {
-
-    @Test
-    void contextLoads() {
-
-    }
-
-//    @Test
-//    void testSms1() {
-//        String s = SmsUtil.sendSms(1, "15814011616", "您好,您的验证码是12345");
-//        System.out.println(s);
-//    }
-//
-//    @Test
-//    void testSms2() {
-//        String s = SmsUtil.sendSms(2, "15814011616", "您好,您的验证码是98765");
-//        System.out.println(s);
-//    }
-//
-//    @Test
-//    void testSms3() {
-//        String s = SmsUtil.sendSms(2, "15814011616", "欢迎成为采美机构用户,您的登录账号为:15814011616,初始密码为:123456,您可使用该账号密码登录采美365网和“采美采购商城”小程序。");
-//        System.out.println(s);
-//    }
-
-    //欢迎成为采美机构用户,您的登录账号为:${name},初始密码为:cm${content},您可使用该账号密码登录采美365网和“采美采购商城”小程序。
-    /**
-     * kuaidi100.key = bEZlgVkW1438
-     * kuaidi100.customer = 1414E0E533E3311FBA5E633C10F78306
-     * kuaidi100.secret = e3bb51a0c8bd40c69342c7c88650c035
-     * kuaidi100.userid = 31872248ba914ac289db3ed3244d527c
-     */
-//    private String key = "bEZlgVkW1438";
-//    private String customer = "1414E0E533E3311FBA5E633C10F78306";
-//    /**
-//     * 查询物流轨迹
-//     */
-//    @Test
-//    public void testQueryTrack() throws Exception{
-//
-//        QueryTrackReq queryTrackReq = new QueryTrackReq();
-//        QueryTrackParam queryTrackParam = new QueryTrackParam();
-//        queryTrackParam.setCom(CompanyConstant.SF);
-//        queryTrackParam.setNum("SF1108462182157");
-//        queryTrackParam.setPhone("15828171629");
-//        String param = new Gson().toJson(queryTrackParam);
-//
-//        queryTrackReq.setParam(param);
-//        queryTrackReq.setCustomer(customer);
-//        queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
+//package com.caimei365.tools;
 //
-//        IBaseClient baseClient = new QueryTrack();
-//        System.out.println(baseClient.execute(queryTrackReq));
-//    }
-//
-//     /**
-//     * 快递信息地图轨迹
-//     */
-//    @Test
-//    public void testQueryMapView() throws Exception{
+//import com.caimei365.tools.utils.SmsUtil;
+//import org.junit.jupiter.api.Test;
+//import org.springframework.boot.test.context.SpringBootTest;
+//import org.yaml.snakeyaml.scanner.ScannerImpl;
 //
-//        QueryTrackReq queryTrackReq = new QueryTrackReq();
-//        QueryTrackParam queryTrackParam = new QueryTrackParam();
-//        queryTrackParam.setCom(CompanyConstant.YD);
-//        queryTrackParam.setNum("4311159956248");
-//        queryTrackParam.setPhone("17725390266");
-//        queryTrackParam.setFrom("河北保定市");
-//        queryTrackParam.setTo("湖南岳阳市");
-//        queryTrackParam.setResultv2("2");
-//        String param = new Gson().toJson(queryTrackParam);
+//import java.util.Calendar;
+//import java.util.Date;
 //
-//        queryTrackReq.setParam(param);
-//        queryTrackReq.setCustomer(customer);
-//        queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
-//
-//        IBaseClient baseClient = new QueryTrackMap();
-//        HttpResult result = baseClient.execute(queryTrackReq);
-//
-//        QueryTrackMapResp queryTrackMapResp = new Gson().fromJson(result.getBody(),QueryTrackMapResp.class);
-//        System.out.println(queryTrackMapResp);
-//    }
+//@SpringBootTest
+//class ToolsApplicationTests {
 //
-//    /**
-//     * 订阅
-//     */
 //    @Test
-//    public void testSubscribe() throws Exception{
-//        SubscribeParameters subscribeParameters = new SubscribeParameters();
-//        subscribeParameters.setCallbackurl("http://www.baidu.com");
-//        subscribeParameters.setPhone("17725390266");
-//
-//        SubscribeParam subscribeParam = new SubscribeParam();
-//        subscribeParam.setParameters(subscribeParameters);
-//        subscribeParam.setCompany(CompanyConstant.ST);
-//        subscribeParam.setNumber("773039762404825");
-//        subscribeParam.setKey(key);
+//    void contextLoads() {
 //
-//        SubscribeReq subscribeReq = new SubscribeReq();
-//        subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA);
-//        subscribeReq.setParam(new Gson().toJson(subscribeParam));
-//
-//        IBaseClient subscribe = new Subscribe();
-//        System.out.println(subscribe.execute(subscribeReq));
 //    }
 //
+////    @Test
+////    void testSms1() {
+////        String s = SmsUtil.sendSms(1, "15814011616", "您好,您的验证码是12345");
+////        System.out.println(s);
+////    }
+////
+////    @Test
+////    void testSms2() {
+////        String s = SmsUtil.sendSms(2, "15814011616", "您好,您的验证码是98765");
+////        System.out.println(s);
+////    }
+////
+////    @Test
+////    void testSms3() {
+////        String s = SmsUtil.sendSms(2, "15814011616", "欢迎成为采美机构用户,您的登录账号为:15814011616,初始密码为:123456,您可使用该账号密码登录采美365网和“采美采购商城”小程序。");
+////        System.out.println(s);
+////    }
+//
+//    //欢迎成为采美机构用户,您的登录账号为:${name},初始密码为:cm${content},您可使用该账号密码登录采美365网和“采美采购商城”小程序。
 //    /**
-//     * 智能识别接口(正式用户可以使用)
+//     * kuaidi100.key = bEZlgVkW1438
+//     * kuaidi100.customer = 1414E0E533E3311FBA5E633C10F78306
+//     * kuaidi100.secret = e3bb51a0c8bd40c69342c7c88650c035
+//     * kuaidi100.userid = 31872248ba914ac289db3ed3244d527c
 //     */
-//    @Test
-//    public void testAutoNum() throws Exception{
-//        AutoNumReq autoNumReq = new AutoNumReq();
-//        autoNumReq.setKey(key);
-//        autoNumReq.setNum("17725390266");
+////    private String key = "bEZlgVkW1438";
+////    private String customer = "1414E0E533E3311FBA5E633C10F78306";
+////    /**
+////     * 查询物流轨迹
+////     */
+////    @Test
+////    public void testQueryTrack() throws Exception{
+////
+////        QueryTrackReq queryTrackReq = new QueryTrackReq();
+////        QueryTrackParam queryTrackParam = new QueryTrackParam();
+////        queryTrackParam.setCom(CompanyConstant.SF);
+////        queryTrackParam.setNum("SF1108462182157");
+////        queryTrackParam.setPhone("15828171629");
+////        String param = new Gson().toJson(queryTrackParam);
+////
+////        queryTrackReq.setParam(param);
+////        queryTrackReq.setCustomer(customer);
+////        queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
+////
+////        IBaseClient baseClient = new QueryTrack();
+////        System.out.println(baseClient.execute(queryTrackReq));
+////    }
+////
+////     /**
+////     * 快递信息地图轨迹
+////     */
+////    @Test
+////    public void testQueryMapView() throws Exception{
+////
+////        QueryTrackReq queryTrackReq = new QueryTrackReq();
+////        QueryTrackParam queryTrackParam = new QueryTrackParam();
+////        queryTrackParam.setCom(CompanyConstant.YD);
+////        queryTrackParam.setNum("4311159956248");
+////        queryTrackParam.setPhone("17725390266");
+////        queryTrackParam.setFrom("河北保定市");
+////        queryTrackParam.setTo("湖南岳阳市");
+////        queryTrackParam.setResultv2("2");
+////        String param = new Gson().toJson(queryTrackParam);
+////
+////        queryTrackReq.setParam(param);
+////        queryTrackReq.setCustomer(customer);
+////        queryTrackReq.setSign(SignUtils.querySign(param ,key,customer));
+////
+////        IBaseClient baseClient = new QueryTrackMap();
+////        HttpResult result = baseClient.execute(queryTrackReq);
+////
+////        QueryTrackMapResp queryTrackMapResp = new Gson().fromJson(result.getBody(),QueryTrackMapResp.class);
+////        System.out.println(queryTrackMapResp);
+////    }
+////
+////    /**
+////     * 订阅
+////     */
+////    @Test
+////    public void testSubscribe() throws Exception{
+////        SubscribeParameters subscribeParameters = new SubscribeParameters();
+////        subscribeParameters.setCallbackurl("http://www.baidu.com");
+////        subscribeParameters.setPhone("17725390266");
+////
+////        SubscribeParam subscribeParam = new SubscribeParam();
+////        subscribeParam.setParameters(subscribeParameters);
+////        subscribeParam.setCompany(CompanyConstant.ST);
+////        subscribeParam.setNumber("773039762404825");
+////        subscribeParam.setKey(key);
+////
+////        SubscribeReq subscribeReq = new SubscribeReq();
+////        subscribeReq.setSchema(ApiInfoConstant.SUBSCRIBE_SCHEMA);
+////        subscribeReq.setParam(new Gson().toJson(subscribeParam));
+////
+////        IBaseClient subscribe = new Subscribe();
+////        System.out.println(subscribe.execute(subscribeReq));
+////    }
+////
+////    /**
+////     * 智能识别接口(正式用户可以使用)
+////     */
+////    @Test
+////    public void testAutoNum() throws Exception{
+////        AutoNumReq autoNumReq = new AutoNumReq();
+////        autoNumReq.setKey(key);
+////        autoNumReq.setNum("17725390266");
+////
+////        IBaseClient baseClient = new AutoNum();
+////        System.out.println(baseClient.execute(autoNumReq));
+////    }
+//
+//}
 //
-//        IBaseClient baseClient = new AutoNum();
-//        System.out.println(baseClient.execute(autoNumReq));
-//    }
-
-}
-