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 16a9d75e..5c0d6a21 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/tPigController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/tPigController.java @@ -2,13 +2,18 @@ package com.cweb.controller; import com.alibaba.fastjson.JSONObject; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; 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.model.UserInfoModel; import com.hai.service.HighUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -56,15 +61,26 @@ public class tPigController { @RequestMapping(value = "/getTPigCinemaToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "【小程序】电影票获取千猪Token") - public ResponseData getTPigCinemaToken(@RequestParam(name = "userId", required = true) Long userId) { + public ResponseData queryCinemaUrl() { try { - HighUser highUser = highUserService.findByUserId(userId); + HighUserModel sessionModel = userCenter.getSessionModel(HighUserModel.class); + if (sessionModel == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } + // 查询用户 + HighUser user = sessionModel.getHighUser(); + if (user == null || sessionModel.getHighUser() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); + } - JSONObject token = QianZhuConfig.getToken(highUser.getId().toString() , highUser.getName() , highUser.getPhone()); + // 获取token + JSONObject token = QianZhuConfig.getToken(""+user.getId() , user.getName() , user.getPhone()); String url = ""; if (token.getBoolean("success")) { JSONObject data = token.getJSONObject("data"); url = CommonSysConst.getSysConfig().getQinzhuHtmlUrl()+"/cinema/?platformId="+CommonSysConst.getSysConfig().getQinzhuPlatformId()+"&token="+data.getString("accessToken"); + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取地址失败"); } return ResponseMsgUtil.success(url); } catch (Exception e) {