下单退款相关更新

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>

View File

@@ -6,17 +6,16 @@
{{data.productName}}
</view>
<view class="u-flex u-m-t-32" :class="{'gray':data.productId=='-999'}">
<up-number-box :min="0" :max="data.num" :buttonSize="44" v-model="number" integer
<up-number-box :min="0" :max="maxNum" :buttonSize="44" v-model="number" integer
:disabled="data.productId=='-999'">
<template #minus>
<view class="minus number-box-btn">
</view>
<view class="minus number-box-btn"></view>
</template>
<template #input>
<view class="u-flex-1 u-row-center u-text-center input">
<up-input :disabled="data.productId=='-999'" @change="parseIntNumber($event,false)"
@blur="parseIntNumber($event,true)" v-model="number" border="none"
type="number"></up-input>
type="digit"></up-input>
</view>
</template>
<template #plus>
@@ -83,6 +82,8 @@
let model = ref(null)
let modelShow = ref(props.show)
let number = ref(0)
let maxNum = ref(0)
const tags = ref([{
label: "点错",
checked: false
@@ -110,16 +111,12 @@
})
function parseIntNumber(val, isNow) {
console.log(val)
let newval = val * 1
if (newval > props.data.num) {
newval = props.data.num
}
// 判断是否是称重商品。如果是可以输入小数
if (props.data.isWeight != 1) {
if (newval < 1) {
newval = 1
}
if (newval > props.data.num - props.data.returnNum) {
newval = props.data.num - props.data.returnNum
}
if (isNow) {
number.value = newval * 1
return
@@ -149,9 +146,8 @@
function open() {
model.value.open()
if (props.data.productId == '-999') {
number.value = props.data.num
}
number.value = props.data.num - props.data.returnNum
maxNum.value = props.data.num - props.data.returnNum
}
function close() {

View File

@@ -109,7 +109,7 @@
*/
async function getOrderDetail () {
let res = await getHistoryOrder({orderId: options.id})
console.log(res)
console.log("订单详情===",res)
if(res.userId){
shopUserDetail({userId:res.userId}).then(res=>{
if(res){
@@ -125,13 +125,12 @@
info: value,
placeNum: key
}))
console.log("goodsList===",orderDetail.goodsList);
orderDetail.info = res
console.log("orderDetail===",orderDetail);
}
function onSeatFeeTuicai(seatFee) {
seatFee={...seatFee,num:seatFee.num,productName:seatFee.productName}
console.log(seatFee);
tuicai.show = true
tuicai.isSeatFee = seatFee
tuicai.selGoods = seatFee
@@ -143,7 +142,6 @@
}
async function onSeatFeeTuiKuan(seatFee) {
console.log(seatFee,'调试1');
const canTuikuan=await hasTuiKuan()
if(!canTuikuan){
return
@@ -177,10 +175,8 @@
tuicai.selGoods = goods
}
async function tuicaiConfirm(e) {
console.log(e)
const res = await refundOrder(e)
tuicai.show = false
console.log(res)
if(res){
go.back()
}else{
@@ -216,9 +212,9 @@
if(!canTuikuan){
return
}
console.log(goods,'debug');
if (Array.isArray(goods)) {
go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info),
goodsList:JSON.stringify(goods)
})
@@ -229,11 +225,10 @@
goods.unitPrice = goods.unitPrice
goods.userCouponId = goods.userCouponId ? goods.userCouponId:''
go.to('PAGES_ORDER_TUIKUAN', {
orderInfo: JSON.stringify(orderDetail.info),
goodsList:JSON.stringify([goods])
})
}
}
@@ -280,7 +275,6 @@
function watchEmit() {
uni.$off('orderDetail:update')
uni.$once('orderDetail:update', (newval) => {
console.log(newval);
getOrderDetail()
})
}

View File

@@ -28,7 +28,7 @@
<view class="u-m-l-16">{{formatTime(data.createTime)}}</view>
</view>
<view class="u-m-t-32">
<view class="u-font-32">{{goosZhonglei}}种商品{{goodsNumber}}</view>
<view class="u-font-32">{{data.goods.length}}商品</view>
<view class="border-bottom u-p-b-32">
<view class="" v-for="(item,index) in data.goods" :key="index">
<view class="u-flex u-row-between u-col-top u-m-t-32" v-if="item.productId!=-999">
@@ -38,8 +38,8 @@
{{item.skuName}}
</view>
</view>
<view class="u-flex u-flex-1 u-row-right">
<view>×{{item.num}}</view>
<view class="u-flex u-flex-1 u-row-right" style="align-items: center;">
<view style="margin-right: 10rpx;">×{{item.num}}</view>
<template v-if="item.userCouponId">
<view class="u-text-right u-relative" :style="computedPriceStyle()">
<text class="line-th">{{item.payAmount}}</text>
@@ -109,10 +109,11 @@
</template>
<script setup>
import { computed, reactive, ref, watch } from 'vue';
import dayjs from 'dayjs';
import orderEnum from '@/commons/orderEnum.js'
import go from '@/commons/utils/go.js'
import { computed, reactive, ref, watch } from 'vue';
import { mathFloorPrice } from '@/commons/utils/goodsUtil.js'
const emits = defineEmits(['printOrder'])
const props = defineProps({
data: {
@@ -139,17 +140,7 @@
const priceSize = 9
let minWidth=ref(36)
/**
* 计算菜品价格
* @param {Object} item
*/
function goodsPriceAmount(item) {
const total=(item.payAmount * item.num).toFixed(2)
const minW=total.length * priceSize + 15
minWidth.value=minW<minWidth.value?minWidth.value:minW
return total
}
function computedPriceStyle() {
return {
@@ -166,7 +157,6 @@
} else {
$goodsMap[goods.productId] = goods.num * 1
goosZhonglei.value += 1
goodsNumber.value += goods.num * 1
}
}
}

View File

@@ -251,11 +251,12 @@
returnProductCoupAllPrice,
returnProductCanUseNum
} from '../quan_util.js'
import { mathFloorPrice } from '@/commons/utils/goodsUtil.js'
import { getCouponList } from '@/http/api/coupon.js'
import { getHistoryOrder } from '@/http/api/order.js'
import { getPayTypeList } from '@/http/api/payType.js'
import { scanPay,microPay,cashPay,vipPay,creditPay,getOrderPayUrl } from '@/http/api/pay.js'
import { scanPay,microPay,cashPay,vipPay,creditPay,getOrderPayUrl,queryOrderStatus } from '@/http/api/pay.js'
import { shopUserDetail } from '@/http/api/shopUser.js'
import { calcUsablePoints,calcDeductionAmount,payedDeductPoints,consumeAwardPoints } from '@/http/api/points.js'
@@ -390,22 +391,45 @@
const packAmount = computed(() => {
if(pageData.goodsList){
let price = pageData.goodsList.filter(v => v.packNumber > 0 && v.status !== "return").reduce((a, b) => {
return a + (b.packNumber * b.packAmount)
console.log(b)
return a + ((b.packAmount||0)*b.packNumber).toFixed(2)*1
}, 0)
console.log(price)
return price
}
})
/**
* 订单金额
* 桌位费
*/
const tableFee = computed(() => {
return order.seatNum > 0 ? order.seatNum*order.seatAmount : 0
})
/**
* 菜品金额
*/
const originPrice = computed(() => {
console.log("order===",order)
if(pageData.goodsList){
let goodsPrice = pageData.goodsList.filter(v => v.price != 0 && v.status !== "return").reduce((a, b) => {
return a + (b.num * b.price)
return a + parseFloat(mathFloorPrice(b.num * b.unitPrice,b))
}, 0)
return (goodsPrice + (pageData.seatNum*uni.getStorageSync("shopInfo").tableFee||0) + packAmount.value).toFixed(2)
console.log("菜品原金额===",goodsPrice)
return (parseFloat(goodsPrice) + parseFloat(tableFee.value) + parseFloat(packAmount.value)).toFixed(2)
}
})
const newOriginPrice = computed(() => {
if(pageData.goodsList){
let goodsPrice = pageData.goodsList.filter(v => v.price != 0 && v.status !== "return").reduce((a, b) => {
return a + parseFloat(mathFloorPrice(b.num * b.unitPrice,b) - mathFloorPrice(b.returnNum*b.unitPrice,b) - mathFloorPrice(b.refundNum*b.unitPrice,b))
}, 0)
console.log("减去退款退费的菜品金额===",goodsPrice)
console.log("桌位费===", tableFee.value)
return (goodsPrice + tableFee.value + packAmount.value).toFixed(2)
}
})
@@ -468,7 +492,7 @@
* 支付金额
*/
const payPrice = computed(() => {
console.log("originPrice===",originPrice.value)
console.log("originPrice===",newOriginPrice.value)
console.log("vipDiscount===",vipDiscount.value)
console.log("discountSaleAmount===",discountSaleAmount.value)
console.log("pointCanDicountPrice===",pointCanDicountPrice.value)
@@ -476,7 +500,7 @@
console.log("discount===",discount.value)
console.log("fullCouponDiscountAmount===",fullCouponDiscountAmount.value)
console.log("accountPoints===",accountPoints)
let total = (originPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
let total = (newOriginPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
.value - fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
console.log("payPrice===",total)
return (total < 0 ? 0 : total).toFixed(2)
@@ -486,13 +510,12 @@
* 积分使用前金额
*/
const orderAmount = computed(() => {
let total = (originPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
let total = (newOriginPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
.value - fullCouponDiscountAmount.value
console.log(total)
return (total < 0 ? 0 : total).toFixed(2)
})
watch(() => accountPoints.sel, (newval) => {
if (newval) {
calcDeDuctionPoints()
@@ -943,12 +966,27 @@
}
}
} catch (error) {
console.log(error)
let res;
let timer;
if( error.code == 211 && error.msg == '等待用户付款'){
uni.showLoading({
title: '支付中...'
})
timer = setInterval(async ()=>{
res = await queryOrderStatus({orderId: pars.orderId})
if ( res == 'done') {
clearInterval(timer)
uni.hideLoading()
paySuccess()
}
console.log(res)
},1000)
}
payStatus = '';
return false;
}
paySuccess()
}
@@ -959,13 +997,14 @@
infoBox.showToast('支付成功')
payStatus = 'success'
setTimeout(() => {
uni.removeStorageSync("table_code")
// uni.$emit('orderDetail:update')
uni.$emit('get:table')
uni.$emit('update:orderDetail')
uni.navigateBack({
delta: 1
})
}, 500)
}, 1500)
}
/**

View File

@@ -18,6 +18,8 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
return price * coup.num
}
//返回新的商品列表,过滤掉退菜的,退单的商品
export function returnNewGoodsList(arr) {
let goods_list = []
@@ -44,7 +46,6 @@ export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
if (selCoupNumber >= findGoodsTotalNumber) {
return false
}
console.log(selCoupNumber,findGoodsTotalNumber);
return findGoodsTotalNumber < selCoupNumber ? false : true
}
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
@@ -61,7 +62,6 @@ export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
const discountAmount = (price * coup.num).toFixed(2)
console.log(discountAmount);
// const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
// const canUse=discountAmount>0
@@ -96,7 +96,6 @@ export function returnProductPayPrice(goods,vipUser){
}
//返回商品券抵扣的商品价格
export function returnProductCoupAllPrice(productPriceArr,startIndex,num,isMember=true){
console.log(productPriceArr);
return productPriceArr.slice(startIndex,startIndex+num).reduce((prve,cur)=>{
let curPrice=0
if(typeof cur==='object'){
@@ -110,13 +109,10 @@ export function returnProductCoupAllPrice(productPriceArr,startIndex,num,isMembe
//返回商品券可抵扣的商品数量
export function returnProductCanUseNum(productPriceArr,startIndex,num){
console.log(productPriceArr);
console.log(num);
let n=0;
for(let i=0;i<num;i++){
if(productPriceArr[startIndex*1+i]){
n+=1
console.log(n);
}else{
break
}
@@ -136,12 +132,10 @@ export function returnGoodsPayPriceMap(goodsArr){
Object.values(goodsArr).forEach(item=>{
goods_arr = [...goods_arr,...Object.values(item)]
})
console.log(goods_arr)
return goods_arr.reduce((prve,cur)=>{
if(!prve.hasOwnProperty(cur.productId)){
prve[cur.productId]=[]
}
console.log(Math.ceil(cur.num))
let arr = new Array(Math.ceil(cur.num)).fill(cur).map(v=>{
return {
memberPrice:v.memberPrice?v.memberPrice:v.price,
@@ -149,7 +143,6 @@ export function returnGoodsPayPriceMap(goodsArr){
}
})
prve[cur.productId].push(...arr)
console.log(prve)
return prve
},{})
@@ -167,7 +160,6 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
let coupMap={}
for(let i in coupArr){
const coup=coupArr[i]
console.log(coup)
if(coupMap.hasOwnProperty(coup.proId)){
coupMap[coup.proId].push(coup)
}else{
@@ -192,15 +184,12 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
})
goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
const arr=new Array(cur.number).fill(cur.payPrice)
console.log(arr);
prve.push(...arr)
return prve
},[])
}
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
console.log(coup);
const coupNum = Math.min(goodsPayPriceMap[coup.proId].length,coup.number)
console.log(coupNum);
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
}
}

View File

@@ -1,16 +1,23 @@
<template>
<view class="min-page bg-gray u-p-30">
<view class="bg-fff u-p-24 border-r-12 u-flex u-row-between">
<view>全退</view>
<view>
<my-radio v-model="allTui" :disabled="option.productId=='-999'"></my-radio>
<view class="bg-fff u-p-l-30 u-p-r-30 ">
<view class="myTabs u-m-t-20">
<my-tabs :list="pageData.tabsList" :modelValue="pageData.tabsIndex" :textKey="'label'" @change="tabsChange"></my-tabs>
</view>
</view>
<view v-if="pageData.tabsIndex == 2" class="bg-fff u-p-24 border-r-12 u-flex u-row-between" style="margin-top: 30rpx;">
<up-input type="digit" placeholder="请输入退款金额" @change="parseIntNumber($event)" border="surround" v-model="pageData.modify" >
<template #prefix>
<up-text text="¥" margin="0 3px 0 0" type="tips" ></up-text>
</template>
</up-input>
</view>
<view class="u-m-t-24 u-font-24 u-font-24">
<text class="color-red">*</text>
<text>客座费只能全退</text>
</view>
<view class="bg-fff border-r-12 list u-m-t-32">
<view v-if="pageData.tabsIndex != 2" class="bg-fff border-r-12 list u-m-t-32">
<view class="u-flex u-row-between border-top item u-p-t-32 u-p-b-32"
v-for="(item,index) in orderDetail.goodsList" :key="index">
<view>
@@ -43,23 +50,30 @@
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between" >
<view>支付金额</view>
<view>
{{to2(totalPrice)}}
{{to2(orderDetail.info.payAmount)}}
</view>
</view>
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between" >
<view>剩余可退金额</view>
<view class="color-red">
{{to2(orderDetail.info.payAmount - orderDetail.info.refundAmount)}}
</view>
</view>
<view class="bg-fff u-m-t-32 u-p-24 border-r-12 u-flex u-row-between" >
<view>退款金额</view>
<view class="color-red">
{{to2(tuikuanPrice)}}
{{to2(pageData.tabsIndex == 1 ? alltuikuanPrice : (pageData.tabsIndex == 2 ? pageData.modify : tuikuanPrice))}}
</view>
</view>
</template>
<view class="bg-fff u-p-24 border-r-12 u-m-t-32">
<!-- <view class="bg-fff u-p-24 border-r-12 u-m-t-32">
<view>退回优惠券</view>
<view class="u-font-24 color-999 u-m-t-16" v-if="!option.userCouponId">
该订单未使用优惠券
</view>
</view>
</view> -->
<view class="bg-fff u-p-24 border-r-12 u-m-t-32">
<view>
<text class="color-red">*</text>
@@ -92,36 +106,25 @@
import infoBox from '@/commons/utils/infoBox.js';
import {hasPermission} from '@/commons/utils/hasPermission.js'
import { refundOrder } from '@/http/api/order.js'
let allTui = ref(false)
import { mathFloorPrice } from '@/commons/utils/goodsUtil.js'
let note = ref('')
const tuikuan = reactive({
list: ['点错', '数量点错', '客人要求', '协商退费'],
sel: -1
})
const pageData = reactive({
tabsList: [
{label: '部分退款', value: 0},
{label: '全部退款', value: 1},
{label: '自定义退款', value: 2},
],
tabsIndex: 0,
modify: '',
})
const option=reactive({
productId:'-999'
})
onLoad((opt) => {
console.log(JSON.parse(opt.goodsList));
orderDetail.goodsList = JSON.parse(opt.goodsList)
option.productId = orderDetail.goodsList[0].productId
option.orderId = orderDetail.goodsList[0].orderId
if(option.productId=='-999'){
allTui.value=true
}
})
watch(() => allTui.value, (newval) => {
orderDetail.goodsList.map(v => {
v.number = newval ? v.num : 0
})
})
function changeTuiKuanSel(i) {
tuikuan.sel = i
}
const orderDetail = reactive({
goodsList: [],
info: {},
@@ -129,53 +132,120 @@
totalAmount: 0
}
})
onLoad((opt) => {
orderDetail.info = JSON.parse(opt.orderInfo)
orderDetail.goodsList = JSON.parse(opt.goodsList)
console.log(orderDetail)
option.productId = orderDetail.goodsList[0].productId
option.orderId = orderDetail.goodsList[0].orderId
})
/**
* tabs切换
* @param {Object} i
*/
function tabsChange(i) {
pageData.tabsIndex = pageData.tabsList[i].value
if( pageData.tabsIndex == 0){ // 部分退款
orderDetail.goodsList.map(v => {
v.number = '0.00'
})
}
if( pageData.tabsIndex == 1){ // 全部退款
orderDetail.goodsList.map(v => {
v.number = v.num.toFixed(2)
})
}
if( pageData.tabsIndex == 2){ // 自定义退款
orderDetail.goodsList.map(v => {
v.number = '0.00'
})
}
}
function changeTuiKuanSel(i) {
tuikuan.sel = i
}
function parseIntNumber (e) {
if ( e > (orderDetail.info.payAmount - orderDetail.info.refundAmount) ) {
setTimeout(()=>{
pageData.modify = (orderDetail.info.payAmount - orderDetail.info.refundAmount).toFixed(2)
},100)
}
}
/**
* 菜品总数量
*/
const totalNumber = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
return prve + cur.num * 1
}, 0)
})
/**
* 退款菜品总数量
*/
const tuikuanNumber = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
return prve + cur.number * 1
}, 0)
})
const totalPrice = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
return prve + cur.priceAmount * 1
}, 0)
})
/**
* 退款总金额
*/
const tuikuanPrice = computed(() => {
return orderDetail.goodsList.reduce((prve, cur) => {
const n=(cur.number/cur.num*100) * cur.priceAmount
console.log(n)
console.log((n/100).toFixed(2))
console.log(parseFloat(prve) + parseFloat((n/100).toFixed(2)))
return parseFloat(prve) + parseFloat((n/100).toFixed(2))
const n= mathFloorPrice(cur.number * cur.unitPrice,cur)
return (parseFloat(prve) + parseFloat(n)).toFixed(2)
}, 0)
})
/**
* 剩余退款金额
*/
const surplusRefundPrice = computed(() => {
return orderDetail.info.payAmount - orderDetail.goodsList.reduce((prve, cur) => {
const n = parseFloat( mathFloorPrice(cur.refundNum * cur.unitPrice,cur))
return (parseFloat(prve) + parseFloat(n)).toFixed(2)*1
}, 0)
})
/**
* 退款总金额
*/
const alltuikuanPrice = computed(() => {
return orderDetail.info.payAmount - orderDetail.goodsList.reduce((prve, cur) => {
const n = parseFloat( mathFloorPrice(cur.refundNum * cur.unitPrice,cur))
return (parseFloat(prve) + parseFloat(n)).toFixed(2)*1
}, 0)
})
function to2(n) {
return Number(n).toFixed(2);
}
function changeItem(item, step) {
if( item.num <= 0){
return
}
if(item.productId=='-999'){
return
}
console.log(item);
if( pageData.tabsIndex != 0) {
return;
}
let newval = item.number * 1 + step * 1;
if (newval <= 0) {
newval = 0;
}
if (newval >= (item.num-(item.refundNum>0?item.refundNum:0))) {
newval = (item.num-(item.refundNum>0?item.refundNum:0));
if (newval >= (item.num)) {
newval = item.num
}
item.number = newval;
allTui.value = totalNumber.value == tuikuanNumber.value ? true : false;
console.log(totalNumber.value)
console.log(tuikuanNumber.value)
item.number = newval.toFixed(2);
pageData.tabsIndex = totalNumber.value == tuikuanNumber.value ? 1 : 0;
}
/**
@@ -186,20 +256,18 @@
if(!canTuikuan){
return infoBox.showToast('您没有退款权限')
}
if (tuikuanNumber.value <= 0) {
if (pageData.tabsIndex != 2&&tuikuanNumber.value <= 0) {
return infoBox.showToast('退款商品数量不能为0')
}
const selTag=tuikuan.list[tuikuan.sel]
const noteResult=`${selTag?selTag:''}${note.value?(','+note.value):''}`
if (!noteResult) {
return infoBox.showToast('请输入或选择退款原因!')
}
let refundAmount = orderDetail.goodsList.reduce((prve, cur) => {
return prve + (cur.number * 1 * cur.unitPrice)
}, 0)
let params = {
orderId: option.orderId,
refundAmount: refundAmount.toFixed(2),
refundReason: noteResult,
refundDetails: orderDetail.goodsList.filter(v=>v.number*1).map(v=>{
return {
@@ -209,6 +277,16 @@
}
})
}
if( pageData.tabsIndex == 2){
params.modify = true
params.refundAmount = (pageData.modify*1).toFixed(2)
} else {
params.modify = false
params.refundAmount = pageData.tabsIndex == 1 ? alltuikuanPrice.value : tuikuanPrice.value
}
if ( pageData.tabsIndex == 2 && params.refundAmount > orderDetail.info.payAmount){
return infoBox.showToast('退款金额不能大于付款金额!')
}
await refundOrder(params)
infoBox.showToast('退款请求提交成功')
setTimeout(()=>{