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

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

@@ -47,16 +47,9 @@
<view class="u-m-l-18 color-999">x{{item.num}}</view>
</view>
<view class="u-flex">
<template v-if="item.type==1">
<view class="color-red">
-{{item.discountAmount}}
</view>
</template>
<template v-if="item.type==2">
<view class="color-red">
-{{(item.discountAmount*discount.discount/100).toFixed(2)}}
</view>
</template>
<view class="color-red">
-{{item.discountAmount}}
</view>
<view class="u-m-l-12" @click="delQuan(index)">
<up-icon :size="16" name="minus-circle-fill" color="rgb(255, 0, 0)"></up-icon>
</view>
@@ -68,12 +61,11 @@
</view>
<view class="border-bottom u-p-b-30" v-if="(discount.price&&discount.currentPrice!=order.amount)||accountPoints.sel">
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
v-if="discount.price&&discount.currentPrice!=order.amount">
<view class="border-bottom u-p-b-30" v-if="discount.value||accountPoints.sel">
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 " v-if="discount.value">
<view>服务员改价</view>
<view class=" u-flex u-col-center">
<text style="color: rgb(255, 95, 46);">-{{to2(order.amount- discount.currentPrice)}}</text>
<text style="color: rgb(255, 95, 46);">-{{to2(discount.value)}}</text>
</view>
</view>
<view class="u-flex u-p-l-24 u-p-r-24 u-row-between u-p-t-30 "
@@ -210,7 +202,7 @@
<edit-discount @confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
:price="order.amount"></edit-discount>
:price="order.amount-productCouponDiscountAmount" :discount="discount.discount"></edit-discount>
<up-modal :title="modal.title" :content="modal.content" :show="modal.show" :confirmText="modal.confirmText"
:cancelText="modal.cancelText" showCancelButton closeOnClickOverlay @confirm="confirmModelConfirm"
@@ -265,15 +257,15 @@
})
function confirmModelCancel() {
modal.show=false
modal.key=''
modal.data=''
modal.show = false
modal.key = ''
modal.data = ''
}
function cashConfirmShow() {
modal.content = '是否确认已现金收款' + payPrice.value
modal.key='cash'
modal.show=true
modal.key = 'cash'
modal.show = true
}
async function confirmModelConfirm() {
if (modal.key == 'cash') {
@@ -318,7 +310,7 @@
}
const res = await Api.$calcUsablePoints({
memberId: order.memberId,
orderAmount: pointCanDicountPrice.value
orderAmount:payPrice.value
})
accountPoints.calcRes = res
accountPoints.num = res.maxUsablePoints
@@ -326,7 +318,7 @@
}
watch(() => accountPoints.sel, (newval) => {
if (newval) {
calcUsablePoints()
calcDeDuctionPoints()
}
})
async function calcDeDuctionPoints() {
@@ -366,8 +358,7 @@
go.to('PAGES_ORDER_QUAN', {
orderId: order.id,
memberId: order.memberId,
orderPrice: (payPrice.value * 1 + coupAllPrice.value * 1).toFixed(2),
discuount:discount.discount
orderPrice: (payPrice.value * 1 + coupAllPrice.value * 1).toFixed(2)
})
}
async function discountShow() {
@@ -406,7 +397,7 @@
if (!n) {
return ''
}
return n.toFixed(2)
return Number(n).toFixed(2)
}
const pays = reactive({
list: ['扫码收款', '二维码收款'],
@@ -439,6 +430,7 @@
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
console.log(data);
pays.quan = []
setUser({
vipUserId: data.id ? data.id : '',
type: data.id ? 0 : 1 //0 设置 1 取消
@@ -454,6 +446,9 @@
uni.$off('choose-quan')
uni.$on('choose-quan', (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);
@@ -478,14 +473,17 @@
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).toFixed(2)
console.log(coup.discountAmount);
proCoupStartIndex, num, isMember).toFixed(2)
}
}
productCoup = productCoup.filter(v => v.num >= 1)
console.log(productCoup);
pays.quan = [...manjianCoup, ...productCoup]
console.log(pays.quan);
})
}
@@ -525,12 +523,18 @@
//打折相关数据
const discount = reactive({
discount: 100
discount: 100,
currentPrice: 0,
value: 0
})
function editDiscountConfirm(form) {
console.log(form);
Object.assign(discount, form)
accountPoints.sel = false
Object.assign(discount, {
...form,
value: form.price - form.currentPrice
})
getPayUrl()
}
@@ -590,7 +594,7 @@
infoBox.showToast('余额不足')
return
}
if (payStatus) {
return infoBox.showToast(tipsMap[payStatus])
}
@@ -637,7 +641,9 @@
success: function(res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
pay({code: res.result})
pay({
code: res.result
})
}
});
}
@@ -682,18 +688,28 @@
})
}
const coupAllPrice = computed(() => {
return pays.quan.reduce((prve, cur) => {
if(cur.type==1){
return prve + cur.discountAmount * 1
}else{
return prve + (cur.discountAmount * discount.discount/100)
}
const n = pays.quan.reduce((prve, cur) => {
return prve + cur.discountAmount * 1
}, 0)
return n
})
const payPrice = computed(() => {
const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
// const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
// const calcPrice = discountPrice - coupAllPrice.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
// return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
const total = (order.amount || 0) - productCouponDiscountAmount.value - discount.value -
fullCouponDiscountAmount.value - accountPoints.price * (accountPoints.sel ? 1 : 0)
return (total < 0 ? 0 : total).toFixed(2)
})
const fullCouponDiscountAmount = computed(() => {
return pays.quan.filter(v => v.type == 1).reduce((prve, cur) => {
return prve + cur.discountAmount * 1
}, 0)
})
const productCouponDiscountAmount = computed(() => {
return pays.quan.filter(v => v.type == 2).reduce((prve, cur) => {
return prve + cur.discountAmount * 1
}, 0)
})
watch(() => payPrice.value, (newval) => {
getPayUrl()
@@ -715,9 +731,9 @@
}
})
const pointCanDicountPrice = computed(() => {
const discountPrice = discount.currentPrice ? discount.currentPrice : order.amount
const calcPrice = discountPrice - coupAllPrice.value
return (calcPrice <= 0 ? 0 : calcPrice).toFixed(2)
const total = (order.amount || 0) - productCouponDiscountAmount.value - discount.value -
fullCouponDiscountAmount.value
return (total < 0 ? 0 : total).toFixed(2)
})
watch(() => pointCanDicountPrice.value, (newval) => {
calcUsablePoints()