Browse Source

站内消息

Duan_xu 2 years ago
parent
commit
177f3f5bd0

+ 82 - 3
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -3,14 +3,17 @@ package com.caimei365.user.controller;
 import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.*;
+import com.caimei365.user.model.vo.MessageCenter;
 import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.service.LoginService;
 import com.caimei365.user.service.SellerService;
+import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.ParseException;
 import java.util.Map;
 
 /**
@@ -43,7 +46,7 @@ public class LoginApi {
     @ApiOperation("登录(用户名,密码)")
     @IpSave(saveName = "用户登录",saveParams = true)
     @PostMapping("/password")
-    public ResponseJson<UserLoginVo> passwordLogin(LoginPasswordDto loginPasswordDto) {
+    public ResponseJson<UserLoginVo> passwordLogin(LoginPasswordDto loginPasswordDto)throws ParseException {
         return loginService.passwordLogin(loginPasswordDto);
     }
 
@@ -81,13 +84,89 @@ public class LoginApi {
     @ApiOperation("微信授权登录(小程序)")
     @IpSave(saveName = "微信授权登录(小程序)",saveParams = false)
     @PostMapping("/auth/applets")
-    public ResponseJson<UserLoginVo> appletsAuthorization(AuthAppletsDto authAppletsDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<UserLoginVo> appletsAuthorization(AuthAppletsDto authAppletsDto, @RequestHeader HttpHeaders headers) throws ParseException {
         String code = authAppletsDto.getCode();
         String encryptedData = authAppletsDto.getEncryptedData();
         String iv = authAppletsDto.getIv();
         return loginService.appletsAuthorization(code, encryptedData, iv, headers);
     }
 
+    @ApiOperation("机构站内消息未读消息记录数")
+    @GetMapping("/auth/ClubMessageCount")
+    public ResponseJson<Map<String, Object>> ClubMessageCount(Integer messageType,Integer commonId){
+
+        return loginService.ClubMessageCount(messageType,commonId);
+    }
+
+    @ApiOperation("供应商站内消息未读消息记录数")
+    @GetMapping("/auth/shopMessageCount")
+    public ResponseJson<Map<String, Object>> shopMessageCount(Integer messageType,Integer commonId){
+
+        return loginService.shopMessageCount(messageType,commonId);
+    }
+
+    @ApiOperation("供应商站内消息未读消息总记录数")
+    @GetMapping("/auth/ShopCount")
+    public ResponseJson<Map<String, Object>> ShopCount(Integer messageType,Integer commonId){
+
+        return loginService.ShopCount(messageType,commonId);
+    }
+
+    @ApiOperation("机构站内消息未读消息总记录数")
+    @GetMapping("/auth/ClubCount")
+    public ResponseJson<Map<String, Object>> ClubCount(Integer messageType,Integer commonId){
+
+        return loginService.ClubCount(messageType,commonId);
+    }
+
+
+    @ApiOperation("机构站内消息列表")
+    @GetMapping("/auth/ClubMessageList")
+    public ResponseJson<PageInfo<MessageCenter>> ClubMessageList(Integer commonId,Integer messageType,Integer source, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                 @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
+        return loginService.ClubMessageList(commonId,messageType,source,pageNum,pageSize);
+
+    }
+
+    @ApiOperation("供应商站内消息列表")
+    @GetMapping("/auth/shopMessageList")
+    public ResponseJson<PageInfo<MessageCenter>> shopMessageList(Integer commonId,Integer messageType,Integer source, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                 @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
+
+        return loginService.shopMessageList(commonId,messageType,source,pageNum,pageSize);
+    }
+
+
+    @ApiOperation("机构站内消息改为已读")
+    @GetMapping("/auth/updateMessageAsRead")
+    public Integer updateMessageAsRead(Integer messageType,Integer commonId){
+        return loginService.updateMessageAsRead(messageType,commonId);
+    }
+
+    @ApiOperation("供应商站内消息改为已读")
+    @GetMapping("/auth/updateShopMessageAsRead")
+    public Integer updateShopMessageAsRead(Integer messageType,Integer commonId){
+        return loginService.updateShopMessageAsRead(messageType,commonId);
+    }
+
+    @ApiOperation("删除站内消息")
+    @PostMapping("/auth/deleteMessage")
+    public ResponseJson<Void> deleteMessage(String id){
+        Integer i=loginService.deleteMessage(id);
+        if (i<=0){
+            return ResponseJson.error("删除失败!", null);
+        }
+          return ResponseJson.success("删除成功", null);
+    }
+
+
+    @ApiOperation("站内消息所有消息改为已读")
+    @PostMapping("/auth/updateRead")
+    public Integer updateRead(Integer userType,String Id){
+        return loginService.updateRead(userType,Id);
+    }
+
+
     /**
      * 微信公众号授权链接(www)
      *
@@ -179,7 +258,7 @@ public class LoginApi {
     @ApiOperation("校验扫码登录结果")
     @ApiImplicitParam(required = true, name = "state", value = "安全认证key")
     @GetMapping("/auth/scan/result")
-    public ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state){
+    public ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state)throws ParseException{
         return loginService.qrCodeAuthScanResult(state);
     }
 

+ 55 - 0
src/main/java/com/caimei365/user/mapper/MessageCenterMapper.java

@@ -0,0 +1,55 @@
+package com.caimei365.user.mapper;
+
+import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.vo.CouponVo;
+import com.caimei365.user.model.vo.MessageCenter;
+import com.caimei365.user.model.vo.UserVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2022/7/7
+ */
+@Mapper
+public interface MessageCenterMapper {
+
+
+    void addMessageCenter(MessageCenter messageCenter);
+
+    Integer clubIdCule(Integer userId);
+
+    Integer shopID(Integer userId);
+
+    UserVo clubList(Integer userId);
+
+    CouponVo CouponList(Integer couponType);
+
+    Integer MessageCount(Integer userType,Integer messageType,Integer commonId);
+
+    /**
+     *commonId是通过userType类型来区分供应商和机构
+     */
+    Integer Count(Integer userType,Integer commonId);
+
+    List<MessageCenter> MessageList(Integer userType,Integer messageType,Integer commonId);
+
+    MessageCenter MainImage(Integer userType, Integer commonId);
+
+    String receiptDate(Integer shopID);
+
+    Integer newReceiptType(Integer shopID);
+
+    Integer updateMessageAsRead(Integer userType,Integer messageType,Integer commonId);
+
+    Integer userId(String openid);
+
+    Integer deleteMessage(String id);
+
+    Integer updateRead(Integer userType,String Id);
+
+}

