Pu Zhibing
2026-01-06 15b0467aa04f8176e72dcc9905fb37117cbfc946
功能优化
4个文件已修改
290 ■■■■■ 已修改文件
ruoyi-auth/src/main/java/com/ruoyi/auth/service/QywxInnerService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerGoodsController.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/fliter/ParamsAuthFilter.java 232 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-auth/src/main/java/com/ruoyi/auth/service/QywxInnerService.java
@@ -90,7 +90,7 @@
        JSONObject response = RestUtils.get(getOauthUrl);
        if(response.containsKey(Constants.QY_WX_ERR_CODE) && response.getInteger(Constants.QY_WX_ERR_CODE) != 0){
            logger.error(response.toString());
            return new JSONObject();
            throw new ServiceException("获取企业微信信息异常");
        }
        logger.info("----------------userinfo-------------");
        logger.info(response.toString());
@@ -110,7 +110,7 @@
        //获取错误日志
        if(detailResponse.containsKey(Constants.QY_WX_ERR_CODE) && detailResponse.getInteger(Constants.QY_WX_ERR_CODE) != 0){
            logger.error(detailResponse.toString());
            return new JSONObject();
            throw new ServiceException("获取企业微信信息异常");
        }
        logger.info("----------------userinfo detail -------------");
        logger.info(detailResponse.toString());
