Explorar o código

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

# Conflicts:
#	src/main/java/com/caimei365/user/controller/BaseApi.java
Aslee %!s(int64=2) %!d(string=hai) anos
pai
achega
9f8482bd17
Modificáronse 28 ficheiros con 1754 adicións e 119 borrados
  1. 226 0
      src/main/java/com/caimei365/user/components/WeChatService.java
  2. 7 0
      src/main/java/com/caimei365/user/controller/BaseApi.java
  3. 156 55
      src/main/java/com/caimei365/user/controller/LoginApi.java
  4. 3 0
      src/main/java/com/caimei365/user/controller/RegisterApi.java
  5. 6 0
      src/main/java/com/caimei365/user/feign/ToolsFeign.java
  6. 16 0
      src/main/java/com/caimei365/user/idempotent/IpSave.java
  7. 103 0
      src/main/java/com/caimei365/user/idempotent/IpSaveAspect.java
  8. 90 0
      src/main/java/com/caimei365/user/mapper/MessageCenterMapper.java
  9. 4 0
      src/main/java/com/caimei365/user/mapper/ShopMapper.java
  10. 5 0
      src/main/java/com/caimei365/user/mapper/SuperVipMapper.java
  11. 110 0
      src/main/java/com/caimei365/user/model/vo/MessageCenter.java
  12. 4 0
      src/main/java/com/caimei365/user/model/vo/ShopHomeVo.java
  13. 6 0
      src/main/java/com/caimei365/user/model/vo/UserLoginVo.java
  14. 4 0
      src/main/java/com/caimei365/user/model/vo/UserVo.java
  15. 27 3
      src/main/java/com/caimei365/user/service/LoginService.java
  16. 1 4
      src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java
  17. 400 17
      src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java
  18. 33 6
      src/main/java/com/caimei365/user/service/impl/OperationServiceImpl.java
  19. 169 19
      src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java
  20. 2 0
      src/main/java/com/caimei365/user/service/impl/RemoteCallServiceImpl.java
  21. 18 0
      src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java
  22. 74 3
      src/main/java/com/caimei365/user/utils/RequestUtil.java
  23. 31 7
      src/main/resources/mapper/LoginMapper.xml
  24. 242 0
      src/main/resources/mapper/MessageCenter.xml
  25. 2 1
      src/main/resources/mapper/OperationMapper.xml
  26. 3 0
      src/main/resources/mapper/ShopMapper.xml
  27. 9 1
      src/main/resources/mapper/SuperVipMapper.xml
  28. 3 3
      src/test/java/com/caimei365/user/UserApplicationTests.java

+ 226 - 0
src/main/java/com/caimei365/user/components/WeChatService.java

@@ -17,7 +17,10 @@ import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
 import java.security.AlgorithmParameters;
 import java.security.Security;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -295,4 +298,227 @@ public class WeChatService {
         return map;
     }
 
+    /**
+     * 购买会员消息推送
+     * @param accessToken 微信公众号
+     * @param openid 公众号的openid
+     * @param title 标题
+     * @param name 商品名称
+     * @param money 金额
+     * @param remarkText 备注
+     * @param pagePath 跳转链接
+     */
+    public void sendTemplateMsgs(String accessToken, String openid, String title, String name, Double money, String date,String remarkText, String pagePath) {
+        JSONObject first = new JSONObject();
+        first.put("value", title);
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", name);
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", money.toString());
+        JSONObject keyword3 = new JSONObject();
+        keyword3.put("value", date);
+        JSONObject remark = new JSONObject();
+        remark.put("value", remarkText);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("keyword3", keyword3);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", miniAppId);
+        miniProgram.put("pagepath", pagePath);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser",openid);
+        json.put("template_id","Sj5QEHxYrXMOvkY0t7ptj_6LJvBE6H4O-N0TRS3l3tc");
+        json.put("url","https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
+//            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:", e);
+        }
+    }
+
+    /**
+     * 续费会员消息推送
+     * @param accessToken 微信公众号
+     * @param openid 公众号的openid
+     * @param title 标题
+     * @param name 商品名称
+     * @param remarkText 备注
+     * @param pagePath 跳转链接
+     */
+    public void sendTemplateMsg(String accessToken, String openid,String date,String remarkText, String pagePath) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date dat=new Date();
+        JSONObject first = new JSONObject();
+        first.put("value", "恭喜您成功续费采美超级会员");
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", "超级会员");
+        JSONObject keyword2 = new JSONObject();
+        keyword1.put("value", dateFormat.format(dat));
+        JSONObject remark = new JSONObject();
+        remark.put("value", "如在使用中有任何疑问,请在小程序内联系在线客服");
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", miniAppId);
+        miniProgram.put("pagepath", pagePath);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser",openid);
+        json.put("template_id","QHsM0AhlgGaX6kJ6vFm1wAKIkNjnZdWPjFGOKopLbsM");
+        json.put("url","https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
+//            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:", e);
+        }
+    }
+
+    /**
+     * 续费会员消息推送
+     * @param accessToken 微信公众号
+     * @param openid 公众号的openid
+     * @param remarkText 备注
+     * @param pagePath 跳转链接
+     */
+    public void sendTemplateMessg(String accessToken, String openid, String nickName,String time,String remarkText, String pagePath) {
+        JSONObject first = new JSONObject();
+        first.put("value", "绑定成功提醒");
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", "您已成功绑定采美平台");
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", nickName);
+        JSONObject keyword3 = new JSONObject();
+        keyword2.put("value", time);
+        JSONObject remark = new JSONObject();
+        remark.put("value", remarkText);
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("keyword3", keyword3);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", miniAppId);
+        miniProgram.put("pagepath", pagePath);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser",openid);
+        json.put("template_id","ph3XjF5o2QPuANQW2XlO7PRYU7Y9t-3fAX5TSqwTftk");
+        json.put("url","https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
+//            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:", e);
+        }
+    }
+
+
+    /**
+     * 上架费消息推送
+     * @param accessToken 微信公众号
+     * @param openid 公众号的openid
+     * @param remarkText 备注
+     * @param pagePath 跳转链接
+     */
+    public void sendTemplate(String accessToken, String openid, String date, String newTime,String endTime,Double money,String remarkText, String pagePath) {
+        JSONObject first = new JSONObject();
+        first.put("value", "维护费到期提醒");
+        JSONObject keyword1 = new JSONObject();
+        keyword1.put("value", "尊敬的采美供应商用户,您的账号维护费用"+date+"天后即将到期!");
+        JSONObject keyword2 = new JSONObject();
+        keyword2.put("value", "维护费");
+        JSONObject keyword3 = new JSONObject();
+        keyword2.put("value", "年付");
+        JSONObject keyword4 = new JSONObject();
+        keyword2.put("value", newTime);
+        JSONObject keyword5 = new JSONObject();
+        keyword2.put("value", endTime);
+        JSONObject keyword6 = new JSONObject();
+        keyword2.put("value", money);
+        JSONObject remark = new JSONObject();
+        remark.put("value", "为了更好给您服务,请及时联系采美客服缴费!");
+
+        JSONObject data = new JSONObject();
+        data.put("first", first);
+        data.put("keyword1", keyword1);
+        data.put("keyword2", keyword2);
+        data.put("keyword3", keyword3);
+        data.put("keyword4", keyword4);
+        data.put("keyword5", keyword5);
+        data.put("keyword6", keyword6);
+        data.put("remark", remark);
+
+        JSONObject miniProgram = new JSONObject();
+        miniProgram.put("appid", miniAppId);
+        miniProgram.put("pagepath", pagePath);
+
+        JSONObject json = new JSONObject(new LinkedHashMap());
+        json.put("touser",openid);
+        json.put("template_id","jYUIq63wP6mGFvkgNHgTOXAgF7j6h_VZKgST_-2fqCo");
+        json.put("url","https://www.caimei365.com/");
+        json.put("miniprogram", miniProgram);
+        json.put("data", data);
+        // json 字符串
+        String jsonString = json.toJSONString();
+        log.info(">>>>>>>>推送微信模板消息:" + jsonString);
+        try {
+            // https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN
+//            String requestUrl =  "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="+accessToken;
+            String requestUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+accessToken;
+            // 发送请求
+            String result = RequestUtil.httpRequest(requestUrl, "POST", jsonString);
+            log.info(">>>>>>>>推送结果:" + result);
+        } catch (Exception e) {
+            log.error("推送微信模板消息失败:", e);
+        }
+    }
+
+
+
+
+
+
 }

