tapd相关修改更新
This commit is contained in:
@@ -88,7 +88,7 @@
|
||||
<view>¥0.00</view>
|
||||
<view class="line-th color-666 ">¥{{returnTotalMoney(item)}}</view>
|
||||
</template>
|
||||
<template v-else-if="user.isVip == 1">
|
||||
<template v-else-if="isVip == 1">
|
||||
<view>¥{{item.num*item.memberPrice}}</view>
|
||||
<view class="line-th color-666 ">¥{{item.num*item.price}}</view>
|
||||
</template>
|
||||
@@ -147,11 +147,11 @@
|
||||
</view>
|
||||
|
||||
<view class="u-flex">
|
||||
<view class="u-flex u-m-r-24" v-if="youhuiAllPrice>0">
|
||||
<view class="u-flex u-m-r-24" v-if="discountsPrice>0">
|
||||
<view class="color-red u-m-r-6 ">
|
||||
已优惠¥{{youhuiAllPrice}}
|
||||
已优惠¥{{discountsPrice}}
|
||||
</view>
|
||||
<!-- <up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon> -->
|
||||
<up-icon name="info-circle" color="#999" :size="14" @click="youhuiDetailShow"></up-icon>
|
||||
|
||||
</view>
|
||||
<!-- <view>
|
||||
@@ -221,8 +221,15 @@
|
||||
<text>{{vipDiscountPrice}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-b-18" v-if="discountSaleAmount">
|
||||
<view>单品打折</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{ discountSaleAmount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-b-18" v-if="discountAmount">
|
||||
<view>打折</view>
|
||||
<view>服务改价优惠 </view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text>{{to2(discountAmount) }}</text>
|
||||
@@ -235,11 +242,11 @@
|
||||
<text>{{to2(orderInfo.fullCouponDiscountAmount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="productCouponDiscountAmount*1>0">
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.productCouponDiscountAmount*1>0">
|
||||
<view>商品券抵扣</view>
|
||||
<view class="color-red">
|
||||
<text>¥</text>
|
||||
<text> {{productCouponDiscountAmount }}</text>
|
||||
<text> {{to2(orderInfo.productCouponDiscountAmount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-between u-m-t-18" v-if="orderInfo.pointsDiscountAmount">
|
||||
@@ -262,21 +269,11 @@
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js'
|
||||
import { isTui, isTuiCai, isGift, canTuiKuan, canTuicai, mathFloorPrice } from '@/commons/utils/goodsUtil.js'
|
||||
|
||||
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
|
||||
const pop = reactive({
|
||||
youhui: false
|
||||
})
|
||||
|
||||
function youhuiDetailShow() {
|
||||
pop.youhui = true
|
||||
}
|
||||
|
||||
function productCouponDikou(item) {
|
||||
return '商品券抵扣¥' + returnProductCoupPrice(item)
|
||||
}
|
||||
|
||||
function youhuiDetailHide() {
|
||||
pop.youhui = false
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
@@ -300,6 +297,166 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 计算菜品数量
|
||||
*/
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((a, b) => {
|
||||
const bTotal = b.info.length
|
||||
return a + bTotal
|
||||
}, 0)
|
||||
return result.toFixed(0)
|
||||
})
|
||||
|
||||
/**
|
||||
* 桌位费
|
||||
*/
|
||||
const seatFeePrice = computed(() => {
|
||||
const n = props.orderInfo.seatNum > 0 ? props.orderInfo.seatNum*uni.getStorageSync('shopInfo').tableFee : 0
|
||||
return n.toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 判断是否是会员
|
||||
*/
|
||||
const isVip = computed(() => {
|
||||
return uni.getStorageSync('shopInfo').isMemberPrice && props.user && props.user.id && props.user.isVip
|
||||
})
|
||||
|
||||
const freePrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift == true || isGift(v)).reduce((a,
|
||||
b) => {
|
||||
const price = (b.isMember && b.memberPrice) ? b.memberPrice : b.price
|
||||
return a + (b.num * price)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
const vipDiscountPrice = computed(() => {
|
||||
if (!isVip.value) {
|
||||
return 0
|
||||
}
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount <= 0 && v.isGift != 1 && v.status !== "return" && (v.price != v.unitPrice) && (v.memberPrice != v.price)).reduce(( a, b) => {
|
||||
return a + (b.num * (b.price - b.memberPrice))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 单品打折优惠
|
||||
*/
|
||||
const discountSaleAmount = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount > 0 && v.isGift != 1 && v.status !== "return" ).reduce(( a, b) => {
|
||||
return a + (b.num * (b.price - b.discountSaleAmount))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 打折优惠
|
||||
*/
|
||||
const discountAmount = computed(() => {
|
||||
return props.orderInfo.discountAmount||0
|
||||
})
|
||||
|
||||
/**
|
||||
* 总优惠金额
|
||||
*/
|
||||
const discountsPrice = computed(() => {
|
||||
// 满减券优惠
|
||||
let fullCouponDiscountAmount = props.orderInfo.fullCouponDiscountAmount
|
||||
// 商品券优惠
|
||||
let productCouponDiscountAmount = props.orderInfo.productCouponDiscountAmount
|
||||
// 积分抵扣优惠
|
||||
let pointsDiscountAmount = props.orderInfo.pointsDiscountAmount
|
||||
return (parseFloat(vipDiscountPrice.value) + parseFloat(discountSaleAmount.value) + discountAmount.value + fullCouponDiscountAmount + productCouponDiscountAmount + pointsDiscountAmount).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).reduce((prve, cur) => {
|
||||
let memberPrice = cur.memberPrice ? cur.memberPrice : cur.price
|
||||
let tPrice = (isVip.value ? memberPrice : cur.price)
|
||||
tPrice = cur.memberPrice != cur.unitPrice&& cur.price != cur.unitPrice ? cur.unitPrice : tPrice
|
||||
console.log(tPrice)
|
||||
let Total = Math.floor(tPrice * cur.num * 100) / 100
|
||||
|
||||
return prve + Total - (cur.returnNum*tPrice) - (cur.refundNum*cur.unitPrice)
|
||||
}, 0)
|
||||
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.seatAmount || 0
|
||||
const total = productCoupPrice.value*1 + seatAmount*1 + packFee.value*1
|
||||
return (total <= 0 ? 0 : total).toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 已优惠金额
|
||||
*/
|
||||
const youhuiAllPrice = computed(() => {
|
||||
const n = vipDiscountPrice.value * 1
|
||||
return (n < 0 ? 0 : n).toFixed(2)
|
||||
})
|
||||
|
||||
function youhuiDetailShow() {
|
||||
pop.youhui = true
|
||||
}
|
||||
|
||||
function productCouponDikou(item) {
|
||||
return '商品券抵扣¥' + returnProductCoupPrice(item)
|
||||
}
|
||||
|
||||
function youhuiDetailHide() {
|
||||
pop.youhui = false
|
||||
}
|
||||
|
||||
/**
|
||||
* 转桌/并桌
|
||||
*/
|
||||
@@ -327,17 +484,7 @@
|
||||
.orderInfo.tableId
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 计算菜品数量
|
||||
*/
|
||||
const goodsNumber = computed(() => {
|
||||
let result = 0
|
||||
result = props.data.reduce((a, b) => {
|
||||
const bTotal = b.info.length
|
||||
return a + bTotal
|
||||
}, 0)
|
||||
return result.toFixed(0)
|
||||
})
|
||||
|
||||
function returnProductCoupPrice(item) {
|
||||
if (!item.isMember) {
|
||||
return item.price * item.num
|
||||
@@ -345,29 +492,7 @@
|
||||
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)
|
||||
return n.toFixed(2)
|
||||
})
|
||||
const emits = defineEmits(['tuicai', 'tuikuan', 'printOrder'])
|
||||
|
||||
function returnVipMoney(item) {
|
||||
if (!item.memberPrice || !props.user.isVip) {
|
||||
return 0
|
||||
}
|
||||
return (item.memberPrice * item.num).toFixed(2)
|
||||
}
|
||||
|
||||
function returnTotalMoney(item) {
|
||||
return (Math.floor(item.num*item.unitPrice*100)/100).toFixed(2)
|
||||
@@ -467,112 +592,6 @@
|
||||
emits('printOrder')
|
||||
}
|
||||
|
||||
/**
|
||||
* 桌位费
|
||||
*/
|
||||
const seatFeePrice = computed(() => {
|
||||
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 freePrice = computed(() => {
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.gift == true || isGift(v)).reduce((a,
|
||||
b) => {
|
||||
const price = (b.isMember && b.memberPrice) ? b.memberPrice : b.price
|
||||
return a + (b.num * price)
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 0)
|
||||
return goodsPrice.toFixed(2)
|
||||
})
|
||||
const vipDiscountPrice = computed(() => {
|
||||
if (!props.user.isVip) {
|
||||
return 0
|
||||
}
|
||||
const goodsPrice = props.data.reduce((prve, cur) => {
|
||||
const curTotal = cur.info.filter(v => v.discountSaleAmount <= 0 && v.isGift != 1 && v.status !== "return" && (v.price !=
|
||||
v.unitPrice) && (v.memberPrice != v.price)).reduce((
|
||||
a,
|
||||
b) => {
|
||||
return a + (b.num * (b.price - b.memberPrice))
|
||||
}, 0)
|
||||
return prve + curTotal
|
||||
}, 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).reduce((prve,
|
||||
cur) => {
|
||||
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(() => {
|
||||
const n = vipDiscountPrice.value * 1
|
||||
return (n < 0 ? 0 : n).toFixed(2)
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
total: 0,
|
||||
query: {
|
||||
orderNo: "",
|
||||
platformType: "APP",
|
||||
userId: "",
|
||||
platformType: "",
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
startTime: today.start,
|
||||
@@ -54,7 +55,9 @@
|
||||
})
|
||||
|
||||
onLoad((opt)=>{
|
||||
|
||||
if( opt.type == 'user' && opt.userId ) {
|
||||
pageData.query.userId = opt.userId
|
||||
}
|
||||
})
|
||||
onShow(init)
|
||||
onPullDownRefresh(()=>{
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<view class="u-flex">
|
||||
<view class="hui">减</view>
|
||||
<view class="u-m-l-18">{{item.name}}</view>
|
||||
<view class="u-m-l-18 color-999">x{{item.number}}</view>
|
||||
<view class="u-m-l-18 color-999">x1</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="color-red">
|
||||
@@ -224,7 +224,7 @@
|
||||
|
||||
<edit-discount :nowPrice="order.orderAmount-productCouponDiscountAmount-fullCouponDiscountAmount"
|
||||
@confirm="editDiscountConfirm" title="优惠金额" :ref="setModel" name="editMoney"
|
||||
:price="order.orderAmount-productCouponDiscountAmount" :discount="discount.discount"></edit-discount>
|
||||
:price="payPrice-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"
|
||||
@@ -242,7 +242,6 @@
|
||||
import go from '@/commons/utils/go.js'
|
||||
|
||||
import { hasPermission } from '@/commons/utils/hasPermission.js'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
import editDiscount from '@/components/my-components/edit-discount.vue'
|
||||
import editAccountPoints from './components/edit-accountPoints.vue'
|
||||
import {
|
||||
@@ -256,8 +255,8 @@
|
||||
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,queryOrderStatus } from '@/http/api/pay.js'
|
||||
import { shopUserDetail } from '@/http/api/shopUser.js'
|
||||
import { scanPay,microPay,cashPay,vipPay,creditPay,getOrderPayUrl,queryOrderStatus } from '@/http/api/pay.js'
|
||||
import { calcUsablePoints,calcDeductionAmount,payedDeductPoints,consumeAwardPoints } from '@/http/api/points.js'
|
||||
|
||||
|
||||
@@ -270,16 +269,16 @@
|
||||
show: false,
|
||||
data: ''
|
||||
})
|
||||
let option = {
|
||||
isNowPay: false
|
||||
}
|
||||
|
||||
const pageData = reactive({
|
||||
goodsList: [], //菜品列表
|
||||
user: { //会员信息
|
||||
userId: null,
|
||||
amount: 0
|
||||
},
|
||||
buyer: {}
|
||||
shopInfo: uni.getStorageSync('shopInfo'),
|
||||
buyer: {},
|
||||
payUrlShow: false,
|
||||
})
|
||||
const order = reactive({
|
||||
orderAmount: 0
|
||||
@@ -325,7 +324,6 @@
|
||||
})
|
||||
onLoad(async (opt) => {
|
||||
console.log(opt);
|
||||
option = opt
|
||||
Object.assign(order, opt)
|
||||
getPayType()
|
||||
init()
|
||||
@@ -352,15 +350,9 @@
|
||||
Object.values(orderRes.detailMap).forEach(item=>{
|
||||
pageData.goodsList = [...pageData.goodsList,...item]
|
||||
})
|
||||
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])
|
||||
|
||||
// 获取用户信息
|
||||
console.log("order===",order)
|
||||
console.log("pageData.user===",pageData.user)
|
||||
if (order.userId||pageData.user.userId) {
|
||||
|
||||
@@ -377,6 +369,15 @@
|
||||
console.log("order==",order)
|
||||
pageData.seatNum = order.seatNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否是会员
|
||||
*/
|
||||
const isVip = computed(() => {
|
||||
return uni.getStorageSync('shopInfo').isMemberPrice && pageData.user && pageData.user.id && pageData.user.isVip
|
||||
})
|
||||
|
||||
const coupAllPrice = computed(() => {
|
||||
const n = pays.quan.reduce((prve, cur) => {
|
||||
return prve + cur.discountAmount * 1
|
||||
@@ -399,14 +400,13 @@
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 桌位费
|
||||
*/
|
||||
const tableFee = computed(() => {
|
||||
return order.seatNum > 0 ? order.seatNum*order.seatAmount : 0
|
||||
console.log("桌位费===", order.seatNum > 0 ? order.seatNum*pageData.shopInfo.tableFee : 0)
|
||||
return order.seatNum > 0 ? order.seatNum*pageData.shopInfo.tableFee : 0
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 菜品金额
|
||||
@@ -414,21 +414,22 @@
|
||||
const originPrice = 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))
|
||||
return a + parseFloat(mathFloorPrice(b.num * b.price,b))
|
||||
}, 0)
|
||||
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))
|
||||
let memberPrice = b.memberPrice ? b.memberPrice : b.price
|
||||
let tPrice = (isVip.value ? memberPrice : b.price)
|
||||
tPrice = b.memberPrice != b.unitPrice&& b.price != b.unitPrice ? b.unitPrice : tPrice
|
||||
return a + parseFloat(mathFloorPrice(b.num * tPrice,b) - mathFloorPrice(b.returnNum*tPrice,b) - mathFloorPrice(b.refundNum*b.unitPrice,b))
|
||||
}, 0)
|
||||
console.log("减去退款退费的菜品金额===",goodsPrice)
|
||||
console.log("桌位费===", tableFee.value)
|
||||
return (goodsPrice + tableFee.value + packAmount.value).toFixed(2)
|
||||
}
|
||||
})
|
||||
@@ -437,7 +438,7 @@
|
||||
* 会员优惠金额
|
||||
*/
|
||||
const vipDiscount = computed(() => {
|
||||
if (!pageData.user.isVip) {
|
||||
if (!isVip.value) {
|
||||
return 0
|
||||
}
|
||||
if(pageData.goodsList){
|
||||
@@ -492,15 +493,13 @@
|
||||
* 支付金额
|
||||
*/
|
||||
const payPrice = computed(() => {
|
||||
console.log("originPrice===",newOriginPrice.value)
|
||||
console.log("newOriginPrice===",newOriginPrice.value)
|
||||
console.log("vipDiscount===",vipDiscount.value)
|
||||
console.log("discountSaleAmount===",discountSaleAmount.value)
|
||||
console.log("pointCanDicountPrice===",pointCanDicountPrice.value)
|
||||
console.log("productCouponDiscountAmount===",productCouponDiscountAmount.value)
|
||||
console.log("discount===",discount.value)
|
||||
console.log("fullCouponDiscountAmount===",fullCouponDiscountAmount.value)
|
||||
console.log("accountPoints===",accountPoints)
|
||||
let total = (newOriginPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
|
||||
let total = (newOriginPrice.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)
|
||||
@@ -510,7 +509,7 @@
|
||||
* 积分使用前金额
|
||||
*/
|
||||
const orderAmount = computed(() => {
|
||||
let total = (newOriginPrice.value*1) - discountSaleAmount.value - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
|
||||
let total = (newOriginPrice.value*1) - (vipDiscount.value*1) - productCouponDiscountAmount.value - discount
|
||||
.value - fullCouponDiscountAmount.value
|
||||
console.log(total)
|
||||
return (total < 0 ? 0 : total).toFixed(2)
|
||||
@@ -527,7 +526,9 @@
|
||||
}
|
||||
})
|
||||
watch(() => payPrice.value, (newval) => {
|
||||
getPayUrl()
|
||||
if( pageData.payUrlShow){
|
||||
getPayUrl()
|
||||
}
|
||||
if (newval <= 0) {
|
||||
const arr = ['cash', 'member-account']
|
||||
pays.payTypes.list.map(v => {
|
||||
@@ -563,11 +564,14 @@
|
||||
}
|
||||
})
|
||||
}, 2000)
|
||||
if( newval == 1 ){
|
||||
getPayUrl()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function getPayParam () {
|
||||
return {
|
||||
let params = {
|
||||
shopId: uni.getStorageSync("shopInfo").id,
|
||||
orderId: order.id,
|
||||
originAmount: originPrice.value, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
@@ -575,18 +579,27 @@
|
||||
seatNum: pageData.seatNum, // 用餐人数
|
||||
discountAmount: discount.value, // 手动优惠金额
|
||||
fullCouponDiscountAmount: fullCouponDiscountAmount.value, // 满减金额
|
||||
productCouponDiscountAmount: productCouponDiscountAmount.value,
|
||||
vipPrice: vipDiscount.value != 0 ? 1: 0, // 是否使用会员价
|
||||
pointsDiscountAmount: accountPoints.sel ? accountPoints.price : 0,
|
||||
pointsNum: accountPoints.sel ? accountPoints.num : 0,
|
||||
couponList: [],
|
||||
}
|
||||
if( pays.quan.length > 0 ){
|
||||
pays.quan.forEach(v => {
|
||||
params.couponList.push(v.id)
|
||||
})
|
||||
}
|
||||
params.couponList = params.couponList.join(",")
|
||||
// params.couponList = JSON.stringify(params.couponList)
|
||||
return params
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单支付URL
|
||||
*/
|
||||
function getPayUrl() {
|
||||
console.log(discount)
|
||||
console.log(getPayParam())
|
||||
console.log("支付参数 ===",getPayParam())
|
||||
let par = getPayParam()
|
||||
let params = {
|
||||
shopId: uni.getStorageSync("shopInfo").id,
|
||||
@@ -597,6 +610,7 @@
|
||||
}
|
||||
getOrderPayUrl(params).then(res => {
|
||||
payCodeUrl.value = res
|
||||
pageData.payUrlShow = true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -624,39 +638,32 @@
|
||||
*/
|
||||
function setQuan(arr) {
|
||||
console.log("choose-quan===",arr)
|
||||
discount.discount = 100
|
||||
discount.value = 0
|
||||
discount.currentPrice = order.orderAmount
|
||||
const manjianCoup = arr.filter(v => v.type == 1 && v.number >= 1)
|
||||
let manjianCoup = arr.filter(v => v.type == 1)
|
||||
let productCoup = arr.filter(v => v.type == 2)
|
||||
let setmanjianCoup = pays.quan.filter(v => v.type == 1)
|
||||
let setproductCoup = pays.quan.filter(v => v.type == 2)
|
||||
|
||||
if ( manjianCoup.length > 0) {
|
||||
setmanjianCoup = manjianCoup
|
||||
}
|
||||
//商品券分组
|
||||
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]
|
||||
}
|
||||
let goods;
|
||||
let tPrice;
|
||||
productCoup.map(item=>{
|
||||
goods = pageData.goodsList.find(v => v.productId == item.proId)
|
||||
if(!goods)return;
|
||||
let memberPrice = goods.memberPrice ? goods.memberPrice : goods.price
|
||||
tPrice = (isVip.value ? memberPrice : goods.price)
|
||||
tPrice = goods.memberPrice != goods.unitPrice&& goods.price != goods.unitPrice ? goods.unitPrice : tPrice
|
||||
item.discountAmount = tPrice
|
||||
})
|
||||
|
||||
if( !goods || tPrice > payPrice.value){
|
||||
productCoup = [];
|
||||
}
|
||||
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.number)
|
||||
const number = Math.min($goodsPayPriceMap[coup.proId].length, coupUseNum)
|
||||
coup.number = number
|
||||
const findGoods = order.detailList.find(v => v.productId == coup.proId)
|
||||
const isMember = findGoods.isMember
|
||||
coup.discountAmount = returnProductCoupAllPrice($goodsPayPriceMap[coup.proId],
|
||||
proCoupStartIndex, number, isMember).toFixed(2)
|
||||
}
|
||||
}
|
||||
productCoup = productCoup.filter(v => v.number >= 1)
|
||||
pays.quan = [...manjianCoup, ...productCoup]
|
||||
// productCoup = productCoup.filter(v => v.number >= 1)
|
||||
pays.quan = [...setmanjianCoup, ...productCoup,...setproductCoup]
|
||||
console.log("优惠券2===",pays.quan)
|
||||
}
|
||||
|
||||
|
||||
@@ -696,8 +703,8 @@
|
||||
}
|
||||
console.log("calcUsablePoints",pageData.user)
|
||||
const res = await calcUsablePoints({
|
||||
userId: pageData.user.id,
|
||||
orderAmount: orderAmount ? orderAmount : payPrice.value
|
||||
shopUserId: pageData.user.id,
|
||||
orderAmount: payPrice.value
|
||||
})
|
||||
accountPoints.calcRes = res
|
||||
accountPoints.num = res.maxUsablePoints
|
||||
@@ -710,8 +717,8 @@
|
||||
return ''
|
||||
}
|
||||
const res = await calcDeductionAmount({
|
||||
userId: pageData.user.id,
|
||||
orderAmount: orderAmount.value,
|
||||
shopUserId: pageData.user.id,
|
||||
orderAmount: payPrice.value,
|
||||
points: accountPoints.num
|
||||
})
|
||||
if (res) {
|
||||
@@ -735,16 +742,16 @@
|
||||
* 选择优惠券
|
||||
*/
|
||||
function toQuan() {
|
||||
console.log(order);
|
||||
console.log(pageData.user);
|
||||
if (!order.userId&&!pageData.user.id) {
|
||||
return infoBox.showToast('请先选择会员', 0.5).then(() => {
|
||||
return uni.$utils.showToast('请先选择会员', 0.5).then(() => {
|
||||
chooseUser()
|
||||
})
|
||||
}
|
||||
go.to('PAGES_ORDER_QUAN', {
|
||||
orderId: order.id,
|
||||
shopUserId: pageData.user.id,
|
||||
orderPrice: (payPrice.value * 1 + coupAllPrice.value * 1).toFixed(2)
|
||||
orderPrice: (payPrice.value * 1).toFixed(2)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -848,7 +855,7 @@
|
||||
*/
|
||||
function changePayType(i, item) {
|
||||
if (item.disabled) {
|
||||
return infoBox.showToast(item.payName + '不可用')
|
||||
return uni.$utils.showToast(item.payName + '不可用')
|
||||
}
|
||||
pays.payTypes.selIndex = i
|
||||
console.log(item.payType)
|
||||
@@ -898,11 +905,11 @@
|
||||
// return cashConfirmShow()
|
||||
}
|
||||
if (payType == 'member-account' && pageData.user.amount * 1 < payPrice.value * 1) {
|
||||
infoBox.showToast('余额不足')
|
||||
uni.$utils.showToast('余额不足')
|
||||
return
|
||||
}
|
||||
if (payStatus) {
|
||||
return infoBox.showToast(tipsMap[payStatus])
|
||||
return uni.$utils.showToast(tipsMap[payStatus])
|
||||
}
|
||||
try {
|
||||
pay()
|
||||
@@ -919,18 +926,12 @@
|
||||
async function pay(par) {
|
||||
const payType = pays.payTypes.list[pays.payTypes.selIndex].payType
|
||||
let pars = getPayParam()
|
||||
console.log(payType)
|
||||
console.log(discount)
|
||||
console.log(pars)
|
||||
payStatus = 'paying'
|
||||
let params = {
|
||||
shopId: uni.getStorageSync("shopInfo").id,
|
||||
checkOrderPay: {
|
||||
couponList: pays.quan.map(v => {
|
||||
return {
|
||||
userCouponId: v.id,
|
||||
num: v.number
|
||||
}
|
||||
}),
|
||||
|
||||
...pars
|
||||
},
|
||||
...par
|
||||
@@ -961,7 +962,7 @@
|
||||
params.shopUserId = pageData.user.id
|
||||
await vipPay(params)
|
||||
} else {
|
||||
infoBox.showToast('余额不足')
|
||||
uni.$utils.showToast('余额不足')
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -994,7 +995,7 @@
|
||||
* 支付成功回调
|
||||
*/
|
||||
function paySuccess() {
|
||||
infoBox.showToast('支付成功')
|
||||
uni.$utils.showToast('支付成功')
|
||||
payStatus = 'success'
|
||||
setTimeout(() => {
|
||||
uni.removeStorageSync("table_code")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="u-p-l-30 u-p-r-30 u-p-t-30 u-font-28 ">
|
||||
<up-sticky offset-top="0">
|
||||
<my-tabs v-model="pageData.types.sel" :list="pageData.types.list"></my-tabs>
|
||||
<my-tabs v-model="pageData.types.sel" @change="tabChange" :list="pageData.types.list"></my-tabs>
|
||||
</up-sticky>
|
||||
<view class="u-m-t-32">
|
||||
<template v-if="pageData.types.sel==0">
|
||||
@@ -60,8 +60,8 @@
|
||||
<view class="u-flex">
|
||||
<up-image width="80rpx" height="80rpx" :src="item.productCover"></up-image>
|
||||
<view class="u-m-l-18">
|
||||
<view class="u-m-l-18">{{item.productName}}</view>
|
||||
<view class="u-m-l-18 u-m-t-10 u-font-24 color-666">x{{item.num}}</view>
|
||||
<view class="u-m-l-18">{{item.name}}{{item.productName?' | '+item.productName : ''}}</view>
|
||||
<!-- <view class="u-m-l-18 u-m-t-10 u-font-24 color-666">x{{item.num}}</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class=" u-m-t-14 u-flex">
|
||||
@@ -70,7 +70,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-10 color-999 u-font-24">
|
||||
{{ formatStr(item.useRestrictions)}}
|
||||
{{ item.useRestrictions }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="right u-flex u-flex-col u-col-bottom u-row-center">
|
||||
@@ -200,6 +200,10 @@
|
||||
})
|
||||
})
|
||||
|
||||
function tabChange () {
|
||||
getQuan()
|
||||
}
|
||||
|
||||
/**
|
||||
* 抵扣金额
|
||||
*/
|
||||
@@ -249,12 +253,13 @@
|
||||
return {
|
||||
...calcCoup,
|
||||
checked: false,
|
||||
use:option.orderPrice<=0?false:v.use
|
||||
use: option.orderPrice<=0?false:v.use
|
||||
}
|
||||
}).filter((v) => v.use);
|
||||
})
|
||||
// .filter((v) => v.use);
|
||||
pageData.fullReductionCoupon = fullReductionCoupon
|
||||
pageData.productCoupon = productCoupon
|
||||
console.log(pageData)
|
||||
console.log(res)
|
||||
pageData.hasAjax = true;
|
||||
}
|
||||
|
||||
@@ -262,18 +267,24 @@
|
||||
setModalShow('clear', false, '')
|
||||
}
|
||||
|
||||
/**
|
||||
* 继续选择
|
||||
*/
|
||||
async function confirmModelConfirm() {
|
||||
if (modal.key == 'clear') {
|
||||
pageData.fullReductionCouponSel = {
|
||||
id: ''
|
||||
if( modal.data ){
|
||||
pageData.fullReductionCouponSel = {
|
||||
id: ''
|
||||
}
|
||||
const item = modal.data
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = pageData.productCoupon.filter(v => v.checked)
|
||||
const noCheckedArr = pageData.productCoupon.filter(v => !v.checked)
|
||||
noCheckedArr.map(v => {
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
|
||||
})
|
||||
}
|
||||
const item = modal.data
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = pageData.productCoupon.filter(v => v.checked)
|
||||
const noCheckedArr = pageData.productCoupon.filter(v => !v.checked)
|
||||
noCheckedArr.map(v => {
|
||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr)
|
||||
})
|
||||
|
||||
setModalShow('clear', false, '')
|
||||
}
|
||||
}
|
||||
@@ -284,8 +295,6 @@
|
||||
modal.data = data
|
||||
}
|
||||
|
||||
|
||||
|
||||
function back() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
@@ -295,14 +304,20 @@
|
||||
* @param {Object} item
|
||||
*/
|
||||
function changeProductCoupon(item) {
|
||||
if (!item.use) {
|
||||
if (!item.use) { return }
|
||||
if ( payPrice.value <= 0 ) {
|
||||
modal.content = '当前支付金额不满足选择商品券的最低使用需求,无法选择'
|
||||
modal.cancelText = '取消'
|
||||
modal.confirmText = '确定'
|
||||
setModalShow('clear', true)
|
||||
return
|
||||
}
|
||||
if (pageData.fullReductionCouponSel.id && !item.checked) {
|
||||
if (!item.checked) {
|
||||
const goodsQuan = pageData.productCoupon.filter(v => v.checked)
|
||||
const fullReductionCoupon = pageData.fullReductionCouponSel.id ? [pageData.fullReductionCouponSel] : []
|
||||
let coupArr = [...goodsQuan, item]
|
||||
const payPrice = option.orderPrice - returnCouponAllPrice(coupArr, canDikouGoodsArr, pageData.user)
|
||||
|
||||
console.log(payPrice)
|
||||
if (payPrice<=0) {
|
||||
modal.content = '选择该商品券后支付金额将为0,继续选择将取消选择的满减券'
|
||||
modal.cancelText = '取消'
|
||||
@@ -318,7 +333,7 @@
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
console.log(2)
|
||||
item.checked = !item.checked
|
||||
const CheckedArr = pageData.productCoupon.filter(v => v.checked)
|
||||
if (CheckedArr.length <= 0) {
|
||||
@@ -342,7 +357,6 @@
|
||||
if (!item.use) {
|
||||
return
|
||||
}
|
||||
console.log(item);
|
||||
if (item.id == pageData.fullReductionCouponSel.id) {
|
||||
pageData.fullReductionCouponSel = {
|
||||
id: ''
|
||||
@@ -364,15 +378,23 @@
|
||||
*/
|
||||
function toEmitChooseQuan(item) {
|
||||
let arr = []
|
||||
let discountAmount = 0;
|
||||
if (item) {
|
||||
arr = [item]
|
||||
} else {
|
||||
if (pageData.fullReductionCouponSel.id) {
|
||||
arr.push(pageData.fullReductionCouponSel)
|
||||
}
|
||||
const goodsQuan = pageData.productCoupon.filter(v => v.checked)
|
||||
let goodsQuan = pageData.productCoupon.filter(v => v.checked)
|
||||
arr.push(...goodsQuan)
|
||||
}
|
||||
arr.map(item=>{
|
||||
discountAmount += item.discountAmount
|
||||
})
|
||||
if( discountAmount > option.orderPrice){
|
||||
|
||||
}
|
||||
console.log(arr)
|
||||
uni.$emit('choose-quan', arr)
|
||||
back()
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ export function isTui(item) {
|
||||
}
|
||||
//是否使用会员价
|
||||
export function isUseVipPrice(vipUser,goods){
|
||||
return vipUser.id&&vipUser.isVip&&goods.isMember
|
||||
return vipUser.id&&vipUser.isVip&&uni.getStorageSync("shopInfo").isMemberPrice
|
||||
}
|
||||
|
||||
//计算商品券优惠价格
|
||||
@@ -90,8 +90,9 @@ export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
|
||||
}
|
||||
//返回商品实际支付价格
|
||||
export function returnProductPayPrice(goods,vipUser){
|
||||
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
|
||||
const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
|
||||
let memberPrice = goods.memberPrice ? goods.memberPrice : goods.unitPrice;
|
||||
let price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.unitPrice;
|
||||
price = goods.memberPrice != goods.unitPrice&& goods.price != goods.unitPrice ? goods.unitPrice : price
|
||||
return price
|
||||
}
|
||||
//返回商品券抵扣的商品价格
|
||||
@@ -101,9 +102,9 @@ export function returnProductCoupAllPrice(productPriceArr,startIndex,num,isMembe
|
||||
if(typeof cur==='object'){
|
||||
curPrice=isMember?cur.memberPrice*1:cur.price
|
||||
}else{
|
||||
curPrice=cur*1
|
||||
curPrice = cur*1
|
||||
}
|
||||
return prve+curPrice
|
||||
return prve + curPrice
|
||||
},0)
|
||||
}
|
||||
|
||||
@@ -172,24 +173,24 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
for(let i in arr){
|
||||
const coup=arr[i]
|
||||
if(!goodsMap.hasOwnProperty(coup.proId)){
|
||||
goodsMap[coup.proId]=goodsArr.filter(v=>v.productId==coup.proId).map(v=>{
|
||||
goodsMap[coup.proId]= goodsArr.filter(v=>v.productId==coup.proId).map((v,i)=>{
|
||||
return {
|
||||
...v,
|
||||
payPrice:returnProductPayPrice(v,vipUser)
|
||||
payPrice: returnProductPayPrice(v,vipUser)
|
||||
}
|
||||
}).sort((a,b)=>{
|
||||
const aPrice=a.payPrice
|
||||
const bPrice=b.payPrice
|
||||
let aPrice=a.payPrice
|
||||
let bPrice=b.payPrice
|
||||
return aPrice-bPrice
|
||||
})
|
||||
goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
|
||||
const arr=new Array(cur.number).fill(cur.payPrice)
|
||||
goodsPayPriceMap[coup.proId] = goodsMap[coup.proId].reduce((prve,cur)=>{
|
||||
const arr=new Array(cur.num).fill(cur.payPrice)
|
||||
prve.push(...arr)
|
||||
return prve
|
||||
},[])
|
||||
}
|
||||
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
|
||||
const coupNum = Math.min(goodsPayPriceMap[coup.proId].length,coup.number)
|
||||
const coupNum = Math.min(coupMap[coup.proId].length)
|
||||
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
|
||||
}
|
||||
}
|
||||
@@ -230,7 +231,7 @@ export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
|
||||
}
|
||||
return {
|
||||
...v,
|
||||
use: v.use && isfullAmount
|
||||
use: isfullAmount
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user