+ 104 - 0
src/main/java/com/caimei365/user/model/vo/MessageCenter.java

@@ -0,0 +1,104 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 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;
+    /**
+     * 订单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;
+
+
+
+}

+ 3 - 0
src/main/java/com/caimei365/user/model/vo/UserLoginVo.java

@@ -150,4 +150,7 @@ public class UserLoginVo implements Serializable {
 
     @ApiModelProperty("是否是协销组长,有id则是,没有则不是")
     private Integer leaderId;
+
+    @ApiModelProperty("未读消息总数")
+    private Integer savedCount;
 }

+ 4 - 0
src/main/java/com/caimei365/user/model/vo/UserVo.java

@@ -131,4 +131,8 @@ public class UserVo implements Serializable {
      * 审核不通过原因列表
      */
     private List<String> auditNoteList;
+    /**
+     * 登入时间
+     */
+    private String loginTime;
 }

+ 27 - 3
src/main/java/com/caimei365/user/service/LoginService.java

@@ -4,9 +4,12 @@ import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.AuthBindDto;
 import com.caimei365.user.model.dto.LoginPasswordDto;
 import com.caimei365.user.model.dto.ScanBindDto;
+import com.caimei365.user.model.vo.MessageCenter;
 import com.caimei365.user.model.vo.UserLoginVo;
+import com.github.pagehelper.PageInfo;
 import org.springframework.http.HttpHeaders;
 
+import java.text.ParseException;
 import java.util.Map;
 
 
@@ -28,7 +31,7 @@ public interface LoginService {
      *                         }
      * @return BaseUser
      */
-    ResponseJson<UserLoginVo> passwordLogin(LoginPasswordDto loginPasswordDto);
+    ResponseJson<UserLoginVo> passwordLogin(LoginPasswordDto loginPasswordDto) throws ParseException;
 
     /**
      * 微信授权登录(小程序)
@@ -38,7 +41,28 @@ public interface LoginService {
      * @param iv            加密算法的初始向量
      * @return BaseUser
      */
-    ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, HttpHeaders headers);
+    ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, HttpHeaders headers) throws ParseException;
+
+
+    ResponseJson<PageInfo<MessageCenter>> ClubMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
+
+    ResponseJson<PageInfo<MessageCenter>> shopMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
+
+    ResponseJson<Map<String, Object>> ClubMessageCount(Integer messageType,Integer commonId);
+
+    ResponseJson<Map<String, Object>> shopMessageCount(Integer messageType,Integer commonId);
+
+    ResponseJson<Map<String, Object>> ShopCount(Integer messageType,Integer commonId);
+
+    ResponseJson<Map<String, Object>> ClubCount(Integer messageType,Integer commonId);
+
+     Integer updateMessageAsRead(Integer messageType,Integer commonId);
+
+    Integer updateShopMessageAsRead(Integer messageType,Integer commonId);
+
+     Integer updateRead(Integer userType,String Id);
+
+    Integer deleteMessage(String id);
 
     /**
      * 微信公众号授权链接(www)
@@ -80,7 +104,7 @@ public interface LoginService {
      * @param state   安全认证key(第一步获取参数时自定义生成的uuid)
      * @return UserLoginVo
      */
-    ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state);
+    ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state) throws ParseException;
 
     /**
      * 微信扫码后,绑定机构账号

+ 388 - 5
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -13,18 +13,22 @@ import com.caimei365.user.model.dto.ScanBindDto;
 import com.caimei365.user.model.dto.SuperVipDto;
 import com.caimei365.user.model.po.OperationPo;
 import com.caimei365.user.model.po.SuperVipPo;
-import com.caimei365.user.model.vo.LoginFailRecordVo;
-import com.caimei365.user.model.vo.UserLoginVo;
+import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.LoginService;
 import com.caimei365.user.utils.JwtUtil;
 import com.caimei365.user.utils.Md5Util;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -55,6 +59,8 @@ public class LoginServiceImpl implements LoginService {
     private AsyncService asyncService;
     @Resource
     private SellerMapper sellerMapper;
+    @Resource
+    private MessageCenterMapper messageCenterMapper;
     /**
      * 小程序邀请码过期天数
      */