+ 7 - 0
src/main/java/com/caimei365/user/controller/BaseApi.java

@@ -1,6 +1,7 @@
 package com.caimei365.user.controller;
 
 import com.aliyuncs.exceptions.ClientException;
+import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.MobileDto;
 import com.caimei365.user.model.dto.PasswordDto;
@@ -55,6 +56,7 @@ public class BaseApi {
      */
     @ApiOperation("获取图片验证码")
     @ApiImplicitParam(required = true, name = "platformType", value = "0:www,1:crm/h5,2:小程序")
+    @IpSave(saveName = "获取图片验证码",saveParams = false)
     @GetMapping("/captcha")
     public ResponseJson<Map<String, Object>> getCaptchaImage(Integer platformType) {
         return baseService.getCaptchaImage(platformType);
@@ -82,6 +84,7 @@ public class BaseApi {
             @ApiImplicitParam(required = false, name = "token", value = "图片token")
 
     })
+    @IpSave(saveName = "获取短信验证码",saveParams = true)
     @GetMapping("/sms/code")
     public ResponseJson getSmsCode(String mobile, Integer activateCodeType, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
         return baseService.getSmsCode(mobile, activateCodeType, platformType, isCheckCaptcha, imgCode, token);
@@ -110,6 +113,7 @@ public class BaseApi {
             @ApiImplicitParam(required = false, name = "imgCode", value = "图片验证码"),
             @ApiImplicitParam(required = false, name = "token", value = "图片token")
     })
+    @IpSave(saveName = "绑定账号,发送短信验证",saveParams = true)
     @GetMapping("/sms/bind")
     public ResponseJson getBindSmsCode(String mobile, String bindMobile, Integer userId, Integer platformType, Integer isCheckCaptcha, String imgCode, String token) {
         return baseService.getBindSmsCode(mobile, bindMobile, userId, platformType, isCheckCaptcha, imgCode, token);
@@ -144,6 +148,7 @@ public class BaseApi {
      *                    }
      */
     @ApiOperation("修改密码(旧:/user/findCompanyPwd)")
+    @IpSave(saveName = "修改密码",saveParams = true)
     @PostMapping("/update/password")
     public ResponseJson updatePassword(PasswordDto passwordDto) {
         return baseService.updatePassword(passwordDto);
@@ -178,6 +183,7 @@ public class BaseApi {
     }
 
     @ApiOperation("超级会员会员中心")
+    @IpSave(saveName = "超级会员中心",saveParams = true)
     @GetMapping("/super/center")
     public ResponseJson<Map<String, Object>> superCenter(Integer userId,Integer source) {
         if (null == userId) {
@@ -187,6 +193,7 @@ public class BaseApi {
     }
 
     @ApiOperation("超级会员套餐详情")
+    @IpSave(saveName = "超级会员套餐详情",saveParams = false)
     @GetMapping("/super/package")
     public ResponseJson findPackage(){
         return baseService.findPackage();

+ 156 - 55
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -1,15 +1,19 @@
 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;
 
 /**
@@ -18,7 +22,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/3/8
  */
-@Api(tags="登录API")
+@Api(tags = "登录API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/user/login")
@@ -29,30 +33,31 @@ public class LoginApi {
 
     /**
      * 登录(用户名,密码)
-     *
+     * <p>
      * spi旧接口:/user/login
      *
      * @param loginPasswordDto {
-     *                           mobileOrEmail 手机号或邮箱
-     *                           password      密码
-     *                           unionId       微信unionId
+     *                         mobileOrEmail 手机号或邮箱
+     *                         password      密码
+     *                         unionId       微信unionId
      *                         }
      * @return UserLoginVo
      */
     @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);
     }
 
     /**
      * 协销登录(手机号,密码)
-     *
+     * <p>
      * spi旧接口:/seller/login
      *
      * @param loginPasswordDto {
-     *                           mobileOrEmail 手机号
-     *                           password 密码
+     *                         mobileOrEmail 手机号
+     *                         password 密码
      *                         }
      * @return UserLoginVo
      */
@@ -67,27 +72,122 @@ public class LoginApi {
 
     /**
      * 微信授权登录(小程序),用户数据存入Redis,key前缀:wxInfo:applets:
-     *
+     * <p>
      * spi旧接口:/club/authorization,小程序sessionKey(wxInfo)、PC端sessionKey(wxInfoMap)
      *
      * @param authAppletsDto {
-     *                           code          微信授权code
-     *                           encryptedData 微信加密数据
-     *                           iv            加密算法的初始向量
-     *                         }
+     *                       code          微信授权code
+     *                       encryptedData 微信加密数据
+     *                       iv            加密算法的初始向量
+     *                       }
      */
     @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 ResponseJson<Void> updateMessageAsRead(Integer messageType, Integer commonId) {
+        Integer i = loginService.updateMessageAsRead(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);
+        if (i <= 0) {
+            return ResponseJson.error("没有未读消息了!", null);
+        }
+        return ResponseJson.success("标记已读成功", null);
+    }
+
+    @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 ResponseJson<Void> updateRead(Integer userType, String Id) {
+        Integer i = loginService.updateRead(userType, Id);
+        if (i <= 0) {
+            return ResponseJson.error("id错误", null);
+        }
+        return ResponseJson.success("标记已读成功", null);
+    }
+
+
     /**
      * 微信公众号授权链接(www)
-     *
+     * <p>
      * spi旧接口:/user/authorizationLink
      *
      * @param redirectUri 用于微信授权的中间页面
@@ -95,8 +195,8 @@ public class LoginApi {
      */
     @ApiOperation("微信公众号授权链接(www)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "redirectUri", value = "用于微信授权的中间页面"),
-        @ApiImplicitParam(required = false, name = "mode", value = "授权方式:1静默授权,其他手动同意授权")
+            @ApiImplicitParam(required = true, name = "redirectUri", value = "用于微信授权的中间页面"),
+            @ApiImplicitParam(required = false, name = "mode", value = "授权方式:1静默授权,其他手动同意授权")
     })
     @GetMapping("/auth/link")
     public ResponseJson<String> getAuthorizationLink(String redirectUri, Integer mode) {
@@ -105,7 +205,7 @@ public class LoginApi {
 
     /**
      * 微信公众号授权登录(www),用户数据存入Redis,key前缀:wxInfo:website:
-     *
+     * <p>
      * spi旧接口:/user/authorizationLogin,小程序sessionKey(wxInfo)、PC端sessionKey(wxInfoMap)
      *
      * @param code  微信code
@@ -114,10 +214,11 @@ public class LoginApi {
      */
     @ApiOperation("微信公众号授权登录(www)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "code", value = "微信授权code"),
-        @ApiImplicitParam(required = true, name = "state", value = "安全认证key"),
-        @ApiImplicitParam(required = false, name = "mode", value = "1:静默授权,2:用户手动授权")
+            @ApiImplicitParam(required = true, name = "code", value = "微信授权code"),
+            @ApiImplicitParam(required = true, name = "state", value = "安全认证key"),
+            @ApiImplicitParam(required = false, name = "mode", value = "1:静默授权,2:用户手动授权")
     })
+    @IpSave(saveName = "微信公众号授权登录(www)", saveParams = false)
     @GetMapping("/auth/website")
     public ResponseJson<UserLoginVo> websiteAuthorization(String code, String state, Integer mode, @RequestHeader HttpHeaders headers) {
         return loginService.websiteAuthorization(code, state, mode, headers);
@@ -135,29 +236,29 @@ public class LoginApi {
 
     /**
      * 获取生成微信二维码的参数
-     *
+     * <p>
      * spi旧接口:/user/toWechatLogin
      *
-     * @return Map(appId,redirectUri,state)
+     * @return Map(appId, redirectUri, state)
      */
     @ApiOperation("获取生成微信二维码的参数")
     @GetMapping("/auth/parameters")
-    public ResponseJson<Map<String, String>> getAuthParameters(){
+    public ResponseJson<Map<String, String>> getAuthParameters() {
         return loginService.getAuthParameters();
     }
 
     /**
      * 微信用户扫码,微信服务器回调
-     *
+     * <p>
      * spi旧接口:/user/wechatLogin
      *
-     * @param code      微信code
-     * @param state     安全认证key(第一步获取参数时自定义生成的uuid)
+     * @param code  微信code
+     * @param state 安全认证key(第一步获取参数时自定义生成的uuid)
      */
     @ApiOperation("扫码后微信服务器回调")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "code", value = "微信授权code"),
-        @ApiImplicitParam(required = false, name = "state", value = "安全认证key")
+            @ApiImplicitParam(required = false, name = "code", value = "微信授权code"),
+            @ApiImplicitParam(required = false, name = "state", value = "安全认证key")
     })
     @GetMapping("/auth/callback")
     public void qrCodeAuthScan(String code, String state) {
@@ -166,49 +267,49 @@ public class LoginApi {
 
     /**
      * 校验扫码结果,用户数据存入Redis,key前缀:wxInfo:website:
-     *
+     * <p>
      * spi旧接口:/user/polling,小程序sessionKey(wxInfo)、PC端sessionKey(wxInfoMap)
      *
-     * @param state   安全认证key(第一步获取参数时自定义生成的uuid)
+     * @param state 安全认证key(第一步获取参数时自定义生成的uuid)
      * @return UserLoginVo
      */
     @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);
     }
 
     /**
      * 微信扫码后,绑定机构账号
-     *
+     * <p>
      * spi旧接口:/user/bindOrganization
      *
      * @param scanBindDto {
-     *                           mobileOrEmail 手机号或邮箱
-     *                           password      密码
-     *                           mobile        手机号
-     *                           smsCode       手机验证码
-     *                           unionId       微信unionId
-     *                           linkName      联系人
-     *                     }
+     *                    mobileOrEmail 手机号或邮箱
+     *                    password      密码
+     *                    mobile        手机号
+     *                    smsCode       手机验证码
+     *                    unionId       微信unionId
+     *                    linkName      联系人
+     *                    }
      */
     @ApiOperation("微信扫码后绑定机构账号")
     @PostMapping("/auth/scan/bind")
-    public ResponseJson<UserLoginVo> qrCodeAuthScanBind(ScanBindDto scanBindDto){
+    public ResponseJson<UserLoginVo> qrCodeAuthScanBind(ScanBindDto scanBindDto) {
         return loginService.qrCodeAuthScanBind(scanBindDto);
     }
 
     /**
      * 运营人员邀请码授权登录
-     *
+     * <p>
      * spi旧接口:/club/invitationCode
      *
      * @param authInvitationDto {
-     *                             invitationCode 邀请码
-     *                             nickName       微信昵称
-     *                             avatarUrl      微信头像(headimgurl)
-     *                             unionId        微信unionId
+     *                          invitationCode 邀请码
+     *                          nickName       微信昵称
+     *                          avatarUrl      微信头像(headimgurl)
+     *                          unionId        微信unionId
      *                          }
      * @return UserLoginVo
      */
@@ -224,17 +325,17 @@ public class LoginApi {
 
     /**
      * 运营人员绑定微信
-     *
+     * <p>
      * spi旧接口:/club/bindingWx
      *
      * @param authBindDto {
-     *                         userId    要绑定的用户Id(userID)
-     *                         mobile    手机号
-     *                         smsCode   手机验证码(verificationCode)
-     *                         unionId   微信unionId
-     *                         nickName       微信昵称
-     *                         avatarUrl      微信头像(headimgurl)
-     *                     }
+     *                    userId    要绑定的用户Id(userID)
+     *                    mobile    手机号
+     *                    smsCode   手机验证码(verificationCode)
+     *                    unionId   微信unionId
+     *                    nickName       微信昵称
+     *                    avatarUrl      微信头像(headimgurl)
+     *                    }
      * @return UserLoginVo
      */
     @ApiOperation("运营人员绑定微信")

+ 3 - 0
src/main/java/com/caimei365/user/controller/RegisterApi.java

@@ -1,6 +1,7 @@
 package com.caimei365.user.controller;
 
 import com.caimei365.user.idempotent.Idempotent;
+import com.caimei365.user.idempotent.IpSave;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.*;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
@@ -37,6 +38,7 @@ public class RegisterApi {
      */
     @ApiOperation("检查手机号是否可以注册")
     @ApiImplicitParam(required = true, name = "bindMobile", value = "手机号或邮箱")
+    @IpSave(saveName = "检查手机号是否可以注册",saveParams = true)
     @GetMapping("/check")
     public ResponseJson registerCheck(String bindMobile) {
         return registerService.registerCheck(bindMobile);
@@ -63,6 +65,7 @@ public class RegisterApi {
      */
     @ApiOperation("注册普通机构")
     @Idempotent(prefix = "idempotent_club", keys = {"#clubRegisterDto"}, expire = 5)
+    @IpSave(saveName = "注册普通机构",saveParams = true)
     @PostMapping("/club")
     public ResponseJson clubRegister(ClubRegisterDto clubRegisterDto, @RequestHeader HttpHeaders headers) {
         return registerService.clubRegister(clubRegisterDto, headers);

+ 6 - 0
src/main/java/com/caimei365/user/feign/ToolsFeign.java

@@ -22,4 +22,10 @@ public interface ToolsFeign {
     @PostMapping("/tools/sms/send")
     String getSendSms(@RequestParam Integer type, @RequestParam String mobile, @RequestParam String content);
 
+    /**
+     * 请求发消息
+     */
+    @PostMapping("/tools/mq/send")
+    String sendCommonMessage(@RequestParam String topic, @RequestParam String content, @RequestParam String tag, @RequestParam Integer sort, @RequestParam Integer async, @RequestParam Integer oneway, @RequestParam Integer delay);
+
 }

+ 16 - 0
src/main/java/com/caimei365/user/idempotent/IpSave.java

@@ -0,0 +1,16 @@
+package com.caimei365.user.idempotent;
+
+import java.lang.annotation.*;
+
+/**
+ * @author Administrator
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface IpSave {
+
+    String saveName();
+
+    boolean saveParams();
+}

+ 103 - 0
src/main/java/com/caimei365/user/idempotent/IpSaveAspect.java

@@ -0,0 +1,103 @@
+package com.caimei365.user.idempotent;
+
+
+import com.caimei365.user.feign.ToolsFeign;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Method;
+
+
+/**
+ *
+ */
+@Slf4j
+@Aspect
+@Component
+public class IpSaveAspect {
+
+    @Resource
+    private ToolsFeign toolsFeign;
+
+    /**
+     * 切入点,根据自定义IpSave实际路径进行调整
+     */
+    @Pointcut("@annotation(com.caimei365.user.idempotent.IpSave)")
+    public void executeIdempotent() {
+    }
+
+    @Around("executeIdempotent()")
+    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
+        //获取方法对象
+        Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
+        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
+        HttpServletRequest request = servletRequestAttributes.getRequest();
+        // ip
+        String unknown = "unknown";
+        String ip = "";
+        ip = request.getHeader("x-forwarded-for");
+        if (StringUtils.isBlank(ip)) {
+            ip = request.getHeader("X-Real-IP");
+        }
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+
+        if (ip == null || ip.length() == 0 || unknown.equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        // 接口路径
+        String requestURI = request.getRequestURI();
+        //获取自定义注解
+        IpSave ipSave = method.getAnnotation(IpSave.class);
+        // 访问名 注解的值
+        String s = ipSave.saveName();
+        // 是否存储发送参数
+        boolean sp = ipSave.saveParams();
+        // 接口真实发送参数
+        String queryString = "";
+        if (sp) {
+            queryString = request.getQueryString();
+        }
+        String mes = "";
+        if (StringUtils.isNotBlank(ip)) {
+            mes += ip + "¥";
+        } else {
+            mes = "¥";
+        }
+        if (StringUtils.isNotBlank(requestURI)) {
+            mes += requestURI + "¥";
+        } else {
+            mes += "¥";
+        }
+        if (StringUtils.isNotBlank(queryString)) {
+            mes += queryString + "¥";
+        } else {
+            mes += "¥";
+        }
+        if (StringUtils.isNotBlank(s)) {
+            mes += s;
+        }
+        //异步给mq存
+        toolsFeign.sendCommonMessage("IpSave", mes, null, 1, 1, null, null);
+
+        return joinPoint.proceed();
+    }
+}
+

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

@@ -0,0 +1,90 @@
+package com.caimei365.user.mapper;
+
+
+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 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);
+
+    List<Integer> receiptShopID();
+
+    UserVo clubList(Integer userId);
+
+    CouponVo CouponList(Integer couponType);
+
+    Integer MessageCount(Integer userType,Integer messageType,Integer commonId);
+
+    /**
+     *commonId是通过userType类型来区分供应商和机构
+     */
+    Integer Count(Integer userType,Integer commonId);
+
+    Integer receStatct(Integer shopID);
+
+    /**
+     * 上架费数量
+     */
+    Integer listingFee(Integer shopID);
+
+    /**
+     * 上架费过期数量
+     */
+    Integer listingfeeExpire(Integer shopID);
+
+    List<MessageCenter> MessageList(Integer userType,Integer messageType,Integer commonId);
+
+    String contractMobile(Integer clubID);
+
+    String contractMobiles(Integer ShopID);
+
+    String getOpenidListByPermission(String unionId);
+
+    String FromUnionId(Integer userID);
+
+    String UnionIdList(Integer userID);
+
+    Integer getVipHistoryCount(Integer userID);
+
+    MessageCenter MainImage(Integer userType, Integer commonId,Integer orderID);
+
+    MessageCenter productImage(Integer productID,Integer shopID);
+
+    Integer productCount(Integer orderID);
+
+    String receiptDate(Integer shopID);
+
+    Double receiptAmount(Integer shopID);
+
+    Integer newReceiptType(Integer shopID);
+
+    Integer updateMessageAsRead(Integer userType,Integer messageType,Integer commonId);
+
+    Integer userId(String openid);
+
+    Integer userIds(Integer shopID);
+
+    String shopName(Integer shopID);
+
+    Integer deleteMessage(String id);
+
+    Integer updateRead(Integer userType,String Id);
+
+}

+ 4 - 0
src/main/java/com/caimei365/user/mapper/ShopMapper.java

@@ -68,6 +68,10 @@ public interface ShopMapper {
      * 公司资质照片
      */
     List<String> getShopCertById(Integer shopId, int shopCertTypeId);
+    /**
+     * 医疗器械经营许可
+     */
+    String medicalPracticeLicense(Integer shopId);
 
     /**
      * 供应商首页-轮播图片

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

@@ -42,6 +42,11 @@ public interface SuperVipMapper {
      */
     SuperVipPo findSuperVip(Integer userId);
 
+    /**
+     * vip过期推送
+     */
+    List<SuperVipPo> findVip();
+
     /**
      * 查用户名下采美豆余额
      *

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

@@ -0,0 +1,110 @@
+package com.caimei365.user.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ */
+@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;
+
+    /**
+     *订单状态
+     */
+    private Integer status;
+    /**
+     * 商品ID
+     */
+    private Integer productId;
+
+    /**
+     * 供应商公司名称
+     */
+    private String shopName;
+}

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

@@ -70,6 +70,10 @@ public class ShopHomeVo implements Serializable {
      * 上架商品数量
      */
     private Integer normalNum;
+    /**
+     * 医疗器械经营许可
+     */
+   private String medicalPracticeLicense;
     /**
      * 公司资质照片1
      */

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

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

+ 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;
 
     /**
      * 微信扫码后,绑定机构账号

+ 1 - 4
src/main/java/com/caimei365/user/service/impl/BaseServiceImpl.java

@@ -403,10 +403,7 @@ public class BaseServiceImpl implements BaseService {
         String dbPassword = Md5Util.md5(passWord);
         baseMapper.updatePasswordByUserId(dbPassword, dbUserId);
         //重新设置密码后将登录失败表中近30分钟记录置为删除
-        Calendar c = Calendar.getInstance();
-        c.setTime(new Date());
-        c.add(Calendar.MINUTE, -30);
-        loginMapper.updateLoginFailRecord(dbUserId, c.getTime());
+        redisService.remove("login-"+dbUserId);
         return ResponseJson.success("密码修改成功", "");
     }
 

+ 400 - 17
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -13,19 +13,29 @@ 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.service.RemoteCallService;
 import com.caimei365.user.utils.JwtUtil;
+import com.caimei365.user.utils.MathUtil;
 import com.caimei365.user.utils.Md5Util;
+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 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
@@ -55,6 +65,12 @@ public class LoginServiceImpl implements LoginService {
     private AsyncService asyncService;
     @Resource
     private SellerMapper sellerMapper;
+    @Resource
+    private MessageCenterMapper messageCenterMapper;
+    @Resource
+    private RemoteCallService remoteCallService;
+
+
     /**
      * 小程序邀请码过期天数
      */
@@ -72,7 +88,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();
@@ -84,19 +100,26 @@ public class LoginServiceImpl implements LoginService {
         }
         //处理比对密码
         UserLoginVo baseUser = loginMapper.getLoginUserByMobileOrEmail(mobileOrEmail);
-
-        if (baseUser != null) {
+        if (null != baseUser) {
+            String key = "login-" + baseUser.getUserId();
+            boolean exists = redisService.exists(key);
             //如果30分钟内输入错误记录>=5,return该账号暂时被冻结,请(30-最前一次时间)分钟后重试或直接修改密码
-            Calendar c = Calendar.getInstance();
-            c.setTime(new Date());
-            c.add(Calendar.MINUTE, -30);
-            List<LoginFailRecordVo> fail = loginMapper.findLoginFailRecord(baseUser.getUserId(), c.getTime());
-            if (null != fail && fail.size() >= 5) {
-                Integer minutes = loginMapper.findTimes(fail.get(0).getId(),new Date());
-                return ResponseJson.error("该账号暂时被冻结,请" + (30 - minutes) + "分钟后重试或直接修改密码", null);
+            if (exists) {
+                String val = (String) redisService.get(key);
+                String[] split = val.split(",");
+                int count = Integer.parseInt(split[0]);
+                if (count >= 5) {
+                    long s = Long.parseLong(split[1]);
+                    int l = (int) Math.floor((System.currentTimeMillis() - s) / 1000 / 60);
+                    return ResponseJson.error("该账号暂时被冻结,请" + (30 - l) + "分钟后重试或直接修改密码", null);
+                }
             }
             // 如果前端传入unionId,则存入返回前端
             baseUser.setUnionId(unionId);
+
+            Integer clubId = messageCenterMapper.clubIdCule(baseUser.getUserId());
+            Integer savedCount = null;
+
             // 比对密码
             String md5Password = Md5Util.md5(password);
             String dbPassword = baseUser.getPassword();
@@ -110,9 +133,21 @@ public class LoginServiceImpl implements LoginService {
                 }
             } else {
                 // 增加一次错误输入密码记录,30分钟内连续五次冻结
-                loginMapper.insertLoginFailRecord(new Date(),baseUser.getUserId());
-                if (null != fail && 4 ==fail.size() ) {
-                    return ResponseJson.error("您已连续输错5次密码,账号被暂时冻结,请于30分钟后重试或直接修改密码",null);
+                if (exists) {
+                    String val = (String) redisService.get(key);
+                    String[] split = val.split(",");
+                    int count = Integer.parseInt(split[0]);
+                    if (count < 5) {
+                        count++;
+                        String va = count + "," + System.currentTimeMillis();
+                        redisService.set(key, va);
+                    }
+                    if (count >= 5) {
+                        redisService.set(key, 5 + "," + System.currentTimeMillis(), 1800L);
+                    }
+                } else {
+                    String val = 1 + "," + System.currentTimeMillis();
+                    redisService.set(key, val);
                 }
             }
         }
@@ -128,7 +163,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 +195,15 @@ 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);
+            log.info(">>>>>" + shopID);
+            Integer newReceiptType = messageCenterMapper.newReceiptType(shopID);
+            log.info(">>>>>" + newReceiptType);
+        }
         if (null != seller) {
             loginMapper.updateServiceProviderUnionId(seller.getUserId(), unionId);
             String token = JwtUtil.createToken(seller.getUserId());
@@ -179,6 +223,206 @@ 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 (null != mess.getClubId()) {
+                MessageCenter messageCenter = messageCenterMapper.MainImage(1, 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());
+                }
+            }
+        });
+        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 -> {
+                String shopName=messageCenterMapper.shopName(commonId);
+                MessageCenter messageCenter = messageCenterMapper.productImage(mess.getProductId(),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());
+            }
+            mess.setShopName(shopName);
+        });
+        if (source == 2) {
+            messageCenterMapper.updateMessageAsRead(2, messageType, commonId);
+        }
+        PageInfo<MessageCenter> pageData = new PageInfo<>(list);
+        return ResponseJson.success(pageData);
+    }
+
+
+
+//    /**
+//     * 当天天下午3点推送超级会员过期条件
+//     */
+////    @Scheduled(cron = "0 0 15 * * ?")
+//    @Scheduled(cron = "0 0/2 * * * ?")
+//    private Void Timerw() throws ParseException {
+//
+//        List<SuperVipPo> superV = vipMapper.findVip();
+//        superV.forEach(superVip -> {
+//            Integer clubId = messageCenterMapper.clubIdCule(superVip.getUserId());
+//            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 = null;
+//                    try {
+//                        da1 = sdf.parse(endTime);
+//                    } catch (ParseException e) {
+//                        e.printStackTrace();
+//                    }
+//                    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)
      *
@@ -320,6 +564,22 @@ public class LoginServiceImpl implements LoginService {
 //            loginUser.setUserIdentity(2);
 //            loginUser.setUserPermission(2);
 //        }
+
+        if (loginUser.getUserId() != null) {
+            Integer shopID = messageCenterMapper.shopID(loginUser.getUserId());
+            Integer newReceiptType = messageCenterMapper.newReceiptType(shopID);
+            Integer listingFeeCount= messageCenterMapper.listingFee(shopID);
+            Integer listingfeeExpireCount= messageCenterMapper.listingfeeExpire(shopID);
+            Integer receStatctCount=messageCenterMapper.receStatct(shopID);
+            Integer listingFee=0;
+            if(listingFeeCount>0 && listingfeeExpireCount>0){
+                if(receStatctCount<=0){
+                    listingFee=1;
+                }
+            }
+            loginUser.setListingFee(listingFee);
+        }
+
         // 登录异步赠送10采美豆
         asyncService.loginUpdateBeans(loginUser.getUserId(), loginUser.getUserIdentity());
         loginUser.setManager(sellerMapper.findManagerByUser(loginUser.getUserId()));
@@ -386,7 +646,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 +663,32 @@ 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);
+                Integer listingFeeCount= messageCenterMapper.listingFee(shopID);
+                Integer listingfeeExpireCount= messageCenterMapper.listingfeeExpire(shopID);
+                Integer receStatctCount=messageCenterMapper.receStatct(shopID);
+                Integer listingFee=0;
+                if(listingFeeCount>0 && listingfeeExpireCount>0){
+                    if(receStatctCount<=0){
+                        listingFee=1;
+                    }
+                }
+
+            }
+        }
+
+
         // 用户数据存入Redis,key前缀:wxInfo:website:
         String infoDataStr = JSON.toJSONString(infoData);
         Map<String, Object> infoDataMap = JSON.parseObject(infoDataStr);
@@ -564,16 +850,86 @@ 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);
+            //发短信
+            String message = "【采美365】恭喜您成功成为运营人员,您可通过微信直接登录采美商城进行采购。";
+            String mobile = messageCenterMapper.contractMobile(operation.getClubId());
+            if (mobile != null && mobile != "") {
+                remoteCallService.remoteSendSms(2, 3, mobile, message);
+            }
+
+            try {
+                log.info("***********机构通过邀请码登入微信公众号推送************");
+                String accessToken = weChatService.getAccessToken();
+                String openid = messageCenterMapper.getOpenidListByPermission(unionId);
+                String time = current;
+                String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
+                // 跳转到【小程序付款-选择支付方式页面】
+                String pagePath = "https://www.caimei365.com/";
+                // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+                log.error("获取openid>>>>>" + openid);
+                weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
+            } catch (Exception e) {
+                log.error("【机构通过邀请码登入通知】获取微信公众号access_token异常!", e);
+            }
+
+
         } 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);
+
+            //发短信
+            String message = "【采美365】恭喜您成功成为运营人员,您可通过微信直接登录采美商城进行采购。";
+            String mobile = messageCenterMapper.contractMobiles(operation.getShopId());
+            if (mobile != null && mobile != "") {
+                remoteCallService.remoteSendSms(2, 3, mobile, message);
+            }
+            try {
+                log.info("***********供应商通过邀请码登入微信公众号推送************");
+                String accessToken = weChatService.getAccessToken();
+                String openid = messageCenterMapper.getOpenidListByPermission(unionId);
+                String time = current;
+                String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
+                // 跳转到【小程序付款-选择支付方式页面】
+                String pagePath = "https://www.caimei365.com/";
+                // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+                log.error("获取openid>>>>>" + openid);
+                weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
+            } catch (Exception e) {
+                log.error("【供应商通过邀请码登入通知】获取微信公众号access_token异常!", e);
+            }
+
         }
         // 更新运营人员信息
         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.setShopMessType(null);
