diff --git a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java index 421f4257..c1a11dd9 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java @@ -76,4 +76,24 @@ public class tPigController { } } + @RequestMapping(value = "/getGatewayToken", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "【小程序】电话费") + public ResponseData getGatewayToken(@RequestParam(name = "userId", required = true) Long userId) { + try { + HighUser highUser = highUserService.findByUserId(userId); + + JSONObject token = QianZhuConfig.getMobileToken(highUser.getUnionId() , highUser.getName() , highUser.getPhone()); + String url = ""; + if (token.getBoolean("success")) { + JSONObject data = token.getJSONObject("data"); + url = "https://m-test.qianzhu8.com/mobile/?platformId=" + CommonSysConst.getSysConfig().getQinzhuPlatformId() + "&token=" + data.getString("accessToken"); + } + + return ResponseMsgUtil.success(token); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java index 95f2f91e..799fd5bc 100644 --- a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java +++ b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java @@ -1,10 +1,12 @@ package com.hai.config; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.MD5Util; import com.hai.common.utils.ResponseMsgUtil; +import com.hai.common.utils.WxUtils; import com.hai.model.ResponseData; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -41,6 +43,23 @@ public class QianZhuConfig { return HttpsUtils.doGet(CommonSysConst.getSysConfig().getQinzhuUrl()+"/api/v2/platform/getToken", map); } + public static JSONObject getMobileToken(String platformUniqueId,String nickname,String mobile) throws Exception { + Map contentMap = new HashMap<>(); + contentMap.put("platformUniqueId", platformUniqueId); + contentMap.put("nickname", nickname); + contentMap.put("mobile", mobile); + + Map map = new HashMap<>(); + map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId()); + map.put("action", "users.getTokenV2"); + map.put("version", "1.0"); + map.put("content", JSON.toJSONString(contentMap)); + map.put("traceId", WxUtils.makeNonStr()); + map.put("timestamp", new Date().getTime()); + map.put("sign", MD5Util.encode(generateSignature(map,CommonSysConst.getSysConfig().getQinzhuSecret()).getBytes()).toLowerCase()); + return HttpsUtils.doPost("https://live.qianzhu8.com/gateway", JSON.toJSONString(map)); + } + /** * KFC