修改订单支付详情优惠券积分等逻辑

This commit is contained in:
2024-11-22 14:41:13 +08:00
parent b69159d965
commit 70933ce1e4
6 changed files with 149 additions and 82 deletions

View File

@@ -38,7 +38,7 @@
</uni-tag>
</view>
<view class="u-m-r-20 u-flex " v-if="item.userCouponId">
<uni-tag :text="'商品券抵扣'+item.priceAmount"
<uni-tag :text=" productCouponDikou(item)"
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
</uni-tag>
</view>
@@ -58,7 +58,7 @@
<view class="u-text-right u-m-t-28">
<template v-if="isTui(item)">
<view>0.00</view>
<view class="line-th color-666 " >{{returnTotalMoney(item)}}
<view class="line-th color-666 ">{{returnTotalMoney(item)}}
</view>
</template>
<template v-else-if="isGift(item)||item.userCouponId">
@@ -67,9 +67,8 @@
</view>
</template>
<template v-else>
<template
v-if="item.priceAmount*1!=returnTotalMoney(item)*1">
<view>{{item.priceAmount}}</view>
<template v-if="returnCanTuiMoney(item)*1!=returnTotalMoney(item)*1">
<view>{{returnCanTuiMoney(item)}}</view>
<view class=" color-666 line-th">
{{returnTotalMoney(item)}}</view>
</template>
@@ -214,14 +213,21 @@
<text>{{to2(orderInfo.fullCouponDiscountAmount) }}</text>
</view>
</view>
<view class="u-flex u-row-between u-m-t-18"
<view class="u-flex u-row-between u-m-t-18" v-if="productCouponDiscountAmount*1>0">
<view>商品券抵扣</view>
<view class="color-red">
<text></text>
<text> {{productCouponDiscountAmount }}</text>
</view>
</view>
<!-- <view class="u-flex u-row-between u-m-t-18"
v-if="orderInfo.productCouponDiscountAmount||productCoupPrice*1>0">
<view>商品券抵扣</view>
<view class="color-red">
<text></text>
<text> {{to2(orderInfo.productCouponDiscountAmount||productCoupPrice) }}</text>
</view>
</view>
</view> -->
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.pointsDiscountAmount">
<view>积分抵扣</view>
<view class="color-red">
@@ -261,6 +267,10 @@
pop.youhui = true
}
function productCouponDikou(item) {
return '商品券抵扣¥' + returnProductCoupPrice(item)
}
function youhuiDetailHide() {
pop.youhui = false
}
@@ -287,6 +297,30 @@
}
}
})
function returnProductCoupPrice(item) {
if (!item.isMember) {
return item.price * item.num
}
const price = item.memberPrice ? item.memberPrice : item.price
return price * item.num
}
const productCouponDiscountAmount = computed(() => {
// if(props.orderInfo.productCouponDiscountAmount){
// return orderInfo.productCouponDiscountAmount.toFixed(2)
// }
if (!props.data.length) {
return 0
}
const n = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.userCouponId).reduce((a, b) => {
return a + returnProductCoupPrice(b)
}, 0)
return prve + curTotal
}, 0)
console.log(n);
return n.toFixed(2)
})
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
function returnVipMoney(item) {
@@ -299,6 +333,21 @@
function returnTotalMoney(item) {
return (item.price * item.num).toFixed(2)
}
const canTuiKuanPrice = computed(() => {
return props.data.reduce((prve,cur)=>{
const curTotal=cur.info.filter(v=>!v.userCouponId).reduce((a,b)=>{
return a+b.priceAmount*1
},0)
// const curTotal=cur.info.filter(v=>canTuiKuan(props.orderInfo,v)&&!v.userCouponId).reduce((a,b)=>{
// return a+b.priceAmount*1
// },0)
return prve+curTotal
},0)
})
function returnCanTuiMoney(item) {
return (item.priceAmount/canTuiKuanPrice.value*props.orderInfo.amount).toFixed(2)
}
function to2(n) {
if (!n) {
@@ -314,7 +363,7 @@
function tuikuan(item, index) {
hasPermission('允许退款').then(res => {
if (res) {
emits('tuikuan', item, index)
emits('tuikuan', {...item,priceAmount:returnCanTuiMoney(item)}, index)
}
})
}
@@ -331,12 +380,12 @@
const n = props.seatFee.priceAmount * (isTui(props.seatFee) ? 0 : 1)
return n.toFixed(2)
})
const discountAmount=computed(()=>{
if(props.orderInfo.discountAmount){
const discountAmount = computed(() => {
if (props.orderInfo.discountAmount) {
return props.orderInfo.discountAmount
}
console.log(props.orderInfo.originAmount*(1-props.orderInfo.discountRatio));
return (props.orderInfo.originAmount*(1-props.orderInfo.discountRatio))
console.log(props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio));
return (props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio))
})
const goodsOriginAllPrice = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
@@ -348,13 +397,8 @@
}, 0)
return goodsPrice.toFixed(2)
})
const canTuiKuanPrice=computed(()=>{
const discountAmount=props.orderInfo.originAmount||(100-props.orderInfo.discountRatio)*props.orderInfo.originAmount/100
const n= props.orderInfo.originAmount-discountAmount
console.log(n);
return m
})
const freePrice = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
@@ -372,7 +416,8 @@
return 0
}
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" && (v.isMember && v.memberPrice) && (v.memberPrice != v.price)).reduce((
const curTotal = cur.info.filter(v => v.gift != true && v.status !== "return" && (v.isMember &&
v.memberPrice) && (v.memberPrice != v.price)).reduce((
a,
b) => {
return a + (b.num * (b.price - b.memberPrice))
@@ -402,7 +447,8 @@
const youhuiAllPrice = computed(() => {
return (freePrice.value * 1 + vipDiscountPrice.value * 1 + props.orderInfo.fullCouponDiscountAmount + props
.orderInfo.pointsDiscountAmount + productCoupPrice.value * 1 + (props.orderInfo.discountAmount ||
.orderInfo.pointsDiscountAmount + (props.orderInfo.status == 'unpaid' ? productCoupPrice.value :
productCouponDiscountAmount.value) * 1 + (props.orderInfo.discountAmount ||
0)).toFixed(2)
@@ -419,8 +465,12 @@
})
const allPrice = computed(() => {
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
return (n < 0 ? 0 : n).toFixed(2)
if (props.orderInfo.status == 'unpaid') {
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
return (n < 0 ? 0 : n).toFixed(2)
}
return props.orderInfo.amount
})
const goodsNumber = computed(() => {