From 6a97be196f47a0399fe03cc94b3daf445d002cf2 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 2 Sep 2024 17:52:08 +0800 Subject: [PATCH] /1 --- .../bweb/controller/SecUserController.java | 1 + .../com/bweb/controller/TestController.java | 76 +++++++++++-------- .../controller/goods/GoodsController.java | 6 +- .../qianZhu/StarbucksController.java | 6 ++ .../com/order/controller/OrderController.java | 5 +- .../order/controller/OrderPayController.java | 16 +++- .../business/BsOrderCinemaController.java | 4 +- .../business/BsOrderGoodsController.java | 7 ++ .../business/BsOrderStarbucksController.java | 22 +++++- .../business/OrderCouponController.java | 5 ++ .../com/hfkj/schedule/OrderGoodsSchedule.java | 25 +++--- .../com/hfkj/common/utils/CommonUtil.java | 36 +++++++++ .../com/hfkj/common/utils/HttpsUtils.java | 69 ++++++----------- .../com/hfkj/dao/BsOrderCouponMapperExt.java | 2 + .../hfkj/model/order/OrderCouponModel.java | 4 + .../coupon/impl/BsOrderCouponServiceImpl.java | 4 + .../goods/impl/BsOrderCinemaServiceImpl.java | 4 +- .../goods/impl/BsOrderGoodsServiceImpl.java | 3 + .../impl/BsOrderStarbucksServiceImpl.java | 4 + .../service/order/OrderCreateService.java | 4 + .../hfkj/service/pay/huift/TradeService.java | 18 +++-- .../service/pay/huift/config/HuiftConfig.java | 4 + 22 files changed, 220 insertions(+), 105 deletions(-) diff --git a/bweb/src/main/java/com/bweb/controller/SecUserController.java b/bweb/src/main/java/com/bweb/controller/SecUserController.java index b58eccf..8ce6a93 100644 --- a/bweb/src/main/java/com/bweb/controller/SecUserController.java +++ b/bweb/src/main/java/com/bweb/controller/SecUserController.java @@ -73,6 +73,7 @@ public class SecUserController { secUser.setUserName(body.getString("userName")); secUser.setLoginName(body.getString("loginName")); + secUser.setPlatformCode(body.getString("platformCode")); secUser.setTelephone(body.getString("telephone")); secUser.setRoleId(body.getLong("roleId")); secUserService.editUser(secUser); diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index 3713e00..b9f5238 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -9,6 +9,7 @@ import com.hfkj.common.utils.*; import com.hfkj.entity.*; import com.hfkj.meituan.MeiTuanService; import com.hfkj.model.ResponseData; +import com.hfkj.model.goods.GoodsModel; import com.hfkj.service.discount.CouponDiscountService; import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.GoodsMsgService; @@ -23,6 +24,7 @@ import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -119,17 +121,25 @@ public class TestController { @RequestMapping(value="/orderGoodsUpdate",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "商品更新") - public ResponseData orderGoodsUpdate() { + public ResponseData orderMsgUpdate() { try { - List orderGoodsList = orderGoodsService.getList(); + Map map = new HashMap<>(); - for (BsOrderGoods goods : orderGoodsList) { - BsOrderChild child = orderChildService.getDetail(goods.getChildOrderNo()); - goods.setStatus(child.getStatus()); - goods.setUpdateTime(new Date()); - orderGoodsService.update(goods); + map.put("status", 1); + + List list = goodsMsgService.getList(map); + + List specsList = goodsSpecsService.getList(new HashMap<>()); + + + for (GoodsMsg goodsMsg : list) { + List goodsSpecsList = specsList.stream().filter(s -> s.getGoodsId().equals(goodsMsg.getId())).collect(Collectors.toList()); + if (!goodsSpecsList.isEmpty()) { + goodsMsg.setSaleNum(CommonUtil.saleNumRandom(goodsSpecsList.get(0).getSalePrice())); + } + goodsMsgService.update(goodsMsg); } return ResponseMsgUtil.success("成功"); @@ -176,38 +186,44 @@ public class TestController { @RequestMapping(value="/getLogisticsMsg",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询物流") - public ResponseData getLogisticsMsg(@RequestParam(value = "id" , required = false) Long id) { + public ResponseData getLogisticsMsg() { try { - Map map = new HashMap<>(); + Map objectMap = new HashMap<>(); - BsOrderGoods orderGoods = bsOrderGoodsService.queryDetail(id); + objectMap.put("status" , 2); - if (orderGoods == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); - } + List orderGoodsList = orderGoodsService.getList(objectMap); + + for (BsOrderGoods goods : orderGoodsList) { - GoodsUserAddress userAddress = addressService.queryDetail(orderGoods.getDeliveryAddressId()); + if (goods == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); + } - if (userAddress == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); - } + GoodsUserAddress userAddress = addressService.queryDetail(goods.getDeliveryAddressId()); - GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo() , userAddress.getPhone()); + if (userAddress == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); + } - if (logistics.getLogisticsStatus() != null) { - orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); - orderGoods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); - } else { - orderGoods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); - orderGoods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); - } + if (goods.getLogisticsNo() != null) { + GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(goods.getLogisticsNo() , userAddress.getPhone()); + if (logistics.getLogisticsStatus() != null) { + goods.setLogisticsStatus(logistics.getLogisticsStatus()); + goods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); + } else { + goods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); + goods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); + } - bsOrderGoodsService.update(orderGoods); - map.put("logistics", logistics); - JSONArray object = JSONArray.parseArray(logistics.getLogisticsTraceDetails()); - map.put("logisticsTraceDetails", object); + goods.setUpdateTime(new Date()); + + bsOrderGoodsService.update(goods); + } + + } - return ResponseMsgUtil.success(map); + return ResponseMsgUtil.success("map"); } catch (Exception e) { log.error("error!",e); diff --git a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java index 25cf899..d89c2c2 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java @@ -130,6 +130,7 @@ public class GoodsController { map.put("status", 1); List list = goodsMsgService.getList(map); + List specsList = goodsSpecsService.getList(new HashMap<>()); List goodsModels = new ArrayList<>(); @@ -137,10 +138,8 @@ public class GoodsController { GoodsModel goodsModel = new GoodsModel(); - Map mapSpecs = new HashMap<>(); - mapSpecs.put("goodsId" , goodsMsg.getId()); + List goodsSpecs = specsList.stream().filter(s -> s.getGoodsId().equals(goodsMsg.getId())).collect(Collectors.toList()); - List goodsSpecs = goodsSpecsService.getList(mapSpecs); if (!goodsSpecs.isEmpty()) { BigDecimal minPrice = goodsSpecs.get(0).getSalePrice(); BigDecimal minOriginalPrice = goodsSpecs.get(0).getOriginalPrice(); @@ -169,7 +168,6 @@ public class GoodsController { } } - return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsModels.size(), pageSize, new PageInfo<>(goodsModels))); } catch (Exception e) { diff --git a/cweb/src/main/java/com/cweb/controller/qianZhu/StarbucksController.java b/cweb/src/main/java/com/cweb/controller/qianZhu/StarbucksController.java index 715571a..9beafa7 100644 --- a/cweb/src/main/java/com/cweb/controller/qianZhu/StarbucksController.java +++ b/cweb/src/main/java/com/cweb/controller/qianZhu/StarbucksController.java @@ -94,6 +94,10 @@ public class StarbucksController { BigDecimal tallPrice = StarbucksUtil.calculatePrice(productConfig.getDiscount() , item.getBigDecimal("salesTallPrice")); List priceList = new ArrayList<>(); + List priceListOriginal = new ArrayList<>(); + priceListOriginal.add(item.getBigDecimal("marketTallPrice")); + priceListOriginal.add(item.getBigDecimal("marketGrandePrice")); + priceListOriginal.add(item.getBigDecimal("marketVentiPrice")); // 判断如果卖家 大于 原价 展示原价 if (tallPrice.compareTo(item.getBigDecimal("marketTallPrice")) > 0) { item.put("tallPrice" , item.getBigDecimal("marketTallPrice")); @@ -124,7 +128,9 @@ public class StarbucksController { } Collections.sort(priceList); + Collections.sort(priceListOriginal); item.put("tallPrice" ,priceList.get(0)); + item.put("tallOriginalPrice" ,priceListOriginal.get(0)); List dataList = new ArrayList<>(); diff --git a/order/src/main/java/com/order/controller/OrderController.java b/order/src/main/java/com/order/controller/OrderController.java index 39e16ad..41fd029 100644 --- a/order/src/main/java/com/order/controller/OrderController.java +++ b/order/src/main/java/com/order/controller/OrderController.java @@ -55,6 +55,7 @@ public class OrderController { @ApiOperation(value = "创建订单") public ResponseData create(@RequestBody OrderModel body) { try { + System.out.println("body" + body.toString()); // 用户session UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); @@ -98,11 +99,11 @@ public class OrderController { @ApiOperation(value = "取消订单") public ResponseData cancel(@RequestBody JSONObject body) { try { + if (body == null|| StringUtils.isBlank(body.getString("orderNo"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - return ResponseMsgUtil.success(orderService.cancel(body.getString("orderNo"), false)); } catch (Exception e) { @@ -133,6 +134,7 @@ public class OrderController { @RequestParam(value = "pageNum" , required = true) Integer pageNum, @RequestParam(value = "pageSize" , required = true) Integer pageSize) { try { + // 用户session UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); if (userSession == null) { @@ -177,6 +179,7 @@ public class OrderController { @RequestParam(value = "pageNum" , required = true) Integer pageNum, @RequestParam(value = "pageSize" , required = true) Integer pageSize) { try { + Map param = new HashMap<>(); param.put("orderNo", orderNo); param.put("userPhone", userPhone); diff --git a/order/src/main/java/com/order/controller/OrderPayController.java b/order/src/main/java/com/order/controller/OrderPayController.java index 72f4ff2..17957a1 100644 --- a/order/src/main/java/com/order/controller/OrderPayController.java +++ b/order/src/main/java/com/order/controller/OrderPayController.java @@ -44,6 +44,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.Date; import java.util.Map; +import java.util.stream.Collectors; /** * @className: OrderController @@ -190,8 +191,21 @@ public class OrderPayController { if (merPay == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); }*/ + + if (order.getOrderChildList().stream().collect(Collectors.groupingBy(OrderChildModel::getProductType, Collectors.toList())).size() > 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂不支持合并下单"); + } + + String shopCode = HuiftConfig.shopcode98; + String signSecret = HuiftConfig.signSecret98; + + if (order.getOrderChildList().get(0).getProductType() == 1) { + shopCode = HuiftConfig.shopcode95; + signSecret = HuiftConfig.signSecret95; + } + // 请求支付渠道 - JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order); + JSONObject thirdPreOrder = huiftTradeService.thirdPreOrder(order , shopCode , signSecret); for (OrderChildModel orderChild : order.getOrderChildList()) { orderChild.setSettleAccount(HuiftConfig.shopcode); orderChild.setSettleAccountKey(HuiftConfig.signSecret); diff --git a/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java b/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java index 323af35..d23ab63 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderCinemaController.java @@ -63,8 +63,8 @@ public class BsOrderCinemaController { Map map = new HashMap<>(); - if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { - map.put("merId", userModel.getAccount().getObjectId()); + if (userModel.getAccount().getPlatformCode() != null) { + map.put("platformCode", userModel.getAccount().getPlatformCode()); } map.put("orderNo", orderNo); diff --git a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java index b366a90..acdd6eb 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -100,6 +100,9 @@ public class BsOrderGoodsController { if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { map.put("merId", userModel.getAccount().getObjectId()); } + if (userModel.getAccount().getPlatformCode() != null) { + map.put("platformCode", userModel.getAccount().getPlatformCode()); + } map.put("logisticsNo", logisticsNo); map.put("goodsType", goodsType); @@ -163,6 +166,10 @@ public class BsOrderGoodsController { map.put("merId", userModel.getAccount().getObjectId()); } + if (userModel.getAccount().getPlatformCode() != null) { + map.put("platformCode", userModel.getAccount().getPlatformCode()); + } + map.put("logisticsNo", logisticsNo); map.put("goodsType", goodsType); map.put("goodsBrand", goodsBrand); diff --git a/order/src/main/java/com/order/controller/business/BsOrderStarbucksController.java b/order/src/main/java/com/order/controller/business/BsOrderStarbucksController.java index f33bbe9..ab51262 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderStarbucksController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderStarbucksController.java @@ -2,14 +2,18 @@ package com.order.controller.business; import com.github.pagehelper.PageInfo; +import com.hfkj.common.security.SessionObject; +import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.PageUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.BsOrderChild; import com.hfkj.entity.BsOrderStarbucks; import com.hfkj.model.ResponseData; +import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.order.OrderStarbucksModel; import com.hfkj.service.goods.BsOrderStarbucksService; import com.hfkj.service.order.BsOrderChildService; +import com.hfkj.sysenum.SecUserObjectTypeEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -42,6 +46,9 @@ public class BsOrderStarbucksController { @Resource private BsOrderStarbucksService bsOrderStarbucksService; + @Resource + private UserCenter userCenter; + @RequestMapping(value="/getListStarbucks",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询列表") @@ -61,7 +68,13 @@ public class BsOrderStarbucksController { @RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); + Map map = new HashMap<>(); + + map.put("orderNo", orderNo); map.put("childOrderNo", childOrderNo); map.put("productType", 4); @@ -72,7 +85,13 @@ public class BsOrderStarbucksController { map.put("status", status); List list = bsOrderChildService.getList(map); - List starbucksList = bsOrderStarbucksService.getList(new HashMap<>()); + + Map map1 = new HashMap<>(); + + if (userModel.getAccount().getPlatformCode() != null) { + map1.put("platformCode", userModel.getAccount().getPlatformCode()); + } + List starbucksList = bsOrderStarbucksService.getList(map1); List starbucksModelList = new ArrayList<>(); @@ -89,7 +108,6 @@ public class BsOrderStarbucksController { starbucksModel.setPayType(starbucks.get(0).getPayType()); starbucksModelList.add(starbucksModel); } - } if (storeAddress != null) { diff --git a/order/src/main/java/com/order/controller/business/OrderCouponController.java b/order/src/main/java/com/order/controller/business/OrderCouponController.java index edd135a..9c5d177 100644 --- a/order/src/main/java/com/order/controller/business/OrderCouponController.java +++ b/order/src/main/java/com/order/controller/business/OrderCouponController.java @@ -122,6 +122,11 @@ public class OrderCouponController { } else if (SecUserObjectTypeEnum.type2.getCode() == userSessionObject.getAccount().getObjectType()) { param.put("merId", userSessionObject.getAccount().getObjectId()); } + + if (userSessionObject.getAccount().getPlatformCode() != null) { + param.put("platformCode", userSessionObject.getAccount().getPlatformCode()); + } + param.put("orderNo", orderNo); param.put("userPhone", userPhone); param.put("tradeStatus", tradeStatus); diff --git a/schedule/src/main/java/com/hfkj/schedule/OrderGoodsSchedule.java b/schedule/src/main/java/com/hfkj/schedule/OrderGoodsSchedule.java index 3a91767..3b68208 100644 --- a/schedule/src/main/java/com/hfkj/schedule/OrderGoodsSchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/OrderGoodsSchedule.java @@ -81,20 +81,21 @@ public class OrderGoodsSchedule { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); } - GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(goods.getLogisticsNo() , userAddress.getPhone()); - - if (logistics.getLogisticsStatus() != null) { - goods.setLogisticsStatus(logistics.getLogisticsStatus()); - goods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); - } else { - goods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); - goods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); + if (goods.getLogisticsNo() != null) { + GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(goods.getLogisticsNo() , userAddress.getPhone()); + if (logistics.getLogisticsStatus() != null) { + goods.setLogisticsStatus(logistics.getLogisticsStatus()); + goods.setLogisticsStatusDesc(logistics.getLogisticsStatusDesc()); + } else { + goods.setLogisticsStatus(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getCode()); + goods.setLogisticsStatusDesc(OrderLogisticsStatusEnum.statusWAIT_ACCEPT.getName()); + } + + goods.setUpdateTime(new Date()); + + bsOrderGoodsService.update(goods); } - goods.setUpdateTime(new Date()); - - bsOrderGoodsService.update(goods); - } } } diff --git a/service/src/main/java/com/hfkj/common/utils/CommonUtil.java b/service/src/main/java/com/hfkj/common/utils/CommonUtil.java index a1f5efc..4aa8ee4 100644 --- a/service/src/main/java/com/hfkj/common/utils/CommonUtil.java +++ b/service/src/main/java/com/hfkj/common/utils/CommonUtil.java @@ -2,6 +2,7 @@ package com.hfkj.common.utils; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Random; public class CommonUtil { @@ -16,4 +17,39 @@ public class CommonUtil { return length + "米"; } + + public static Integer saleNumRandom(BigDecimal price){ + + + if (price.compareTo(new BigDecimal(41)) < 0) { + return randomNumberGenerator(3000 , 15000); + } + if (price.compareTo(new BigDecimal(40)) > 0 && price.compareTo(new BigDecimal(200)) < 0) { + return randomNumberGenerator( 500, 3000); + } + if (price.compareTo(new BigDecimal(201)) > 0 && price.compareTo(new BigDecimal(400)) < 0) { + return randomNumberGenerator( 200, 500); + } + if (price.compareTo(new BigDecimal(401)) > 0) { + return randomNumberGenerator( 10, 200); + } + + return 0; + } + + /** + * @MethodName RandomNumberGenerator + * @Description: 获取区间随机数 + * @param min + * @param max + * @return: java.lang.Integer + * @Author: Sum1Dream + * @Date: 2024/9/2 下午4:02 + */ + public static Integer randomNumberGenerator(Integer min , Integer max){ + + Random random = new Random(); + + return random.nextInt(max - min + 1) + min; + } } diff --git a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java index 3de6e31..7e53848 100644 --- a/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java +++ b/service/src/main/java/com/hfkj/common/utils/HttpsUtils.java @@ -54,7 +54,7 @@ public class HttpsUtils { // 设置连接池 connMgr = new PoolingHttpClientConnectionManager(); // 设置连接池大小 - connMgr.setMaxTotal(100); + connMgr.setMaxTotal(5000); connMgr.setDefaultMaxPerRoute(connMgr.getMaxTotal()); // Validate connections after 1 sec of inactivity connMgr.setValidateAfterInactivity(1000); @@ -100,7 +100,8 @@ public class HttpsUtils { } apiUrl += param; String result = null; - HttpClient httpClient = null; + CloseableHttpClient httpClient; + CloseableHttpResponse response = null; try { if (apiUrl.startsWith("https")) { @@ -111,7 +112,7 @@ public class HttpsUtils { } HttpGet httpGet = new HttpGet(apiUrl); - HttpResponse response = httpClient.execute(httpGet); + response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); @@ -120,48 +121,19 @@ public class HttpsUtils { return JSON.parseObject(result); } catch (Exception e) { log.error(e.getMessage(),e); - } - return null; - } - - public static JSONObject doGet(String url, Map params , String o) { - String apiUrl = url; - StringBuffer param = new StringBuffer(); - int i = 0; - for (String key : params.keySet()) { - if (i == 0) - param.append("?"); - else - param.append("&"); - param.append(key).append("=").append(params.get(key)); - i++; - } - apiUrl += param; - String result = null; - HttpClient httpClient = null; - try { - - if (apiUrl.startsWith("https")) { - httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) - .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); - } else { - httpClient = HttpClients.createDefault(); - } - - HttpGet httpGet = new HttpGet(apiUrl); - HttpResponse response = httpClient.execute(httpGet); - HttpEntity entity = response.getEntity(); - if (entity != null) { - InputStream instream = entity.getContent(); - result = IOUtils.toString(instream, "UTF-8"); + } finally { + if (response != null) { + try { + EntityUtils.consume(response.getEntity()); + } catch (IOException e) { + log.error(e.getMessage(),e); + } } - return JSON.parseObject(result); - } catch (Exception e) { - log.error(e.getMessage(),e); } return null; } + public static JSONObject doGet(String url, Map params , Map headers) { String apiUrl = url; StringBuffer param = new StringBuffer(); @@ -176,7 +148,8 @@ public class HttpsUtils { } apiUrl += param; String result = null; - HttpClient httpClient = null; + CloseableHttpClient httpClient = null; + CloseableHttpResponse response = null; try { if (apiUrl.startsWith("https")) { @@ -190,7 +163,7 @@ public class HttpsUtils { for (Map.Entry e : headers.entrySet()) { httpGet.addHeader(e.getKey(), e.getValue()); } - HttpResponse response = httpClient.execute(httpGet); + response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); @@ -199,6 +172,14 @@ public class HttpsUtils { return JSON.parseObject(result); } catch (Exception e) { log.error(e.getMessage(),e); + } finally { + if (response != null) { + try { + EntityUtils.consume(response.getEntity()); + } catch (IOException e) { + log.error(e.getMessage(),e); + } + } } return null; } @@ -223,7 +204,7 @@ public class HttpsUtils { * @return */ public static JSONObject doPost(String apiUrl, Map params) { - CloseableHttpClient httpClient = null; + CloseableHttpClient httpClient; if (apiUrl.startsWith("https")) { httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); @@ -349,7 +330,7 @@ public class HttpsUtils { * @return */ public static JSONObject doPost(String apiUrl, String str) { - CloseableHttpClient httpClient = null; + CloseableHttpClient httpClient; if (apiUrl.startsWith("https")) { httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()) .setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build(); diff --git a/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java b/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java index f62a811..3bbe20d 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderCouponMapperExt.java @@ -31,6 +31,7 @@ public interface BsOrderCouponMapperExt { " b.pay_channel payChannel," + " b.pay_type payType," + " b.pay_serial_no paySerialNo," + + " b.platform_code platformCode," + " b.`status` tradeStatus," + " b.create_time createTime," + " b.pay_time payTime," + @@ -47,6 +48,7 @@ public interface BsOrderCouponMapperExt { " and b.mer_id = #{param.merId} " + " and b.order_no like concat('%',#{param.orderNo},'%') " + " and b.child_order_no = #{param.orderChildNo} " + + " and b.platform_code = #{param.platformCode} " + " and b.user_phone like concat('%',#{param.userPhone},'%') " + " and b.pay_type = #{param.payType}" + " and b.status = #{param.tradeStatus}" + diff --git a/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java b/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java index bf7ab54..442c2dc 100644 --- a/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java +++ b/service/src/main/java/com/hfkj/model/order/OrderCouponModel.java @@ -120,4 +120,8 @@ public class OrderCouponModel { @ExcelProperty("是否异常") public String exceptionStatus; + @ColumnWidth(20) + @ExcelProperty("平台") + public String platformCode; + } diff --git a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java index 10215ae..145a8d5 100644 --- a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java @@ -7,6 +7,7 @@ import com.hfkj.entity.BsOrderCouponExample; import com.hfkj.model.order.OrderCouponModel; import com.hfkj.service.coupon.BsOrderCouponService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -60,6 +61,9 @@ public class BsOrderCouponServiceImpl implements BsOrderCouponService { if (MapUtils.getLong(param, "createTimeE") != null) { param.put("createTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "createTimeE")), DateUtil.Y_M_D_HMS)); } + if (StringUtils.isNotBlank(MapUtils.getString(param, "platformCode"))) { + param.put("platformCode", MapUtils.getString(param, "platformCode")); + } return orderCouponMapper.getOrderList(param); } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java index 56b59af..674a091 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderCinemaServiceImpl.java @@ -80,7 +80,9 @@ public class BsOrderCinemaServiceImpl implements BsOrderCinemaService { if (StringUtils.isNotBlank(MapUtils.getString(map, "userPhone"))) { criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); } - + if (StringUtils.isNotBlank(MapUtils.getString(map, "platformCode"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platformCode")); + } if (StringUtils.isNotBlank(MapUtils.getString(map, "goodsSpecsName"))) { criteria.andGoodsSpecsNameEqualTo(MapUtils.getString(map, "goodsSpecsName")); } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java index 5872750..674a1ae 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java @@ -154,6 +154,9 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { if (StringUtils.isNotBlank(MapUtils.getString(map, "goodsSpecsName"))) { criteria.andGoodsSpecsNameEqualTo(MapUtils.getString(map, "goodsSpecsName")); } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platformCode"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platformCode")); + } if (StringUtils.isNotBlank(MapUtils.getString(map, "goodsName"))) { criteria.andGoodsNameLike("%"+MapUtils.getString(map, "goodsName")+"%"); diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java index 2beaa4b..af74557 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderStarbucksServiceImpl.java @@ -77,6 +77,10 @@ public class BsOrderStarbucksServiceImpl implements BsOrderStarbucksService { criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone")); } + if (StringUtils.isNotBlank(MapUtils.getString(map, "platformCode"))) { + criteria.andPlatformCodeEqualTo(MapUtils.getString(map, "platformCode")); + } + if (MapUtils.getLong(map, "createTimeS") != null) { criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); } diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index a2102e2..68556db 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -122,6 +122,7 @@ public class OrderCreateService { orderCoupon.setOrderNo(orderChild.getOrderNo()); orderCoupon.setChildOrderNo(orderChild.getChildOrderNo()); orderCoupon.setMerId(orderChild.getMerId()); + orderCoupon.setPlatformCode(businessObj.getString("platformCode")); orderCoupon.setUserId(order.getUserId()); orderCoupon.setUserPhone(order.getUserPhone()); orderCoupon.setGoodsId(goodsMsg.getId()); @@ -226,6 +227,7 @@ public class OrderCreateService { orderGoods.setOrderNo(orderChild.getOrderNo()); orderGoods.setChildOrderNo(orderChild.getChildOrderNo()); orderGoods.setMerId(orderChild.getMerId()); + orderGoods.setPlatformCode(object.getString("platformCode")); orderGoods.setMerName(goodsMsg.getMerName()); orderGoods.setUserId(order.getUserId()); orderGoods.setUserPhone(order.getUserPhone()); @@ -316,6 +318,7 @@ public class OrderCreateService { bsOrderCinema.setOrderNo(orderChild.getOrderNo()); bsOrderCinema.setChildOrderNo(orderChild.getChildOrderNo()); bsOrderCinema.setMerId(productConfig.getMerId()); + bsOrderCinema.setPlatformCode(object.getString("platformCode")); bsOrderCinema.setUserId(order.getUserId()); bsOrderCinema.setUserPhone(object.getString("phone")); bsOrderCinema.setImg(data.getString("pic")); @@ -416,6 +419,7 @@ public class OrderCreateService { bsOrderStarbucks.setOrderNo(orderChild.getOrderNo()); bsOrderStarbucks.setChildOrderNo(orderChild.getChildOrderNo()); bsOrderStarbucks.setMerId(productConfig.getMerId()); + bsOrderStarbucks.setPlatformCode(object.getString("platformCode")); bsOrderStarbucks.setProductId(orderItemObject.getInteger("productId")); bsOrderStarbucks.setUserId(order.getUserId()); bsOrderStarbucks.setUserPhone(object.getString("phone")); diff --git a/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java b/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java index 7a42ea0..859f5aa 100644 --- a/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java +++ b/service/src/main/java/com/hfkj/service/pay/huift/TradeService.java @@ -7,6 +7,7 @@ import com.hfkj.common.exception.SysCode; import com.hfkj.common.utils.HttpsUtils; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrder; +import com.hfkj.entity.BsOrderChild; import com.hfkj.model.order.OrderModel; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.pay.huift.config.HuiftConfig; @@ -36,16 +37,16 @@ public class TradeService { * @return * @throws Exception */ - public JSONObject thirdPreOrder(OrderModel order) throws Exception { + public JSONObject thirdPreOrder(OrderModel order , String shopCode , String signSecret) throws Exception { Map param = new HashMap<>(); - param.put("shopCode", HuiftConfig.shopcode); + param.put("shopCode", shopCode); param.put("outTradeNo", order.getOrderNo()); param.put("transAmt", order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()); param.put("callbackUrl", CommonSysConst.getSysConfig().getDomainName() + "/order/notify/huiftPay"); // param.put("remark", ""); // 备注 // param.put("outAppId", ""); param.put("outRedirectPath", CommonSysConst.getSysConfig().getDomainName()+"/cweb/#/order/order/orderList"); - param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase()); + param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, signSecret).getBytes()).toLowerCase()); JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPreOrder", JSONObject.toJSONString(param)); if (response.getString("status").equals("ok")) { return response.getJSONObject("data"); @@ -59,11 +60,11 @@ public class TradeService { * @return * @throws Exception */ - public JSONObject thirdPayResult(String preOrderNo) throws Exception { + public JSONObject thirdPayResult(String preOrderNo , String shopCode , String signSecret) throws Exception { Map param = new HashMap<>(); - param.put("shopCode", HuiftConfig.shopcode); + param.put("shopCode", shopCode); param.put("preOrderNo", preOrderNo); - param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase()); + param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, signSecret).getBytes()).toLowerCase()); JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayResult", JSONObject.toJSONString(param)); if (response.getString("status").equals("ok")) { return response.getJSONObject("data"); @@ -82,6 +83,7 @@ public class TradeService { public JSONObject thirdPayRefund(String refundOrderNo, BigDecimal refundPrice, String orderNo) throws Exception { // 查询订单 BsOrder order = orderService.getOrder(orderNo); + OrderModel orderModel = orderService.getDetail(orderNo); if (order == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的的订单"); } @@ -93,11 +95,11 @@ public class TradeService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式错误"); } Map param = new HashMap<>(); - param.put("shopCode", HuiftConfig.shopcode); + param.put("shopCode", orderModel.getOrderChildList().get(0).getSettleAccount()); param.put("preOrderNo", order.getPayChannelOrderNo()); param.put("outRefundNo", refundOrderNo); param.put("refundAmt", refundPrice.multiply(new BigDecimal("100")).intValue()); - param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, HuiftConfig.signSecret).getBytes()).toLowerCase()); + param.put("sign", HuiftConfig.md5Encode(HuiftConfig.paramSort(param, orderModel.getOrderChildList().get(0).getSettleAccountKey()).getBytes()).toLowerCase()); JSONObject response = HttpsUtils.doPost(HuiftConfig.reqUrl + "/hfq/v1/thirdPay/thirdPayRefund", JSONObject.toJSONString(param)); if (response.getString("status").equals("ok")) { return response.getJSONObject("data"); diff --git a/service/src/main/java/com/hfkj/service/pay/huift/config/HuiftConfig.java b/service/src/main/java/com/hfkj/service/pay/huift/config/HuiftConfig.java index 39625db..5d5339f 100644 --- a/service/src/main/java/com/hfkj/service/pay/huift/config/HuiftConfig.java +++ b/service/src/main/java/com/hfkj/service/pay/huift/config/HuiftConfig.java @@ -19,6 +19,10 @@ public class HuiftConfig { public final static String reqUrl = CommonSysConst.getSysConfig().getHuiftReqUrl(); public final static String shopcode = CommonSysConst.getSysConfig().getHuiftShopCode(); public final static String signSecret = CommonSysConst.getSysConfig().getHuiftSignSecret(); + public final static String shopcode98 = "20240653-59c4-4181-9157-17fd4b95c3fc"; + public final static String signSecret98 = "19C17F9E19B8DDDDF2FD2EE4EA9F6C61"; + public final static String shopcode95 = "b4b121b6-ec5c-44e1-a020-d2f21e754b55"; + public final static String signSecret95 = "4AA9E79115848B797B53FBD830B402F4"; /** * 参数排序