+            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);
         // 删除标识

+ 33 - 6
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) {
@@ -79,12 +102,12 @@ public class OperationServiceImpl implements OperationService {
                 name = operationMapper.findShopNameById(operationDto.getShopId());
             }
             String mobile = operationDto.getMobile();
-            if (StringUtils.isNotEmpty(mobile)) {
-                // 欢迎成为${name}的运营人员,您的邀请码为${code}。
-                String content = "欢迎成为"+name+"的运营人员,您的邀请码为"+invitationCode+"。您可使用以下两种方式激活您的身份:1. 您可在微信搜索“采美采购商城”小程序,使用邀请码登录并绑定微信;2. 进入“采美采购商城”小程序后,使用邀请码登录并绑定微信。绑定微信后,您可通过微信授权直接登录“采美采购商城”小程序或微信扫码直接登录采美365网站。";
-                remoteCallService.remoteSendSms(0, 1, mobile, content);
-                log.info("欢迎成为"+ name +"的运营人员,您的邀请码为:" + invitationCode);
-            }
+//            if (StringUtils.isNotEmpty(mobile)) {
+//                // 欢迎成为${name}的运营人员,您的邀请码为${code}。
+//                String content = "欢迎成为"+name+"的运营人员,您的邀请码为"+invitationCode+"。您可使用以下两种方式激活您的身份:1. 您可在微信搜索“采美采购商城”小程序,使用邀请码登录并绑定微信;2. 进入“采美采购商城”小程序后,使用邀请码登录并绑定微信。绑定微信后,您可通过微信授权直接登录“采美采购商城”小程序或微信扫码直接登录采美365网站。";
+//                remoteCallService.remoteSendSms(0, 1, mobile, content);
+//                log.info("欢迎成为"+ name +"的运营人员,您的邀请码为:" + invitationCode);
+//            }
         }
         if (operationDto.getShopId() == null) {
             operation.setUserType(1);
@@ -128,6 +151,10 @@ 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());
+
             //发送短信
             String name = null;
             if (operation.getClubId() != null) {

+ 169 - 19
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -19,15 +19,15 @@ 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;
-import java.util.Map;
+import java.util.*;
 
 /**
  * Description
@@ -60,7 +60,11 @@ public class RegisterServiceImpl implements RegisterService {
     @Resource
     private MessagePushMapper messagePushMapper;
     @Resource
+    private MessageCenterMapper messageCenterMapper;
+    @Resource
     private RemoteCallService remoteCallService;
+    @Resource
+    private WeChatService weChatService;
 
     /**
      * 检查账号可以注册
@@ -214,17 +218,29 @@ public class RegisterServiceImpl implements RegisterService {
         // user更新clubId
         user.setClubId(club.getClubId());
         registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
-        // 注册成功短信
-        String content = "注册成功!您可以通过手机号"+clubRegisterDto.getBindMobile()+"登录。";
-        boolean smsFlag = remoteCallService.remoteSendSms(0, 1, clubRegisterDto.getBindMobile(), content);
-        if (!smsFlag) {
-            // 短信发送失败重试一次
-            remoteCallService.remoteSendSms(0, 1, clubRegisterDto.getBindMobile(), content);
-        }
-        /*
-            绑定微信,成为机构运营人员
-         */
+        //推送信息中心-账户通知
+        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);
+
+        //    绑定微信,成为机构运营人员
         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(messageCente);
