wlzboy
2025-11-07 2aebbc9601ab439707f69b08e467808df9f7549c
ruoyi-admin/src/main/java/com/ruoyi/web/controller/evaluation/EvaluationController.java
@@ -8,13 +8,13 @@
import com.ruoyi.common.utils.WechatUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.config.WechatMpConfig;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.system.domain.EvaluationDetail;
import com.ruoyi.system.service.IEvaluationDimensionService;
import com.ruoyi.system.domain.EvaluationDimension;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@@ -47,6 +47,9 @@
    @Autowired
    private IEvaluationDimensionService evaluationDimensionService;
    @Autowired
    private WechatMpConfig wechatMpConfig;
    /**
     * 查询客户评价列表
@@ -150,12 +153,6 @@
        }
    }
    @Value("${wechat.appId}")
    private String wechatAppId;
    @Value("${wechat.appSecret}")
    private String wechatAppSecret;
    /**
     * 生成微信授权URL
     */
@@ -170,7 +167,12 @@
            logger.info("生成微信授权URL - 原始redirectUri: {}", redirectUri);
            
            // 生成微信授权URL,使用snsapi_userinfo获取用户信息
            String authUrl = WechatUtils.generateAuthUrl(wechatAppId, redirectUri, "snsapi_userinfo", state);
            String authUrl = WechatUtils.generateAuthUrl(
                wechatMpConfig.getAppId(),
                redirectUri,
                "snsapi_userinfo",
                state
            );
            if (authUrl == null) {
                return error("生成微信授权URL失败");
            }
@@ -180,7 +182,7 @@
            Map<String, String> result = new HashMap<>();
            result.put("authUrl", authUrl);
            result.put("originalRedirectUri", redirectUri);
            result.put("appId", wechatAppId);
            result.put("appId", wechatMpConfig.getAppId());
            return success(result);
        } catch (Exception e) {
            logger.error("生成微信授权URL失败", e);
@@ -201,7 +203,11 @@
            }
            // 获取网页授权Access Token
            JSONObject tokenInfo = WechatUtils.getWebAccessToken(wechatAppId, wechatAppSecret, code);
            JSONObject tokenInfo = WechatUtils.getWebAccessToken(
                wechatMpConfig.getAppId(),
                wechatMpConfig.getAppSecret(),
                code
            );
            if (tokenInfo == null) {
                return error("获取微信授权信息失败");
            }