From eef3008a8cfb082483be131da64e0f8c456c1302 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 17 Jun 2024 17:03:02 +0800 Subject: [PATCH] Changes --- .../controller/goods/GoodsController.java | 3 + .../main/java/com/cweb/config/AuthConfig.java | 1 + .../com/cweb/controller/CommonController.java | 42 ++++ .../controller/qianZhu/CinemaController.java | 185 ++++++++++++++++++ order/src/main/resources/dev/logback.xml | 22 +++ .../java/com/hfkj/config/CommonSysConfig.java | 16 +- .../hfkj/qianzhu/channel/CinemaService.java | 141 +++++++++++++ .../hfkj/qianzhu/channel/QianZhuService.java | 109 +++++++++++ .../resources/dev/commonConfig.properties | 10 +- 9 files changed, 514 insertions(+), 15 deletions(-) create mode 100644 cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java create mode 100644 service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java create mode 100644 service/src/main/java/com/hfkj/qianzhu/channel/QianZhuService.java diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java index 2a45795..339bfda 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java @@ -256,6 +256,7 @@ public class GoodsController { @RequestParam(value = "goodsType" , required = false) Long goodsType, @RequestParam(value = "goodsBrand" , required = false) Long goodsBrand, @RequestParam(value = "type" , required = false) Integer type, + @RequestParam(value = "merId" , required = false) Long merId, @RequestParam(value = "status" , required = false) Integer status, @RequestParam(value = "pageNum" , required = true) Integer pageNum, @RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { @@ -281,6 +282,8 @@ public class GoodsController { if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { map.put("merId", userModel.getAccount().getObjectId()); + } else { + map.put("merId", merId); } map.put("type", type); diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index 846b070..7cfd592 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -91,6 +91,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/common/*") .excludePathPatterns("/fileUpload/*") .excludePathPatterns("/wxMsg/*") + .excludePathPatterns("/cinema/*") ; } diff --git a/cweb/src/main/java/com/cweb/controller/CommonController.java b/cweb/src/main/java/com/cweb/controller/CommonController.java index b6b7a6d..b406d83 100644 --- a/cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/cweb/src/main/java/com/cweb/controller/CommonController.java @@ -10,6 +10,7 @@ import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsOrderGoods; import com.hfkj.entity.GoodsLogistics; import com.hfkj.model.ResponseData; +import com.hfkj.qianzhu.channel.QianZhuService; import com.hfkj.service.CommonService; import com.hfkj.service.goods.BsOrderGoodsService; import io.swagger.annotations.Api; @@ -85,5 +86,46 @@ public class CommonController { } } + @RequestMapping(value = "/getAllCities", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询中国大陆所有城市") + public ResponseData getAllCities() { + try { + + Object data = redisUtil.get("qianZhuCity"); + + if (data == null) { + + JSONObject jsonObjects = QianZhuService.getAllCities(); + redisUtil.set("qianZhuCity", jsonObjects); + + return ResponseMsgUtil.success(jsonObjects); + + } else { + return ResponseMsgUtil.success(data); + } + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/listByCityId", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询城市区域") + public ResponseData listByCityId(@RequestParam(value = "cityId", required = false) Integer cityId) { + try { + + Map params = new HashMap<>(); + params.put("cityId", cityId); + return ResponseMsgUtil.success(QianZhuService.listByCityId(params)); + + } catch (Exception e) { + log.error("HighUserCardController --> oilCardRefund() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java b/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java new file mode 100644 index 0000000..2b1b01a --- /dev/null +++ b/cweb/src/main/java/com/cweb/controller/qianZhu/CinemaController.java @@ -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 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 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 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 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 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); + } + } +} diff --git a/order/src/main/resources/dev/logback.xml b/order/src/main/resources/dev/logback.xml index b2b05c1..5f29239 100644 --- a/order/src/main/resources/dev/logback.xml +++ b/order/src/main/resources/dev/logback.xml @@ -202,4 +202,26 @@ + + + log/QianZhuLog.log + + log/QianZhuLog/QianZhuLog.log.%d.%i + + + 64 MB + + + + + %d %p (%file:%line\)- %m%n + + UTF-8 + + + + + + + diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index aba5d24..fc074c0 100644 --- a/service/src/main/java/com/hfkj/config/CommonSysConfig.java +++ b/service/src/main/java/com/hfkj/config/CommonSysConfig.java @@ -11,11 +11,6 @@ import org.springframework.stereotype.Component; @Data public class CommonSysConfig { - /** - * 普惠GO域名地址 - */ - private String domainName; - /** * 微信小程序appid */ @@ -104,9 +99,10 @@ public class CommonSysConfig { private String etcPublicKey; private String etcPrivateKey; - // 贵行V家园小程序支付 - private String huiftReqUrl; - private String huiftShopCode; - private String huiftSignSecret; - + /** + * 千猪接口请求参数 + */ + private String qianZhuUrl; + private String qianZhuPlatformId; + private String qianZhuSecret; } diff --git a/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java b/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java new file mode 100644 index 0000000..310abae --- /dev/null +++ b/service/src/main/java/com/hfkj/qianzhu/channel/CinemaService.java @@ -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 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 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 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 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 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, "查询失败!"); + } + + } + + + + +} diff --git a/service/src/main/java/com/hfkj/qianzhu/channel/QianZhuService.java b/service/src/main/java/com/hfkj/qianzhu/channel/QianZhuService.java new file mode 100644 index 0000000..8e650f1 --- /dev/null +++ b/service/src/main/java/com/hfkj/qianzhu/channel/QianZhuService.java @@ -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 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 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 data, String key){ + Set 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(); + } +} diff --git a/service/src/main/resources/dev/commonConfig.properties b/service/src/main/resources/dev/commonConfig.properties index d1951a0..7f8777e 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -1,6 +1,4 @@ -domainName=https://phgcs.dctpay.com - wechatMpAppid=wxa075e8509802f826 wechatMpSecret=0e606fc1378d35e359fcf3f15570b2c5 @@ -53,6 +51,8 @@ etcChannelCode = GZETCFXQD etcPublicKey = MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMyQb5gR1rweB5oHKqRPJtJjLQKsn5PXOVfaNdGt/2kPkHvRdN3L9zOaAvFEXcEl2V0sg3D8a+2Sfy1YANAZvjscTQYOaoFl+LVyQZvgyyX8RQw+26Jmbqh8DwenUbNf7DFYVSDxIMBLOiWPkGsYGFONjsUVmfykSeVTcEgQB3VwIDAQAB etcPrivateKey = MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAO8+KWh/OmBahFk7TWOEjPl13BT5NdlbGvQ/311Yua6CQqul9w1DIR2TwFUUh/Bko/eVoLROfF2XVjHbw2bImTdJ7y9C3511HI59YPNzqyql0DHjLxbH0VW92eUgk8mG09wtrUMu1ImN0b7aFE3uqAgz6pwh3TUiQWsDWz+l/MG7AgMBAAECgYEA7nYsOd8OpbmzT2m/omEdTwz9993KocKgZDJCBj4InftyTrrXO93cZSm/PE6BjMgTcxUuIGpWpcbRgFLHOmzZ4Qd+k/6Yb1ErMTfdGlgrxv2B+vztWYfjmFzEiXpecFH47ED6iYrrqm14X3InpnBv4rUkGdqqNbyPGgTO2ncs/3kCQQD+xqRAQSb/TROlqJdO91y6z9v0PO2GLmokqYg444rKYZKhDE0tdJeLU/sfK8SMg5+SlwdQm4nlo8EDJ/w2CEn3AkEA8GRqVkKgIuH413/a6+luYDjlf30WY7Mi1sm3QPSZ6+eH35UwsL6mdX6mjRpUN9Hez6FMfE7s3XOldoPVMzR1XQJBAOa2VTkGhtz8HEWQZOySXfuhjSogHmu7Dk2C5CO4Eg/wycpjDGSUR0NZWnfAt60S6GbjszEQmJBGeNt10xPO78MCQQCWXwnRaZ3IFDhXfQfRWFSN5ilQ5UszFGQvnUB/ZkI+ObdZmXY6qRdxGcdPLnAN9r78fDZe7/Pk1qljCDY98IuVAkEAnSeO/221gDhL1wnbUhGuX1yo8f5Eo/wDTW5cBxXFGZeexhB8I4jnEV4E/xmikkb3jDFvmrnFk+XUtDqkrvicRQ== -huiftReqUrl=https://linktest.huift.com.cn -huiftShopCode=50041b27-f985-dcb0-1cc0-f106b09bf1fe -huiftSignSecret=DB4D8069A9AC6DDF9D75667EE5CF182A + +#QIANZHU +qianZhuUrl=https://live-test.qianzhu8.com +qianZhuPlatformId=10376 +qianZhuSecret=ktxb49sh2jfhgn8g