From fa668c325f2dac348fb9f80c0c6c679f9ce1e41b Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期二, 10 三月 2026 18:28:17 +0800
Subject: [PATCH] 小程序   接口开发

---
 server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java b/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
index 3fdc912..f6978ea 100644
--- a/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
+++ b/server/dmmall_service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -1,10 +1,13 @@
 package com.doumee.config.Jwt;
 
+import com.alibaba.fastjson.JSONObject;
 import com.doumee.config.annotation.LoginRequired;
 import com.doumee.config.annotation.LoginShopRequired;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
 import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.model.Member;
+import com.doumee.dao.business.model.Shop;
 import io.jsonwebtoken.JwtException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +23,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.lang.reflect.Method;
+import java.util.Objects;
 
 @Configuration
 public class WebMvcConfig implements WebMvcConfigurer {
@@ -103,6 +106,11 @@
             if(StringUtils.isBlank(tokenRedis)){
                 throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
             }
+            Member member = JSONObject.parseObject(tokenRedis, Member.class);
+            if(Objects.isNull(member)||StringUtils.isBlank(member.getOpenId())){
+                throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+            }
+            String openid = member.getOpenId();
             Integer memberId = getTokenId(token);
             Integer isDeleted = dao.queryForObject(" select COALESCE(ISDELETED,0)  from Member where id  = ?", Integer.class, memberId);
             if(isDeleted== Constants.ONE){
@@ -114,6 +122,10 @@
             }
             if(isForbidden == Constants.TWO){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸叉敞閿�,璇疯仈绯荤鐞嗗憳");
+            }
+            String dbOpenid = dao.queryForObject(" select ifnull(open_id,'')  from Member where id  = ?", String.class, memberId);
+            if(StringUtils.isBlank(dbOpenid)||!openid.equals(dbOpenid)){
+                throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�");
             }
             Integer count = dao.queryForObject("select count(1) from Member where id  = ?", Integer.class, memberId);
             if (count != null && count > 0) {
@@ -138,6 +150,11 @@
             if(StringUtils.isBlank(tokenRedis)){
                 throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
             }
+            Shop shop = JSONObject.parseObject(tokenRedis, Shop.class);
+            if(Objects.isNull(shop)||StringUtils.isBlank(shop.getOpenId())){
+                throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
+            }
+            String openid = shop.getOpenId();
             Integer shopId = getTokenId(token);
             Integer isDeleted = dao.queryForObject(" select COALESCE(ISDELETED,0)  from shop where id  = ?", Integer.class, shopId);
             if(isDeleted== Constants.ONE){
@@ -147,6 +164,10 @@
             if(isForbidden== Constants.ONE){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸茬鐢�,璇疯仈绯荤鐞嗗憳");
             }
+            String dbOpenid = dao.queryForObject(" select ifnull(open_id,'')  from shop where id  = ?", String.class, shopId);
+            if(StringUtils.isBlank(dbOpenid)||!openid.equals(dbOpenid)){
+                throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"宸茶繃鏈燂紝璇烽噸鏂扮櫥褰�");
+            }
             Integer count = dao.queryForObject("select count(1) from shop where id  = ?", Integer.class, shopId);
             if (count != null && count > 0) {
                 request.setAttribute(JwtTokenUtil.ShopId_Name, shopId);

--
Gitblit v1.9.3