积分问题修复
This commit is contained in:
@@ -75,11 +75,6 @@
|
||||
return false
|
||||
}
|
||||
}
|
||||
watch(()=>props.disablePayType,(newval)=>{
|
||||
console.log('watch:props.disablePayType',newval);
|
||||
},{
|
||||
immediate:true
|
||||
})
|
||||
|
||||
const orderVIP = ref(null)
|
||||
const emits = defineEmits(['customevent', 'groupChange']);
|
||||
|
||||
@@ -470,22 +470,16 @@
|
||||
shopUserId: props.orderVIP.id,
|
||||
orderAmount: maxMoney.value
|
||||
})
|
||||
console.log(res);
|
||||
Object.assign(pointsRes, res)
|
||||
const maxUsablePoints = res.maxUsablePoints
|
||||
maxPointDiscount.value = res.maxDeductionAmount
|
||||
// props.listinfo.pointsDiscountAmount = await APImemberPointscalcDeductionAmount({
|
||||
// points: maxUsablePoints,
|
||||
// shopUserId: props.orderVIP.id,
|
||||
// orderAmount: maxMoney
|
||||
// })
|
||||
if (usePoints.value) {
|
||||
cartStore.setUserPoints(maxUsablePoints)
|
||||
}
|
||||
cartStore.setUserPoints(res.maxUsablePoints||0)
|
||||
console.log('getMaxPointsDiscount:cartStore.orderCostSummary.pointUsed', cartStore.orderCostSummary.pointUsed);
|
||||
}
|
||||
watch(() => maxMoney.value, (newval) => {
|
||||
console.log('maxMoney.value', newval);
|
||||
if (usePoints.value) {
|
||||
getMaxPointsDiscount()
|
||||
}
|
||||
})
|
||||
watch(() => usePoints.value, (newval) => {
|
||||
if (newval) {
|
||||
@@ -493,6 +487,7 @@
|
||||
} else {
|
||||
cartStore.setUserPoints(0)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
const handleConfirm = async (integral) => {
|
||||
@@ -532,7 +527,7 @@
|
||||
calcUsablePointsData.integral = null
|
||||
props.listinfo.pointsDiscountAmount = 0
|
||||
calcUsablePointsData.showModal = false
|
||||
cartStore.setUserPoints(0);
|
||||
// cartStore.setUserPoints(0);
|
||||
}
|
||||
|
||||
// * 复制订单号
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
</view>
|
||||
|
||||
|
||||
{{cartStore.orderCostSummary}}
|
||||
<!-- {{cartStore.orderCostSummary}} -->
|
||||
|
||||
<!-- 详情 -->
|
||||
<orderInfo :useVipPrice="cartStore.useVipPrice" :packfee="packfee" :shifu="shifu" :nowCarts="cartStore.carts"
|
||||
@@ -215,7 +215,6 @@
|
||||
}
|
||||
|
||||
function updateChargeSel(newval) {
|
||||
console.log('updateChargeSel', newval);
|
||||
rechargeItem.value = newval
|
||||
//充值并付款时只能微信支付
|
||||
if (newval && newval.id) {
|
||||
@@ -231,7 +230,6 @@
|
||||
if (paymentMethodref.value) {
|
||||
paymentMethodref.value.groupChanges(2)
|
||||
}
|
||||
console.log('watch: cartStore.orderCostSummary.finalPayAmount', disablePayType.value);
|
||||
return
|
||||
}
|
||||
if (shopUserInfo.value.amount < newval) {
|
||||
@@ -239,11 +237,9 @@
|
||||
if (paymentMethodref.value) {
|
||||
paymentMethodref.value.groupChanges(2)
|
||||
}
|
||||
console.log('watch: cartStore.orderCostSummary.finalPayAmount', disablePayType.value);
|
||||
return
|
||||
}
|
||||
disablePayType.value = []
|
||||
console.log('watch: cartStore.orderCostSummary.finalPayAmount', disablePayType.value);
|
||||
}
|
||||
|
||||
async function onMessage(Message) {
|
||||
@@ -430,6 +426,7 @@
|
||||
|
||||
//拿到订单数据后续初始化处理
|
||||
function getOrderInfoAfterCalcInit(res) {
|
||||
console.log('getOrderInfoAfterCalcInit',res);
|
||||
if (res && res.id) {
|
||||
Object.assign(listinfo, res);
|
||||
// 历史订单
|
||||
@@ -666,7 +663,7 @@
|
||||
}
|
||||
// 生成订单
|
||||
const createOrder = async () => {
|
||||
cartStore.carts = [];
|
||||
// cartStore.carts = [];
|
||||
const res = await storeMemberpay.actionscreateOrder({
|
||||
dineMode: is_type.value == 0 ? 'dine-in' : 'take-out', //堂食 dine-in 外带 take-out 外卖 take-away
|
||||
seatNum: uni.cache.get('dinersNum') ? uni.cache.get('dinersNum') : '', //用餐人数
|
||||
@@ -733,7 +730,35 @@
|
||||
}
|
||||
let payStatusTimer = null
|
||||
let orderIsLock = true;
|
||||
let usePoints=ref(0)
|
||||
|
||||
|
||||
let checkOrderPay = {}
|
||||
|
||||
const istoricalorders = async () => {
|
||||
|
||||
checkOrderPay = {
|
||||
orderId:'',
|
||||
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
|
||||
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
|
||||
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
|
||||
originAmount: cartStore.orderCostSummary.goodsRealAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
|
||||
discountAmount: 0, //手动优惠金额 写死0
|
||||
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
|
||||
otherCouponDiscountAmount: cartStore.orderCostSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||
couponList: cartStore.backendCoupons.map(v => v.id), //用户使用的卡券
|
||||
orderAmount: cartStore.orderCostSummary.finalPayAmount, // 最终订单金额
|
||||
roundAmount: 0, //抹零金额 减免多少钱
|
||||
pointsDiscountAmount: cartStore.orderCostSummary
|
||||
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: cartStore.orderCostSummary.pointUsed, //(扣除各类折扣 enable_deduction后使用)
|
||||
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
|
||||
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore
|
||||
.consumeDiscount.id : '',
|
||||
remark: orderRemarker.value, //用户备注
|
||||
}
|
||||
|
||||
//先付
|
||||
if (isPayBefor()) {
|
||||
console.log('isPayBefor');
|
||||
@@ -741,16 +766,19 @@
|
||||
console.log('cartStore.carts', cartStore.carts);
|
||||
// 购物车有数据
|
||||
if (!cartStore.isEmpty) {
|
||||
usePoints=cartStore.orderCostSummary.pointUsed
|
||||
const res = await createOrder()
|
||||
//历史订单数据
|
||||
const res1 = await APIgetOrderById({
|
||||
orderId: res.id
|
||||
})
|
||||
console.log('历史订单数据',res1);
|
||||
orderRemarker.value=res1.remark;
|
||||
cartStore.setOldOrder(res1)
|
||||
}
|
||||
nextTick(goToPay)
|
||||
|
||||
console.log('istoricalorders:cartStore.orderCostSummary.pointUsed',cartStore.orderCostSummary.pointUsed);
|
||||
console.log('istoricalorders:cartStore.userPoints',cartStore.userPoints);
|
||||
goToPay()
|
||||
// goToPay()
|
||||
|
||||
} else {
|
||||
@@ -815,7 +843,6 @@
|
||||
})
|
||||
return
|
||||
}
|
||||
console.log('userInfo.usePayPwd',userInfo.usePayPwd);
|
||||
if(userInfo.usePayPwd){
|
||||
ispws.value = true
|
||||
return
|
||||
@@ -825,9 +852,7 @@
|
||||
}
|
||||
|
||||
const canPayRes = await search_pay_lock()
|
||||
console.log('canPayRes', canPayRes);
|
||||
const canPay = canPayRes.status == 1 ? true : false;
|
||||
console.log('canPay', canPay);
|
||||
if (!canPay) {
|
||||
uni.showToast({
|
||||
title: '有人正在付款中!',
|
||||
@@ -855,32 +880,12 @@
|
||||
orderorderInfo()
|
||||
return false;
|
||||
} else {
|
||||
console.log(' ordershopUserInfo.value', ordershopUserInfo.value);
|
||||
let checkOrderPay = {
|
||||
orderId: listinfo.id,
|
||||
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
|
||||
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
|
||||
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
|
||||
originAmount: cartStore.orderCostSummary.goodsRealAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
|
||||
discountAmount: 0, //手动优惠金额 写死0
|
||||
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
|
||||
otherCouponDiscountAmount: cartStore.orderCostSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||
couponList: cartStore.backendCoupons.map(v => v.id), //用户使用的卡券
|
||||
orderAmount: cartStore.orderCostSummary.finalPayAmount, // 最终订单金额
|
||||
roundAmount: 0, //抹零金额 减免多少钱
|
||||
pointsDiscountAmount: cartStore.orderCostSummary
|
||||
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: cartStore.orderCostSummary.pointUsed, //(扣除各类折扣 enable_deduction后使用)
|
||||
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
|
||||
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore
|
||||
.consumeDiscount.id : '',
|
||||
remark: orderRemarker.value, //用户备注
|
||||
}
|
||||
checkOrderPay.orderId=listinfo.id;
|
||||
console.log('cartStore.orderCostSummary',cartStore.orderCostSummary);
|
||||
console.log('topay checkOrderPay', checkOrderPay);
|
||||
try {
|
||||
if (rechargeItem.value.id && rechargeId.value) {
|
||||
//充值支付
|
||||
//充值并且支付
|
||||
const payRes = await rechargePayOrder({
|
||||
checkOrderPay: {
|
||||
...checkOrderPay,
|
||||
@@ -936,29 +941,18 @@
|
||||
// 余额支付
|
||||
const accountPayevent = async (pwd) => {
|
||||
ispws.value = false;
|
||||
|
||||
let checkOrderPay = {
|
||||
userId: uni.cache.get('userInfo').id,
|
||||
orderId: listinfo.id,
|
||||
vipPrice: cartStore.useVipPrice ? 1 : 0, //是否使用会员价0否1是
|
||||
userAllPack: is_type.value == 0 ? 0 : 1, //是否整单打包
|
||||
seatNum: is_type.value == 0 ? cartStore.seatFeeConfig.personCount : 0, //用餐人数
|
||||
originAmount: cartStore.orderCostSummary.goodsRealAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, //折扣比例(计算时 向上取整保留 两位小数) 写死1
|
||||
discountAmount: 0, //手动优惠金额 写死0
|
||||
productCouponDiscountAmount: cartStore.orderCostSummary.productCouponDeduction, //商品优惠券抵扣金额
|
||||
otherCouponDiscountAmount: cartStore.orderCostSummary.fullCouponDeduction, //其他优惠券抵扣金额
|
||||
couponList: cartStore.backendCoupons.map(v => v.id), //用户使用的卡券
|
||||
orderAmount: cartStore.orderCostSummary.finalPayAmount, // 最终订单金额
|
||||
roundAmount: 0, //抹零金额 减免多少钱
|
||||
pointsDiscountAmount: cartStore.orderCostSummary
|
||||
.pointDeductionAmount, //积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: cartStore.orderCostSummary.pointUsed, //(扣除各类折扣 enable_deduction后使用)
|
||||
newCustomerDiscountAmount: cartStore.orderCostSummary.newUserDiscount, //新客立减
|
||||
newCustomerDiscountId: cartStore.orderCostSummary.newUserDiscount > 0 ? cartStore.consumeDiscount
|
||||
.id : '',
|
||||
remark: orderRemarker.value, //用户备注
|
||||
}
|
||||
checkOrderPay.userId=uni.cache.get('userInfo').id
|
||||
checkOrderPay.orderId=listinfo.id
|
||||
console.log('余额支付本地计算',cartStore.orderCostSummary);
|
||||
console.log('余额支付提交参数',{
|
||||
checkOrderPay,
|
||||
payType: paymentmethod.payType,
|
||||
pwd: pwd,
|
||||
shopUserId: orderVIP.value.id,
|
||||
buyerRemark: '',
|
||||
returnUrl: ''
|
||||
});
|
||||
console.log('积分',checkOrderPay.pointsNum);
|
||||
try {
|
||||
await storeMemberpay.balancePayOrder({
|
||||
checkOrderPay,
|
||||
@@ -1064,6 +1058,7 @@
|
||||
})
|
||||
|
||||
async function init(opt) {
|
||||
console.log('init');
|
||||
cartStore.clearOrderConfig()
|
||||
Object.assign(options, opt)
|
||||
listinfo.id = options.orderId;
|
||||
|
||||
@@ -207,10 +207,10 @@ function showDetailHandle(item) {
|
||||
ruleList.push(otherCouponRule);
|
||||
}
|
||||
const shareRuleText = `${ruleList.join('、')}`;
|
||||
|
||||
let foods=item.foods;
|
||||
selectListItemDetails.value = [
|
||||
`可适用门店:${item.useShops}`,
|
||||
`可适用商品:${item.foods}`,
|
||||
`可适用商品:${foods}`,
|
||||
`可使用类型:${convertValuesToLabels(item.useType)}`,
|
||||
`可用时间段:${item.useTimeType == 'all' ? '全段时间可用' : `${item.useStartTime} - ${item.useEndTime}`}`,
|
||||
`限量规则:每人限领${item.getLimit == -10086 ? `无限张` : `${item.getLimit}张`},每日最多可使用${item.useLimit == -10086 ? `无限张` : `${item.useLimit}张`}`,
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
|
||||
</view>
|
||||
<view class="flex-colum">
|
||||
<view class="Box_bottom" :class="(form.checkCode!=''&&form.password!=''&&form.payPassword!='')?'active':''"
|
||||
@click="userInfosavePayPassword">确定</view>
|
||||
<view class="Box_bottom active"
|
||||
@click="userInfosavePayPassword">重置密码</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -271,14 +271,14 @@
|
||||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
color: #5082fd;
|
||||
z-index: 1;
|
||||
z-index: 100;
|
||||
.yzm {
|
||||
padding: 8rpx 20rpx;
|
||||
background: #E5E5E5;
|
||||
background: #FFD158;
|
||||
border-radius: 24rpx;
|
||||
font-weight: 500;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
color: #5F2E0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,18 +303,15 @@
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
line-height: 96rpx;
|
||||
background-color: #999;
|
||||
background-color: #FFD158;
|
||||
border-radius: 48rpx;
|
||||
font-size: 32rpx;
|
||||
font-size: 36rpx;
|
||||
font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
color: #ffffff;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.Box_bottom.active {
|
||||
background-color: #E3AD7F;
|
||||
}
|
||||
}
|
||||
|
||||
.getPhone {
|
||||
|
||||
@@ -175,7 +175,6 @@ export const useCartsStore = defineStore('cart',
|
||||
// 订单费用汇总
|
||||
const orderCostSummary = computed(() => {
|
||||
allGoods.value = getAllGoodsList()
|
||||
console.log('orderCostSummary:allGoods.value',allGoods.value );
|
||||
const costSummary = OrderPriceCalculator.calculateOrderCostSummary(
|
||||
allGoods.value,
|
||||
dinnerType.value,
|
||||
@@ -350,6 +349,7 @@ export const useCartsStore = defineStore('cart',
|
||||
|
||||
function setOldOrder(data) {
|
||||
oldOrder.value = data
|
||||
allGoods.value=getAllGoodsList()
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +560,10 @@ export const useCartsStore = defineStore('cart',
|
||||
|
||||
|
||||
function clearOrderConfig(){
|
||||
console.log('clearOrderConfig');
|
||||
backendCoupons.value=[];
|
||||
allGoods.value=[];
|
||||
carts.value=[]
|
||||
seatFeeConfig.value.personCount=uni.cache.get('dinersNum') || 0;
|
||||
dinnerType.value='dine-in';
|
||||
userPoints.value=0
|
||||
@@ -586,6 +589,7 @@ export const useCartsStore = defineStore('cart',
|
||||
totalOriginPrice,
|
||||
orderCostSummary,
|
||||
setCoupons,
|
||||
userPoints,
|
||||
setUserPoints,
|
||||
setPointDeductionRule,
|
||||
setOldOrder,
|
||||
|
||||
@@ -136,21 +136,33 @@ export function returnCouponCanUse(args) {
|
||||
};
|
||||
}
|
||||
|
||||
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user,shopInfo);
|
||||
// 计算门槛金额
|
||||
let fullAmount = goodsOrderPrice;
|
||||
// 是否抵扣全部商品
|
||||
const isDikouAll = coupon.useFoods.length === 0;
|
||||
let canCalcGoodsArr = [];
|
||||
// 订单里参与门槛计算的商品
|
||||
if (!isDikouAll) {
|
||||
canDikouGoodsArr = returnCanDikouGoodsArr(canDikouGoodsArr, selCoupon, user,shopInfo);
|
||||
|
||||
//优惠券指定门槛商品列表
|
||||
let canCalcGoodsArr=[...canDikouGoodsArr]
|
||||
//部分商品参与门槛计算
|
||||
if(coupon.thresholdFoods.length){
|
||||
canCalcGoodsArr = canDikouGoodsArr.filter((v) => {
|
||||
return coupon.useFoods.find((food) => food.id == v.productId);
|
||||
return coupon.thresholdFoods.find((food) => food.id == v.productId);
|
||||
});
|
||||
fullAmount = canCalcGoodsArr.reduce((pre, cur) => {
|
||||
return pre + returnGoodsPrice(cur, user,shopInfo) * cur.num;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 是否全部商品可用
|
||||
const isDikouAll = coupon.useFoods.length === 0;
|
||||
// 订单可用商品列表
|
||||
let canUseGoodsArr = [];
|
||||
if (!isDikouAll) {
|
||||
canUseGoodsArr = canDikouGoodsArr.filter((v) => {
|
||||
return coupon.useFoods.find((food) => food.id == v.productId);
|
||||
});
|
||||
}
|
||||
if(user.isVip&&!coupon.vipPriceShare){
|
||||
return {
|
||||
canUse: false,
|
||||
@@ -169,15 +181,14 @@ export function returnCouponCanUse(args) {
|
||||
reason: "当前选中的券不可与其他券同享"
|
||||
};
|
||||
}
|
||||
|
||||
// 没有符合条件的商品
|
||||
if (!isDikouAll && canCalcGoodsArr.length === 0) {
|
||||
// 满减券和折扣券计算门槛金额是否满足
|
||||
if([1,3].includes(coupon.type)){
|
||||
if(canCalcGoodsArr.length<=0){
|
||||
return {
|
||||
canUse: false,
|
||||
reason: "没有符合条件的商品"
|
||||
reason: "没有可参与计算门槛的商品"
|
||||
};
|
||||
}
|
||||
|
||||
// 不满足门槛金额
|
||||
if (fullAmount < coupon.fullAmount) {
|
||||
return {
|
||||
@@ -185,22 +196,24 @@ export function returnCouponCanUse(args) {
|
||||
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`
|
||||
};
|
||||
}
|
||||
|
||||
// 商品券特殊验证
|
||||
if (coupon.type === 2) {
|
||||
if (!(isDikouAll || canCalcGoodsArr.length === 0)) {
|
||||
}
|
||||
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
||||
if([2,4,5].includes(coupon.type)){
|
||||
// 没有符合条件的商品
|
||||
if (!isDikouAll && canCalcGoodsArr.length === 0) {
|
||||
return {
|
||||
canUse: false,
|
||||
reason: "没有符合条件的商品可抵扣"
|
||||
reason: "没有符合条件的商品"
|
||||
};
|
||||
}
|
||||
if(canDikouGoodsArr.length<=0){
|
||||
}
|
||||
//商品兑换券是否达到门槛金额
|
||||
if(coupon.type==2&&goodsOrderPrice<coupon.fullAmount){
|
||||
return {
|
||||
canUse: false,
|
||||
reason: "没有符合条件的商品可抵扣"
|
||||
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 买一送一券特殊验证
|
||||
if (coupon.type === 6) {
|
||||
@@ -322,20 +335,27 @@ export function returnCouponZhekouDiscount(
|
||||
maxDiscountAmount
|
||||
} = coupon;
|
||||
|
||||
// 计算商品优惠券折扣总和,使用BigNumber避免精度问题
|
||||
const goodsCouponDiscount = selCoupon
|
||||
.filter((v) => v.type == 2)
|
||||
.reduce((prve, cur) => {
|
||||
return prve + cur.discount.discountPrice;
|
||||
}, 0);
|
||||
goodsOrderPrice -= goodsCouponDiscount;
|
||||
// 使用bignumber处理高精度计算
|
||||
// 1. 计算折扣率(百分比转小数):discountRate / 100
|
||||
const discountRatio = new BigNumber(discountRate).dividedBy(100);
|
||||
// 2. 计算优惠比例:1 - 折扣率(例如:8折的优惠比例是 1 - 0.8 = 0.2)
|
||||
const discountAmountRatio = new BigNumber(1).minus(discountRatio);
|
||||
// 3. 计算折扣金额:商品订单金额 × 优惠比例
|
||||
let discountPrice = new BigNumber(goodsOrderPrice).times(discountAmountRatio).decimalPlaces(2, BigNumber.ROUND_FLOOR).toNumber();
|
||||
if (maxDiscountAmount != 0) {
|
||||
return new BigNumber(prve).plus(new BigNumber(cur.discount.discountPrice));
|
||||
}, new BigNumber(0));
|
||||
|
||||
// 将商品订单价格转换为BigNumber并减去优惠券折扣
|
||||
const adjustedGoodsOrderPrice = new BigNumber(goodsOrderPrice).minus(goodsCouponDiscount);
|
||||
console.log('adjustedGoodsOrderPrice', adjustedGoodsOrderPrice.toNumber());
|
||||
|
||||
// 计算优惠比例:(100 - 折扣率) / 100
|
||||
const discountAmountRatio = new BigNumber(100).minus(discountRate).dividedBy(100);
|
||||
|
||||
// 计算折扣金额:调整后的商品订单金额 × 优惠比例
|
||||
let discountPrice = adjustedGoodsOrderPrice.times(discountAmountRatio)
|
||||
.decimalPlaces(2, BigNumber.ROUND_FLOOR)
|
||||
.toNumber();
|
||||
|
||||
// 应用最大折扣金额限制
|
||||
if (maxDiscountAmount !== 0) {
|
||||
discountPrice = discountPrice >= maxDiscountAmount ? maxDiscountAmount : discountPrice;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user