935090232@qq.com
2022-04-20 446868d70ffeecaeeffb3bed900c0be97ecadbab
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WeChatApiTools.java
@@ -3,18 +3,30 @@
import com.matrix.component.tools.HttpRequest;
import com.matrix.component.tools.HttpResponse;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.PropertiesUtil;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
@Service
public class WeChatApiTools {
   @Value("${wechar_login_url}")
   private String wecharLoginUrl;
   @Value("${xcx_manager_appid}")
   private String xcxManagerAppid;
   @Value("${xcx_manager_secret}")
   private String xcxManagerSecret;
   @Autowired
   private BusParameterSettingsDao busParameterSettingsDao;
@@ -45,12 +57,24 @@
    * @param code
    * @return
    */
   public  String getXcxLoginUrl(String code,Long companyId, String type) {
      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);      }
   public  String getXcxLoginUrl(String code,Long companyId) {
      String wechatLoginUrl =wecharLoginUrl;
      return String.format(wechatLoginUrl, getAppid(companyId), getSecret(companyId), code);
   }
   /**
    * 获取管理端小程序登录地址
    *
    * @param code
    * @return
    */
   public String getManagerXcxLoginUrl(String code) {
      String wechatLoginUrl = wecharLoginUrl;
      String appId =xcxManagerAppid;
      String secret = xcxManagerSecret;
      return String.format(wechatLoginUrl, appId, secret, code);
   }
   /**
@@ -70,19 +94,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