修改代客下单相关逻辑

This commit is contained in:
YeMingfei666 2024-10-31 18:25:52 +08:00
parent 8403afd685
commit 924f296ad1
1 changed files with 78 additions and 60 deletions

View File

@ -407,7 +407,11 @@
<div class="flex mt-14">
<template v-if="table">
<template v-if="!postPay">
<template v-if="!postPay&& isCreateOrder && table && table.tableId">
<template
v-if="
postPay && isCreateOrder && table && table.tableId
"
>
<!-- <template v-if="false"> -->
<button
class="my-btn flex-1 default"
@ -1293,7 +1297,7 @@ import {
$strMatch,
returnGiftArr,
returnPackFee,
formatOrderGoodsList
formatOrderGoodsList,
} from "./util.js";
import { $status } from "@/utils/table.js";
@ -1619,6 +1623,7 @@ export default {
const oldackFee = returnPackFee(this.order.old.list);
const packFee = nowPackFee + oldackFee;
const returnStatus = ["return", "refunding", "refund"];
console.log(this.order.seatFee);
const seatFee =
this.order.seatFee.totalAmount *
(returnStatus.includes(this.order.seatFee.status) ? 0 : 1);
@ -1703,7 +1708,12 @@ export default {
}
},
table(newval, oldval) {
if (newval&&newval.tableId) {
if(oldval.tableId&&newval.tableId){
this.isCreateOrder = false;
}
if (newval && newval.tableId) {
this.createOrder.data.amount = 0;
this.createOrder.data.id = "";
this.onTableChange();
}
},
@ -1880,8 +1890,7 @@ export default {
this.order.extra.selIndex = index;
},
async morePayClick() {
if (this.order.list.length <= 0 && !this.createOrder.data) {
if (!this.createOrder.data.id && this.order.list.length <= 0) {
return this.$message("请选择菜品");
}
const canJiesuan = await this.shoukuanClick();
@ -1896,7 +1905,7 @@ export default {
// this.order.payType = "";
},
async cashPayClick() {
if(!this.createOrder.data.id&&this.order.list.length <= 0){
if (!this.createOrder.data.id && this.order.list.length <= 0) {
return this.$message("没有要结算的订单或商品!");
}
const canJiesuan = await this.shoukuanClick();
@ -1913,10 +1922,10 @@ export default {
});
},
async returnCreateOrderData() {
if (this.key == "isJieZhang"||this.order.list.length <= 0) {
if (this.key == "isJieZhang" || this.order.list.length <= 0) {
//
// this.order.old.list = formatOrderGoodsList(this.createOrder.data.detailList||[]);
this.isCreateOrder=true
this.isCreateOrder = true;
return this.createOrder.data;
}
this.order.list = [];
@ -1928,9 +1937,9 @@ export default {
postPay: this.postPay,
orderld: this.order.orderId,
});
this.isCreateOrder=true
this.order.old.list = formatOrderGoodsList(res.detailList||[]);
this.getOrderData({orderId:res.id})
this.isCreateOrder = true;
this.order.old.list = formatOrderGoodsList(res.detailList || []);
this.getOrderData({ orderId: res.id });
this.createOrder.data = res;
this.createOrder.discount = 1;
// const lastItem = this.order.old.list[this.order.old.list.length - 1];
@ -1943,7 +1952,6 @@ export default {
return res;
},
async payBeforeClear() {
this.loading = false;
this.order.query.page = 1;
this.goods.total = 0;
@ -1979,7 +1987,7 @@ export default {
this.pays();
},
async scanPayClick() {
if(!this.createOrder.data.id&&this.order.list.length <= 0 ){
if (!this.createOrder.data.id && this.order.list.length <= 0) {
return this.$message("没有要结算的订单或商品!");
}
const canJiesuan = await this.shoukuanClick();
@ -2055,11 +2063,20 @@ export default {
tableId: this.table.tableId,
num: this.perpole,
});
this.order.seatFee = res;
this.order.seatFee = res
this.perpole = res.totalNumber || res.number;
return res;
},
//
async onTableChange() {
const tableRes = await $returnTableDetail({
tableId: this.table.tableId,
});
console.log(tableRes);
const orderId=tableRes.orderId ||this.table.orderId
if (orderId) {
this.getOrderData({ orderId:orderId });
}
const res = await this.getMasterId();
this.masterId = res.masterId;
//1
@ -2080,23 +2097,18 @@ export default {
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
if (!orderId) {
this.getCart();
}
this.getCacheOrder();
console.log(this.isCreateOrder);
if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) {
//
const seatFee = await $choseCount({
masterId: this.masterId,
tableId: this.table.tableId,
num: res.seatFee ? res.seatFee.totalNumber : this.perpole,
});
console.log(seatFee);
this.order.seatFee = seatFee;
this.perpole = seatFee.totalNumber;
}
if (this.isCreateOrder) {
this.toCreateOrder(true);
await this.changePerpole();
}
// if (this.isCreateOrder) {
// this.toCreateOrder(true);
// }
},
//
async getTableDetail() {
@ -2129,13 +2141,13 @@ export default {
console.log(this.order.selGoods);
const res = await $returnCart({
...e,
cartId:this.order.selGoods.cartId,
cartId: this.order.selGoods.cartId,
tableId: this.table.tableId,
});
this.order.selGoods.status = "return";
this.order.old.selIndex = -1;
// this.getCart();
this.getOrderData()
this.getOrderData();
// console.log(this.order.selGoods);
},
@ -2258,9 +2270,7 @@ export default {
//
isSellOut(item) {
return (
item.isPauseSale ||
(
(item.isStock == 1 ? item.stockNumber <= 0 : false))
item.isPauseSale || (item.isStock == 1 ? item.stockNumber <= 0 : false)
);
},
toggleFullScreen() {
@ -2443,18 +2453,10 @@ export default {
this.toCreateOrder(isNowPay);
},
async toCreateOrder(isNowPay = false) {
console.log(this.order);
console.log(this.order.orderId);
let res = "";
try {
if (!this.shopInfo.isTableFee) {
const seatFee = await $choseCount({
masterId: this.masterId,
tableId: this.table.tableId,
num: this.perpole,
});
this.order.seatFee = seatFee;
this.order.seatFee = res;
await this.changePerpole();
}
res = await $createOrder({
masterId: this.order.masterId || this.masterId,
@ -2464,17 +2466,16 @@ export default {
postPay: this.postPay,
orderld: this.order.orderId,
});
this.getOrderData({ orderId: res.id });
} catch (error) {}
if (!res) {
this.createOrder.status = "success";
return;
}
//
console.log(this.postPay);
console.log(isNowPay);
console.log(this.postPay && isNowPay);
this.createOrder.status = "success";
this.getCart();
this.order.list=[];
// this.getCart();
if (this.postPay && !isNowPay) {
this.$notify({
title: "下单成功",
@ -2482,7 +2483,6 @@ export default {
});
return this.close();
}
this.createOrder.data = res;
if (!this.isPrverOrder) {
const { masterId } = await this.getMasterId();
this.masterId = masterId;
@ -2510,7 +2510,7 @@ export default {
//
updateOrder(par = {}) {
let item = this.order.list[this.order.selIndex];
console.log(item.specSnap);
console.log(this.table);
const { productId, skuId, isPack, isGift, number, id } = item;
$updateCart({
cartId: id,
@ -2576,7 +2576,7 @@ export default {
//
orderBtnsClick(key) {
const orderGoods = this.order.list[this.order.selIndex];
if (this.key != "isJieZhang"&&this.postPay) {
if (this.key != "isJieZhang" && this.postPay) {
this.createOrderClose();
}
if (key === "sku") {
@ -2753,7 +2753,6 @@ export default {
this.getCacheOrder();
});
await this.getMasterId();
},
//
removeCart() {
@ -2980,6 +2979,7 @@ export default {
}
} else {
//
console.log(this.table)
res = await addCart({
masterId: this.masterId,
vipUserId: this.vipUser.id,
@ -3126,7 +3126,17 @@ export default {
//
setCart(res) {
console.log(res);
this.order.seatFee = res.seatFee ? res.seatFee : this.order.seatFee;
const { seatFee } = res;
this.order.seatFee = seatFee
? {
...seatFee,
totalNumber: seatFee.num,
number: seatFee.num,
name: seatFee.productName,
totalAmount: seatFee.priceAmount || seatFee.totalAmount,
}
: this.order.seatFee;
console.log(this.order.seatFee);
this.perpole = res.seatFee ? res.seatFee.totalNumber : 1;
const nowCart = res.records.find((v) => v.placeNum == 0);
// this.order.list = nowCart ? nowCart.info.filter(v=>v.isGift!=='true') : [];
@ -3335,7 +3345,7 @@ export default {
this.shopInfo = shopInfo;
if (!params.masterId) {
await this.getMasterId();
this.getCart()
this.getCart();
} else {
this.masterId = params.masterId;
}
@ -3349,6 +3359,7 @@ export default {
this.getCategory();
this.getTable();
console.log(params);
if (key == "isJieZhang") {
this.perpole = perpoleNumber;
this.table = params.tableId ? { name: item.name } : "";
@ -3361,6 +3372,13 @@ export default {
this.isCreateOrder = true;
return;
}
if( key == "isPayOrder" ){
this.isCreateOrder =true
}
if(params.orderId) {
const orderRes = await this.getOrderData(params);
}
// this.getCart();
// this.getCacheOrder();
// if (!params) {
@ -3375,14 +3393,15 @@ export default {
? item.useType
: item.useType.replace(/-after|-before/g, "");
}
this.isCreateOrder =
this.key == "isPayOrder" || this.key == "isJieZhang" ? true : false;
this.perpole = perpoleNumber;
this.table = params.tableId ? { name: item.name } : "";
this.table = params.tableId ? item : "";
},
async getOrderData(params) {
const res = await tbOrderInfoDetail(params?params.orderId:this.createOrder.data.id);
const res = await tbOrderInfoDetail(
params ? params.orderId : this.createOrder.data.id
);
if (res.status != "unpaid") {
return res;
}
@ -3409,12 +3428,11 @@ export default {
}
: {
name: "客座费",
number: res.seatCount||0,
totalNumber: res.seatCount||0,
totalAmount: res.seatAmount||0,
number: res.seatCount || 0,
totalNumber: res.seatCount || 0,
totalAmount: res.seatAmount || 0,
status: "",
};
console.log(this.order.seatFee);
this.order.old.list = Object.entries(goodsMap).map(([key, value]) => ({
info: value.map((v) => {
return {
@ -3435,7 +3453,7 @@ export default {
return res;
},
close() {
this.reset()
this.reset();
if (this.table.tableId) {
this.$router.replace({ path: "/tool/table_list" });
} else {