修改代客下单相关逻辑

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