diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index fe7196c1..4d3f28b8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -24,6 +24,7 @@ import com.hai.service.HighGasOilPriceService; import com.hai.service.HighOrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -87,7 +88,21 @@ public class HighGasController { iterator.remove(); } } - return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum,distance.size(),pageSize,new PageInfo<>(distance))); + + PageInfo> mapPageInfo = PageUtil.initPageInfoObj(pageNum, distance.size(), pageSize, new PageInfo<>(distance)); + for (Map map : mapPageInfo.getList()) { + if (StringUtils.isNotBlank(MapUtils.getString(map, "oil_no"))) { + // 查询是否配置了优惠比例 + HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNo(MapUtils.getString(map, "oil_no")); + if (gasDiscountOilPrice != null) { + // 优惠比例 / 100 = 最终优惠比例 + BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); + // 油品国标价 * 最终优惠比例 + map.put("price_vip", new BigDecimal(MapUtils.getString(map, "price_official")).multiply(priceRate).setScale(1, BigDecimal.ROUND_DOWN)); + } + } + } + return ResponseMsgUtil.success(mapPageInfo); } return ResponseMsgUtil.success(new PageInfo<>()); } catch (Exception e) { @@ -117,7 +132,7 @@ public class HighGasController { for (Object oilPriceObject : originalOilPriceList) { JSONObject price = JSON.parseObject(JSONObject.toJSONString(oilPriceObject), JSONObject.class); // 查询是否配置了优惠比例 - HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNoName(price.getString("oilNoName")); + HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNo(price.getString("oilNo")); if (gasDiscountOilPrice != null) { // 优惠比例 / 100 = 最终优惠比例 BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 7a8b4755..60306ed5 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -169,7 +169,7 @@ public class HighOrderController { } if (childOrder.getGoodsType() == 3) { - if (childOrder.getGoodsPrice() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) { + if (childOrder.getGoodsPrice() == null || childOrder.getGasPriceGun() == null || childOrder.getGasPriceVip() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) { log.error("HighOrderController --> addOrder() error!", "参数错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } @@ -180,33 +180,8 @@ public class HighOrderController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息"); } highOrder.setPayType(2); // 第三方平台 - - // 获取当前加油价格 - JSONObject jsonObject = TuanYouConfig.queryCompanyPriceDetail(store.getStoreKey(), childOrder.getGasOilNo()); - if (jsonObject == null || !jsonObject.getString("code").equals("200")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未获取到加油价格"); - } - if(jsonObject.getJSONArray("result").size() == 0) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未获取到加油价格"); - } - /* // 处理油品价格 - for (Object oilPriceObject : originalOilPriceList) { - JSONObject price = JSON.parseObject(JSONObject.toJSONString(oilPriceObject), JSONObject.class); - // 查询是否配置了优惠比例 - HighGasDiscountOilPrice gasDiscountOilPrice = highGasDiscountOilPriceService.getDetailByOilNoName(price.getString("oilNoName")); - if (gasDiscountOilPrice != null) { - // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); - // 油品国标价 * 最终优惠比例 - price.put("priceVip", price.getBigDecimal("priceOfficial").multiply(priceRate).setScale(1, BigDecimal.ROUND_DOWN)); - } - newOilPriceList.add(price); - }*/ - JSONObject priceDetail = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.getJSONArray("result").get(0)), JSONObject.class); childOrder.setGoodsName(store.getStoreName()); childOrder.setGoodsImg(store.getStoreLogo()); - childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); - childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); childOrder.setGoodsActualPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); childOrder.setGoodsSpecName("默认"); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); @@ -431,4 +406,11 @@ public class HighOrderController { return ResponseMsgUtil.exception(e); } } +/* + public static void main(String[] args) { + BigDecimal bigDecimal1 = new BigDecimal("1200").divide(new BigDecimal("5.58"), 10, BigDecimal.ROUND_DOWN); + System.out.println(bigDecimal1); + BigDecimal bigDecimal2 = bigDecimal1.multiply(new BigDecimal("5.40")).setScale(2, BigDecimal.ROUND_HALF_UP); + System.out.println(bigDecimal2); + }*/ } diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java index 54bda4cb..56094c08 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOilPriceMapperExt.java @@ -14,8 +14,10 @@ public interface HighGasOilPriceMapperExt { @Select("