tapd相关修改更新
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user