'提交代码'

dev-discount
= 3 years ago
parent 7a23915980
commit d2737e8e20
  1. 20
      hai-cweb/src/main/java/com/cweb/controller/tPigController.java
  2. 19
      hai-service/src/main/java/com/hai/config/QianZhuConfig.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);
}
}
} }

@ -1,10 +1,12 @@
package com.hai.config; package com.hai.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MD5Util; import com.hai.common.utils.MD5Util;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -41,6 +43,23 @@ public class QianZhuConfig {
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getQinzhuUrl()+"/api/v2/platform/getToken", map); return HttpsUtils.doGet(CommonSysConst.getSysConfig().getQinzhuUrl()+"/api/v2/platform/getToken", map);
} }
public static JSONObject getMobileToken(String platformUniqueId,String nickname,String mobile) throws Exception {
Map<String,Object> contentMap = new HashMap<>();
contentMap.put("platformUniqueId", platformUniqueId);
contentMap.put("nickname", nickname);
contentMap.put("mobile", mobile);
Map<String,Object> 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 * KFC

Loading…
Cancel
Save