+
             OperationPo operation = new OperationPo();
             // 组织Id,采美默认0
             operation.setOrganizeId(0);
@@ -269,9 +285,9 @@ public class RegisterServiceImpl implements RegisterService {
             log.info("注册普通机构,默认绑定为机构运营人员");
         }
         log.info("注册普通机构成功,手机号>>>" + clubRegisterDto.getBindMobile());
-        if (!smsFlag) {
-            log.info("短信发送失败,手机号:" + clubRegisterDto.getBindMobile());
-        }
+//        if (!smsFlag) {
+//            log.info("短信发送失败,手机号:" + clubRegisterDto.getBindMobile());
+//        }
         //新用户自主注册送1000采美豆
         UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
         beansHistory.setUserId(user.getUserId());
@@ -285,7 +301,7 @@ public class RegisterServiceImpl implements RegisterService {
     }
 
     /**
-     * 普通机构升级会员机构
+     * 普通机构升级会员机构(资质机构)
      *
      * @param upgradeDto ClubUpgradeDto:{
      *                   clubId                 机构ID
@@ -650,6 +666,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 +887,8 @@ public class RegisterServiceImpl implements RegisterService {
         user.setShopId(shop.getShopId());
         registerMapper.updateUserShopId(user.getUserId(), shop.getShopId());
         log.info("注册供应商---------userID:" + user.getUserId());
+
+
         return ResponseJson.success();
     }
 
@@ -965,10 +997,13 @@ 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){
+        Integer clubId = messageCenterMapper.clubIdCule(userId);
         SuperVipDto endFlag = findEnd(userId);
         Integer userBeans = vipMapper.findUserBeans(userId);
         VipPackage pac = vipMapper.findUserPackage(packageId);
+
+
         //过期和没买过都是生效时间重置,到期时间=现在+套餐时间
         if (endFlag.getVipFlag() == 0 || endFlag.getVipFlag() == -1) {
             //1.查用户采美豆,够就用采美豆下单,不够就返回信息
@@ -976,6 +1011,44 @@ public class RegisterServiceImpl implements RegisterService {
                 //用户采美豆>=套餐需要的采美豆,调用采美豆支付方法
                 //传空表示新客户
                 beanPay(userId, packageId, null, endFlag.getVipFlag());
+                //推送站内消息
+                if (clubId != null) {
+                    //推送信息中心-账户通知
+                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    String current = dateFormat.format(new Date());
+                    //1.日期格式
+                    log.info("输出间隔月份----------->", pac.getDuration());
+                    MessageCenter messageCenter = new MessageCenter();
+                    messageCenter.setShopId(null);
+                    messageCenter.setClubId(clubId);
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(2);
+                    messageCenter.setAccountType(2);
+                    messageCenter.setContent(pac.getDuration() + "个月");
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+
+                    try {
+                        log.info("***********会员充值微信公众号推送************");
+                        String accessToken = weChatService.getAccessToken();
+                        String unionId=messageCenterMapper.UnionIdList(userId);
+                        String openid = messageCenterMapper.getOpenidListByPermission(unionId);
+                        String title="恭喜您成为采美商城超级会员";
+                        String name=pac.getDuration() + "个月";
+                        Double price=pac.getPrice();
+                        String date="30";
+                        String time = current;
+                        String remarkText = "如在使用中有任何疑问,请在小程序内联系在线客服";
+                        // 跳转到【小程序付款-选择支付方式页面】
+                        String pagePath = "/pages/user/member/member";
+                        // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+                        log.error("获取openid>>>>>" + openid);
+                        weChatService.sendTemplateMsgs(accessToken, openid,title,name,price,date,remarkText, pagePath);
+                    } catch (Exception e) {
+                        log.error("【会员充值微信通知】获取微信公众号access_token异常!", e);
+                    }
+
+                }
                 return ResponseJson.success("支付采美豆购买成功");
             }
             return ResponseJson.error("用户采美豆不足", null);
@@ -983,6 +1056,43 @@ public class RegisterServiceImpl implements RegisterService {
             if (Double.valueOf(userBeans) >= (pac.getPrice() * pac.getProportion())) {
                 //续费生效时间不变,原到期时间+套餐时间
                 beanPay(userId, packageId, endFlag.getEndTime(), endFlag.getVipFlag());
+                     //推送站内消息
+                if (clubId != null) {
+                    //推送信息中心-账户通知
+                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    String current = dateFormat.format(new Date());
+                    //1.日期格式
+                    log.info("输出间隔月份----------->", pac.getDuration());
+                    MessageCenter messageCenter = new MessageCenter();
+                    messageCenter.setShopId(null);
+                    messageCenter.setClubId(clubId);
+                    messageCenter.setUserType(1);
+                    messageCenter.setMessageType(2);
+                    messageCenter.setAccountType(2);
+                    messageCenter.setContent(pac.getDuration() + "个月");
+                    messageCenter.setTime(current);
+                    messageCenterMapper.addMessageCenter(messageCenter);
+
+                    try {
+                        log.info("***********会员续费微信公众号推送************");
+                        String accessToken = weChatService.getAccessToken();
+                        String unionId=messageCenterMapper.UnionIdList(userId);
+                        String openid = messageCenterMapper.getOpenidListByPermission(unionId);
+                        String date=current;
+                        String remarkText = "如在使用中有任何疑问,请在小程序内联系在线客服";
+                        // 跳转到【小程序付款-选择支付方式页面】
+                        String pagePath = "/pages/user/member/member";
+                        // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
+                        log.error("获取openid>>>>>" + openid);
+                        weChatService.sendTemplateMsg(accessToken, openid,date,remarkText, pagePath);
+                    } catch (Exception e) {
+                        log.error("【会员充值微信通知】获取微信公众号access_token异常!", e);
+                    }
+
+
+
+                }
+
                 return ResponseJson.success("支付采美豆购买成功");
             }
             return ResponseJson.error("用户采美豆不足", null);
@@ -1011,10 +1121,14 @@ public class RegisterServiceImpl implements RegisterService {
         }
         cal.setTime(beginTime);
         cal.add(Calendar.MONTH, pac.getDuration());
+
+
         // 查询未支付的当前超级会员套餐购买记录
         Integer dbHistoryId = vipMapper.getVipHistoryId(userId, packageId);
         //userId, packageId, beginTime, endTime, payStatus, payWay, payType, price, userBeans, payTime
         VipPayHistoryPo payHistory = new VipPayHistoryPo();
+
+
         payHistory.setUserBeans(0d);
         payHistory.setUserId(userId);
         payHistory.setPackageId(packageId);
@@ -1025,6 +1139,19 @@ public class RegisterServiceImpl implements RegisterService {
         // 线上支付
         payHistory.setPayWay(1);
         payHistory.setPrice(pac.getPrice());
+
+        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.getEndTime().getTime() - payHistory.getBeginTime().getTime()) / 24 / 60 / 60 / 30 / 1000;
+        //2.会员有效期(日)
+        Long t = (payHistory.getEndTime().getTime() - payHistory.getBeginTime().getTime()) / 24 / 60 / 60 / 1000;
+        Integer count =messageCenterMapper.getVipHistoryCount(userId);
+
+
         if (null != dbHistoryId && dbHistoryId > 0) {
             payHistory.setId(dbHistoryId);
             // 更新未支付的当前超级会员购买记录
@@ -1033,19 +1160,24 @@ public class RegisterServiceImpl implements RegisterService {
             // 新增超级会员购买记录
             vipMapper.addPayHistory(payHistory);
         }
+
         if (payHistory.getId() > 0) {
+
             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();
+        Integer clubId = messageCenterMapper.clubIdCule(userId);
         if (superVip == null) {
             superVipDto.setVipFlag(0);
         } else {
@@ -1056,8 +1188,12 @@ public class RegisterServiceImpl implements RegisterService {
             } else {
                 superVipDto.setVipFlag(1);
                 superVipDto.setEndTime(endTime.getEndTime());
+
             }
+
+
         }
+
         return superVipDto;
     }
 
@@ -1244,5 +1380,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);
+//    }
+
+
 }
 

+ 2 - 0
src/main/java/com/caimei365/user/service/impl/RemoteCallServiceImpl.java

@@ -50,6 +50,8 @@ public class RemoteCallServiceImpl implements RemoteCallService {
             list.add("15814011616");
             list.add("13100721916");
             list.add("15113936829");
+            list.add("18476937515");
+            list.add("18175515644");
             if ("prod".equals(profile) || list.contains(mobile)) {
                 if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
                     String regex = "^(1[3-9]\\d{9}$)";

+ 18 - 0
src/main/java/com/caimei365/user/service/impl/ShopServiceImpl.java

@@ -22,8 +22,10 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import redis.clients.jedis.Jedis;
 
 import javax.annotation.Resource;
 import java.util.*;
@@ -246,6 +248,7 @@ public class ShopServiceImpl implements ShopService {
             String[] businessScope = supplier.getBusinessScope().split("/");
             supplier.setBusinessScopeArr(businessScope);
             supplier.setLogo(ImageUtils.getImageURL("shopLogo", supplier.getLogo(), 0, wwwDomain));
+            supplier.setMedicalPracticeLicense(shopMapper.medicalPracticeLicense(shopId));
         }
         //公司资质照片
         List<String> productionLicence = shopMapper.getShopCertById(shopId, 2);
@@ -372,6 +375,11 @@ public class ShopServiceImpl implements ShopService {
         // 9.已下架数量
         Integer downNum = shopMapper.getShopProductCount(user.getShopId(), 3);
         result.put("downNum", downNum);
+        Jedis jedis=new Jedis("172.31.165.27", 6379);
+        jedis.auth("6#xsI%b4o@5c3RoE");
+        jedis.lpush("constraint","1");
+        result.put("constraint", jedis.rpop("constraint"));
+
         // 10.单品销售排名
         List<Map<String, Object>> salesRankingList = shopMapper.getSalesRankingList(user.getShopId());
         if (salesRankingList != null && salesRankingList.size() > 0) {
@@ -412,6 +420,16 @@ public class ShopServiceImpl implements ShopService {
         return ResponseJson.success(result);
     }
 
+    /**
+     *constraint加入缓存
+     */
+    @Scheduled(cron = "0 0 23 * * ?")
+    public void Open() {
+        Jedis jedis=new Jedis("172.31.165.27", 6379);
+        jedis.auth("6#xsI%b4o@5c3RoE");
+        jedis.lpush("constraint","0");
+    }
+
     @Override
     public ResponseJson<Map<String, Object>> getShopArticleById(Integer articleId) {
         Map<String, Object> map = new HashMap<>(2);

+ 74 - 3
src/main/java/com/caimei365/user/utils/RequestUtil.java

@@ -1,11 +1,16 @@
 package com.caimei365.user.utils;
 
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
+import org.springframework.util.StringUtils;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import java.io.*;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.StandardCharsets;
+import java.security.cert.X509Certificate;
 import java.util.List;
 import java.util.Map;
 
@@ -113,4 +118,70 @@ public class RequestUtil {
         return result.toString();
     }
 
+    /**
+     * 向指定 URL 发送请求
+     * @param requestUrl 发送请求的 URL
+     * @param requestMethod 请求方法GET/POST
+     * @param jsonString json字符串参数
+     * @return 远程资源的响应结果
+     */
+    public static String httpRequest(String requestUrl, String requestMethod, String jsonString) {
+        StringBuffer buffer = new StringBuffer();
+        try {
+            // 创建SSLContext对象,并使用我们指定的信任管理器初始化
+            TrustManager[] tm = {
+                    new javax.net.ssl.X509TrustManager(){
+                        @Override
+                        public void checkClientTrusted(X509Certificate[] chain, String authType) {
+                        }
+                        @Override
+                        public void checkServerTrusted(X509Certificate[] chain, String authType) {
+                        }
+                        @Override
+                        public X509Certificate[] getAcceptedIssuers() {
+                            return null;
+                        }
+                    }
+            };
+            SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
+            sslContext.init(null, tm, new java.security.SecureRandom());
+            // 从上述SSLContext对象中得到SSLSocketFactory对象
+            SSLSocketFactory ssf = sslContext.getSocketFactory();
+
+            URL url = new URL(requestUrl);
+            HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection();
+            httpUrlConn.setSSLSocketFactory(ssf);
+            httpUrlConn.setDoOutput(true);
+            httpUrlConn.setDoInput(true);
+            httpUrlConn.setUseCaches(false);
+            // 设置请求方式(GET/POST)
+            httpUrlConn.setRequestMethod(requestMethod);
+            if ("GET".equalsIgnoreCase(requestMethod)) {
+                httpUrlConn.connect();
+            }
+            // 当有数据需要提交时
+            if (StringUtils.hasLength(jsonString)) {
+                OutputStream outputStream = httpUrlConn.getOutputStream();
+                // 注意编码格式,防止中文乱码
+                outputStream.write(jsonString.getBytes(StandardCharsets.UTF_8));
+                outputStream.close();
+            }
+
+            // 将返回的输入流转换成字符串
+            InputStream inputStream = httpUrlConn.getInputStream();
+            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
+            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
+            String str = null;
+            while ((str = bufferedReader.readLine()) != null) {
+                buffer.append(str);
+            }
+            bufferedReader.close();
+            inputStreamReader.close();
+            // 释放资源
+            inputStream.close();
+            httpUrlConn.disconnect();
+            return buffer.toString();
+        } catch (Exception ignored) {}
+        return null;
+    }
 }

