admin
2024-10-16 62a447d89331aee1feae7724c7616aa1bb2cfe79
fanli/src/main/java/com/yeshi/fanli/service/impl/config/WXGZServiceImpl.java
@@ -1,43 +1,43 @@
package com.yeshi.fanli.service.impl.config;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.service.inter.config.WXGZService;
import com.yeshi.fanli.util.Constant;
import org.yeshi.utils.wx.WXUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service
public class WXGZServiceImpl implements WXGZService {
   @Override
   public void initMenu() {
      String appId = Constant.systemCommonConfig.getWxGZAppId();
      String appSecret = Constant.systemCommonConfig.getWxGZAppSecret();
      String accessToken = WXUtil.getAcessToken(appId, appSecret);
      JSONObject root = new JSONObject();
      JSONArray items = new JSONArray();
      JSONObject data1 = new JSONObject();
      data1.put("type", "view");
      data1.put("name", "下载" + Constant.systemCommonConfig.getProjectChineseName());
      data1.put("url", Constant.wxGZConfig.getAppDownloadLink());
      items.add(data1);
      data1 = new JSONObject();
      data1.put("type", "view");
      data1.put("name", "领取优惠券");
      data1.put("url", Constant.wxGZConfig.getH5Url());
      items.add(data1);
      data1 = new JSONObject();
      data1.put("type", "view");
      data1.put("name", "帮助中心");
      data1.put("url", Constant.wxGZConfig.getHelpUrl());
      items.add(data1);
      root.put("button", items);
      WXUtil.createMenu(accessToken, root);
   }
}
package com.yeshi.fanli.service.impl.config;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.service.inter.config.WXGZService;
import com.yeshi.fanli.util.Constant;
import org.yeshi.utils.wx.WXUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service
public class WXGZServiceImpl implements WXGZService {
   @Override
   public void initMenu(String wxGZAppId,String wxGZAppsecret) {
      String appId = wxGZAppId;
      String appSecret = wxGZAppsecret;
      String accessToken = WXUtil.getAcessToken(appId, appSecret);
      JSONObject root = new JSONObject();
      JSONArray items = new JSONArray();
      JSONObject data1 = new JSONObject();
      data1.put("type", "view");
      data1.put("name", "下载" + Constant.systemCommonConfig.getProjectChineseName());
      data1.put("url", Constant.wxGZConfig.getAppDownloadLink());
      items.add(data1);
      data1 = new JSONObject();
      data1.put("type", "view");
      data1.put("name", "领取优惠券");
      data1.put("url", Constant.wxGZConfig.getH5Url());
      items.add(data1);
      data1 = new JSONObject();
      data1.put("type", "view");
      data1.put("name", "帮助中心");
      data1.put("url", Constant.wxGZConfig.getHelpUrl());
      items.add(data1);
      root.put("button", items);
      WXUtil.createMenu(accessToken, root);
   }
}