From 8bd5956340227b820d6fe4a4772b2901d307b104 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Mon, 22 Dec 2025 16:09:45 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=83=A8=E5=88=86=E6=89=93?=
=?UTF-8?q?=E5=8D=B0=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=BB=B7=E6=A0=BC=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/goods-price.vue | 123 ++++++++++++++-------------
components/paymentMethod.vue | 1 -
lib/goods.ts | 17 ++--
pages/order/components/orderInfo.vue | 2 +
stores/carts.js | 10 ++-
5 files changed, 80 insertions(+), 73 deletions(-)
diff --git a/components/goods-price.vue b/components/goods-price.vue
index 83eb9f8..6db6a42 100644
--- a/components/goods-price.vue
+++ b/components/goods-price.vue
@@ -1,75 +1,76 @@
-
-
- {{ returnPrice() }}
-
-
+
+
+ {{ returnPrice() }}
+
+
-
- 0
- "
- class="memberPrice"
- >
-
- {{ cart.memberPrice }}
-
-
+ ">
+
+ {{ cart.memberPrice }}
+
+
- {{ cart.salePrice }}
-
+ {{ cart.salePrice }}
+
-
\ No newline at end of file
diff --git a/components/paymentMethod.vue b/components/paymentMethod.vue
index 6196bc2..65a219b 100644
--- a/components/paymentMethod.vue
+++ b/components/paymentMethod.vue
@@ -145,7 +145,6 @@ onMounted(() => {
watch(
() => props.disablePayType,
(newval) => {
- console.log('props.disablePayType', newval);
// 加兜底:radiovalue 未初始化时不处理
if (Object.keys(radiovalue.value).length === 0) return;
diff --git a/lib/goods.ts b/lib/goods.ts
index db90e61..4b73719 100644
--- a/lib/goods.ts
+++ b/lib/goods.ts
@@ -599,17 +599,18 @@ export function calcSingleGoodsRealPrice(
calcMemberPrice(goods, isMember, memberDiscountRate)
);
-
- console.log('is_time_discount',goods)
-
if(goods.is_time_discount||goods.isTimeDiscount){
+ console.log('限时折扣',activity)
+ console.log('goods',goods)
//限时折扣优先
- return truncateToTwoDecimals(
+ const limitPrice= truncateToTwoDecimals(
new BigNumber(goods.salePrice)
.times((activity?activity.discountRate:100) / 100)
.decimalPlaces(2, BigNumber.ROUND_UP)
.toNumber()
);
+ console.log('limitPrice',limitPrice)
+ return limitPrice;
}
// 3. 优先级3:营销活动折扣(如限时折扣,需按商品ID匹配活动)
let isActivityApplicable = false;
@@ -623,8 +624,7 @@ export function calcSingleGoodsRealPrice(
}
}
}
- console.log('isActivityApplicable',isActivityApplicable)
- console.log('activity',activity)
+
if (!activity || !isActivityApplicable) {
return memberPrice.toNumber();
}
@@ -644,12 +644,12 @@ export function calcSingleGoodsRealPrice(
// );
// }
- if (activity&&activity.discountPriority == "vip-price" && isMember) {
+ if (activity.discountPriority == "vip-price" && isMember) {
return memberPrice.toNumber();
}
// 处理活动与会员的同享/不同享逻辑
- if (activity&&activity.vipPriceShare) {
+ if (activity.vipPriceShare) {
// 同享:会员价基础上叠加工活动折扣
return truncateToTwoDecimals(
memberPrice.multipliedBy(activity.discountRate).toNumber()
@@ -716,6 +716,7 @@ export function calcGoodsRealAmount(
const availableNum = Math.max(0, goods.number - (goods.returnNum || 0));
if (availableNum <= 0) continue;
const realPrice = new BigNumber(calcSingleGoodsRealPrice(goods, config));
+ console.log('goods',goods);
console.log('realPrice',realPrice.toNumber());
total = total.plus(realPrice.multipliedBy(availableNum));
}
diff --git a/pages/order/components/orderInfo.vue b/pages/order/components/orderInfo.vue
index 0e0a31a..f23ea7d 100644
--- a/pages/order/components/orderInfo.vue
+++ b/pages/order/components/orderInfo.vue
@@ -41,6 +41,8 @@
:limitDiscount="cartStore.limitTimeDiscount"
> -->
diff --git a/stores/carts.js b/stores/carts.js
index f3a4526..ed69114 100644
--- a/stores/carts.js
+++ b/stores/carts.js
@@ -2,6 +2,7 @@ import {
defineStore
} from "pinia";
// import yskUtils from 'ysk-utils'
+import yskUtils from '@/lib/index'
// const {
// OrderPriceCalculator,
// BaseCartItem,
@@ -12,8 +13,6 @@ import {
// MerchantReductionType,
// GoodsType
// } = yskUtils
-// import yskUtils from '@/lib/index'
-import yskUtils from 'ysk-utils'
const {
OrderPriceCalculator
} = yskUtils
@@ -327,10 +326,15 @@ export const useCartsStore = defineStore("cart", () => {
if (!item) {
return null
}
- const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(v, limitTimeDiscount
+ console.log('v',v);
+ console.log('limitTimeDiscount',limitTimeDiscount.value);
+ console.log('shopInfo',shopInfo.value);
+ console.log('shopUserInfo',shopUserInfo.value);
+ const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount({...v,memberPrice:item.memberPrice}, limitTimeDiscount
.value,
shopInfo.value,
shopUserInfo.value, 'product_id');
+ console.log('is_time_discount',is_time_discount);
return {
...item,
is_time_discount: is_time_discount ? 1 : 0