|
@@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ematou.wxservice.api.WeChatApi;
|
|
|
import com.ematou.wxservice.api.WeChatApiRestTemplate;
|
|
|
+import com.ematou.wxservice.common.constant.WeChatAccount;
|
|
|
import com.ematou.wxservice.common.constant.WeChatConstant;
|
|
|
import com.ematou.wxservice.service.WeChatService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
@@ -38,41 +40,72 @@ public class MenuButtonManager {
|
|
|
@Autowired
|
|
|
WeChatService weChatService;
|
|
|
|
|
|
+ @Value("${wechat}")
|
|
|
+ String wechat;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
// TODO 初始化菜单按钮
|
|
|
//ViewButton testBtn = new ViewButton("测试按钮", WeChatConstant.EventType.VIEW.toLowerCase(), "http://f3dhion.nat.ipyingshe.com/view/main");
|
|
|
-
|
|
|
- ClickButton myCodeBtn = new ClickButton("我的取件码", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_TAKE_PARCEL_CODE);
|
|
|
- ClickButton scanPush = new ClickButton("扫码取件", WeChatConstant.EventType.SCANCODE_PUSH.toLowerCase(), WeChatConstant.CustomEventKey.SCANCODE_PUSH_BUTTON);
|
|
|
- MiniProgramButton miniProgramButton = new MiniProgramButton("小程序",WeChatConstant.EventType.MINIPROGRAM.toLowerCase(),"http://mp.weixin.qq.com","wx1f09731935da5dd7","/pages/index/index");
|
|
|
-
|
|
|
- //ClickButton myHistoryBtn = new ClickButton("取件历史", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_HISTORY_RECORD);
|
|
|
- //ViewButton addressEntryBtn = new ViewButton("收货地址管理", WeChatConstant.EventType.VIEW.toLowerCase(), "http://kmall-test.ds-bay.com:8080/qrcode/verification.html");
|
|
|
- MenuButton takeParcelMenuButton = new MenuButton("取件服务");
|
|
|
- takeParcelMenuButton.setSub_button(Arrays.asList(scanPush,miniProgramButton)); // myCodeBtn 我的取件码菜单屏蔽
|
|
|
-
|
|
|
- ViewButton companyState = new ViewButton("公司状态", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=3&sn=da0db13971baf7a27bf639f2f7eaebbe&scene=18#wechat_redirect");
|
|
|
- ViewButton companyInfo = new ViewButton("公司简介", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/s?__biz=MzIwMTI2MTg1MA==&mid=503159833&idx=1&sn=fbddc8c56f960d7912cee60c959c42e8&chksm=0ef9aa6c398e237a862143c4f4c7314c0159a77e87ad4fd39a89d22181bcb05aedc9a816c8b2&scene=18#wechat_redirect");
|
|
|
- ViewButton industryReport = new ViewButton("行业周报", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=1&sn=f7becf0ef818d4a57a4ca4acfde72613&scene=18#wechat_redirect");
|
|
|
- ClickButton policySupport = new ClickButton("政策支持", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.POLICY_SUPPORT);
|
|
|
- ClickButton callCompanyBtn = new ClickButton("联系我们", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.CALL_COMPANY);
|
|
|
- MenuButton companyMenuButton = new MenuButton("公司信息");
|
|
|
- companyMenuButton.setSub_button(Arrays.asList(companyState, companyInfo, policySupport, industryReport, callCompanyBtn));
|
|
|
-
|
|
|
- ViewButton supplier = new ViewButton("供应商拓展", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=2&sn=cd51f61ada3218168fe3af6c3318b6ca&scene=18#wechat_redirect");
|
|
|
- ViewButton showGoods = new ViewButton("货源展示区", WeChatConstant.EventType.VIEW.toLowerCase(), "https://mp.weixin.qq.com/bizmall/mallshelf?id=&t=mall/list&biz=MzIwMTI2MTg1MA==&shelf_id=5&showwxpaytitle=1#wechat_redirect");
|
|
|
- ViewButton showNews = new ViewButton("展会快讯", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=4&sn=89a19c85a4742d13eb3e4ceab2179ba8&scene=18#wechat_redirect");
|
|
|
- MenuButton goodsMenuButton = new MenuButton("货源展示");
|
|
|
- goodsMenuButton.setSub_button(Arrays.asList(supplier, showGoods, showNews));
|
|
|
-
|
|
|
HashMap<String, List<Button>> map = new HashMap<>();
|
|
|
- map.put("button", Arrays.asList(companyMenuButton, goodsMenuButton, takeParcelMenuButton));
|
|
|
+ if(WeChatAccount.E_MA_TO.getItem().equals(wechat)){
|
|
|
+ ClickButton myCodeBtn = new ClickButton("我的取件码", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_TAKE_PARCEL_CODE);
|
|
|
+ ClickButton scanPush = new ClickButton("扫码取件", WeChatConstant.EventType.SCANCODE_PUSH.toLowerCase(), WeChatConstant.CustomEventKey.SCANCODE_PUSH_BUTTON);
|
|
|
+ MiniProgramButton miniProgramButton = new MiniProgramButton("小程序",WeChatConstant.EventType.MINIPROGRAM.toLowerCase(),"http://mp.weixin.qq.com","wx1f09731935da5dd7","/pages/index/index");
|
|
|
+
|
|
|
+ //ClickButton myHistoryBtn = new ClickButton("取件历史", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_HISTORY_RECORD);
|
|
|
+ //ViewButton addressEntryBtn = new ViewButton("收货地址管理", WeChatConstant.EventType.VIEW.toLowerCase(), "http://kmall-test.ds-bay.com:8080/qrcode/verification.html");
|
|
|
+ MenuButton takeParcelMenuButton = new MenuButton("取件服务");
|
|
|
+ takeParcelMenuButton.setSub_button(Arrays.asList(scanPush)); // myCodeBtn 我的取件码菜单屏蔽
|
|
|
+
|
|
|
+ ViewButton companyState = new ViewButton("公司状态", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=3&sn=da0db13971baf7a27bf639f2f7eaebbe&scene=18#wechat_redirect");
|
|
|
+ ViewButton companyInfo = new ViewButton("公司简介", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/s?__biz=MzIwMTI2MTg1MA==&mid=503159833&idx=1&sn=fbddc8c56f960d7912cee60c959c42e8&chksm=0ef9aa6c398e237a862143c4f4c7314c0159a77e87ad4fd39a89d22181bcb05aedc9a816c8b2&scene=18#wechat_redirect");
|
|
|
+ ViewButton industryReport = new ViewButton("行业周报", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=1&sn=f7becf0ef818d4a57a4ca4acfde72613&scene=18#wechat_redirect");
|
|
|
+ ClickButton policySupport = new ClickButton("政策支持", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.POLICY_SUPPORT);
|
|
|
+ ClickButton callCompanyBtn = new ClickButton("联系我们", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.CALL_COMPANY);
|
|
|
+ MenuButton companyMenuButton = new MenuButton("公司信息");
|
|
|
+ companyMenuButton.setSub_button(Arrays.asList(companyState, companyInfo, policySupport, industryReport, callCompanyBtn));
|
|
|
+
|
|
|
+ ViewButton supplier = new ViewButton("供应商拓展", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=2&sn=cd51f61ada3218168fe3af6c3318b6ca&scene=18#wechat_redirect");
|
|
|
+ ViewButton showGoods = new ViewButton("货源展示区", WeChatConstant.EventType.VIEW.toLowerCase(), "https://mp.weixin.qq.com/bizmall/mallshelf?id=&t=mall/list&biz=MzIwMTI2MTg1MA==&shelf_id=5&showwxpaytitle=1#wechat_redirect");
|
|
|
+ ViewButton showNews = new ViewButton("展会快讯", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=4&sn=89a19c85a4742d13eb3e4ceab2179ba8&scene=18#wechat_redirect");
|
|
|
+ MenuButton goodsMenuButton = new MenuButton("货源展示");
|
|
|
+ goodsMenuButton.setSub_button(Arrays.asList(supplier, showGoods, showNews));
|
|
|
+
|
|
|
+ map.put("button", Arrays.asList(companyMenuButton, goodsMenuButton, takeParcelMenuButton));
|
|
|
+
|
|
|
+ } else if (WeChatAccount.QH_E_MA_TO.getItem().equals(wechat)) {
|
|
|
+ ClickButton myCodeBtn = new ClickButton("我的取件码", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_TAKE_PARCEL_CODE);
|
|
|
+ ClickButton scanPush = new ClickButton("扫码取件", WeChatConstant.EventType.SCANCODE_PUSH.toLowerCase(), WeChatConstant.CustomEventKey.SCANCODE_PUSH_BUTTON);
|
|
|
+ //ClickButton myHistoryBtn = new ClickButton("取件历史", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.MY_HISTORY_RECORD);
|
|
|
+ //ViewButton addressEntryBtn = new ViewButton("收货地址管理", WeChatConstant.EventType.VIEW.toLowerCase(), "http://kmall-test.ds-bay.com:8080/qrcode/verification.html");
|
|
|
+ MenuButton takeParcelMenuButton = new MenuButton("取件服务");
|
|
|
+ takeParcelMenuButton.setSub_button(Arrays.asList(scanPush)); // myCodeBtn 我的取件码菜单屏蔽
|
|
|
+
|
|
|
+ ViewButton companyState = new ViewButton("公司状态", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=3&sn=da0db13971baf7a27bf639f2f7eaebbe&scene=18#wechat_redirect");
|
|
|
+ ViewButton companyInfo = new ViewButton("公司简介", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/s?__biz=MzIwMTI2MTg1MA==&mid=503159833&idx=1&sn=fbddc8c56f960d7912cee60c959c42e8&chksm=0ef9aa6c398e237a862143c4f4c7314c0159a77e87ad4fd39a89d22181bcb05aedc9a816c8b2&scene=18#wechat_redirect");
|
|
|
+ ViewButton industryReport = new ViewButton("行业周报", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=1&sn=f7becf0ef818d4a57a4ca4acfde72613&scene=18#wechat_redirect");
|
|
|
+ ClickButton policySupport = new ClickButton("政策支持", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.POLICY_SUPPORT);
|
|
|
+ ClickButton callCompanyBtn = new ClickButton("联系我们", WeChatConstant.EventType.CLICK.toLowerCase(), WeChatConstant.CustomEventKey.CALL_COMPANY);
|
|
|
+ MenuButton companyMenuButton = new MenuButton("公司信息");
|
|
|
+ companyMenuButton.setSub_button(Arrays.asList(companyState, companyInfo, policySupport, industryReport, callCompanyBtn));
|
|
|
+
|
|
|
+ ViewButton supplier = new ViewButton("供应商拓展", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=2&sn=cd51f61ada3218168fe3af6c3318b6ca&scene=18#wechat_redirect");
|
|
|
+ ViewButton showGoods = new ViewButton("货源展示区", WeChatConstant.EventType.VIEW.toLowerCase(), "https://mp.weixin.qq.com/bizmall/mallshelf?id=&t=mall/list&biz=MzIwMTI2MTg1MA==&shelf_id=5&showwxpaytitle=1#wechat_redirect");
|
|
|
+ ViewButton showNews = new ViewButton("展会快讯", WeChatConstant.EventType.VIEW.toLowerCase(), "http://mp.weixin.qq.com/mp/homepage?__biz=MzIwMTI2MTg1MA==&hid=4&sn=89a19c85a4742d13eb3e4ceab2179ba8&scene=18#wechat_redirect");
|
|
|
+ MenuButton goodsMenuButton = new MenuButton("货源展示");
|
|
|
+ goodsMenuButton.setSub_button(Arrays.asList(supplier, showGoods, showNews));
|
|
|
+
|
|
|
+
|
|
|
+ map.put("button", Arrays.asList(companyMenuButton, goodsMenuButton, takeParcelMenuButton));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
String menu = JSON.toJSONString(map);
|
|
|
-
|
|
|
logger.info("初始化菜单信息:" + menu);
|
|
|
|
|
|
+
|
|
|
CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
|
|
|
int retry = 0;
|
|
|
while (retry < 3) {
|