Browse Source

站内消息

Duan_xu 2 years ago
parent
commit
fdb170f6e4

+ 2 - 1
src/main/java/com/caimei365/commodity/controller/CouponApi.java

@@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.ParseException;
 import java.util.Map;
 
 /**
@@ -101,7 +102,7 @@ public class CouponApi {
     @PostMapping("/collar")
     @IpSave(saveName = "领取优惠券",saveParams = true)
     @Idempotent(prefix = "idempotent_collarCoupons", keys = {"#couponsDto"}, expire = 5)
-    public ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) {
+    public ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) throws ParseException {
         if (couponsDto.getCouponId() == null || couponsDto.getSource() == null || couponsDto.getUserId() == null) {
             return ResponseJson.error("参数异常", null);
         }

+ 26 - 0
src/main/java/com/caimei365/commodity/mapper/MessageCenterMapper.java

@@ -0,0 +1,26 @@
+package com.caimei365.commodity.mapper;
+
+import com.caimei365.commodity.model.vo.CouponVo;
+import com.caimei365.commodity.model.vo.MessageCenter;
+import com.caimei365.commodity.model.vo.UserVo;
+import org.apache.ibatis.annotations.Mapper;
+
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/7/7
+ */
+@Mapper
+public interface MessageCenterMapper {
+
+
+    void addMessageCenter(MessageCenter messageCenter);
+
+    Integer clubIdCule(Integer userId);
+
+    UserVo clubList(Integer userId);
+
+    CouponVo CouponList(Integer couponType);
+}

+ 56 - 0
src/main/java/com/caimei365/commodity/model/vo/MessageCenter.java

