Browse Source

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

# Conflicts:
#	src/main/java/com/caimei365/user/mapper/SuperVipMapper.java
#	src/main/java/com/caimei365/user/service/impl/HeHeServiceImpl.java
#	src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java
kaick 1 year ago
parent
commit
862e782a7c

+ 25 - 9
src/main/java/com/caimei365/user/components/WeChatService.java

@@ -5,7 +5,9 @@ import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.user.feign.ToolsFeign;
+import com.caimei365.user.mapper.BaseMapper;
 import com.caimei365.user.model.ResponseJson;
+import com.caimei365.user.model.po.WxUnion;
 import com.caimei365.user.utils.RequestUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.codec.binary.Base64;
@@ -14,21 +16,20 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Component;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URLDecoder;
 import java.security.AlgorithmParameters;
 import java.security.Security;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * 微信 服务工具类
@@ -68,6 +69,8 @@ public class WeChatService {
     private String imageDomain;
     @Resource
     private ToolsFeign toolsFeign;
+    @Resource
+    private BaseMapper baseMapper;
 
     public void setRedirectUri(String redirectUri) {
         redirectUri = redirectUri;
@@ -177,7 +180,7 @@ public class WeChatService {
      *
      * @param code    微信凭证
      * @param headers HttpHeaders
-     * @param mode    1:采美小程序,2:呵呵商城小程序+,3联合丽格小程序
+     * @param mode    1:采美小程序,2:颜选美学商城小程序+,3联合丽格小程序
      * @return HashMap
      */
     public ResponseJson<Map<String, Object>> getInfoMapByApplets(String code, HttpHeaders headers, Integer mode) {
@@ -189,24 +192,28 @@ public class WeChatService {
         returnMap.put("referer", referer);
         String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
         Map<String, String> requestUrlParam = new HashMap<String, String>(4);
+        Integer type;
         if (mode == 1) {
             // 小程序appId
             requestUrlParam.put("appid", miniAppId);
             log.info("采美小程序appId: ---" + miniAppId);
             // 小程序appSecret
             requestUrlParam.put("secret", miniAppSecret);
+            type = 1;
         } else if(mode == 2) {
-            // 呵呵商城小程序appId
+            // 颜选美学商城小程序appId
             requestUrlParam.put("appid", heHeAppId);
-            log.info("呵呵商城appId: ---" + heHeAppId);
-            // 呵呵商城小程序appSecret
+            log.info("颜选美学商城appId: ---" + heHeAppId);
+            // 颜选美学商城小程序appSecret
             requestUrlParam.put("secret", heHeAppSecret);
+            type = 2;
         } else {
             // 联合丽格小程序appId
             requestUrlParam.put("appid", mcareAppId);
             log.info("联合丽格appId: ---" + mcareAppId);
             // 联合丽格小程序appSecret
             requestUrlParam.put("secret", mcareAppSecret);
+            type = 3;
         }
         // 小程序端返回的code
         requestUrlParam.put("js_code", code);
@@ -229,6 +236,15 @@ public class WeChatService {
         String errCode = jsonObject.getString("errcode");
         String errMsg = jsonObject.getString("errmsg");
         log.info("openId----->" + openId + ", unionId------>" + unionId);
+        WxUnion byWxUnion = baseMapper.getByWxUnion(type, openId, null); //保存unionId和openId
+        if (null !=unionId&&(null == byWxUnion||null ==byWxUnion.getUnionId())) {
+            byWxUnion = baseMapper.getByWxUnion(null, null, unionId);
+            if (null == byWxUnion) {
+                baseMapper.addWxUnion(type, openId, unionId);
+            } else {
+                baseMapper.updateWxUnion(type, openId, unionId);
+            }
+        }
         returnMap.put(Keys.OPEN_ID, openId);
         returnMap.put(Keys.UNION_ID, unionId);
         returnMap.put(Keys.SESSION_KEY, sessionKey);

+ 2 - 2
src/main/java/com/caimei365/user/controller/HeHeApi.java

@@ -12,12 +12,12 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 
 /**
- * 呵呵商城用户API
+ * 颜选美学商城用户API
  *
  * @author : plf
  * @date : 2021/4/21
  */
-@Api(tags = "呵呵商城用户API")
+@Api(tags = "颜选美学商城用户API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/user/he")

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

@@ -233,6 +233,33 @@ public class LoginApi {
         String iv = authAppletsDto.getIv();
         return loginService.appletsOrganizeAuthorization(code, encryptedData, iv, headers);
     }
+    @ApiOperation("颜选美学站内消息列表")
+    @GetMapping("/auth/heheMessageList")
+    public ResponseJson<PageInfo<MessageCenter>> heheMessageList(Integer commonId,
+                                                                 Integer messageType,
+                                                                 @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                 @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return loginService.messageList(commonId, messageType, 4, pageNum, pageSize);
+    }
+    @ApiOperation("颜选美学所有站内消息未读消息记录数")
+    @GetMapping("/auth/heheMessageCount")
+    public ResponseJson<Map<String, Object>> heheMessageCount(Integer commonId) {
+        return loginService.messageCount(4, commonId);
+    }
+    @ApiOperation("颜选美学站内消息未读消息记录数")
+    @GetMapping("/auth/heheOneMessageCount")
+    public ResponseJson<Map<String, Object>> heheOneMessageCount(Integer messageType, Integer commonId) {
+        return loginService.count(4,messageType, commonId);
+    }
+    @ApiOperation("颜选美学站内消息改为已读")
+    @GetMapping("/auth/updateHeheMessageAsRead")
+    public ResponseJson<Void> updateHeheMessageAsRead(Integer messageType, Integer commonId) {
+        Integer i = loginService.updateMessageAsRead(4,messageType, commonId);
+        if (i <= 0) {
+            return ResponseJson.error("没有未读消息了!", null);
+        }
+        return ResponseJson.success("标记已读成功", null);
+    }
 
     @ApiOperation("机构站内消息未读消息记录数")
     @GetMapping("/auth/ClubMessageCount")
@@ -265,6 +292,8 @@ public class LoginApi {
 
         return loginService.ClubCount(messageType, commonId);
     }
+
+
     @ApiOperation("协销站内消息列表")
     @GetMapping("/auth/SpMessageList")
     public ResponseJson<PageInfo<MessageCenter>> SpMessageList(Integer commonId,
@@ -301,17 +330,19 @@ public class LoginApi {
     @ApiOperation("机构站内消息改为已读")
     @GetMapping("/auth/updateMessageAsRead")
     public ResponseJson<Void> updateMessageAsRead(Integer messageType, Integer commonId) {
-        Integer i = loginService.updateMessageAsRead(messageType, commonId);
+        Integer i = loginService.updateMessageAsRead(1,messageType, commonId);
         if (i <= 0) {
             return ResponseJson.error("没有未读消息了!", null);
         }
         return ResponseJson.success("标记已读成功", null);
     }
 
+
+
     @ApiOperation("供应商站内消息改为已读")
     @GetMapping("/auth/updateShopMessageAsRead")
     public ResponseJson<Void> updateShopMessageAsRead(Integer messageType, Integer commonId) {
-        Integer i = loginService.updateShopMessageAsRead(messageType, commonId);
+        Integer i = loginService.updateMessageAsRead(2,messageType, commonId);
         if (i <= 0) {
             return ResponseJson.error("没有未读消息了!", null);
         }
@@ -320,7 +351,7 @@ public class LoginApi {
     @ApiOperation("协销站内消息改为已读")
     @GetMapping("/auth/updateSpMessageAsRead")
     public ResponseJson<Void> updateSpMessageAsRead(Integer messageType, Integer commonId) {
-        Integer i = loginService.updateSpMessageAsRead(messageType, commonId);
+        Integer i = loginService.updateMessageAsRead(3,messageType, commonId);
         if (i <= 0) {
             return ResponseJson.error("没有未读消息了!", null);
         }

+ 13 - 0
src/main/java/com/caimei365/user/mapper/BaseMapper.java

@@ -1,6 +1,7 @@
 package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.po.CmUser;
+import com.caimei365.user.model.po.WxUnion;
 import com.caimei365.user.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -223,5 +224,17 @@ public interface BaseMapper {
     public List<String> findAdminMobileList(Integer type);
 
     CmUser findUserByMobile(@Param("mobile") String mobile, @Param("oldUserId") Integer oldUserId, @Param("userIdentity") Integer userIdentity);
+    /**
+     * 新增unionid与不同应用的openid关系
+     */
+    int addWxUnion(@Param("type") Integer type,@Param("openid")String openid,@Param("unionId")String unionId);
 
+    /**
+     * 修改unionid与不同应用的openid关系
+     */
+    int updateWxUnion(@Param("type") Integer type,@Param("openid")String openid,@Param("unionId")String unionId);
+    /**
+     * 通过对象查询unionid与不同应用的openid关系对象
+     */
+    WxUnion getByWxUnion(@Param("type") Integer type,@Param("openid")String openid,@Param("unionId")String unionId);
 }

+ 3 - 3
src/main/java/com/caimei365/user/mapper/HeHeMapper.java

@@ -18,7 +18,7 @@ import java.util.List;
 public interface HeHeMapper {
 
     /**
-     * 查询呵呵用户信息
+     * 查询颜选美学用户信息
      *
      * @param openId
      * @return
@@ -34,14 +34,14 @@ public interface HeHeMapper {
     HeHeUserVo findHeHeUserByMobile(String mobile);
 
     /**
-     * 更新呵呵用户信息
+     * 更新颜选美学用户信息
      *
      * @param heHeUser
      */
     void updateHeHeUser(HeHeUserVo heHeUser);
 
     /**
-     * 保存呵呵普通用户信息
+     * 保存颜选美学普通用户信息
      *
      * @param heUserPo
      */

+ 2 - 1
src/main/java/com/caimei365/user/mapper/MessageCenterMapper.java

@@ -7,6 +7,7 @@ import com.caimei365.user.model.vo.UserVo;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -91,5 +92,5 @@ public interface MessageCenterMapper {
 
     List<Integer> getMessageCenterListDay(Integer day);
 
-
+    Map<String,String> getMessageTypeValues(Integer type, Integer id);
 }

+ 1 - 1
src/main/java/com/caimei365/user/mapper/SuperVipMapper.java

@@ -74,7 +74,7 @@ public interface SuperVipMapper {
 
     /**
      * 用户身份修改
-     * 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、呵呵商城用户【V6.2.0版本后0不存在】
+     * 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、颜选美学商城用户【V6.2.0版本后0不存在】
      *
      * @param userId
      * @param userIdentity

+ 1 - 1
src/main/java/com/caimei365/user/model/dto/HeHeUserDto.java

@@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull;
  * @author : plf
  * @date : 2021/4/22
  */
-@ApiModel("呵呵小程序登录")
+@ApiModel("颜选美学小程序登录")
 @Data
 public class HeHeUserDto {
     /**

+ 3 - 3
src/main/java/com/caimei365/user/model/po/CmUser.java

@@ -38,10 +38,10 @@ public class CmUser implements Serializable
     /** 企业绑定手机号(机构,供应商) */
     private String bindMobile;
 
-    /** 用户权限 0游客 1 普通用户 2 会员机构 3 供应商 4 协销 5 普通机构 6 呵呵商城用户【V6.2.0版本后0和1不存在】 */
+    /** 用户权限 0游客 1 普通用户 2 会员机构 3 供应商 4 协销 5 普通机构 6 颜选美学商城用户【V6.2.0版本后0和1不存在】 */
     private Integer userPermission;
 
-    /** 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、呵呵商城用户【V6.2.0版本后0不存在】 */
+    /** 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、颜选美学商城用户【V6.2.0版本后0不存在】 */
     private String userIdentity;
 
     /** 邮箱 */
@@ -65,7 +65,7 @@ public class CmUser implements Serializable
     /** 名称(机构名称,供应商的公司名称) */
     private String name;
 
-    /** 见枚举UserType(1供应商,2协销经理,32协销,3会员机构,4普通机构,6呵呵商城) */
+    /** 见枚举UserType(1供应商,2协销经理,32协销,3会员机构,4普通机构,6颜选美学商城) */
     private String registerUserTypeID;
 
     /** 供应商状态, 3待审核, 90已上线,91已下线,92审核不通过 */

+ 44 - 0
src/main/java/com/caimei365/user/model/po/WxUnion.java

@@ -0,0 +1,44 @@
+package com.caimei365.user.model.po;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+
+import java.io.Serializable;
+
+/**
+ * unionid与不同应用的openid关系对象 wx_union
+ *
+ * @author Kaick
+ * @date 2023-11-30
+ */
+@Accessors(chain  = true )
+@Data
+@Alias("WxUnion")
+public class WxUnion implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 微信unionId */
+    private String unionId;
+
+    /** $column.columnComment */
+        private Integer userId;
+
+    /** crm公众openid */
+    private String crmOpenid;
+
+    /** 采美app openid */
+    private String appOpenid;
+
+    /** 小程序openId */
+    private String miniProgramOpenId;
+
+    /** 呵呵app openid */
+    private String heheOpenid;
+
+
+}
+
+
+

+ 1 - 1
src/main/java/com/caimei365/user/model/vo/HeHeUserVo.java

@@ -13,7 +13,7 @@ import java.io.Serializable;
 @Data
 public class HeHeUserVo implements Serializable {
     /**
-     * 呵呵商城用户id
+     * 颜选美学商城用户id
      */
     private Integer userId;
 

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

@@ -128,6 +128,14 @@ public class MessageCenter implements Serializable {
      * 前用户名称
      */
     private String superUserName;
+    /**
+     * pc链接
+     */
+    private String pcLink;
+    /**
+     * app链接
+     */
+    private String appLink;
 
     /**
      * 当前id

+ 6 - 4
src/main/java/com/caimei365/user/service/LoginService.java

@@ -91,19 +91,21 @@ public interface LoginService {
 
     ResponseJson<PageInfo<MessageCenter>> shopMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
 
+    ResponseJson<PageInfo<MessageCenter>> messageList(Integer commonId,Integer messageType,Integer userType, int pageNum, int pageSize);
+    ResponseJson<Map<String, Object>> messageCount(Integer userType ,Integer commonId);
+    ResponseJson<Map<String, Object>> count(Integer userType,Integer messageType,Integer commonId);
+
     ResponseJson<Map<String, Object>> ClubMessageCount(Integer messageType,Integer commonId);
 
     ResponseJson<Map<String, Object>> shopMessageCount(Integer messageType,Integer commonId);
 
     ResponseJson<Map<String, Object>> SpCount(Integer messageType,Integer commonId);
-    ResponseJson<Map<String, Object>> ShopCount(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 updateMessageAsRead(Integer userType,Integer messageType,Integer commonId);
 
-    Integer updateShopMessageAsRead(Integer messageType,Integer commonId);
-    Integer updateSpMessageAsRead(Integer messageType,Integer commonId);
 
      Integer updateRead(Integer userType,String Id);
 

+ 38 - 5
src/main/java/com/caimei365/user/service/impl/HeHeServiceImpl.java

@@ -2,6 +2,7 @@ package com.caimei365.user.service.impl;
 
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.components.WeChatService;
+import com.caimei365.user.feign.ToolsFeign;
 import com.caimei365.user.mapper.HeHeMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.HeHeUserDto;
@@ -12,6 +13,10 @@ import com.caimei365.user.model.vo.HeHeUserVo;
 import com.caimei365.user.service.HeHeService;
 import com.caimei365.user.service.RemoteCallService;
 import com.caimei365.user.utils.CodeUtil;
+import com.caimei365.user.utils.message.InsideMessage;
+import com.caimei365.user.utils.message.MessageModel;
+import com.caimei365.user.utils.message.MessageType;
+import com.caimei365.user.utils.message.MqInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -44,7 +49,10 @@ public class HeHeServiceImpl implements HeHeService {
     private String active;
     @Resource
     private RemoteCallService remoteCallService;
-
+    @Resource
+    private AsyncService asyncService;
+    @Resource
+    private ToolsFeign toolsFeign;
     @Override
     public ResponseJson<HeHeUserVo> authorization(String code, HttpHeaders headers) {
         // 小程序微信授权获取登录信息
@@ -60,6 +68,7 @@ public class HeHeServiceImpl implements HeHeService {
             heHeUser.setOpenId(openId);
             return ResponseJson.error(-2, "用户未注册", heHeUser);
         }
+        asyncService.loginUpdateBeans(heHeUser.getUserId(), null);
         return ResponseJson.success(heHeUser);
     }
 
@@ -87,7 +96,7 @@ public class HeHeServiceImpl implements HeHeService {
                     user.setUserName(heHeUserDto.getNickName());
                     user.setName(heHeUserDto.getNickName());
                     user.setPassword("HeHe");
-                    //6:呵呵商城用户
+                    //6:颜选美学商城用户
                     user.setUserIdentity(6);
                     user.setRegisterUserTypeId(6);
                     user.setRegisterTime(currentTime);
@@ -109,7 +118,19 @@ public class HeHeServiceImpl implements HeHeService {
                         Double couponAmount = heHeMapper.getCouponAmount(couponId);
                         String content = "恭喜您成功注册登录。现赠送" + couponAmount + "元优惠券到您的领券中心,请赶紧登录颜选美学小程序领取下单吧。退订回T";
                         boolean result = remoteCallService.remoteSendSms(17, 3, heHeUserDto.getMobile(), content);
-                        log.info("【呵呵新人券派送】mobile:" + heHeUserDto.getMobile() + ",result:" + result);
+                        log.info("【颜选美学新人券派送】mobile:" + heHeUserDto.getMobile() + ",result:" + result);
+                        //站内信
+                        MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                        insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                                .mqInfo(new MqInfo().topic("MessageLine").delay(1).async(0))
+                                .info(new InsideMessage()
+                                        .userType(4)
+                                        .messageType(4)
+                                        .couponType(4)
+                                        .content("恭喜您成功注册登录。现赠送"+couponAmount+"元优惠券到您的领券中心,快去领取下单吧。")
+                                        .thisId(heUserPo.getUserId())
+                                );
+                        toolsFeign.sendCommonMessage(insideMessageMessageModel);
                     });
                     heHeUser = heHeMapper.findHeHeUserByMobile(heHeUserDto.getMobile());
                     Integer shareUserId = heHeUserDto.getShareUserId();
@@ -129,7 +150,19 @@ public class HeHeServiceImpl implements HeHeService {
                             Double couponAmount = heHeMapper.getCouponAmount(couponId);
                             String content = "恭喜您成功邀请一位好友注册登录,现赠送"+couponAmount+"元优惠券到您的领券中心,请赶紧登录颜选美学小程序领取下单吧。退订回T";
                             boolean result = remoteCallService.remoteSendSms(18, 3, mobile, content);
-                            log.info("【呵呵好友邀请券派送】mobile:" + mobile + ",result:" + result);
+                            log.info("【颜选美学好友邀请券派送】mobile:" + mobile + ",result:" + result);
+                            //站内信
+                            MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
+                            insideMessageMessageModel.code(MessageType.WEB_INSIDE_MESSAGE)
+                                    .mqInfo(new MqInfo().topic("MessageLine").delay(1).async(0))
+                                    .info(new InsideMessage()
+                                            .userType(4)
+                                            .messageType(4)
+                                            .couponType(5)
+                                            .content("恭喜您成功邀请一位好友注册登录,现赠送"+couponAmount+"元优惠券到您的领券中心,快去领取下单吧。")
+                                            .thisId(shareUserId)
+                                    );
+                            toolsFeign.sendCommonMessage(insideMessageMessageModel);
                         });
                     }
                 }
@@ -148,7 +181,7 @@ public class HeHeServiceImpl implements HeHeService {
             // 短信发送失败重试一次
             remoteCallService.remoteSendSms(0, 1, mobile, content);
         }
-        log.info("呵呵商城注册验证码:" + randomCode);
+        log.info("颜选美学商城注册验证码:" + randomCode);
         redisService.set("heCode:" + mobile, randomCode, 300L);
         return ResponseJson.success("发送成功");
     }

+ 74 - 22
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -10,21 +10,20 @@ import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.*;
 import com.caimei365.user.model.po.OperationPo;
 import com.caimei365.user.model.po.SuperVipPo;
-import com.caimei365.user.model.vo.*;
+import com.caimei365.user.model.vo.MessageCenter;
+import com.caimei365.user.model.vo.OperationVo;
+import com.caimei365.user.model.vo.UserLoginVo;
 import com.caimei365.user.service.LoginService;
 import com.caimei365.user.service.RemoteCallService;
 import com.caimei365.user.utils.JwtUtil;
-import com.caimei365.user.utils.MathUtil;
 import com.caimei365.user.utils.Md5Util;
 import com.caimei365.user.utils.ValidateUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import lombok.SneakyThrows;
 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.util.ObjectUtils;
 
@@ -32,9 +31,6 @@ import javax.annotation.Resource;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Description
@@ -543,12 +539,16 @@ public class LoginServiceImpl implements LoginService {
         Integer accountCount = messageCenterMapper.MessageCount(1, 2, commonId);
         Integer notificationCount = messageCenterMapper.MessageCount(1, 3, commonId);
         Integer promotionCount = messageCenterMapper.MessageCount(1, 4, commonId);
+        Integer infoCount = messageCenterMapper.MessageCount(1, 5, commonId);
+        Integer activityCount = messageCenterMapper.MessageCount(1, 6, 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);
+        map.put("infoCount", infoCount);
+        map.put("activityCount", activityCount);
         return ResponseJson.success(map);
     }
 
@@ -601,20 +601,6 @@ public class LoginServiceImpl implements LoginService {
     }
 
 
-    @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 updateSpMessageAsRead(Integer messageType, Integer commonId) {
-        return messageCenterMapper.updateMessageAsRead(3, messageType, commonId);
-    }
 
     @Override
     public Integer deleteMessage(String id) {
@@ -636,7 +622,28 @@ public class LoginServiceImpl implements LoginService {
         return num;
     }
 
-
+    @Override
+    public ResponseJson<PageInfo<MessageCenter>> messageList(Integer commonId, Integer messageType, Integer userType, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<MessageCenter> list = setMessageList(userType, messageType, commonId);
+        PageInfo<MessageCenter> pageData = new PageInfo<>(list);
+        return ResponseJson.success(pageData);
+    }
+    @Override
+    public ResponseJson<Map<String, Object>> messageCount(Integer userType , Integer commonId) {
+        return ResponseJson.success(setMessageCount(userType,commonId));
+    }
+    @Override
+    public ResponseJson<Map<String, Object>> count(Integer userType,Integer messageType, Integer commonId) {
+        Integer count = messageCenterMapper.Count(userType, commonId);
+        Map<String, Object> map = new HashMap(1);
+        map.put("count", count);
+        return ResponseJson.success(map);
+    }
+    @Override
+    public Integer updateMessageAsRead(Integer userType,Integer messageType, Integer commonId) {
+        return messageCenterMapper.updateMessageAsRead(userType, messageType, commonId);
+    }
     @Override
     public ResponseJson<PageInfo<MessageCenter>> SpMessageList(Integer commonId, Integer messageType, Integer source, int pageNum, int pageSize) {
         PageHelper.startPage(pageNum, pageSize);
@@ -686,6 +693,12 @@ public class LoginServiceImpl implements LoginService {
                     mess.setRefundType(messageCenter.getRefundType());
                     mess.setStatus(messageCenter.getStatus());
                 }
+                if (5 == mess.getMessageType() || 6 == mess.getMessageType()) {
+                    Map<String, String> typeValue = messageCenterMapper.getMessageTypeValues(mess.getMessageType(), mess.getThisId());
+                    mess.setMainImage(typeValue.get("image"));
+                    mess.setPcLink(typeValue.get("pcLink"));
+                    mess.setAppLink(typeValue.get("appLink"));
+                }
             }
         });
         if (source == 2) {
@@ -1641,6 +1654,45 @@ public class LoginServiceImpl implements LoginService {
         }
         return superVipDto;
     }
+    /**
+     * 初始化站内信
+     */
+    private List<MessageCenter> setMessageList(Integer userType,Integer messageType,Integer commonId) {
+        List<MessageCenter> list = messageCenterMapper.MessageList(userType, messageType, commonId);
+        list.forEach(mess -> {
+            if (null != mess.getOrderId()) {
+                MessageCenter messageCenter = messageCenterMapper.MainImage(userType, commonId, mess.getOrderId());
+                Integer productCount = messageCenterMapper.productCount(mess.getOrderId());
+                if (null != messageCenter) {
+                    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(productCount);
+                    mess.setRefundType(messageCenter.getRefundType());
+                    mess.setStatus(messageCenter.getStatus());
+                }
+            }
+        });
+        return list;
+    }
 
+    private Map<String, Object> setMessageCount(Integer userType, Integer commonId) {
+        Integer count = messageCenterMapper.Count(userType, commonId);
+        Integer tradeCount = messageCenterMapper.MessageCount(userType, 1, commonId);
+        Integer accountCount = messageCenterMapper.MessageCount(userType, 2, commonId);
+        Integer notificationCount = messageCenterMapper.MessageCount(userType, 3, commonId);
+        Integer promotionCount = messageCenterMapper.MessageCount(userType, 4, commonId);
+        Map<String, Object> map = new HashMap(5);
+        map.put("count", count);
+        map.put("tradeCount", tradeCount);
+        map.put("accountCount", accountCount);
+        map.put("notificationCount", notificationCount);
+        map.put("promotionCount", promotionCount);
+        return map;
+    }
 
 }

+ 1 - 1
src/main/java/com/caimei365/user/utils/AliyunSmsUtil.java

@@ -56,7 +56,7 @@ public class AliyunSmsUtil {
             // 模版内容: 欢迎成为采美机构用户,您的登录账号为:${name},初始密码为:cm${content},您可使用该账号密码登录采美365网和“采美采购商城”小程序。
             templateCode = "SMS_215122672";
         } else if (type == 7) {
-            // 模版内容: 您"呵呵商城"小程序的验证码为:${code},验证码 5 分钟内有效。
+            // 模版内容: 您"颜选美学商城"小程序的验证码为:${code},验证码 5 分钟内有效。
             templateCode = "SMS_215334982";
             signName = "采美365";
         } else if (type == 8) {

+ 74 - 2
src/main/resources/mapper/BaseMapper.xml

@@ -679,10 +679,82 @@
         select
         cm_admin_mobile.mobile
         from cm_admin_mobile AS cm_admin_mobile
-        <where>  cm_admin_mobile.delFlag = 0 and cm_admin_mobile.enabledStatus = 1
-            <if test="type != null  and type != ''"> and cm_admin_mobile.type = #{type}</if>
+        <where>cm_admin_mobile.delFlag = 0 and cm_admin_mobile.enabledStatus = 1
+            <if test="type != null  and type != ''">and cm_admin_mobile.type = #{type}</if>
         </where>
         group by cm_admin_mobile.id
         order by cm_admin_mobile.createTime desc
     </select>
+
+    <insert id="addWxUnion" parameterType="WxUnion">
+        insert into wx_union
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="unionId != null and unionId != ''">unionId,</if>
+            <if test="type != null  and type == 1">
+                appOpenid,
+            </if>
+            <if test="type != null  and type == 2">
+                heheOpenid,
+            </if>
+            <if test="type != null  and type == 3">
+                crmOpenid,
+            </if>
+            <if test="type != null  and type == 4">
+                miniProgramOpenId,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="unionId != null and unionId != ''">#{unionId},</if>
+            <if test="type != null">
+                #{openid},
+            </if>
+        </trim>
+    </insert>
+
+    <update id="updateWxUnion" parameterType="WxUnion">
+        update wx_union
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="type != null  and type == 1">
+                appOpenid = #{openid},
+            </if>
+            <if test="type != null  and type == 2">
+                heheOpenid = #{openid},
+            </if>
+            <if test="type != null  and type == 3">
+                crmOpenid = #{openid},
+            </if>
+            <if test="type != null  and type == 4">
+                miniProgramOpenId = #{openid},
+            </if>
+        </trim>
+        where unionId = #{unionId}
+    </update>
+    <select id="getByWxUnion" parameterType="WxUnion" resultType="WxUnion">
+        select
+        wx_union.unionId,
+        wx_union.userId,
+        wx_union.crmOpenid,
+        wx_union.appOpenid,
+        wx_union.miniProgramOpenId,
+        wx_union.heheOpenid
+        from wx_union AS wx_union
+        <where>
+            <if test="unionId != null  and unionId != ''">
+                and wx_union.unionId = #{unionId}
+            </if>
+            <if test="type != null  and type == 1">
+                and wx_union.appOpenid = #{openid}
+            </if>
+            <if test="type != null  and type == 2">
+                and wx_union.heheOpenid = #{openid}
+            </if>
+            <if test="type != null  and type == 3">
+                and wx_union.crmOpenid = #{openid}
+            </if>
+            <if test="type != null  and type == 4">
+                and wx_union.miniProgramOpenId = #{openid}
+            </if>
+        </where>
+        limit 1
+    </select>
 </mapper>

+ 27 - 12
src/main/resources/mapper/MessageCenter.xml

@@ -65,7 +65,7 @@
             <if test="userType == 2">
                 and  shopID=#{commonId}
             </if>
-            <if test="userType == 3">
+            <if test="userType == 3 or userType == 4">
                 and  thisId=#{commonId}
             </if>
             AND messageType=#{messageType}
@@ -83,7 +83,7 @@
             <if test="userType == 2">
                 and  shopID=#{commonId}
             </if>
-            <if test="userType == 3">
+            <if test="userType == 3 or userType == 4">
                 and  thisId=#{commonId}
             </if>
             and userType=#{userType}
@@ -116,7 +116,7 @@
             <if test="userType == 2">
                 and shopID=#{commonId}
             </if>
-            <if test="userType == 3">
+            <if test="userType == 3 or userType == 4 ">
                 and thisId=#{commonId}
             </if>
             and userType=#{userType}
@@ -171,6 +171,9 @@
             <if test="userType == 3">
                 and sp.serviceProviderID=#{commonId}
             </if>
+            <if test=" userType == 4">
+                and co.userID=#{commonId}
+            </if>
             and co.orderID=#{orderID}
         </where>
         LIMIT 1
@@ -234,7 +237,7 @@
             <if test="userType == 2">
                 and shopID=#{commonId}
             </if>
-            <if test="userType == 3">
+            <if test="userType == 3 or userType == 4">
                 and thisId=#{commonId}
             </if>
             <if test="messageType !=null">
@@ -267,22 +270,34 @@
     </select>
 
     <select id="shopName" resultType="java.lang.String">
-        SELECT name FROM `shop` WHERE shopID=#{shopID}
+        SELECT name
+        FROM `shop`
+        WHERE shopID = #{shopID}
     </select>
     <select id="getMessageCenterListDay" resultType="java.lang.Integer">
-        select distinct  d.shopID as shopID from  cm_receipt as r
-        LEFT JOIN  cm_discern_receipt as d on r.receiptID=d.id
-        LEFT JOIN  shop as s on d.shopID=s.shopID
-        WHERE receStatct=0 and DATEDIFF(r.dateStrings,NOW())=#{day}
+        select distinct d.shopID as shopID
+        from cm_receipt as r
+                 LEFT JOIN cm_discern_receipt as d on r.receiptID = d.id
+                 LEFT JOIN shop as s on d.shopID = s.shopID
+        WHERE receStatct = 0
+          and DATEDIFF(r.dateStrings, NOW()) = #{day}
+    </select>
+    <select id="getMessageTypeValues" resultType="map">
+        <if test="type != null and type == 5 ">
+            select guidanceImage as image from info where id=#{id}
+        </if>
+        <if test="type != null and type == 6 ">
+            select image,appLink,link as pcLink from cm_page_image where id=#{id}
+        </if>
     </select>
 
     <update id="updateMessageCenter" parameterType="com.caimei365.user.model.vo.MessageCenter">
 
         update message_center
         <set>
-<!--            <if test="id != null and id != 0">id = #{id},</if>-->
-<!--            <if test="shopID != null and shopID != ''">shopID = #{shopID},</if>-->
-<!--            <if test="clubID != null and clubID != ''">clubID = #{clubID},</if>-->
+            <!--            <if test="id != null and id != 0">id = #{id},</if>-->
+            <!--            <if test="shopID != null and shopID != ''">shopID = #{shopID},</if>-->
+            <!--            <if test="clubID != null and clubID != ''">clubID = #{clubID},</if>-->
             <if test="orderId != null and orderId != '' ">orderID = #{orderId},</if>
             <if test="userType != null and userType != ''">userType = #{userType},</if>
             <if test="messageType != null and messageType != ''">messageType = #{messageType},</if>