+ 31 - 7
src/main/resources/mapper/LoginMapper.xml

@@ -45,13 +45,36 @@
                cu.status            as operationStatus,
                cu.mobile            as operationMobile
         from user u
-                 left join cm_mall_operation_user cu on cu.userID = u.userID
-        where (u.bindMobile = #{mobileOrEmail}
-            or u.email = #{mobileOrEmail}
-            or (cu.mobile = #{mobileOrEmail} and cu.delFlag != 1)
-            )
-          and u.userIdentity in (1, 2, 3, 4)
-          and u.userOrganizeID = 0
+        left join cm_mall_operation_user cu on cu.userID = u.userID
+        where (u.bindMobile = #{mobileOrEmail} or u.email = #{mobileOrEmail})
+            and u.userIdentity in (1, 2, 3, 4)
+            and u.userOrganizeID = 0
+        union
+        SELECT u.userID             AS userId,
+               u.clubID             AS clubId,
+               u.shopID             AS shopId,
+               u.serviceProviderId  AS serviceProviderId,
+               u.userName           AS userName,
+               u.name               AS NAME,
+               u.mobile             AS mobile,
+               u.bindMobile         AS bindMobile,
+               u.email              AS email,
+               u.userPermission     AS userPermission,
+               u.userIdentity       AS userIdentity,
+               u.password           AS PASSWORD,
+               u.guideFlag          AS guideFlag,
+               u.clubStatus         AS clubStatus,
+               u.manufacturerStatus AS shopStatus,
+               cu.id                AS operationId,
+               cu.status            AS operationStatus,
+               cu.mobile            AS operationMobile
+        FROM USER u
+        LEFT JOIN cm_mall_operation_user cu ON cu.userID = u.userID
+        WHERE
+            cu.mobile = #{mobileOrEmail}
+          and cu.delFlag != 1
+          AND u.userIdentity IN (1, 2, 3, 4)
+          AND u.userOrganizeID = 0
         limit 1
     </select>
     <select id="getLoginUserByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
@@ -267,6 +290,7 @@
         SELECT firstClubType
         FROM club
         WHERE userID = #{userId}
+        limit 1
     </select>
     <select id="findLoginFailRecord" resultType="com.caimei365.user.model.vo.LoginFailRecordVo">
         select id, loginTime, userId

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

@@ -0,0 +1,242 @@
+<?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,ShopMessType)
+        VALUES (#{shopId}, #{clubId}, #{userType}, #{messageType}, #{content},#{time},#{accountType},#{couponType},#{couponFee},#{couponMessageType},#{shopMessType})
+    </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="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="receStatct" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND receStatct=2
+    </select>
+
+    <select id="listingFee" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID}
+    </select>
+
+    <select id="listingfeeExpire" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM `cm_discern_receipt` WHERE newReceiptType=1 AND shopID=#{shopID} AND NOW()> DATE_ADD(receiptDate, INTERVAL 1 YEAR)
+    </select>
+
+    <select id="MessageList" resultType="com.caimei365.user.model.vo.MessageCenter">
+        SELECT * FROM `message_center`
+        <where>
+            <if test="messageType !=null">
+            AND messageType=#{messageType}
+           </if>
+            <if test="userType == 1">
+                and  clubID=#{commonId}
+            </if>
+            <if test="userType == 2">
+                and  shopID=#{commonId}
+            </if>
+           and userType=#{userType}
+        </where>
+        ORDER BY id DESC
+    </select>
+
+    <select id="contractMobile" resultType="java.lang.String">
+        SELECT contractMobile FROM club WHERE clubID=#{clubID}
+    </select>
+
+    <select id="contractMobiles" resultType="java.lang.String">
+        SELECT contractMobile FROM shop WHERE shopID=#{shopID}
+    </select>
+
+    <select id="getOpenidListByPermission" resultType="java.lang.String">
+        SELECT openid FROM `wechat_user` WHERE unionId= #{unionId}
+    </select>
+
+    <select id="FromUnionId" resultType="java.lang.String">
+        SELECT unionID FROM `cm_order` WHERE userID=#{userID} AND unionID IS NOT NULL  ORDER BY orderID DESC LIMIT 1
+    </select>
+
+    <select id="UnionIdList" resultType="java.lang.String">
+        SELECT unionID FROM `cm_mall_operation_user` WHERE userID=#{userID} LIMIT 1
+    </select>
+
+    <select id="getVipHistoryCount" resultType="java.lang.Integer">
+        SELECT count(1)
+        FROM cm_svip_history
+        WHERE  userId = #{userId}
+    </select>
+
+    <select id="MainImage" resultType="com.caimei365.user.model.vo.MessageCenter">
+        SELECT co.refundType,COUNT(p.productID)AS productCount ,p.mainImage,co.onlinePayFlag,ifnull(p.name,'') as productName,co.orderID as orderID,co.status as status
+        FROM cm_order co
+                 LEFT JOIN bp_order_userinfo bou ON bou.orderId = co.orderID
+                 LEFT JOIN USER u ON u.userID = co.userID
+                 LEFT JOIN club c ON u.userID = c.userID
+                 LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID AND sp.status = 90
+                 LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
+                 LEFT JOIN product p ON cop.productID = p.productID
+                 LEFT JOIN cm_shop_order cso ON co.orderid=cso.orderID
+        <where>
+
+            <if test="userType == 1">
+              and  c.clubID=#{commonId}
+            </if>
+            <if test="userType == 2">
+              and  p.shopID=#{commonId}
+            </if>
+        and co.orderID=#{orderID}
+        </where>
+        LIMIT 1
+    </select>
+
+    <select id="productImage" resultType="com.caimei365.user.model.vo.MessageCenter">
+        SELECT s.name as shopName,p.`shopID`,p.`productID`,p.`name` as productName,p.mainImage
+        FROM product p
+        LEFT JOIN cm_order_product cop ON p.productID = cop.productID
+        LEFT JOIN shop s ON s.shopID = p.shopID
+        <where>
+            <if test="productID != null">
+                and p.productID=#{productID}
+            </if>
+                and p.shopID=#{shopID}
+        </where>
+        LIMIT 1
+    </select>
+
+    <select id="productCount" resultType="java.lang.Integer">
+        SELECT COUNT(productID) FROM cm_order_product
+        WHERE orderID=#{orderID}
+    </select>
+
+
+    <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="receiptAmount" resultType="java.lang.Double">
+        SELECT
+            a.receiptAmount
+        FROM cm_discern_receipt a
+                 LEFT JOIN shop s ON s.shopID = a.shopID
+        where
+            a.shopID=#{shopID}
+          AND a.newReceiptType=1
+    </select>
+
+<select id="newReceiptType" resultType="java.lang.Integer">
+    SELECT
+        a.newReceiptType
+    FROM cm_discern_receipt a
+             LEFT JOIN shop s ON s.shopID = a.shopID
+    where
+        a.shopID=#{shopID}
+    LIMIT 1
+</select>
+    <update id="updateMessageAsRead">
+        UPDATE message_center SET saved = 1
+        <where>
+      <if test="userType == 1">
+          and  clubID=#{commonId}
+      </if>
+      <if test="userType == 2">
+          and  shopID=#{commonId}
+      </if>
+        <if test="messageType !=null">
+           and messageType = #{messageType}
+        </if>
+          and userType=#{userType}
+        </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>
+
+    <select id="receiptShopID" resultType="java.lang.Integer">
+        SELECT DISTINCT
+            a.shopID
+        FROM cm_discern_receipt a
+                 LEFT JOIN shop s ON s.shopID = a.shopID
+        WHERE
+            a.newReceiptType=1
+    </select>
+
+    <select id="userIds" resultType="java.lang.Integer">
+        SELECT DISTINCT
+            a.userID
+        FROM shop a
+        WHERE
+            a.shopOD=#{shopID}
+    </select>
+
+
+    <select id="shopName" resultType="java.lang.String">
+        SELECT name FROM `shop` WHERE shopID=#{shopID}
+    </select>
+
+</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>

+ 3 - 0
src/main/resources/mapper/ShopMapper.xml

@@ -118,6 +118,9 @@
     <select id="getShopCertById" resultType="java.lang.String">
         SELECT image FROM shopcert WHERE shopID = #{shopId} AND shopCertTypeID = #{shopCertTypeId}
     </select>
+    <select id="medicalPracticeLicense" resultType="java.lang.String">
+        SELECT medicalPracticeLicenseImg1 FROM shop WHERE shopID = #{shopId}
+    </select>
     <select id="getShopHomeImages" resultType="com.caimei365.user.model.vo.ShopBannerVo">
         select shopBannerID AS id, shopID AS shopId, image, link, title, info
         from shopbanner where shopID = #{shopId}

+ 9 - 1
src/main/resources/mapper/SuperVipMapper.xml

@@ -202,4 +202,12 @@
                 NOW()
             )
     </insert>
-</mapper>
+
+    <select id="findVip" resultType="com.caimei365.user.model.po.SuperVipPo">
+        select userId, beginTime, endTime, updateTime
+        from cm_svip_user
+        where  delFlag = 0
+    </select>
+
+
+</mapper>

+ 3 - 3
src/test/java/com/caimei365/user/UserApplicationTests.java

@@ -71,8 +71,8 @@ class UserApplicationTests {
         }
     }*/
 
-    @Test
-    void contextLoads() {
+//    @Test
+//    void contextLoads() {
 //        Calendar cal = Calendar.getInstance();
 //        cal.setTime(new Date());
 //        cal.set(Calendar.HOUR_OF_DAY, 0);
@@ -84,5 +84,5 @@ class UserApplicationTests {
 //        System.out.println("=======================");
 //        cal.add(Calendar.DAY_OF_MONTH,1);
 //        System.out.println(cal.getTime());
-    }
+//    }
 }