From b54c4e2678ee7c275200da7f1d75542f61fdf9ab Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Sat, 17 Sep 2022 10:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=9F=E5=B7=B4=E5=85=8B?= =?UTF-8?q?=E4=B8=8B=E6=9E=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighThirdPartyController.java | 33 ++++++++++++++++--- .../java/com/hai/common/utils/CommonUtil.java | 10 ++++++ .../com/hai/entity/ApiStarbucksProducts.java | 10 ++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 hai-service/src/main/java/com/hai/common/utils/CommonUtil.java diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java b/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java index 7b4d55bc..7ae4361e 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java @@ -35,6 +35,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.math.RoundingMode; +import java.sql.Array; import java.util.*; import java.util.stream.Collectors; @@ -118,20 +119,44 @@ public class HighThirdPartyController { BigDecimal salesTallPrice = apiStarbucksProducts.getSalesTallPrice().add(apiStarbucksProducts.getMarketTallPrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP); BigDecimal salesGrandePrice = apiStarbucksProducts.getSalesGrandePrice().add(apiStarbucksProducts.getMarketGrandePrice().multiply(productDiscount.divide(new BigDecimal(100)))).setScale(2, RoundingMode.HALF_UP); - if (salesVentiPrice.compareTo(apiStarbucksProducts.getMarketVentiPrice()) > 0) { - salesVentiPrice = apiStarbucksProducts.getMarketVentiPrice(); - } + + + // 判断当前价格是否大雨原价 如果大于显示原价 if (salesTallPrice.compareTo(apiStarbucksProducts.getMarketTallPrice()) > 0) { salesTallPrice = apiStarbucksProducts.getMarketTallPrice(); } if (salesGrandePrice.compareTo(apiStarbucksProducts.getMarketGrandePrice()) > 0) { salesGrandePrice = apiStarbucksProducts.getMarketGrandePrice(); } + if (salesVentiPrice.compareTo(apiStarbucksProducts.getMarketVentiPrice()) > 0) { + salesVentiPrice = apiStarbucksProducts.getMarketVentiPrice(); + } + + String[] strings = apiStarbucksProducts.getCupSize().split(","); + + for (String string : strings) { + if ("中杯".equals(string)) { + apiStarbucksProducts.setShowPrice(salesTallPrice); + break; + } + if ("大杯".equals(string)) { + apiStarbucksProducts.setShowPrice(salesGrandePrice); + break; + } + if ("超大杯".equals(string)) { + apiStarbucksProducts.setShowPrice(salesVentiPrice); + break; + } + } + apiStarbucksProducts.setSalesVentiPrice(salesVentiPrice); apiStarbucksProducts.setSalesTallPrice(salesTallPrice); apiStarbucksProducts.setCount(0); apiStarbucksProducts.setSalesGrandePrice(salesGrandePrice); - starbucksProductsList.add(apiStarbucksProducts); + if (apiStarbucksProducts.getShowPrice() != null) { + starbucksProductsList.add(apiStarbucksProducts); + } + } starbucksProducts.setName(s); starbucksProducts.setExt2(SysConst.getSysConfig().getImgUrl() + ProductImgEnum.getNameByImgUrl(s)); diff --git a/hai-service/src/main/java/com/hai/common/utils/CommonUtil.java b/hai-service/src/main/java/com/hai/common/utils/CommonUtil.java new file mode 100644 index 00000000..96c0c6c3 --- /dev/null +++ b/hai-service/src/main/java/com/hai/common/utils/CommonUtil.java @@ -0,0 +1,10 @@ +package com.hai.common.utils; + +/** + * @author sum1dream + */ +public class CommonUtil { + + + +} diff --git a/hai-service/src/main/java/com/hai/entity/ApiStarbucksProducts.java b/hai-service/src/main/java/com/hai/entity/ApiStarbucksProducts.java index ea2e6d26..8cb38ec3 100644 --- a/hai-service/src/main/java/com/hai/entity/ApiStarbucksProducts.java +++ b/hai-service/src/main/java/com/hai/entity/ApiStarbucksProducts.java @@ -131,6 +131,16 @@ public class ApiStarbucksProducts implements Serializable { private Integer count; + private BigDecimal showPrice; + + public BigDecimal getShowPrice() { + return showPrice; + } + + public void setShowPrice(BigDecimal showPrice) { + this.showPrice = showPrice; + } + /** * ext_1 */