修改订单详情支付逻辑
This commit is contained in:
parent
a2a4a1bf96
commit
c9caed9579
|
|
@ -98,10 +98,10 @@
|
||||||
}
|
}
|
||||||
console.log(item);
|
console.log(item);
|
||||||
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
if (props.orderInfo.pointsDiscountAmount > 0 || props.orderInfo.fullCouponDiscountAmount > 0) {
|
||||||
const shengyuKeTui=canTuiKuanPrice.value
|
return item.canReturnAmount
|
||||||
const bili = Math.floor((item.priceAmount / shengyuKeTui) * 100) / 100
|
// const shengyuKeTui=canTuiKuanPrice.value
|
||||||
console.log(bili);
|
// const bili = Math.floor((item.priceAmount / shengyuKeTui) * 100) / 100
|
||||||
return Math.floor((props.orderInfo.amount-props.orderInfo.refundAmount) * bili * 100) / 100
|
// return Math.floor((props.orderInfo.amount-props.orderInfo.refundAmount) * bili * 100) / 100
|
||||||
} else {
|
} else {
|
||||||
return item.priceAmount
|
return item.priceAmount
|
||||||
}
|
}
|
||||||
|
|
@ -141,7 +141,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function tuikuan() {
|
function tuikuan() {
|
||||||
emits('tuikuan', {...props.data,priceAmount:seatFeePrice.value})
|
emits('tuikuan', {...props.data,priceAmount:props.data.canReturnAmount})
|
||||||
}
|
}
|
||||||
|
|
||||||
function tuicai() {
|
function tuicai() {
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
<template v-if="orderInfo.status=='unpaid'">
|
<template v-if="orderInfo.status=='unpaid'">
|
||||||
<view>
|
<view>
|
||||||
<text>总计¥</text>
|
<text>总计¥</text>
|
||||||
<text class="font-bold u-font-32">{{to2(allPrice*1+seatFeePrice*1+packFee*1) }}</text>
|
<text class="font-bold u-font-32">{{orderInfo.amount }}</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|
@ -358,6 +358,7 @@
|
||||||
return prve + curTotal
|
return prve + curTotal
|
||||||
}, 0)
|
}, 0)
|
||||||
console.log(goodsTotal);
|
console.log(goodsTotal);
|
||||||
|
console.log(seatFeePrice.value);
|
||||||
return (goodsTotal+seatFeePrice.value*1).toFixed(2)
|
return (goodsTotal+seatFeePrice.value*1).toFixed(2)
|
||||||
})
|
})
|
||||||
const TuiKuanPrice = computed(() => {
|
const TuiKuanPrice = computed(() => {
|
||||||
|
|
@ -388,16 +389,14 @@
|
||||||
return seatFee
|
return seatFee
|
||||||
})
|
})
|
||||||
function returnCanTuiMoney(item) {
|
function returnCanTuiMoney(item) {
|
||||||
|
return item.canReturnAmount
|
||||||
if (props.orderInfo.status == 'unpaid') {
|
if (props.orderInfo.status == 'unpaid') {
|
||||||
return returnTotalMoney(item)
|
return returnTotalMoney(item)
|
||||||
} else {
|
} else {
|
||||||
if(props.orderInfo.pointsDiscountAmount>0||props.orderInfo.fullCouponDiscountAmount>0){
|
if(props.orderInfo.pointsDiscountAmount>0||props.orderInfo.fullCouponDiscountAmount>0){
|
||||||
console.log(canTuiKuanPrice.value);
|
return item.canReturnAmount
|
||||||
const bili=Math.floor((item.priceAmount/canTuiKuanPrice.value )*100)/100
|
// const bili=Math.floor((item.priceAmount/canTuiKuanPrice.value )*100)/100
|
||||||
console.log(bili);
|
// return Math.floor((allPrice.value)*bili*100)/100
|
||||||
return Math.floor((allPrice.value)*bili*100)/100
|
|
||||||
// return (item.priceAmount / (canTuiKuanPrice.value + seatFeePrice.value * 1) * props.orderInfo.amount).toFixed(
|
|
||||||
// 2)
|
|
||||||
}else{
|
}else{
|
||||||
return item.priceAmount
|
return item.priceAmount
|
||||||
}
|
}
|
||||||
|
|
@ -420,7 +419,7 @@
|
||||||
if (res) {
|
if (res) {
|
||||||
emits('tuikuan', {
|
emits('tuikuan', {
|
||||||
...item,
|
...item,
|
||||||
priceAmount: returnCanTuiMoney(item)
|
priceAmount: item.canReturnAmount
|
||||||
}, index)
|
}, index)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -504,14 +503,16 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
const youhuiAllPrice = computed(() => {
|
const youhuiAllPrice = computed(() => {
|
||||||
if(props.orderInfo.status!='unpaid'){
|
const n= props.orderInfo.originAmount-props.orderInfo.amount+vipDiscountPrice.value*1
|
||||||
const seatfee=(props.orderInfo.amount==0&&allPrice.value==0)?seatFeePrice.value:0
|
return (n<0?0:n).toFixed(2)
|
||||||
return (goodsOriginAllPrice.value-allPrice.value+seatfee*1).toFixed(2)
|
// if(props.orderInfo.status!='unpaid'){
|
||||||
}
|
// const seatfee=(props.orderInfo.amount==0&&allPrice.value==0)?seatFeePrice.value:0
|
||||||
return (freePrice.value * 1 + vipDiscountPrice.value * 1 + props.orderInfo.fullCouponDiscountAmount + props
|
// return (goodsOriginAllPrice.value-allPrice.value+seatfee*1).toFixed(2)
|
||||||
.orderInfo.pointsDiscountAmount + (props.orderInfo.status == 'unpaid' ? productCoupPrice.value :
|
// }
|
||||||
productCouponDiscountAmount.value) * 1 + (props.orderInfo.discountAmount ||
|
// return (freePrice.value * 1 + vipDiscountPrice.value * 1 + props.orderInfo.fullCouponDiscountAmount + props
|
||||||
0)).toFixed(2)
|
// .orderInfo.pointsDiscountAmount + (props.orderInfo.status == 'unpaid' ? productCoupPrice.value :
|
||||||
|
// productCouponDiscountAmount.value) * 1 + (props.orderInfo.discountAmount ||
|
||||||
|
// 0)).toFixed(2)
|
||||||
|
|
||||||
})
|
})
|
||||||
const packFee = computed(() => {
|
const packFee = computed(() => {
|
||||||
|
|
@ -527,13 +528,21 @@
|
||||||
|
|
||||||
})
|
})
|
||||||
const allPrice = computed(() => {
|
const allPrice = computed(() => {
|
||||||
|
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||||
|
const curTotal = cur.info.reduce((a,
|
||||||
|
b) => {
|
||||||
|
return a + b.canReturnAmount*1
|
||||||
|
}, 0)
|
||||||
|
return prve + curTotal
|
||||||
|
}, 0)
|
||||||
|
return goodsPrice.toFixed(2)
|
||||||
if (props.orderInfo.status == 'unpaid') {
|
if (props.orderInfo.status == 'unpaid') {
|
||||||
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
|
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
|
||||||
return (n < 0 ? 0 : n).toFixed(2)
|
return (n < 0 ? 0 : n).toFixed(2)
|
||||||
}
|
}
|
||||||
const returnAmount=props.orderInfo.seatInfo&&props.orderInfo.seatInfo.returnAmount?props.orderInfo.seatInfo.returnAmount:0
|
const returnAmount=props.orderInfo.seatInfo&&props.orderInfo.seatInfo.returnAmount?props.orderInfo.seatInfo.returnAmount:0
|
||||||
console.log(cantuiSeatFee.value);
|
const canReturnAmount=props.orderInfo.seatInfo&&props.orderInfo.seatInfo.canReturnAmount?props.orderInfo.seatInfo.canReturnAmount:0
|
||||||
const total=props.orderInfo.amount-(returnAmount?returnAmount:cantuiSeatFee.value*1)
|
const total=props.orderInfo.amount-(returnAmount?returnAmount:canReturnAmount)
|
||||||
return (total<=0?0:total).toFixed(2)
|
return (total<=0?0:total).toFixed(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -332,13 +332,14 @@
|
||||||
function pointsConfirm(e) {
|
function pointsConfirm(e) {
|
||||||
accountPoints.num = e
|
accountPoints.num = e
|
||||||
}
|
}
|
||||||
async function calcUsablePoints() {
|
async function calcUsablePoints(orderAmount) {
|
||||||
if (!order.memberId) {
|
if (!order.memberId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log(orderAmount);
|
||||||
const res = await Api.$calcUsablePoints({
|
const res = await Api.$calcUsablePoints({
|
||||||
memberId: order.memberId,
|
memberId: order.memberId,
|
||||||
orderAmount: payPrice.value
|
orderAmount: orderAmount ? orderAmount : payPrice.value
|
||||||
})
|
})
|
||||||
accountPoints.calcRes = res
|
accountPoints.calcRes = res
|
||||||
accountPoints.num = res.maxUsablePoints
|
accountPoints.num = res.maxUsablePoints
|
||||||
|
|
@ -350,12 +351,18 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
async function calcDeDuctionPoints() {
|
async function calcDeDuctionPoints() {
|
||||||
|
if (accountPoints.num <= 0) {
|
||||||
|
accountPoints.price = 0
|
||||||
|
return ''
|
||||||
|
}
|
||||||
const res = await Api.$calcDeDuctionPoints({
|
const res = await Api.$calcDeDuctionPoints({
|
||||||
memberId: order.memberId,
|
memberId: order.memberId,
|
||||||
orderAmount: order.amount,
|
orderAmount: originPrice.value,
|
||||||
points: accountPoints.num
|
points: accountPoints.num
|
||||||
})
|
})
|
||||||
accountPoints.price = res
|
if (res) {
|
||||||
|
accountPoints.price = res
|
||||||
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
watch(() => accountPoints.num, (newval) => {
|
watch(() => accountPoints.num, (newval) => {
|
||||||
|
|
@ -470,48 +477,52 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setQuan(arr) {
|
||||||
|
console.log(arr);
|
||||||
|
discount.discount = 100
|
||||||
|
discount.value = 0
|
||||||
|
discount.currentPrice = order.amount
|
||||||
|
const manjianCoup = arr.filter(v => v.type == 1 && v.num >= 1)
|
||||||
|
let productCoup = arr.filter(v => v.type == 2)
|
||||||
|
console.log(productCoup);
|
||||||
|
//商品券分组
|
||||||
|
let coupMap = {}
|
||||||
|
for (let i in productCoup) {
|
||||||
|
const coup = productCoup[i]
|
||||||
|
if (coupMap.hasOwnProperty(coup.proId)) {
|
||||||
|
coupMap[coup.proId].push(coup)
|
||||||
|
} else {
|
||||||
|
coupMap[coup.proId] = [coup]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(coupMap);
|
||||||
|
for (let key in coupMap) {
|
||||||
|
const arr = coupMap[key]
|
||||||
|
for (let i in arr) {
|
||||||
|
const coup = arr[i]
|
||||||
|
const proCoupStartIndex = returnProCoupStartIndex(arr, i)
|
||||||
|
console.log(proCoupStartIndex);
|
||||||
|
const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
|
||||||
|
coup.num)
|
||||||
|
const num = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
|
||||||
|
coup.num = num
|
||||||
|
console.log($goodsPayPriceMap[coup.proId]);
|
||||||
|
const findGoods = order.detailList.find(v => v.productId == coup.proId)
|
||||||
|
const isMember = findGoods.isMember
|
||||||
|
coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
|
||||||
|
proCoupStartIndex, num, isMember).toFixed(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
productCoup = productCoup.filter(v => v.num >= 1)
|
||||||
|
console.log(productCoup);
|
||||||
|
pays.quan = [...manjianCoup, ...productCoup]
|
||||||
|
console.log(pays.quan);
|
||||||
|
}
|
||||||
|
|
||||||
function watchChooseQuan() {
|
function watchChooseQuan() {
|
||||||
uni.$off('choose-quan')
|
uni.$off('choose-quan')
|
||||||
uni.$on('choose-quan', (arr) => {
|
uni.$on('choose-quan', (arr) => {
|
||||||
console.log(arr);
|
setQuan(arr)
|
||||||
discount.discount = 100
|
|
||||||
discount.value = 0
|
|
||||||
discount.currentPrice = order.amount
|
|
||||||
const manjianCoup = arr.filter(v => v.type == 1 && v.num >= 1)
|
|
||||||
let productCoup = arr.filter(v => v.type == 2)
|
|
||||||
console.log(productCoup);
|
|
||||||
//商品券分组
|
|
||||||
let coupMap = {}
|
|
||||||
for (let i in productCoup) {
|
|
||||||
const coup = productCoup[i]
|
|
||||||
if (coupMap.hasOwnProperty(coup.proId)) {
|
|
||||||
coupMap[coup.proId].push(coup)
|
|
||||||
} else {
|
|
||||||
coupMap[coup.proId] = [coup]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(coupMap);
|
|
||||||
for (let key in coupMap) {
|
|
||||||
const arr = coupMap[key]
|
|
||||||
for (let i in arr) {
|
|
||||||
const coup = arr[i]
|
|
||||||
const proCoupStartIndex = returnProCoupStartIndex(arr, i)
|
|
||||||
console.log(proCoupStartIndex);
|
|
||||||
const coupUseNum = returnProductCanUseNum($goodsPayPriceMap[coup.proId], proCoupStartIndex,
|
|
||||||
coup.num)
|
|
||||||
const num = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
|
|
||||||
coup.num = num
|
|
||||||
console.log($goodsPayPriceMap[coup.proId]);
|
|
||||||
const findGoods = order.detailList.find(v => v.productId == coup.proId)
|
|
||||||
const isMember = findGoods.isMember
|
|
||||||
coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
|
|
||||||
proCoupStartIndex, num, isMember).toFixed(2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
productCoup = productCoup.filter(v => v.num >= 1)
|
|
||||||
console.log(productCoup);
|
|
||||||
pays.quan = [...manjianCoup, ...productCoup]
|
|
||||||
console.log(pays.quan);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -702,9 +713,19 @@
|
||||||
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
|
const orderRes = await orderApi.tbOrderInfoDetail(order.orderId)
|
||||||
Object.assign(order, orderRes)
|
Object.assign(order, orderRes)
|
||||||
$goodsPayPriceMap = returnGoodsPayPriceMap(order.detailList)
|
$goodsPayPriceMap = returnGoodsPayPriceMap(order.detailList)
|
||||||
console.log($goodsPayPriceMap);
|
const hasSelQuan = orderRes.couponInfoList ? JSON.parse(orderRes.couponInfoList) : {
|
||||||
|
fullReductionCoupon: [],
|
||||||
|
productCoupon: []
|
||||||
|
};
|
||||||
|
const fullReductionCoupon = hasSelQuan.fullReductionCoupon.filter(v => v.type == 1)
|
||||||
|
const productCoupon = hasSelQuan.productCoupon.filter(v => v.type == 2)
|
||||||
|
setQuan([...fullReductionCoupon, ...productCoupon])
|
||||||
|
|
||||||
if (orderRes.memberId) {
|
if (orderRes.memberId) {
|
||||||
calcUsablePoints()
|
calcUsablePoints()
|
||||||
|
if (orderRes.pointsNum) {
|
||||||
|
accountPoints.sel = true
|
||||||
|
}
|
||||||
queryAllShopUser({
|
queryAllShopUser({
|
||||||
id: orderRes.memberId
|
id: orderRes.memberId
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
|
@ -733,7 +754,8 @@
|
||||||
// const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
|
// const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
|
||||||
// const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
|
// const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
|
||||||
// return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
|
// return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
|
||||||
const total = (order.amount || 0) - productCouponDiscountAmount.value - discount.value -
|
const total = (originPrice.value) - vipDiscount.value - productCouponDiscountAmount.value - discount
|
||||||
|
.value -
|
||||||
fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
|
fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
|
||||||
return (total < 0 ? 0 : total).toFixed(2)
|
return (total < 0 ? 0 : total).toFixed(2)
|
||||||
})
|
})
|
||||||
|
|
@ -750,8 +772,11 @@
|
||||||
return goodsPrice.toFixed(2)
|
return goodsPrice.toFixed(2)
|
||||||
})
|
})
|
||||||
const originPrice = computed(() => {
|
const originPrice = computed(() => {
|
||||||
const n=(order.amount || 0) * 1 + vipDiscount.value * 1
|
const n = (order.amount || 0) * 1 + vipDiscount.value * 1 + (order.fullCouponDiscountAmount || 0) + (order
|
||||||
return n.toFixed(2)
|
.productCouponDiscountAmount || 0) +
|
||||||
|
(order.pointsDiscountAmount || 0)
|
||||||
|
|
||||||
|
return n.toFixed(2)
|
||||||
})
|
})
|
||||||
const fullCouponDiscountAmount = computed(() => {
|
const fullCouponDiscountAmount = computed(() => {
|
||||||
return pays.quan.filter(v => v.type == 1).reduce((prve, cur) => {
|
return pays.quan.filter(v => v.type == 1).reduce((prve, cur) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue