下单退款相关更新

This commit is contained in:
GaoHao
2025-03-15 18:30:27 +08:00
parent c2135c6119
commit 994cf8bf2b
54 changed files with 682 additions and 2408 deletions

View File

@@ -22,7 +22,11 @@
<view class="item u-m-b-32" v-for="(item,index) in order.info" :key="index">
<view class="u-flex u-col-top">
<view class="u-flex">
<image class="img" :src="item.coverImg||item.productImg" mode=""></image>
<image v-if="item.isTemporary == 0" class="img" :src="item.coverImg||item.productImg" mode=""></image>
<view v-else style="background-color: #3f9eff; width: 152rpx;height: 152rpx;line-height: 152rpx;text-align: center;color: #fff;" >
临时菜
</view>
</view>
<view class="u-p-l-32 u-flex-1">
<view class="u-flex u-row-between u-col-top">
@@ -37,30 +41,35 @@
{{item.name||item.productName}}
</view>
</view>
<view class="u-flex u-m-t-8">
<view class="u-m-r-20 u-flex" v-if="item.isGift">
<uni-tag text="赠送"
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
</uni-tag>
<view class="u-flex u-m-t-8" style="flex-direction: column;align-items: flex-start;">
<view class="u-flex u-m-b-8">
<view class="u-m-r-20 u-flex" v-if="item.isGift">
<uni-tag text="赠送"
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
</uni-tag>
</view>
<view class="u-m-r-20 u-flex " v-if="item.userCouponId">
<uni-tag :text=" productCouponDikou(item)"
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
</uni-tag>
</view>
<view class="u-m-r-20 u-flex" v-if="item.packNumber > 0">
<uni-tag
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
size="small" text="打包" inverted type="success" />
</view>
</view>
<view class="u-m-r-20 u-flex " v-if="item.userCouponId">
<uni-tag :text=" productCouponDikou(item)"
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
</uni-tag>
</view>
<view class="u-m-r-20 u-flex" v-if="item.packNumber > 0">
<uni-tag
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
size="small" text="打包" inverted type="success" />
</view>
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnAmount">
<view class="color-666">退款金额:</view>
<view class="color-999 u-m-l-6">{{item.unitPrice*item.refundNum}}</view>
</view>
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnNum">
<view class="color-666">退菜数量:</view>
<view class="color-999 u-m-l-6">{{item.returnNum}}</view>
<view class="u-flex u-m-t-8">
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.refundNum>0">
<view class="color-666">退款金额:</view>
<view class="color-999 u-m-l-6">{{item.refundNum*item.unitPrice}}</view>
</view>
<view class="u-m-r-20 u-font-24 u-flex" v-if="item.returnNum">
<view class="color-666">退菜数量:</view>
<view class="color-999 u-m-l-6">{{item.returnNum}}</view>
</view>
</view>
</view>
<view class="color-999 u-font-24 u-m-t-8">{{item.skuName||''}}</view>
@@ -70,8 +79,9 @@
</view>
</view>
<view class="u-text-right u-m-t-28">
<template v-if="item.refundNum>0">
<view>{{(returnTotalMoney(item)-item.refundNum*item.unitPrice).toFixed(2)}}</view>
<template v-if="item.refundNum>0||item.returnNum>0">
<!-- <view>{{mathFloorPrice( - mathFloorPrice(parseFloat(item.returnNum*item.unitPrice),item) - mathFloorPrice(parseFloat(item.refundNum*item.unitPrice),item))}}</view> -->
<view>{{mathFloorPrice( parseFloat(mathFloorPrice(item.num*item.unitPrice),item) - (parseFloat(mathFloorPrice(item.returnNum*item.unitPrice,item)) + parseFloat(mathFloorPrice(item.refundNum*item.unitPrice,item))))}}</view>
<view class="line-th color-666 ">{{returnTotalMoney(item)}}</view>
</template>
<template v-else-if="item.userCouponId">
@@ -99,24 +109,29 @@
</view>
</view>
<template v-if="canTuicai(orderInfo,item)">
<view class="u-flex u-row-right gap-20 u-m-t-24" v-if="item.returnNum*item.returnAmount<item.payAmount">
<!-- <my-button :height="60" color="#333" plain type="cancel" shape="circle">更多操作</my-button> -->
<view class="u-flex u-row-right gap-20 u-m-t-24" v-if="item.returnNum*item.unitPrice<item.num*item.unitPrice">
<my-button :width="128" :height="48" plain shape="circle" @tap="tuicai(item,index)"><text
class="no-wrap">退菜</text></my-button>
</view>
</template>
<template v-if="canTuiKuan(orderInfo,item)">
<view class="u-flex u-row-right gap-20 u-m-t-20">
<my-button :width="128" :height="48" plain shape="circle" @tap="tuikuan(item,index)"><text
class="no-wrap">{{item.userCouponId?'退券':'退款' }}</text> </my-button>
</view>
</template>
</view>
</view>
</view>
<view class="u-m-t-32">
<template v-if="seatFeePrice&&seatFeePrice>0">
<view class="u-flex u-row-between border-top u-p-t-32 u-p-b-32 u-col-top">
<view class="no-wrap u-m-r-32">桌位费</view>
<view>{{seatFeePrice||'0.00'}}</view>
</view>
</template>
<template v-if="allPpackFee&&allPpackFee>0">
<view class="u-flex u-row-between border-top u-p-t-32 u-p-b-32 u-col-top">
<view class="no-wrap u-m-r-32">打包费</view>
<view>{{allPpackFee||'0.00'}}</view>
</view>
</template>
<view class="u-flex u-row-between border-top u-p-t-32">
<view>
<template v-if="orderInfo.status=='unpaid'">
@@ -136,6 +151,8 @@
<view class="color-red u-m-r-6 ">
已优惠{{youhuiAllPrice}}
</view>
<!-- <up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon> -->
</view>
<!-- <view>
<text>小计</text>
@@ -144,12 +161,12 @@
</view>
</view>
<template v-if="orderInfo.refundAmount">
<view class="u-flex u-row-between u-m-t-32">
<view>退款金额</view>
<view class="color-999">
<text class="">{{(orderInfo.refundAmount).toFixed(2)}}</text>
<text class="">{{mathFloorPrice(orderInfo.refundAmount)}}</text>
</view>
</view>
<view class="u-flex u-row-between u-m-t-32">
@@ -177,13 +194,13 @@
<template v-if="orderInfo.status=='unpaid'">
<view>
<text>总计</text>
<text class="font-bold u-font-32">{{orderInfo.originAmount.toFixed(2)}}</text>
<text class="font-bold u-font-32">{{allPrice}}</text>
</view>
</template>
<template v-else>
<view>
<text>总计</text>
<text class="font-bold u-font-32">{{orderInfo.payAmount.toFixed(2)}}</text>
<text class="font-bold u-font-32">{{mathFloorPrice(orderInfo.payAmount)}}</text>
</view>
</template>
@@ -240,22 +257,11 @@
</template>
<script setup>
import {
computed,
reactive
} from 'vue';
import { computed, reactive } from 'vue';
import color from '@/commons/color.js'
import {
hasPermission
} from '@/commons/utils/hasPermission.js'
import {
isTui,
isTuiCai,
isGift,
canTuiKuan,
canTuicai,
numSum
} from '@/commons/utils/goodsUtil.js'
import { hasPermission } from '@/commons/utils/hasPermission.js'
import { isTui, isTuiCai, isGift, canTuiKuan, canTuicai, mathFloorPrice } from '@/commons/utils/goodsUtil.js'
const pop = reactive({
youhui: false
})
@@ -313,6 +319,7 @@
res.useType = props.orderInfo.useType
res.tableId = props.orderInfo.tableId
arr.push(res)
})
})
uni.navigateTo({
@@ -326,12 +333,10 @@
const goodsNumber = computed(() => {
let result = 0
result = props.data.reduce((a, b) => {
const bTotal = b.info.reduce((prve, cur) => {
return prve + (cur.number || cur.num) * 1;
}, 0);
const bTotal = b.info.length
return a + bTotal
}, 0)
return result
return result.toFixed(0)
})
function returnProductCoupPrice(item) {
if (!item.isMember) {
@@ -353,7 +358,6 @@
}, 0)
return prve + curTotal
}, 0)
console.log(n);
return n.toFixed(2)
})
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
@@ -366,7 +370,7 @@
}
function returnTotalMoney(item) {
return (item.payAmount).toFixed(2)
return (Math.floor(item.num*item.unitPrice*100)/100).toFixed(2)
}
function returnCanTuiMoney(item) {
// if (props.orderInfo.status == 'unpaid') {
@@ -377,7 +381,7 @@
} else if (item.price != item.unitPrice) {
return item.price*item.num
} else {
return item.payAmount
return (Math.floor(item.num*item.unitPrice*100)/100).toFixed(2)
}
// }
@@ -390,8 +394,6 @@
}, 0)
return prve + curTotal
}, 0)
console.log(goodsTotal);
console.log(seatFeePrice.value);
return (goodsTotal + seatFeePrice.value * 1).toFixed(2)
})
const TuiKuanPrice = computed(() => {
@@ -412,12 +414,7 @@
return prve + curTotal
}, 0)
})
const cantuiSeatFee = computed(() => {
let seatFee = props.orderInfo.seatInfo ? (props.orderInfo.seatInfo.seatAmount) : 0
const bili = Math.floor((seatFee / canTuiKuanPrice.value) * 100) / 100
seatFee = Math.floor((props.orderInfo.amount - props.orderInfo.refundAmount) * bili * 100) / 100
return seatFee
})
@@ -435,18 +432,24 @@
function tuikuan(item, index) {
hasPermission('允许退款').then(res => {
if (res) {
console.log(item)
if (Array.isArray(item)) {
let arr = [];
console.log(item)
item.map(v=>{
v.info.map(obj=>{
obj.number = 0
let infoLit = JSON.parse(JSON.stringify(v.info))
infoLit.map((obj,i)=>{
obj.number = '0.00'
obj.skuName = obj.skuName || ''
obj.priceAmount = obj.priceAmount ? obj.priceAmount : (obj.num*obj.unitPrice).toFixed(2)
obj.unitPrice = obj.unitPrice
obj.num = obj.num - obj.returnNum - obj.refundNum
obj.priceAmount = mathFloorPrice(obj.num*obj.unitPrice ,obj)
})
arr = [...arr,...v.info]
arr = [...arr,...infoLit]
})
arr.map((v,e)=>{
if( v.num <= 0){
// arr.splice(e, 1)
}
})
emits('tuikuan', arr)
} else {
@@ -464,30 +467,21 @@
emits('printOrder')
}
/**
* 桌位费
*/
const seatFeePrice = computed(() => {
if (!props.seatFee.seatAmount) {
return 0
}
const n = props.seatFee.seatAmount * (isTui(props.seatFee) ? 0 : 1)
const n = props.orderInfo.seatNum > 0 ? props.orderInfo.seatNum*props.orderInfo.seatAmount : 0
return n.toFixed(2)
})
const discountAmount = computed(() => {
if (props.orderInfo.discountAmount) {
return props.orderInfo.discountAmount
}
return (props.orderInfo.originAmount * (1 - props.orderInfo.discountRatio))
})
const goodsOriginAllPrice = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.reduce((a,
b) => {
return a + (b.num * b.price)
}, 0)
return prve + curTotal
}, 0)
return goodsPrice.toFixed(2)
})
@@ -517,71 +511,69 @@
}, 0)
return goodsPrice.toFixed(2)
})
// 菜品金额
const productCoupPrice = computed(() => {
if (props.orderInfo.status == 'done') {
return props.orderInfo.productCouponDiscountAmount
}
const goodsPrice = props.data.reduce((a, b) => {
const curTotal = b.info.filter(v => !v.isGift && v.userCouponId).reduce((prve,
const curTotal = b.info.filter(v => !v.isGift).reduce((prve,
cur) => {
const isVip = props.user.isVip && cur.isMember
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.price
const price = isVip ? memberPrice : cur.price
const curTotal = price * cur.num
return prve + curTotal
console.log(cur)
let Total = Math.floor(cur.unitPrice * cur.num * 100) / 100
return prve + Total - (cur.returnNum*cur.unitPrice) - (cur.refundNum*cur.unitPrice)
}, 0)
console.log("菜品金额111==",curTotal)
return a + curTotal
}, 0)
console.log("菜品金额==",goodsPrice)
return goodsPrice.toFixed(2)
})
const allPpackFee = computed(() => {
//不是退菜只要有打包费的都计算,包括赠送
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.packNumber > 0).reduce((a,
b) => {
return a + parseFloat(b.packAmount*b.packNumber).toFixed(2)*1
}, 0)
return prve + curTotal
}, 0)
return goodsPrice.toFixed(2)
})
const packFee = computed(() => {
//不是退菜只要有打包费的都计算,包括赠送
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.status !== "return" && (v.returnNum+v.refundNum < v.num)).reduce((a,
b) => {
return a + parseFloat((b.packAmount*(b.num-(b.returnNum+b.refundNum)>b.packNumber?b.packNumber:b.num-(b.returnNum+b.refundNum))).toFixed(2))
}, 0)
return prve + curTotal
}, 0)
return goodsPrice.toFixed(2)
})
const allPrice = computed(() => {
let seatAmount = (props.orderInfo.seatNum * props.orderInfo.seatAmount) || 0
const total = productCoupPrice.value*1 + seatAmount*1 + packFee.value*1
console.log(seatAmount*1)
console.log(packFee.value*1)
console.log(total)
return (total <= 0 ? 0 : total).toFixed(2)
})
/**
* 已优惠金额
*/
const youhuiAllPrice = computed(() => {
console.log(productCoupPrice)
const n = props.orderInfo.originAmount - props.orderInfo.orderAmount + vipDiscountPrice.value * 1
const n = vipDiscountPrice.value * 1
return (n < 0 ? 0 : n).toFixed(2)
})
const packFee = computed(() => {
//不是退菜只要有打包费的都计算,包括赠送
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.filter(v => v.status !== "return").reduce((a,
b) => {
return a + b.packAmount
}, 0)
return prve + curTotal
}, 0)
return goodsPrice.toFixed(2)
})
const allPrice = computed(() => {
const goodsPrice = props.data.reduce((prve, cur) => {
const curTotal = cur.info.reduce((a,
b) => {
return a + (b.status == 'unpaid' ? b.payAmount : b.status == 'return' ? 0 : b
.payAmount * 1)
}, 0)
return prve + curTotal
}, 0)
return goodsPrice.toFixed(2)
if (props.orderInfo.status == 'unpaid') {
const n = goodsOriginAllPrice.value - youhuiAllPrice.value
return (n < 0 ? 0 : n).toFixed(2)
}
const returnAmount = props.orderInfo.seatInfo && props.orderInfo.seatInfo.seatAmount ? props.orderInfo
.seatInfo.seatAmount : 0
const canReturnAmount = props.orderInfo.seatInfo && props.orderInfo.seatInfo.canReturnAmount ? props
.orderInfo.seatInfo.canReturnAmount : 0
const total = props.orderInfo.amount - (seatAmount ? seatAmount : canReturnAmount)
return (total <= 0 ? 0 : total).toFixed(2)
})
</script>
<style lang="scss" scoped>