@@ -190,7 +190,7 @@
        JSONObject response = RestUtils.get(url);
        if(response.containsKey(Constants.QY_WX_ERR_CODE) && response.getInteger(Constants.QY_WX_ERR_CODE) != 0){
            logger.error(response.toString());
            return "";
            throw new ServiceException("获取企业微信信息异常");
        }
        ticket = response.getString(Constants.QY_WX_TICKET);
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/business/MerGoodsController.java
@@ -70,20 +70,29 @@
                }
            }else{
                Shop shop1 = remoteShopService.getShop(shop.getBelongShopId()).getData();
                ShopGoods shopGoods1 = shopGoodsService.getByShopIdAndGoodsId(shop1.getShopId(), merGoodsPageVo.getGoodsId());
                //经销商设置了统一售价
                if(null != shopGoods1){
                    merGoodsPageVo.setModifyPricePermission(0);
                    merGoodsPageVo.setIsUnifiedPrice(1);
                    merGoodsPageVo.setUnifiedPrice(shopGoods1.getSalesPrice());
                    merGoodsPageVo.setUnifiedServerNum(shopGoods1.getServiceNum());
                }else{
                if(null == shop1){
                    merGoodsPageVo.setModifyPricePermission(1);
                    merGoodsPageVo.setIsUnifiedPrice(0);
                    if(null != shopGoods){
                        merGoodsPageVo.setUnifiedPrice(shopGoods.getSalesPrice());
                        merGoodsPageVo.setUnifiedServerNum(shopGoods.getServiceNum());
                    }
                }else{
                    ShopGoods shopGoods1 = shopGoodsService.getByShopIdAndGoodsId(shop1.getShopId(), merGoodsPageVo.getGoodsId());
                    //经销商设置了统一售价
                    if(null != shopGoods1){
                        merGoodsPageVo.setModifyPricePermission(0);
                        merGoodsPageVo.setIsUnifiedPrice(1);
                        merGoodsPageVo.setUnifiedPrice(shopGoods1.getSalesPrice());
                        merGoodsPageVo.setUnifiedServerNum(shopGoods1.getServiceNum());
                    }else{
                        merGoodsPageVo.setModifyPricePermission(1);
                        merGoodsPageVo.setIsUnifiedPrice(0);
                        if(null != shopGoods){
                            merGoodsPageVo.setUnifiedPrice(shopGoods.getSalesPrice());
                            merGoodsPageVo.setUnifiedServerNum(shopGoods.getServiceNum());
                        }
                    }
                }
            }
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/fliter/ParamsAuthFilter.java
@@ -1,116 +1,116 @@
package com.ruoyi.goods.fliter;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.utils.StringUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
@Component
@Log4j2
public class ParamsAuthFilter implements Filter {
    // 令牌自定义标识
    //@Value("${token.header}")
    private String header = "Authorization";
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        String requestUrl = request.getRequestURI();
        String requestUrlUpperCase = requestUrl.toUpperCase();
        if(requestUrlUpperCase.contains("EXPORT")
                ||requestUrlUpperCase.contains("IMPORTTEMPLATE")
        ){
            filterChain.doFilter(request, response);
            return;
        }
        RepeatedlyRequestWrapper wrapper = new RepeatedlyRequestWrapper(request, response);
        getRequestParams(wrapper);
        ResponseWrapper responseWrapper = new ResponseWrapper(response);
        filterChain.doFilter(wrapper, responseWrapper);
        // 返回的结果
        String content = responseWrapper.getTextContent();
        log.info("-------------------- Response Data ----------------------");
        log.info(requestUrl + " -> " + content);
        response.getOutputStream().write(content.getBytes());
    }
    private void getRequestParams(HttpServletRequest request){
        Map<String, String> params = getUrlParams(request);
        try {
            String requestUrl = request.getRequestURI();
            Map<String, String> urlParams = getUrlParams(request);
            Map<String, String> bodyParams = getBodyParams(request);
            params.putAll(urlParams);
            params.putAll(bodyParams);
            log.info("-------------------- request header ----------------------");
            log.info(header + " -> " + request.getHeader(header));
            log.info("-------------------- request params ----------------------");
            log.info(requestUrl + " -> " + JSONObject.toJSONString(params));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    private Map<String, String> getBodyParams(HttpServletRequest request) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(request.getInputStream()));
        StringBuilder stringBuilder = new StringBuilder();
        String buffer = "";
        while((buffer  = bufferedReader.readLine()) != null){
            stringBuilder.append(buffer);
        }
        String requestBodyStr = stringBuilder.toString();
        if(StringUtils.isNotBlank(requestBodyStr)){
            Map<String, String> result = new HashMap<>();
            try {
                result = JSONObject.parseObject(stringBuilder.toString(), Map.class);
            } catch (Exception e) {
                log.info("requestBodyStr-error -> " + requestBodyStr);
                e.printStackTrace();
            }
            return result;
        }
        return new HashMap<>();
    }
    private Map<String, String> getUrlParams(HttpServletRequest request){
        String queryParams = "";
        try {
            queryParams = request.getQueryString();
            if(StringUtils.isNotBlank(queryParams)) {
                queryParams = URLDecoder.decode(request.getQueryString(), "utf-8");
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        Map<String, String> result = new HashMap<>();
        if(StringUtils.isNotBlank(queryParams)) {
            String[] spilt = queryParams.split("&");
            for (String s : spilt) {
                int index = s.indexOf("=");
                result.put(s.substring(0, index), s.substring(index + 1));
            }
        }
        return result;
    }
}
//package com.ruoyi.goods.fliter;
//
//
//import com.alibaba.fastjson2.JSONObject;
//import com.ruoyi.common.core.utils.StringUtils;
//import lombok.extern.log4j.Log4j2;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.*;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.UnsupportedEncodingException;
//import java.net.URLDecoder;
//import java.util.HashMap;
//import java.util.Map;
//
//@Component
//@Log4j2
//public class ParamsAuthFilter implements Filter {
//
//    // 令牌自定义标识
//    //@Value("${token.header}")
//    private String header = "Authorization";
//
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//        String requestUrl = request.getRequestURI();
//        String requestUrlUpperCase = requestUrl.toUpperCase();
//        if(requestUrlUpperCase.contains("EXPORT")
//                ||requestUrlUpperCase.contains("IMPORTTEMPLATE")
//        ){
//            filterChain.doFilter(request, response);
//            return;
//        }
//        RepeatedlyRequestWrapper wrapper = new RepeatedlyRequestWrapper(request, response);
//        getRequestParams(wrapper);
//
//        ResponseWrapper responseWrapper = new ResponseWrapper(response);
//        filterChain.doFilter(wrapper, responseWrapper);
//
//        // 返回的结果
//        String content = responseWrapper.getTextContent();
//        log.info("-------------------- Response Data ----------------------");
//        log.info(requestUrl + " -> " + content);
//
//        response.getOutputStream().write(content.getBytes());
//    }
//
//
//    private void getRequestParams(HttpServletRequest request){
//        Map<String, String> params = getUrlParams(request);
//        try {
//            String requestUrl = request.getRequestURI();
//            Map<String, String> urlParams = getUrlParams(request);
//            Map<String, String> bodyParams = getBodyParams(request);
//
//            params.putAll(urlParams);
//            params.putAll(bodyParams);
//            log.info("-------------------- request header ----------------------");
//            log.info(header + " -> " + request.getHeader(header));
//            log.info("-------------------- request params ----------------------");
//            log.info(requestUrl + " -> " + JSONObject.toJSONString(params));
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//
//    private Map<String, String> getBodyParams(HttpServletRequest request) throws IOException {
//        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(request.getInputStream()));
//        StringBuilder stringBuilder = new StringBuilder();
//        String buffer = "";
//        while((buffer  = bufferedReader.readLine()) != null){
//            stringBuilder.append(buffer);
//        }
//        String requestBodyStr = stringBuilder.toString();
//        if(StringUtils.isNotBlank(requestBodyStr)){
//            Map<String, String> result = new HashMap<>();
//            try {
//                result = JSONObject.parseObject(stringBuilder.toString(), Map.class);
//            } catch (Exception e) {
//                log.info("requestBodyStr-error -> " + requestBodyStr);
//                e.printStackTrace();
//            }
//            return result;
//        }
//        return new HashMap<>();
//    }
//
//    private Map<String, String> getUrlParams(HttpServletRequest request){
//        String queryParams = "";
//        try {
//            queryParams = request.getQueryString();
//            if(StringUtils.isNotBlank(queryParams)) {
//                queryParams = URLDecoder.decode(request.getQueryString(), "utf-8");
//            }
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        }
//        Map<String, String> result = new HashMap<>();
//        if(StringUtils.isNotBlank(queryParams)) {
//            String[] spilt = queryParams.split("&");
//            for (String s : spilt) {
//                int index = s.indexOf("=");
//                result.put(s.substring(0, index), s.substring(index + 1));
//            }
//        }
//        return result;
//    }
//}
ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
@@ -323,28 +323,13 @@
            AND ts.shop_type = #{param.shopType}
        </if>
        <if test="param.shopProvinceCode!=null and param.shopProvinceCode!=''">
            AND (
            ts.shop_province_code = #{param.shopProvinceCode}
            OR ts.shop_province_code LIKE CONCAT(#{param.shopProvinceCode}, ';%')
            OR ts.shop_province_code LIKE CONCAT('%;', #{param.shopProvinceCode}, ';%')
            OR ts.shop_province_code LIKE CONCAT('%;', #{param.shopProvinceCode})
            )
            and ts.shop_province_code = #{param.shopProvinceCode}
        </if>
        <if test="param.shopCityCode!=null and param.shopCityCode!=''">
            AND (
            ts.shop_city_code = #{param.shopCityCode}
            OR ts.shop_city_code LIKE CONCAT(#{param.shopCityCode}, ';%')
            OR ts.shop_city_code LIKE CONCAT('%;', #{param.shopCityCode}, ';%')
            OR ts.shop_city_code LIKE CONCAT('%;', #{param.shopCityCode})
            )
            AND ts.shop_city_code = #{param.shopCityCode}
        </if>
        <if test="param.shopAreaCode!=null and param.shopAreaCode!=''">
            AND (
            ts.shop_area_code = #{param.shopAreaCode}
            OR ts.shop_area_code LIKE CONCAT(#{param.shopAreaCode}, ';%')
            OR ts.shop_area_code LIKE CONCAT('%;', #{param.shopAreaCode}, ';%')
            OR ts.shop_area_code LIKE CONCAT('%;', #{param.shopAreaCode})
            )
            AND ts.shop_area_code = #{param.shopAreaCode}
        </if>
        <if test="param.signStartTime!=null and param.signStartTime!=''">
            AND Date(ts.sign_time) &gt;= #{param.signStartTime}
@@ -353,13 +338,13 @@
            AND Date(ts.sign_time) &lt;= #{param.signEndTime}
        </if>
        <if test="param.signProvinceCode!=null and param.signProvinceCode!=''">
            AND ts.sign_province_code REGEXP CONCAT('(^|;)' , #{param.signProvinceCode} , '(;|$)')   -- 正则表达式 (^|;) 匹配字符串开头或分号,(;|$) 匹配分号或字符串结尾。
            AND ts.sign_province_code = #{param.signProvinceCode}
        </if>
        <if test="param.signCityCode!=null and param.signCityCode!=''">
            AND ts.sign_city_code = REGEXP CONCAT('(^|;)' ,#{param.signCityCode} , '(;|$)')
            AND ts.sign_city_code = #{param.signCityCode}
        </if>
        <if test="param.signAreaCode!=null and param.signAreaCode!=''">
            AND ts.sign_area_code = REGEXP CONCAT('(^|;)' ,#{param.signAreaCode}, '(;|$)')
            AND ts.sign_area_code = #{param.signAreaCode}
        </if>
        <if test="param.shopStatus!=null and param.shopStatus==0">
            AND ts.frozen_flag = 1