@@ -0,0 +1,56 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/7/7
+ */
+@Data
+public class MessageCenter implements Serializable {
+
+    /**
+    *消息id
+     */
+    private Integer id;
+    /**
+    供应商id
+     */
+    private Integer shopID;
+    /**
+    机构id
+     */
+    private Integer clubID;
+    /**
+   用户类型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;
+}

+ 138 - 0
src/main/java/com/caimei365/commodity/model/vo/UserVo.java

@@ -0,0 +1,138 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/3/15
+ */
+@Data
+public class UserVo implements Serializable {
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+    /**
+     * 用户类型,供应商1,会员机构3,普通机构4
+     */
+    private Integer registerUserTypeId;
+    /**
+     * 注册来源: 0网站 1小程序
+     */
+    private Integer source;
+    /**
+     * 机构ID
+     */
+    private Integer clubId;
+    /**
+     * 供应商ID
+     */
+    private Integer shopId;
+    /**
+     * 协销Id
+     */
+    private Integer serviceProviderId;
+    /**
+     * 用户名
+     */
+    private String userName;
+    /**
+     * 邮箱
+     */
+    private String email;
+    /**
+     * 手机号码
+     */
+    private String mobile;
+    /**
+     * 企业绑定手机号
+     */
+    private String bindMobile;
+    /**
+     * 密码
+     */
+    private String password;
+    /**
+     * 用户身份: 1协销 2会员机构 3供应商 4普通机构
+     */
+    private Integer userIdentity;
+    /**
+     * 用户权限: 2会员机构 3供应商 4协销 5普通机构
+     */
+    private Integer userPermission;
+    /**
+     * 组织名称
+     */
+    private String name;
+    /**
+     * 机构状态:90:已上线,91:已冻结,92:审查资料未通过,待补充资料,1:待审查资料,2:电话预约,3:已预约,20:待确认,21:待拜访,30:待员工推荐,40:已完成第一次采购
+     */
+    private Integer clubStatus;
+    /**
+     * 供应商状态:90:已上线,91:已下线,92:审核不通过,3:待审核
+     */
+    private Integer manufacturerStatus;
+    /**
+     * 协销状态:90:已上线
+     */
+    private Integer serviceProviderStatus;
+    /**
+     * 同意协议标志
+     */
+    private Integer agreeFlag;
+    /**
+     * 注册时间
+     */
+    private String registerTime;
+    /**
+     * 注册ip
+     */
+    private String registerIp;
+    /**
+     * 用户状态,1正常,0冻结
+     */
+    private Integer validFlag;
+    /**
+     * 审核状态,0 待审 1 审核通过 2 审核不通过
+     */
+    private Integer auditStatus;
+
+    /**
+     * 审核时间
+     */
+    private String auditTime;
+
+    /**
+     * 审核备注
+     */
+    private String auditNote;
+
+    /**
+     * 采美豆数量
+     */
+    private Integer userBeans;
+
+    /**
+     * 账户实际可用余额
+     */
+    private Double ableUserMoney;
+
+    /**
+     * 头像
+     */
+    private String image;
+
+    /**
+     * 审核不通过原因列表
+     */
+    private List<String> auditNoteList;
+    /**
+     * 登入时间
+     */
+    private String loginTime;
+}

+ 2 - 1
src/main/java/com/caimei365/commodity/service/CouponService.java

@@ -6,6 +6,7 @@ import com.caimei365.commodity.model.dto.RedeemCouponsDto;
 import com.caimei365.commodity.model.vo.CouponVo;
 import com.github.pagehelper.PageInfo;
 
+import java.text.ParseException;
 import java.util.Map;
 
 /**
@@ -54,7 +55,7 @@ public interface CouponService {
      * @param couponsDto
      * @return
      */
-    ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto);
+    ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) throws ParseException;
 
     /**
      * 兑换优惠券

+ 124 - 9
src/main/java/com/caimei365/commodity/service/impl/CouponServiceImpl.java

@@ -1,28 +1,25 @@
 package com.caimei365.commodity.service.impl;
 
 import com.caimei365.commodity.components.PriceUtilService;
-import com.caimei365.commodity.mapper.CouponMapper;
-import com.caimei365.commodity.mapper.PageMapper;
-import com.caimei365.commodity.mapper.PriceMapper;
-import com.caimei365.commodity.mapper.ShopMapper;
+import com.caimei365.commodity.mapper.*;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.dto.CollarCouponsDto;
 import com.caimei365.commodity.model.dto.RedeemCouponsDto;
 import com.caimei365.commodity.model.po.CouponClubPo;
 import com.caimei365.commodity.model.po.CouponRedemptionCodePo;
-import com.caimei365.commodity.model.vo.ActivityCouponVo;
-import com.caimei365.commodity.model.vo.CouponVo;
-import com.caimei365.commodity.model.vo.ProductItemVo;
-import com.caimei365.commodity.model.vo.ShopVo;
+import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.CouponService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -43,6 +40,8 @@ public class CouponServiceImpl implements CouponService {
     private PriceMapper priceMapper;
     @Resource
     private PriceUtilService priceUtilService;
+    @Resource
+    private MessageCenterMapper messageCenterMapper;
 
     /**
      * 已领取优惠券中心
@@ -131,7 +130,7 @@ public class CouponServiceImpl implements CouponService {
     }
 
     @Override
-    public ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) {
+    public ResponseJson<String> collarCoupons(CollarCouponsDto couponsDto) throws ParseException {
         Integer id = couponMapper.findCouponClubByUserId(couponsDto.getUserId(), couponsDto.getCouponId());
         if (id != null && id > 0) {
             return ResponseJson.error("已经领取过了", null);
@@ -144,6 +143,9 @@ public class CouponServiceImpl implements CouponService {
                 return ResponseJson.error("未成为超级会员无法领取超级会员券!");
             }
         }
+        Timerw(couponsDto.getUserId());
+        Timeto(couponsDto.getUserId());
+        Timeth(couponsDto.getUserId());
         CouponClubPo couponClub = new CouponClubPo();
         BeanUtils.copyProperties(couponsDto, couponClub);
         couponClub.setStatus("1");
@@ -153,6 +155,119 @@ public class CouponServiceImpl implements CouponService {
         return ResponseJson.success("领取成功");
     }
 
+    /**
+     * 每天12点判断
+     */
+    @Scheduled(cron = "0 0 12 * * ?")
+    private Void Timerw(Integer userId) throws ParseException {
+        if(userId!=null){
+           UserVo user= messageCenterMapper.clubList(userId);
+           CouponVo coupon= messageCenterMapper.CouponList(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=sdf.parse(endTime);
+            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());
+            MessageCenter messageCenter=new MessageCenter();
+            //推送信息中心-账户通知
+            if(s>15){
+                if(t==7){
+                    messageCenter.setShopID(null);
+                    messageCenter.setClubID(user.getClubId());
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(4);
+                    messageCenter.setCouponType(2);
+                    messageCenter.setContent(t+"天后过期");
+                    messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 每天下午3点判断
+     */
+    @Scheduled(cron = "0 0 10 * * ?")
+    private Void Timeto(Integer userId) throws ParseException {
+        if(userId!=null){
+            UserVo user= messageCenterMapper.clubList(userId);
+            CouponVo coupon= messageCenterMapper.CouponList(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=sdf.parse(endTime);
+            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());
+            MessageCenter messageCenter=new MessageCenter();
+            //推送信息中心-账户通知
+            if(s==1){
+
+                    messageCenter.setShopID(null);
+                    messageCenter.setClubID(user.getClubId());
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(4);
+                    messageCenter.setCouponType(2);
+                    messageCenter.setContent(null);
+                    messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+
+            }
+        }
+        return null;
+    }
+
+
+    @Scheduled(cron = "0 0 15 * * ?")
+    private Void Timeth(Integer userId) throws ParseException {
+        if(userId!=null){
+            UserVo user= messageCenterMapper.clubList(userId);
+            CouponVo coupon= messageCenterMapper.CouponList(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=sdf.parse(endTime);
+            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());
+            MessageCenter messageCenter=new MessageCenter();
+            //推送信息中心-账户通知
+
+                if(t==3){
+                    messageCenter.setShopID(null);
+                    messageCenter.setClubID(user.getClubId());
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(4);
+                    messageCenter.setCouponType(2);
+                    messageCenter.setContent(t+"天后下架");
+                    messageCenter.setCouponFee(coupon.getCouponAmount().doubleValue());
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                }
+
+        }
+        return null;
+    }
+
+
+
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public ResponseJson<CouponVo> redeemCoupons(RedeemCouponsDto redeemCouponsDto) {

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

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.commodity.mapper.MessageCenterMapper">
+    <insert id="addMessageCenter">
+        INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,accountType,couponType,couponFee)
+        VALUES (#{shopID}, #{clubID}, #{userType}, #{messageType}, #{content},#{time},#{accountType},#{couponType},#{couponFee})
+    </insert>
+
+    <select id="clubIdCule" resultType="java.lang.Integer">
+        SELECT clubID FROM `user` WHERE userId=#{userId}
+    </select>
+
+    <select id="clubList" resultType="com.caimei365.commodity.model.vo.UserVo">
+        SELECT * FROM `user` WHERE userId=#{userId}
+    </select>
+
+    <select id="CouponList" resultType="com.caimei365.commodity.model.vo.CouponVo">
+        SELECT * FROM cm_coupon WHERE couponType=#{couponType} AND  NOW()>= startDate AND endDate >= NOW() AND status=1 AND delFlag=0
+    </select>
+
+</mapper>