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 aab90485..920c8f03 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java @@ -1,16 +1,13 @@ package com.cweb.controller; -import com.alipay.api.domain.Data; -import com.cweb.config.SysConst; -import com.hai.common.pay.util.sdk.WXPayConstants; -import com.hai.common.security.SessionObject; +import com.alibaba.fastjson.JSONObject; + import com.hai.common.security.UserCenter; -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.config.CommonSysConst; +import com.hai.config.QianZhuConfig; import com.hai.entity.HighUser; -import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import io.swagger.annotations.Api; @@ -23,10 +20,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; + @Controller @@ -40,33 +34,43 @@ public class tPigController { @Autowired private UserCenter userCenter; - @RequestMapping(value = "/getTPigToken", method = RequestMethod.GET) + + + @RequestMapping(value = "/getTPigKFCToken", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "【小程序】KFC获取千猪Token") + public ResponseData getH5AccessToken(@RequestParam(name = "userId", required = true) Long userId) { + try { + HighUser highUser = highUserService.findByUserId(userId); + + JSONObject token = QianZhuConfig.getToken(highUser.getUnionId() , highUser.getName() , highUser.getPhone()); + String url = ""; + if (token.getBoolean("success")) { + JSONObject data = token.getJSONObject("data"); + url = "https://m.qianzhu8.com/kfc/?platformId=" + CommonSysConst.getSysConfig().getQinzhuPlatformId() + "&token=" + data.getString("accessToken"); + } + + return ResponseMsgUtil.success(url); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getTPigCinemaToken", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "【小程序】获取千猪Token") - public ResponseData getH5AccessToken(HttpServletRequest request) { + @ApiOperation(value = "【小程序】电影票获取千猪Token") + public ResponseData getTPigCinemaToken(@RequestParam(name = "userId", required = true) Long userId) { try { + HighUser highUser = highUserService.findByUserId(userId); - // 用户 -// SessionObject sessionObject = userCenter.getSessionObject(request); -// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); -// -// HighUser highUser = highUserService.findByUserId(userInfoModel.getHighUser().getId()); - - Map params = new HashMap<>(); -// params.put("platformUniqueId", highUser.getUnionId()); -// params.put("nickname", highUser.getName()); -// params.put("mobile", highUser.getPhone()); - - params.put("platformUniqueId", "oArhO6WlHsR2e5LuPUbxTcGo4nsQ"); - params.put("nickname", "Sum1Dream"); - params.put("platformId", "10376"); - params.put("mobile", "18090580471"); -// params.put("timestamp", String.valueOf(new Date().getTime())); - params.put("timestamp", "1624793550754"); - String sign = WxUtils.generateSignaturePig(params, "ktxb49sh2jfhgn8g" , WXPayConstants.SignType.MD5); - params.put("sign", sign); - return ResponseMsgUtil.success(HttpsUtils.doGet("https://live-test.qianzhu8.com/api/v2/platform/getToken", params , "")); + JSONObject token = QianZhuConfig.getToken(highUser.getUnionId() , highUser.getName() , highUser.getPhone()); + String url = ""; + if (token.getBoolean("success")) { + JSONObject data = token.getJSONObject("data"); + url = "https://m.qianzhu8.com/cinema/?platformId=" + CommonSysConst.getSysConfig().getQinzhuPlatformId() + "&token=" + data.getString("accessToken"); + } + return ResponseMsgUtil.success(url); } 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 a8ed897c..a3b9ac3d 100644 --- a/hai-service/src/main/java/com/hai/config/QianZhuConfig.java +++ b/hai-service/src/main/java/com/hai/config/QianZhuConfig.java @@ -23,10 +23,13 @@ import java.util.*; */ public class QianZhuConfig { - - @RequestMapping(value = "/getToken", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "获取用户token") + /** + * 生成Token + * @param platformUniqueId 用户唯一id + * @param nickname 昵称 + * @param mobile 电话号码 + * @return Token + */ public static JSONObject getToken(String platformUniqueId,String nickname,String mobile) throws Exception { Map map = new HashMap<>(); map.put("platformId", CommonSysConst.getSysConfig().getQinzhuPlatformId());