修改订单支付详情优惠券积分等逻辑
This commit is contained in:
@@ -126,8 +126,8 @@
|
||||
function open() {
|
||||
model.value.open()
|
||||
form.price=props.price
|
||||
form.currentPrice=props.price
|
||||
form.discount=props.discount
|
||||
form.currentPrice=(props.discount*props.price/100).toFixed(2)
|
||||
}
|
||||
|
||||
function close() {
|
||||
|
||||
@@ -17,10 +17,10 @@ import infoBox from "@/commons/utils/infoBox.js"
|
||||
import go from '@/commons/utils/go.js';
|
||||
import { reject } from 'lodash';
|
||||
// 测试服
|
||||
// let baseUrl = 'https://admintestpapi.sxczgkj.cn'
|
||||
let baseUrl = 'https://admintestpapi.sxczgkj.cn'
|
||||
|
||||
//预发布
|
||||
let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
|
||||
// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
|
||||
|
||||
//正式
|
||||
// let baseUrl = 'https://cashieradmin.sxczgkj.cn'
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -315,12 +315,15 @@
|
||||
memberId: option.memberId
|
||||
})
|
||||
canDikouGoodsArr = returnNewGoodsList(order.value.detailList || [])
|
||||
res.fullReductionCoupon = res.fullReductionCoupon.filter((v) => {
|
||||
res.fullReductionCoupon = res.fullReductionCoupon.map((v) => {
|
||||
if(option.orderPrice<=0){
|
||||
return false
|
||||
return {...v,use:false}
|
||||
}else{
|
||||
return v.use && option.orderPrice * 1 >= v
|
||||
.fullAmount * 1
|
||||
return{
|
||||
...v,
|
||||
use:v.use && option.orderPrice * 1 >= v
|
||||
.fullAmount * 1
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
@@ -340,8 +343,7 @@
|
||||
const option = reactive({
|
||||
orderId: '',
|
||||
memberId: '',
|
||||
orderPrice: 0,
|
||||
discuount:100
|
||||
orderPrice: 0
|
||||
})
|
||||
|
||||
function toEmitChooseQuan(item) {
|
||||
@@ -362,7 +364,7 @@
|
||||
const goodsQuan = myQuan.res.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = myQuan.fullReductionCouponSel.id ? [myQuan.fullReductionCouponSel] : []
|
||||
let coupArr = [...fullReductionCoupon, ...goodsQuan]
|
||||
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value,option.discuount)
|
||||
return returnCouponAllPrice(coupArr, canDikouGoodsArr, user.value)
|
||||
})
|
||||
const payPrice = computed(() => {
|
||||
const pay = option.orderPrice - discountAmount.value
|
||||
|
||||
@@ -91,11 +91,12 @@ export function returnProductPayPrice(goods,vipUser){
|
||||
return price
|
||||
}
|
||||
//返回商品券抵扣的商品价格
|
||||
export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
|
||||
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'){
|
||||
curPrice=cur.memberPrice*1
|
||||
curPrice=isMember?cur.memberPrice*1:cur.price
|
||||
}else{
|
||||
curPrice=cur*1
|
||||
}
|
||||
@@ -206,10 +207,8 @@ export function returnFullReductionCouponAllPrice(coupArr) {
|
||||
|
||||
}
|
||||
//计算优惠券总价格
|
||||
export function returnCouponAllPrice(coupArr, goodsArr, vipUser,discount) {
|
||||
console.log(discount);
|
||||
const poductAllprice = (returnProductCouponAllPrice(coupArr, goodsArr, vipUser)*discount/100)
|
||||
console.log(poductAllprice);
|
||||
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
const poductAllprice = returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
|
||||
const pointAllPrice = returnFullReductionCouponAllPrice(coupArr)
|
||||
return (poductAllprice * 1 + pointAllPrice * 1).toFixed(2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user