From 355c53df6614795ca9766a688f3cd1eb20d7bc2e Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Wed, 17 Apr 2019 00:41:10 +0800 Subject: [PATCH] =?UTF-8?q?H5=20=E5=89=8D=E7=AB=AF=EF=BC=9A=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=AF=A6=E6=83=85=E9=A1=B5=EF=BC=8C=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E4=BF=83=E9=94=80=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile-web/src/page/product/detail.vue | 69 ++++++++++++++++--- .../order/biz/service/CartServiceImpl.java | 2 +- .../service/PromotionActivityServiceImpl.java | 5 ++ 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/mobile-web/src/page/product/detail.vue b/mobile-web/src/page/product/detail.vue index 759ce9e9a..fd709d01b 100644 --- a/mobile-web/src/page/product/detail.vue +++ b/mobile-web/src/page/product/detail.vue @@ -9,8 +9,14 @@ - {{ formatPrice(initialSku.price) }} - +
+ {{ formatPrice(calSkuPriceResult.presentPrice) }} + {{ formatPrice(calSkuPriceResult.originalPrice) }} +
+
+ {{ formatPrice(initialSku.price) }} +
+
{{ spu.name }}
{{spu.sellPoint}}
@@ -45,6 +51,7 @@ + @@ -71,16 +78,17 @@ - + + - + @@ -215,6 +223,43 @@ text = text + 'x ' + data.quantity + ' 件'; return text; }, + formatTimeLimitedDiscountText(activity) { + let text = ''; + let timeLimitedDiscount = activity.timeLimitedDiscount.items[0]; + if (timeLimitedDiscount.preferentialType === 1) { + text += '减 ' + timeLimitedDiscount.preferentialValue / 100.0 + ' 元'; + } else if (timeLimitedDiscount.preferentialType === 2) { + text += '打 ' + timeLimitedDiscount.preferentialValue / 10.0 + ' 折'; + } + if (activity.timeLimitedDiscount.quota > 0) { + text += '【限购 ' + activity.timeLimitedDiscount.quota + ' 件】'; + } + return text; + }, + formatFullPrivilegeText(activity) { + let text = ''; + let fullPrivilege = activity.fullPrivilege; + for (let i in fullPrivilege.privileges) { + let privilege = fullPrivilege.privileges[i]; + if (i > 0) { + text += ';'; + } + if (fullPrivilege.cycled) { + text += '每'; + } + if (privilege.meetType === 1) { + text += '满 ' + privilege.meetValue + ' 元,'; + } else if (privilege.meetType === 2) { + text += '满 ' + privilege.meetValue + ' 件,'; + } + if (privilege.preferentialType === 1) { + text += '减 ' + privilege.preferentialValue / 100.0 + ' 元'; + } else if (privilege.preferentialType === 2) { + text += '打 ' + privilege.preferentialValue / 10.0 + ' 折'; + } + } + return text; + }, stepperChange(value) { // 选择 sku 数量时 this.initialSku.quantity = value; @@ -234,6 +279,14 @@ doCalcSkuPrice(skuId) { getCartCalcSkuPrice(skuId).then(data => { this.calSkuPriceResult = data; + // 修改 vanSku.list 里匹配的 sku 的价格(目的,将优惠价赋值到其上) + for (let i in this.vanSku.list) { + let sku = this.vanSku.list[i]; + if (sku.id === skuId) { + sku.price = data.presentPrice; + break; + } + } }); }, onClickCart() { diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java index 6e2ea9053..7ffd16b78 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java @@ -244,7 +244,7 @@ public class CartServiceImpl implements CartService { return presentPrice >= 0 ? presentPrice : sku.getPrice(); // 如果计算优惠价格小于 0 ,则说明无法使用优惠。 } if (PreferentialTypeEnum.DISCOUNT.getValue().equals(item.getPreferentialType())) { // 打折 - return sku.getPrice() * item.getPreferentialValue() / 100; + return sku.getPrice() * item.getPreferentialValue() / 10; } throw new IllegalArgumentException(String.format("折扣活动(%s) 的优惠类型不正确", timeLimitedDiscount.toString())); } diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/PromotionActivityServiceImpl.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/PromotionActivityServiceImpl.java index 0a8fa6f68..1d3aec970 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/PromotionActivityServiceImpl.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/PromotionActivityServiceImpl.java @@ -56,6 +56,11 @@ public class PromotionActivityServiceImpl implements PromotionActivityService { // 不匹配,则进行移除 if (!matched) { iterator.remove(); + } else { // 匹配,则做一些后续的处理 + // 如果是限时折扣,移除不在 spuId 数组中的折扣规则 + if (PromotionActivityTypeEnum.TIME_LIMITED_DISCOUNT.getValue().equals(activity.getActivityType())) { + activity.getTimeLimitedDiscount().getItems().removeIf(item -> !spuIds.contains(item.getSpuId())); + } } } // 返回最终结果