@@ -72,7 +78,7 @@ public class LoginServiceImpl implements LoginService {
      * @return BaseUser
      */
     @Override
-    public ResponseJson<UserLoginVo> passwordLogin(LoginPasswordDto loginPasswordDto) {
+    public ResponseJson<UserLoginVo> passwordLogin(LoginPasswordDto loginPasswordDto) throws ParseException {
         String mobileOrEmail = loginPasswordDto.getMobileOrEmail();
         String password = loginPasswordDto.getPassword();
         String unionId = loginPasswordDto.getUnionId();
@@ -97,6 +103,23 @@ public class LoginServiceImpl implements LoginService {
             }
             // 如果前端传入unionId,则存入返回前端
             baseUser.setUnionId(unionId);
+
+            Integer clubId=messageCenterMapper.clubIdCule(baseUser.getUserId());
+            Integer savedCount=null;
+            if(baseUser.getUserId()!=null){
+                Integer shopID=messageCenterMapper.shopID(baseUser.getUserId());
+                Integer newReceiptType= messageCenterMapper.newReceiptType(shopID);
+                if(shopID==null){
+                    savedCount= messageCenterMapper.Count(1,clubId);
+                    System.out.println(savedCount);
+                }else {
+                    savedCount= messageCenterMapper.Count(2,shopID);
+                }
+            }
+            Timerw(baseUser.getUserId());
+            Timesjf(baseUser.getUserId());
+
+
             // 比对密码
             String md5Password = Md5Util.md5(password);
             String dbPassword = baseUser.getPassword();
@@ -128,7 +151,7 @@ public class LoginServiceImpl implements LoginService {
      * @param headers       HttpHeaders
      */
     @Override
-    public ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, HttpHeaders headers) {
+    public ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, HttpHeaders headers) throws ParseException {
         if (StringUtils.isBlank(code)) {
             return ResponseJson.error("没有获取到微信授权code", null);
         }
@@ -160,6 +183,22 @@ public class LoginServiceImpl implements LoginService {
         log.info("小程序授权登录,返回unionId给前端,用户数据存入Redis,key:wxInfo:applets:" + unionId);
         // 协销授权登录
         UserLoginVo seller = loginMapper.getServiceProviderUserByOpenId(openId);
+        Integer userID=messageCenterMapper.userId(openId);
+        Integer clubId=messageCenterMapper.clubIdCule(userID);
+        Integer savedCount=null;
+if(userID!=null) {
+    Integer shopID = messageCenterMapper.shopID(userID);
+    Integer newReceiptType = messageCenterMapper.newReceiptType(shopID);
+    if (shopID == null) {
+        savedCount = messageCenterMapper.Count(1, clubId);
+        System.out.println(savedCount);
+    } else {
+        savedCount = messageCenterMapper.Count(2, shopID);
+    }
+
+    Timerw(userID);
+    Timesjf(userID);
+    }
         if (null != seller) {
             loginMapper.updateServiceProviderUnionId(seller.getUserId(), unionId);
             String token = JwtUtil.createToken(seller.getUserId());
@@ -179,6 +218,280 @@ public class LoginServiceImpl implements LoginService {
         return operationAuthLogin(openId, unionId, "mini");
     }
 
+    @Override
+    public ResponseJson<Map<String, Object>> ClubMessageCount(Integer messageType,Integer commonId){
+
+        Integer count=messageCenterMapper.Count(1,commonId);
+       Integer tradeCount= messageCenterMapper.MessageCount(1,1,commonId);
+       Integer accountCount=messageCenterMapper.MessageCount(1,2,commonId);
+        Integer notificationCount= messageCenterMapper.MessageCount(1,3,commonId);
+        Integer promotionCount=messageCenterMapper.MessageCount(1,4,commonId);
+        Map<String, Object> map = new HashMap(10);
+        map.put("count", count);
+        map.put("tradeCount", tradeCount);
+        map.put("account",accountCount);
+        map.put("notificationCount", notificationCount);
+        map.put("promotionCount",promotionCount);
+
+
+        return ResponseJson.success(map);
+    }
+    @Override
+    public ResponseJson<Map<String, Object>> shopMessageCount(Integer messageType,Integer commonId){
+        Integer count=messageCenterMapper.Count(2,commonId);
+        Integer tradeCount= messageCenterMapper.MessageCount(2,1,commonId);
+        Integer accountCount=messageCenterMapper.MessageCount(2,2,commonId);
+        Integer notificationCount= messageCenterMapper.MessageCount(2,3,commonId);
+        Integer promotionCount=messageCenterMapper.MessageCount(2,4,commonId);
+        Map<String, Object> map = new HashMap(10);
+        map.put("count", count);
+        map.put("tradeCount", tradeCount);
+        map.put("accountCount",accountCount);
+        map.put("notificationCount", notificationCount);
+        map.put("promotionCount",promotionCount);
+        return ResponseJson.success(map);
+    }
+   @Override
+   public ResponseJson<Map<String, Object>> ShopCount(Integer messageType,Integer commonId){
+       Integer count=messageCenterMapper.Count(2,commonId);
+       Map<String, Object> map = new HashMap(10);
+       map.put("count", count);
+        return ResponseJson.success(map);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> ClubCount(Integer messageType,Integer commonId){
+        Integer count=messageCenterMapper.Count(1,commonId);
+        Map<String, Object> map = new HashMap(10);
+        map.put("count", count);
+        return ResponseJson.success(map);
+    }
+
+
+    @Override
+    public Integer updateMessageAsRead(Integer messageType,Integer commonId){
+
+      return messageCenterMapper.updateMessageAsRead(1,messageType,commonId);
+    }
+
+    @Override
+    public Integer updateShopMessageAsRead(Integer messageType,Integer commonId){
+
+        return messageCenterMapper.updateMessageAsRead(2,messageType,commonId);
+    }
+     @Override
+    public Integer deleteMessage(String id){
+         Integer num=0;
+         String[] IdArr = id.split(",");
+         for (int i = 0; i < IdArr.length; i++) {
+              num= messageCenterMapper.deleteMessage(IdArr[i]);
+         }
+         return num;
+    }
+    @Override
+    public Integer updateRead(Integer userType,String Id){
+        Integer num=0;
+            String[] IdArr = Id.split(",");
+            for (int i = 0; i < IdArr.length; i++) {
+                num= messageCenterMapper.updateRead(userType,IdArr[i]);
+            }
+
+        return num;
+    }
+
+
+    @Override
+    public ResponseJson<PageInfo<MessageCenter>> ClubMessageList(Integer commonId,Integer messageType,Integer source,int pageNum, int pageSize){
+
+    PageHelper.startPage(pageNum, pageSize);
+    List<MessageCenter> list=messageCenterMapper.MessageList(1,messageType,commonId);
+    list.forEach(mess -> {
+        if(mess.getClubId()!=null){
+            MessageCenter messageCenter= messageCenterMapper.MainImage(1,commonId);
+            if(messageCenter!=null){
+                mess.setMainImage(messageCenter.getMainImage());
+                mess.setOnlinePayFlag(messageCenter.getOnlinePayFlag());
+                if(messageCenter.getProductName().length()>10){
+                    mess.setProductName(StringUtils.strip(messageCenter.getProductName().substring(0, 11)));
+                }else {
+                    mess.setProductName(messageCenter.getProductName());
+                }
+                mess.setProductCount(messageCenter.getProductCount());
+                mess.setRefundType(messageCenter.getRefundType());
+            }
+
+        }
+            });
+    if(source ==2){
+        messageCenterMapper.updateMessageAsRead(1,messageType,commonId);
+    }
+
+    PageInfo<MessageCenter> pageData = new PageInfo<>(list);
+        return ResponseJson.success(pageData);
+}
+
+    @Override
+    public ResponseJson<PageInfo<MessageCenter>> shopMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize){
+        PageHelper.startPage(pageNum, pageSize);
+        List<MessageCenter> list=messageCenterMapper.MessageList(2,messageType,commonId);
+        list.forEach(mess -> {
+            if(mess.getShopId()!=null){
+                MessageCenter messageCenter= messageCenterMapper.MainImage(2,commonId);
+                if(messageCenter!=null){
+                    mess.setMainImage(messageCenter.getMainImage());
+                    mess.setOnlinePayFlag(messageCenter.getOnlinePayFlag());
+                    if(messageCenter.getProductName().length()>10){
+                        mess.setProductName(StringUtils.strip(messageCenter.getProductName().substring(0, 11)));
+                    }else {
+                        mess.setProductName(messageCenter.getProductName());
+                    }
+                    mess.setProductCount(messageCenter.getProductCount());
+                    mess.setRefundType(messageCenter.getRefundType());
+                }
+
+            }
+
+        });
+        if(source ==2) {
+            messageCenterMapper.updateMessageAsRead(2, messageType, commonId);
+        }
+        PageInfo<MessageCenter> pageData = new PageInfo<>(list);
+        return ResponseJson.success(pageData);
+    }
+
+
+
+
+    /**
+     * 每天下午3点判断
+     */
+    @Scheduled(cron = "0 0 15 * * ?")
+    private Void Timesjf(Integer userId) throws ParseException {
+        Integer shopID=messageCenterMapper.shopID(userId);
+        if(shopID!=null){
+           String receiptDate= messageCenterMapper.receiptDate(shopID);
+            Calendar calendar = Calendar.getInstance();
+
+            Integer clubId=messageCenterMapper.clubIdCule(userId);
+            if(clubId!=null){
+                Date d=new Date();
+                //1.日期格式
+                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+                Date time = sdf.parse(receiptDate);
+                calendar.setTime(time);
+                calendar.add(Calendar.YEAR, 1);
+               String dateStrings= sdf.format(calendar.getTime());
+                //2.到期时间
+                Date da1=sdf.parse(dateStrings);
+                //到期时间-当前时间=还剩多少天
+                Long s=(da1.getTime()-d.getTime())/24/60/60/1000;
+                //3.输出间隔天数         getTime获取的是毫秒
+                log.info("输出间隔天数----------->",s);
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String current = dateFormat.format(new Date());
+                MessageCenter messageCenter=new MessageCenter();
+                //推送信息中心-上架费服务通知
+                if(s==30){
+                    messageCenter.setShopId(shopID);
+                    messageCenter.setClubId(null);
+                    messageCenter.setUserType(2);
+                    messageCenter.setMessageType(3);
+                    messageCenter.setShopTieredType(1);
+                    messageCenter.setContent(s+"日后");
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                }
+                if(s==7){
+                    messageCenter.setShopId(shopID);
+                    messageCenter.setClubId(null);
+                    messageCenter.setUserType(2);
+                    messageCenter.setMessageType(3);
+                    messageCenter.setShopTieredType(1);
+                    messageCenter.setContent(s+"日后");
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                }
+                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);
+                }
+                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);
+                }
+
+            }
+        }
+
+        return null;
+    }
+
+
+
+
+    /**
+     * 每天下午3点判断
+     */
+    @Scheduled(cron = "0 0 15 * * ?")
+    private Void Timerw(Integer userId) throws ParseException {
+        SuperVipPo superVip = vipMapper.findSuperVip(userId);
+        Integer clubId=messageCenterMapper.clubIdCule(userId);
+        if(clubId!=null){
+            if(superVip!=null){
+                Date d=new Date();
+                //1.日期格式
+                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+                String endTime = sdf.format(superVip.getEndTime());
+                //2.某天的日期
+                Date da1=sdf.parse(endTime);
+                Long s=(d.getTime()-da1.getTime())/24/60/60/1000;
+                //3.输出间隔天数         getTime获取的是毫秒
+                log.info("输出间隔天数----------->",s);
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String current = dateFormat.format(new Date());
+                MessageCenter messageCenter=new MessageCenter();
+                //推送信息中心-账户通知
+                if(s==7){
+                    messageCenter.setShopId(null);
+                    messageCenter.setClubId(clubId);
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(2);
+                    messageCenter.setAccountType(3);
+                    messageCenter.setContent(s+"日后");
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                }
+                if(s==1){
+                    messageCenter.setShopId(null);
+                    messageCenter.setClubId(clubId);
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(2);
+                    messageCenter.setAccountType(3);
+                    messageCenter.setContent("今日后");
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+                }
+            }
+        }
+        return null;
+    }
+
+
+
+
+
     /**
      * 微信公众号授权链接(www)
      *
@@ -386,7 +699,7 @@ public class LoginServiceImpl implements LoginService {
      * @return UserLoginVo
      */
     @Override
-    public ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state) {
+    public ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state) throws ParseException {
         if (StringUtils.isBlank(state)) {
             return ResponseJson.error("参数异常:state不能为空!", null);
         }
@@ -403,6 +716,23 @@ public class LoginServiceImpl implements LoginService {
         String unionId = (String) infoData.get(WeChatService.Keys.UNION_ID);
         String openId = (String) infoData.get(WeChatService.Keys.OPEN_ID);
         log.info(">>>>>>pc商城unionId:" + unionId + " ,openId:" + openId);
+
+        Integer userId=messageCenterMapper.userId(openId);
+        Integer clubId=messageCenterMapper.clubIdCule(userId);
+        Integer savedCount=null;
+        if(userId!=null){
+            Integer shopID=messageCenterMapper.shopID(userId);
+            Integer newReceiptType= messageCenterMapper.newReceiptType(shopID);
+            if(shopID==null){
+                savedCount= messageCenterMapper.Count(1,clubId);
+                System.out.println(savedCount);
+            }else {
+                savedCount= messageCenterMapper.Count(2,shopID);
+            }
+        }
+        Timerw(userId);
+        Timesjf(userId);
+
         // 用户数据存入Redis,key前缀:wxInfo:website:
         String infoDataStr = JSON.toJSONString(infoData);
         Map<String, Object> infoDataMap = JSON.parseObject(infoDataStr);
@@ -564,16 +894,42 @@ public class LoginServiceImpl implements LoginService {
         operationPo.setAvatarUrl(avatarUrl);
         // 绑定状态,1未绑定,2已绑定
         operationPo.setStatus(2);
+
         if (1 == userIdentity) {
             // 机构Id
             operationPo.setClubId(operation.getClubId());
             // 用户类型
             operationPo.setUserType(1);
+
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String current = dateFormat.format(new Date());
+            MessageCenter messageCenter = new MessageCenter();
+            messageCenter.setShopId(null);
+            messageCenter.setClubId(operation.getClubId());
+            messageCenter.setUserType(1);
+            messageCenter.setMessageType(2);
+            messageCenter.setAccountType(7);
+            messageCenter.setContent(nickName);
+            messageCenter.setTime(current);
+            messageCenterMapper.addMessageCenter(messageCenter);
+
         } else {
             // 供应商Id
             operationPo.setShopId(operation.getShopId());
             // 用户类型
             operationPo.setUserType(2);
+
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String current = dateFormat.format(new Date());
+            MessageCenter messageCenter = new MessageCenter();
+            messageCenter.setShopId(operation.getShopId());
+            messageCenter.setClubId(null);
+            messageCenter.setUserType(2);
+            messageCenter.setMessageType(2);
+            messageCenter.setShopMessType(2);
+            messageCenter.setContent(nickName);
+            messageCenter.setTime(current);
+            messageCenterMapper.addMessageCenter(messageCenter);
         }
         // 更新运营人员信息
         operationMapper.updateOperationByInvitation(operationPo);
@@ -654,10 +1010,37 @@ public class LoginServiceImpl implements LoginService {
         if (user != null && 3 == user.getUserIdentity()) {
             operation.setShopId(user.getShopId());
             operation.setUserType(2);
+
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String current = dateFormat.format(new Date());
+            MessageCenter messageCenter = new MessageCenter();
+            messageCenter.setShopId(operation.getShopId());
+            messageCenter.setClubId(null);
+            messageCenter.setUserType(2);
+            messageCenter.setMessageType(2);
+            messageCenter.setShopMessType(2);
+            messageCenter.setContent(nickName);
+            messageCenter.setTime(current);
+            messageCenterMapper.addMessageCenter(messageCenter);
+
         } else if (user != null) {
             operation.setClubId(user.getClubId());
             operation.setUserType(1);
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String current = dateFormat.format(new Date());
+            MessageCenter messageCenter = new MessageCenter();
+            messageCenter.setShopId(null);
+            messageCenter.setClubId(user.getClubId());
+            messageCenter.setUserType(1);
+            messageCenter.setMessageType(2);
+            messageCenter.setAccountType(7);
+            messageCenter.setContent(nickName);
+            messageCenter.setTime(current);
+            messageCenterMapper.addMessageCenter(messageCenter);
         }
+
+
+
         // 绑定状态
         operation.setStatus(2);
         // 删除标识

+ 37 - 0
src/main/java/com/caimei365/user/service/impl/OperationServiceImpl.java

@@ -1,10 +1,12 @@
 package com.caimei365.user.service.impl;
 
 import com.caimei365.user.components.CommonService;
+import com.caimei365.user.mapper.MessageCenterMapper;
 import com.caimei365.user.mapper.OperationMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.OperationDto;
 import com.caimei365.user.model.po.OperationPo;
+import com.caimei365.user.model.vo.MessageCenter;
 import com.caimei365.user.model.vo.OperationVo;
 import com.caimei365.user.model.vo.PaginationVo;
 import com.caimei365.user.service.OperationService;
@@ -16,6 +18,7 @@ import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
@@ -36,6 +39,8 @@ public class OperationServiceImpl implements OperationService {
     private OperationMapper operationMapper;
     @Resource
     private RemoteCallService remoteCallService;
+    @Resource
+    private MessageCenterMapper messageCenterMapper;
 
     /**
      * 添加运营人员
@@ -63,6 +68,24 @@ public class OperationServiceImpl implements OperationService {
         operation.setUserId(operationDto.getUserId());
         operation.setClubId(operationDto.getClubId());
         operation.setShopId(operationDto.getShopId());
+
+        //推送信息中心-账户通知
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String current = dateFormat.format(new Date());
+        MessageCenter messageCenter=new MessageCenter();
+        if(operation.getClubId()!=null){
+            messageCenter.setShopId(null);
+            messageCenter.setClubId(operation.getClubId());
+            messageCenter.setUserType(1);
+            messageCenter.setMessageType(2);
+            messageCenter.setAccountType(7);
+            messageCenter.setContent(operation.getNickName());
+            messageCenter.setTime(current);
+            messageCenterMapper.addMessageCenter(messageCenter);
+        }
+
+
+
         Date date = new Date();
         // 保存生成邀请码
         if (operationDto.getConfigFlag() == 2) {
@@ -128,6 +151,20 @@ public class OperationServiceImpl implements OperationService {
             operation.setInvitationCode(invitationCode);
             operation.setInvitationCodeTime(new Date());
             operation.setStatus(1);
+//推送信息中心-账户通知
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String current = dateFormat.format(new Date());
+            MessageCenter messageCenter = new MessageCenter();
+            if (operation.getClubId() != null) {
+                messageCenter.setShopId(null);
+                messageCenter.setClubId(operation.getClubId());
+                messageCenter.setUserType(1);
+                messageCenter.setMessageType(2);
+                messageCenter.setAccountType(7);
+                messageCenter.setContent(operation.getNickName());
+                messageCenter.setTime(current);
+                messageCenterMapper.addMessageCenter(messageCenter);
+            }
             //发送短信
             String name = null;
             if (operation.getClubId() != null) {

+ 124 - 4
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -19,11 +19,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
@@ -60,6 +62,8 @@ public class RegisterServiceImpl implements RegisterService {
     @Resource
     private MessagePushMapper messagePushMapper;
     @Resource
+    private MessageCenterMapper messageCenterMapper;
+    @Resource
     private RemoteCallService remoteCallService;
 
     /**
@@ -214,6 +218,17 @@ public class RegisterServiceImpl implements RegisterService {
         // user更新clubId
         user.setClubId(club.getClubId());
         registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
+        //推送信息中心-账户通知
+        MessageCenter messageCenter=new MessageCenter();
+        messageCenter.setShopId(null);
+        messageCenter.setClubId(club.getClubId());
+        messageCenter.setUserType(1);
+        messageCenter.setMessageType(2);
+        messageCenter.setAccountType(1);
+        messageCenter.setContent(null);
+        messageCenter.setTime(current);
+        messageCenterMapper.addMessageCenter(messageCenter);
+
         // 注册成功短信
         String content = "注册成功!您可以通过手机号"+clubRegisterDto.getBindMobile()+"登录。";
         boolean smsFlag = remoteCallService.remoteSendSms(0, 1, clubRegisterDto.getBindMobile(), content);
@@ -225,6 +240,17 @@ public class RegisterServiceImpl implements RegisterService {
             绑定微信,成为机构运营人员
          */
         if (StringUtils.isNotEmpty(clubRegisterDto.getNickName())) {
+
+            MessageCenter messageCente=new MessageCenter();
+            messageCente.setShopId(null);
+            messageCente.setClubId(club.getClubId());
+            messageCente.setUserType(1);
+            messageCente.setMessageType(2);
+            messageCente.setAccountType(7);
+            messageCente.setContent(clubRegisterDto.getNickName());
+            messageCente.setTime(current);
+            messageCenterMapper.addMessageCenter(messageCenter);
+
             OperationPo operation = new OperationPo();
             // 组织Id,采美默认0
             operation.setOrganizeId(0);
@@ -285,7 +311,7 @@ public class RegisterServiceImpl implements RegisterService {
     }
 
     /**
-     * 普通机构升级会员机构
+     * 普通机构升级会员机构(资质机构)
      *
      * @param upgradeDto ClubUpgradeDto:{
      *                   clubId                 机构ID
@@ -650,6 +676,20 @@ public class RegisterServiceImpl implements RegisterService {
             user.setClubId(club.getClubId());
             registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
         }
+        //推送信息中心-账户通知
+        MessageCenter messageCenter=new MessageCenter();
+        messageCenter.setShopId(null);
+        messageCenter.setClubId(club.getClubId());
+        messageCenter.setUserType(1);
+        messageCenter.setMessageType(2);
+        messageCenter.setAccountType(1);
+        messageCenter.setContent(null);
+        messageCenter.setTime(current);
+        messageCenterMapper.addMessageCenter(messageCenter);
+
+
+
+
         /*
          * 操作成功,推送短信给机构,获取账号密码。
          * 协销去后台审核,机构用账号密码登录绑定微信
@@ -857,6 +897,19 @@ public class RegisterServiceImpl implements RegisterService {
         user.setShopId(shop.getShopId());
         registerMapper.updateUserShopId(user.getUserId(), shop.getShopId());
         log.info("注册供应商---------userID:" + user.getUserId());
+
+        //推送信息中心-账户通知
+//        MessageCenter messageCenter=new MessageCenter();
+//        messageCenter.setShopID(shop.getShopId());
+//        messageCenter.setClubID(null);
+//        messageCenter.setUserType(2);
+//        messageCenter.setMessageType(2);
+//        messageCenter.setContent(null);
+//        messageCenter.setTime(current);
+//        messageCenterMapper.addMessageCenter(messageCenter);
+
+
+
         return ResponseJson.success();
     }
 
@@ -965,10 +1018,11 @@ public class RegisterServiceImpl implements RegisterService {
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public ResponseJson superVipUpByBeans(Integer userId, Integer packageId, HttpHeaders headers) {
+    public ResponseJson superVipUpByBeans(Integer userId, Integer packageId, HttpHeaders headers){
         SuperVipDto endFlag = findEnd(userId);
         Integer userBeans = vipMapper.findUserBeans(userId);
         VipPackage pac = vipMapper.findUserPackage(packageId);
+
         //过期和没买过都是生效时间重置,到期时间=现在+套餐时间
         if (endFlag.getVipFlag() == 0 || endFlag.getVipFlag() == -1) {
             //1.查用户采美豆,够就用采美豆下单,不够就返回信息
@@ -997,7 +1051,7 @@ public class RegisterServiceImpl implements RegisterService {
      * @param headers
      */
     @Override
-    public ResponseJson<Integer> superVipUpByPay(Integer userId, Integer packageId, HttpHeaders headers) {
+    public ResponseJson<Integer> superVipUpByPay(Integer userId, Integer packageId, HttpHeaders headers){
         SuperVipDto endFlag = findEnd(userId);
         VipPackage pac = vipMapper.findUserPackage(packageId);
         if (null == pac) {
@@ -1034,16 +1088,41 @@ public class RegisterServiceImpl implements RegisterService {
             vipMapper.addPayHistory(payHistory);
         }
         if (payHistory.getId() > 0) {
+           Integer clubId=messageCenterMapper.clubIdCule(userId);
+           if(clubId!=null){
+               //推送信息中心-账户通知
+               SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+               String current = dateFormat.format(new Date());
+               //1.日期格式
+               SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+               String endTime = sdf.format(payHistory.getEndTime());
+               //2.某天的日期
+               Long s=(payHistory.getBeginTime().getTime()-payHistory.getEndTime().getTime())/24/60/60/30/1000;;
+               //3.输出间隔天数         getTime获取的是毫秒
+               log.info("输出间隔月份----------->",s);
+               MessageCenter messageCenter=new MessageCenter();
+               messageCenter.setShopId(null);
+               messageCenter.setClubId(clubId);
+               messageCenter.setUserType(1);
+               messageCenter.setMessageType(2);
+               messageCenter.setAccountType(2);
+               messageCenter.setContent(s+"个月");
+               messageCenter.setTime(current);
+               messageCenterMapper.addMessageCenter(messageCenter);
+           }
             return ResponseJson.success(payHistory.getId());
         }
         return ResponseJson.error("支付开通超级会员异常!", null);
     }
 
 
+
+
+
     /**
      * 根据userId查是否过期,返回dto对象,flag=0未买过,-1过期,1有效,endTime过期时间
      */
-    private SuperVipDto findEnd(Integer userId) {
+    private SuperVipDto findEnd(Integer userId){
         SuperVipPo superVip = vipMapper.findSuperVip(userId);
         SuperVipDto superVipDto = new SuperVipDto();
         if (superVip == null) {
@@ -1057,7 +1136,34 @@ public class RegisterServiceImpl implements RegisterService {
                 superVipDto.setVipFlag(1);
                 superVipDto.setEndTime(endTime.getEndTime());
             }
+
+            Integer clubId = messageCenterMapper.clubIdCule(userId);
+            if (clubId != null) {
+                //推送信息中心-账户通知
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                String current = dateFormat.format(new Date());
+                //1.日期格式
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+                String endTimes = sdf.format(endTime.getEndTime());
+                //2.某天的日期
+                Long s = (endTime.getEndTime().getTime() - endTime.getBeginTime().getTime()) / 24 / 60 / 60 / 30 / 1000;
+                ;
+                //3.输出间隔天数         getTime获取的是毫秒
+                log.info("输出间隔月份----------->", s);
+                MessageCenter messageCenter = new MessageCenter();
+                messageCenter.setShopId(null);
+                messageCenter.setClubId(clubId);
+                messageCenter.setUserType(1);
+                messageCenter.setMessageType(2);
+                messageCenter.setAccountType(2);
+                messageCenter.setContent(s + "个月");
+                messageCenter.setTime(current);
+                messageCenterMapper.addMessageCenter(messageCenter);
+
+
+            }
         }
+
         return superVipDto;
     }
 
@@ -1244,5 +1350,19 @@ public class RegisterServiceImpl implements RegisterService {
         vipMapper.insertShortLink(markId, shortLink, url);
         return shortLink;
     }
+
+//    public static void main(String[] args) throws ParseException {
+//        Date d=new Date();
+//        //1.日期格式
+//        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+//
+//        //2.某天的日期
+//        Date da1=sdf.parse("2022-01-01 03:30:16");
+//        Long s=(d.getTime()-da1.getTime())/24/60/60/30/1000;
+//        //3.输出间隔天数         getTime获取的是毫秒
+//        System.out.println(s);
+//    }
+
+
 }
 

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

@@ -0,0 +1,147 @@
+<?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.user.mapper.MessageCenterMapper">
+    <insert id="addMessageCenter">
+        INSERT INTO message_center (shopID, clubID, userType, messageType, content,time,accountType,couponType,couponFee,couponMessageType)
+        VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content},#{time},#{accountType},#{couponType},#{couponFee},#{couponMessageType})
+    </insert>
+
+    <select id="clubIdCule" resultType="java.lang.Integer">
+        SELECT clubID FROM `user` 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}
+            </if>
+            <if test="userType == 2">
+                and  shopID=#{commonId}
+            </if>
+            AND messageType=#{messageType}
+            and userType=#{userType}
+            AND saved=0
+        </where>
+    </select>
+
+    <select id="Count" resultType="java.lang.Integer">
+        SELECT COUNT(1) FROM `message_center`
+        <where>
+            <if test="userType == 1">
+                and  clubID=#{commonId}
+            </if>
+            <if test="userType == 2">
+                and  shopID=#{commonId}
+            </if>
+            and userType=#{userType}
+            AND saved=0
+        </where>
+
+
+    </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="MainImage" resultType="com.caimei365.user.model.vo.MessageCenter">
+        SELECT co.refundType,COUNT(p.productID)AS productCount ,p.mainImage,co.onlinePayFlag,p.name as productName,co.orderID as orderID
+        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
+
+        <where>
+            <if test="userType == 1">
+              and  c.clubID=#{commonId}
+            </if>
+            <if test="userType == 2">
+              and  p.shopID=#{commonId}
+            </if>
+        </where>
+        LIMIT 1
+    </select>
+
+    <select id="receiptDate" resultType="java.lang.String">
+        SELECT
+       a.receiptDate
+        FROM cm_discern_receipt a
+        LEFT JOIN shop s ON s.shopID = a.shopID
+        where
+        a.shopID=#{shopID}
+        AND a.newReceiptType=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}
+</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}
+        </where>
+    </update>
+
+    <select id="userId" resultType="java.lang.Integer">
+        SELECT userID FROM `cm_mall_operation_user` WHERE openid=#{openid}  LIMIT 1
+    </select>
+
+ <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>
+
+
+</mapper>

+ 2 - 1
src/main/resources/mapper/OperationMapper.xml

@@ -29,7 +29,8 @@
                o.mobile as mobile,
                o.clubID as clubId,
                o.shopID as shopId,
-               o.status as status
+               o.status as status,
+               o.nickName as nickName
         from cm_mall_operation_user o
         where o.id = #{id} and o.delFlag = '0'
     </select>