fix
Helius
2021-11-09 199cb3fb7a7ec4041ecd487f8db9f0360b40391e
fix
6 files modified
62 ■■■■■ changed files
zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WeChatApiTools.java 35 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/system.properties 2 ●●●●● patch | view | raw | blame | history
zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java 17 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java
@@ -293,7 +293,7 @@
            return AjaxResult.buildFailInstance("code不存在");
        }
        AjaxResult res = new AjaxResult();
        String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId(), AppConstance.MINI_PROGRAM_MANAGER_APP_ID);
        String requrl = weChatApiTools.getManagerXcxLoginUrl(code);
        String resultData = HttpCurlUtil.sendGetHttp(requrl, null);
        JSONObject json = JSONObject.fromObject(resultData);
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -609,11 +609,11 @@
    /**
     * 管理端小程序appid
     */
    public static final String MINI_PROGRAM_MANAGER_APP_ID = "miniProgramManagerAppId";
    public static final String MINI_PROGRAM_MANAGER_APP_ID = "xcx_manager_appid";
    /**
     * 管理端小程序secret
     */
    public static final String MINI_PROGRAM_MANAGER_SECRET = "miniProgramManagerSecret";
    public static final String MINI_PROGRAM_MANAGER_SECRET = "xcx_manager_secret";
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WeChatApiTools.java
@@ -45,12 +45,24 @@
     * @param code
     * @return
     */
    public  String getXcxLoginUrl(String code,Long companyId, String type) {
    public  String getXcxLoginUrl(String code,Long companyId) {
        String wechatLoginUrl = PropertiesUtil.getString(WECHAT_LOGIN_URL);
        if (AppConstance.MINIPROGRAM_APPID.equals(type)) {
            return String.format(wechatLoginUrl, getAppid(companyId), getSecret(companyId), code);
        } else {
            return String.format(wechatLoginUrl, getManagerAppId(companyId), getManagerSecret(companyId), code);        }
        return String.format(wechatLoginUrl, getAppid(companyId), getSecret(companyId), code);
    }
    /**
     * 获取管理端小程序登录地址
     *
     * @param code
     * @return
     */
    public String getManagerXcxLoginUrl(String code) {
        String wechatLoginUrl = PropertiesUtil.getString(WECHAT_LOGIN_URL);
        String appId = PropertiesUtil.getString(AppConstance.MINI_PROGRAM_MANAGER_APP_ID);
        String secret = PropertiesUtil.getString(AppConstance.MINI_PROGRAM_MANAGER_SECRET);
        return String.format(wechatLoginUrl, appId, secret, code);
    }
    /**
@@ -70,19 +82,6 @@
        BusParameterSettings secret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_SECRET, companyId);
        return  secret.getParamValue();
    }
    public String getManagerAppId(Long companyId) {
        BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINI_PROGRAM_MANAGER_APP_ID, companyId);
        return  appId.getParamValue();
    }
    public  String  getManagerSecret(Long companyId){
        BusParameterSettings secret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINI_PROGRAM_MANAGER_SECRET, companyId);
        return  secret.getParamValue();
    }
    /**
     * 清空token
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java
@@ -94,7 +94,7 @@
        AjaxResult res = new AjaxResult();
        LogUtil.info("code:{}" + code);
        if (StringUtils.isNotBlank(code)) {
            String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId(), AppConstance.MINIPROGRAM_APPID);
            String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId());
            String reslutData = HttpCurlUtil.sendGetHttp(requrl, null);
            JSONObject json = JSONObject.fromObject(reslutData);
            LogUtil.debug("微信登录获取到登录信息={}", json);
zq-erp/src/main/resources/config/system.properties
@@ -51,6 +51,8 @@
wechar_login_url =https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code
xcx_appid =wx5cc58f796224af61
xcx_secret =facea088aae414e5c2ee86b459887721
xcx_manager_appid=wx2948b3b914a9722e
xcx_manager_secret=1685dfd99a43e213ed8be07870b898ba
#公众号
gzh_appid=wx57e6335559bdbda6
zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java
@@ -126,23 +126,6 @@
        newSetting11.setCategory("店务配置");
        newSettings.add(newSetting11);
        ParameterSettings newSetting12=new ParameterSettings();
        newSetting12.setCode(AppConstance.MINI_PROGRAM_MANAGER_APP_ID);
        newSetting12.setName("管理端小程序AppID");
        newSetting12.setType(1);
        newSetting12.setCategory("微信开发配置");
        newSettings.add(newSetting12);
        ParameterSettings newSetting13=new ParameterSettings();
        newSetting13.setCode(AppConstance.MINI_PROGRAM_MANAGER_SECRET);
        newSetting13.setName("管理端小程序Secret");
        newSetting13.setType(1);
        newSetting13.setCategory("微信开发配置");
        newSettings.add(newSetting13);
        for (ParameterSettings newSetting : newSettings) {
            List<ParameterSettings> parameterSettings = parameterSettingsDao.selectByModel(newSetting);
            if(CollectionUtil.isEmpty(parameterSettings)){