parent
1204c5365b
commit
eef3008a8c
@ -0,0 +1,185 @@ |
||||
package com.cweb.controller.qianZhu; |
||||
|
||||
import com.hfkj.common.utils.DateUtil; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.qianzhu.channel.CinemaService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestMethod; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/cinema") |
||||
@Api(value="电影票数据") |
||||
public class CinemaController { |
||||
|
||||
Logger log = LoggerFactory.getLogger(CinemaController.class); |
||||
|
||||
@RequestMapping(value="/filmsPagedQuery",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据城市分页查询影片") |
||||
public ResponseData filmsPagedQuery(@RequestParam(value = "cityId", required = false) Integer cityId, |
||||
@RequestParam(value = "cityCode", required = false) String cityCode, |
||||
@RequestParam(value = "cinemaId", required = false) String cinemaId, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize |
||||
) { |
||||
try { |
||||
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
if (cityId != null) { |
||||
params.put("cityId", cityId); |
||||
} |
||||
if (cityCode != null) { |
||||
params.put("cityCode", cityCode); |
||||
} |
||||
if (cinemaId != null) { |
||||
params.put("cinemaId", cinemaId); |
||||
} |
||||
params.put("pageIndex", pageNum); |
||||
params.put("pageSize", pageSize); |
||||
|
||||
return ResponseMsgUtil.success(CinemaService.filmsPagedQuery(params)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/pagedQueryNotShownFilms",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "分页查询待上映影片") |
||||
public ResponseData pagedQueryNotShownFilms( |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize |
||||
) { |
||||
try { |
||||
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("pageIndex", pageNum); |
||||
params.put("pageSize", pageSize); |
||||
|
||||
return ResponseMsgUtil.success(CinemaService.pagedQueryNotShownFilms(params)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/cinemaBrands",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询所有影院品牌") |
||||
public ResponseData cinemaBrands( |
||||
) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(CinemaService.cinemaBrands()); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
@RequestMapping(value="/cinemasPagedQuery",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "分页查询城市影院") |
||||
public ResponseData cinemasPagedQuery(@RequestParam(value = "cityId", required = false) Integer cityId, |
||||
@RequestParam(value = "cityCode", required = false) String cityCode, |
||||
@RequestParam(value = "regionId", required = false) Integer regionId, |
||||
@RequestParam(value = "cinemaId", required = false) String cinemaId, |
||||
@RequestParam(value = "showDate", required = false) String showDate, |
||||
@RequestParam(value = "brandKeyword", required = false) String brandKeyword, |
||||
@RequestParam(name = "lon", required = true) BigDecimal lon, |
||||
@RequestParam(name = "lat", required = true) BigDecimal lat, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize |
||||
) { |
||||
try { |
||||
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
|
||||
if (cityId != null) { |
||||
params.put("cityId", cityId); |
||||
} |
||||
if (cityCode != null) { |
||||
params.put("cityCode", cityCode); |
||||
} |
||||
if (cinemaId != null) { |
||||
params.put("cinemaId", cinemaId); |
||||
} |
||||
if (regionId != null) { |
||||
params.put("regionId", regionId); |
||||
} |
||||
if (brandKeyword != null) { |
||||
params.put("brandKeyword", brandKeyword); |
||||
} |
||||
|
||||
params.put("lon", lon); |
||||
params.put("lat", lat); |
||||
params.put("showDate", showDate); |
||||
params.put("pageIndex", pageNum); |
||||
params.put("pageSize", pageSize); |
||||
|
||||
return ResponseMsgUtil.success(CinemaService.cinemasPagedQuery(params)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/listByCinemaId",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据影院id查询影片") |
||||
public ResponseData listByCinemaId( |
||||
@RequestParam(name = "cinemaId", required = true) Integer cinemaId |
||||
) { |
||||
try { |
||||
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("cinemaId", cinemaId); |
||||
|
||||
return ResponseMsgUtil.success(CinemaService.listByCinemaId(params)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/listByCinemaAndFilm",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据影院和影片查询场次") |
||||
public ResponseData listByCinemaAndFilm( |
||||
@RequestParam(name = "cinemaId", required = true) Integer cinemaId, |
||||
@RequestParam(name = "filmId", required = true) Integer filmId |
||||
) { |
||||
try { |
||||
|
||||
Map<String, Object> params = new HashMap<>(); |
||||
params.put("cinemaId", cinemaId); |
||||
params.put("filmId", filmId); |
||||
|
||||
return ResponseMsgUtil.success(CinemaService.listByCinemaAndFilm(params)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,141 @@ |
||||
package com.hfkj.qianzhu.channel; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @ClassName CinemaService |
||||
* @Author Sum1Dream |
||||
* @Description 电影票请求 |
||||
* @Date 2024/6/11 上午11:31 |
||||
**/ |
||||
public class CinemaService { |
||||
|
||||
/** |
||||
* @MethodName filmsPagedQuery |
||||
* @Description: 根据城市分页查询影片 |
||||
* @param map |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/11 上午11:45 |
||||
*/ |
||||
public static JSONObject filmsPagedQuery(Map<String , Object> map) throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v1/films/pagedQuery" , map); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @MethodName pagedQueryNotShownFilms |
||||
* @Description:分页查询待上映影片 |
||||
* @param map |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/11 下午3:01 |
||||
*/ |
||||
public static JSONObject pagedQueryNotShownFilms(Map<String , Object> map) throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v1/films/pagedQueryNotShownFilms" , map); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @MethodName cinemaBrands |
||||
* @Description:查询所有影院品牌 |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/11 下午3:21 |
||||
*/ |
||||
public static JSONObject cinemaBrands() throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v1/cinema-brands/listAll" , new HashMap<>()); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @MethodName cinemasPagedQuery |
||||
* @Description:分页查询城市影院 |
||||
* @param map |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/11 下午3:31 |
||||
*/ |
||||
public static JSONObject cinemasPagedQuery(Map<String , Object> map) throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v2/cinemas/pagedQuery" , map); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @MethodName listByCinemaId |
||||
* @Description:根据影院id查询影片 |
||||
* @param map |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/11 下午4:09 |
||||
*/ |
||||
public static JSONObject listByCinemaId(Map<String , Object> map) throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v1/films/listByCinemaId" , map); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @MethodName listByCinemaAndFilm |
||||
* @Description:根据影院和影片查询场次 |
||||
* @param map |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/13 下午5:48 |
||||
*/ |
||||
public static JSONObject listByCinemaAndFilm(Map<String , Object> map) throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v1/films/listByCinemaAndFilm" , map); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,109 @@ |
||||
package com.hfkj.qianzhu.channel; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.pay.util.sdk.WXPayConstants; |
||||
import com.hfkj.common.utils.HttpsUtils; |
||||
import com.hfkj.common.utils.MD5Util; |
||||
import com.hfkj.config.CommonSysConst; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.*; |
||||
|
||||
public class QianZhuService { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(QianZhuService.class); |
||||
|
||||
/** |
||||
* 请求 |
||||
* @param postUrl 接口请求地址 |
||||
* @param param 参数 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public static JSONObject request(String postUrl, Map<String,Object> param) throws Exception { |
||||
|
||||
log.info("============ 千猪请求-START ============="); |
||||
param.put("platformId", CommonSysConst.getSysConfig().getQianZhuPlatformId()); |
||||
param.put("timestamp", new Date().getTime()); |
||||
param.put("sign", MD5Util.encode(generateSignature(param,CommonSysConst.getSysConfig().getQianZhuSecret()).getBytes()).toLowerCase()); |
||||
|
||||
log.info("请求接口:" + postUrl); |
||||
log.info("请求参数:" + JSONObject.toJSONString(param)); |
||||
|
||||
JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getQianZhuUrl()+ postUrl, JSONObject.toJSONString(param)); |
||||
|
||||
log.info("响应参数:" + response.toJSONString()); |
||||
log.info("============ 千猪请求-END =============="); |
||||
return response; |
||||
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name getAllCities.java |
||||
* @Description // 查询所有城市
|
||||
* @Date 15:45 2022/6/28 |
||||
* @Param [] |
||||
* @return com.alibaba.fastjson.JSONObject |
||||
*/ |
||||
public static JSONObject getAllCities() throws Exception { |
||||
|
||||
JSONObject object = QianZhuService.request("/openApi/v2/cities/listAll" , new HashMap<>()); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* @MethodName listByCityId |
||||
* @Description:查询城市区域 |
||||
* @param |
||||
* @return: com.alibaba.fastjson.JSONObject |
||||
* @Author: Sum1Dream |
||||
* @Date: 2024/6/11 下午3:12 |
||||
*/ |
||||
public static JSONObject listByCityId(Map<String,Object> param) throws Exception { |
||||
JSONObject object = QianZhuService.request("/openApi/v1/regions/listByCityId" , param); |
||||
|
||||
if (object.getBoolean("success") && object.getInteger("code") == 10000) { |
||||
return object; |
||||
} else { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询失败!"); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 生成签名 |
||||
* @param data 数据 |
||||
* @param key 秘钥app_secret |
||||
* @return 加密结果 |
||||
*/ |
||||
public static String generateSignature(final Map<String, Object> data, String key){ |
||||
Set<String> keySet = data.keySet(); |
||||
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
||||
Arrays.sort(keyArray); |
||||
StringBuilder sb = new StringBuilder(); |
||||
for (String k : keyArray) { |
||||
if (k.equals(WXPayConstants.FIELD_SIGN)) { |
||||
continue; |
||||
} |
||||
if (StringUtils.isBlank(sb.toString())) { |
||||
sb.append(k).append("=").append(data.get(k)); |
||||
} else { |
||||
sb.append("&").append(k).append("=").append(data.get(k)); |
||||
} |
||||
} |
||||
sb.append(key); |
||||
return sb.toString(); |
||||
} |
||||
} |
Loading…
Reference in new issue