修改部分代客下单逻辑

This commit is contained in:
YeMingfei666 2024-11-07 13:30:58 +08:00
parent a8c1440a02
commit a9a4efabe9
1 changed files with 91 additions and 82 deletions

View File

@ -86,7 +86,7 @@
<!-- 先付后付start --> <!-- 先付后付start -->
<!-- <el-dropdown @command="changePostPay"> <!-- <el-dropdown @command="changePostPay">
<el-button plain type="primary" size="mini"> <el-button plain type="primary" size="mini">
{{ postPay ? "后付费" : "先付费" }} {{ payAfter ? "后付费" : "先付费" }}
<i class="el-icon-caret-bottom"></i> <i class="el-icon-caret-bottom"></i>
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
@ -96,7 +96,7 @@
</el-dropdown> --> </el-dropdown> -->
<!-- <el-button plain type="primary" size="mini"> <!-- <el-button plain type="primary" size="mini">
{{ postPay ? "后付费" : "先付费" }} {{ payAfter ? "后付费" : "先付费" }}
</el-button> --> </el-button> -->
<!-- 先付后付end --> <!-- 先付后付end -->
@ -177,7 +177,7 @@
<div> <div>
<el-dropdown @command="changePostPay"> <el-dropdown @command="changePostPay">
<el-button plain type="primary" size="mini"> <el-button plain type="primary" size="mini">
{{ postPay ? "后付费" : "先付费" }} {{ payAfter ? "后付费" : "先付费" }}
<i class="el-icon-caret-bottom"></i> <i class="el-icon-caret-bottom"></i>
</el-button> </el-button>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
@ -239,9 +239,7 @@
<div class="u-flex"> <div class="u-flex">
<div class="u-p-r-14 border-r u-m-r-14"> <div class="u-p-r-14 border-r u-m-r-14">
<template <template v-if="!shopInfo.isTableFee && table.tableId">
v-if="!shopInfo.isTableFee && key != 'isJieZhang'"
>
<div <div
class="u-flex cur-pointer" class="u-flex cur-pointer"
@click=" @click="
@ -432,10 +430,10 @@
<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="!payAfter">
<template <template
v-if=" v-if="
postPay && isCreateOrder && table && table.tableId payAfter && isCreateOrder && table && table.tableId
" "
> >
<!-- <template v-if="false"> --> <!-- <template v-if="false"> -->
@ -485,7 +483,7 @@
</button> </button>
</template> </template>
<template v-else> <template v-else>
<template v-if="postPay"> <template v-if="payAfter">
<div class="flex-1"> <div class="flex-1">
<el-button <el-button
type="primary" type="primary"
@ -845,6 +843,9 @@
<span class="txt">{{ <span class="txt">{{
vipUser.id ? vipUser.nickName : "服务员下单" vipUser.id ? vipUser.nickName : "服务员下单"
}}</span> }}</span>
<span class="vip" v-if="vipUser.isVip">
VIP{{ vipUser.isVip }}
</span>
</div> </div>
<div class="other_info"> <div class="other_info">
<div class="item">余额{{ vipUser.amount | to2 }}</div> <div class="item">余额{{ vipUser.amount | to2 }}</div>
@ -1490,7 +1491,7 @@ export default {
title: "支付", title: "支付",
}, },
//truefalse //truefalse
postPay: true, payAfter: true,
// //
isPrint: false, isPrint: false,
// //
@ -1901,23 +1902,24 @@ export default {
// }) // })
} }
}, },
table(newval, oldval) { // table(newval, oldval) {
this.setPostPay(); // this.setPostPay();
this.setUseType(); // this.setUseType();
if (oldval.tableId && newval.tableId) { // if (oldval.tableId && newval.tableId) {
this.perpole = 1; // this.perpole = 1;
this.isCreateOrder = false; // this.isCreateOrder = false;
} // }
if (this.key == "isJieZhang") { // if (this.key == "isJieZhang") {
this.isCreateOrder = false; // this.isCreateOrder = false;
this.key = ""; // this.key = "";
} // return;
if (newval && newval.tableId) { // }
this.createOrder.data.amount = 0; // if (newval && newval.tableId) {
this.createOrder.data.id = ""; // this.createOrder.data.amount = 0;
this.onTableChange(); // this.createOrder.data.id = "";
} // this.onTableChange();
}, // }
// },
masterId: function (val) { masterId: function (val) {
console.log(val); console.log(val);
}, },
@ -1926,7 +1928,7 @@ export default {
this.createOrder.discount = 1; this.createOrder.discount = 1;
} }
}, },
"vipUser.id": function (val) { "vipUser.id": function (val, oldval) {
// if (!this.table.tableId) { // if (!this.table.tableId) {
// return; // return;
// } // }
@ -1936,6 +1938,8 @@ export default {
// masterId = res.masterId; // masterId = res.masterId;
// } // }
// this.masterId = masterId; // this.masterId = masterId;
console.log("this.createOrder.data");
console.log(this.createOrder.data);
$setUser({ $setUser({
tableId: this.table.tableId, tableId: this.table.tableId,
masterId: this.masterId, masterId: this.masterId,
@ -1945,9 +1949,9 @@ export default {
}).then((res) => { }).then((res) => {
if (this.isCreateOrder) { if (this.isCreateOrder) {
this.createOrder.data.memberId = val.id; this.createOrder.data.memberId = val.id;
this.getOrderData().then(()=>{ this.getOrderData().then(() => {
this.pointsValueChange(this.points.value); this.pointsValueChange(this.points.value);
}) });
} }
}); });
}, },
@ -2198,7 +2202,7 @@ export default {
vipUserId: this.vipUser.id, vipUserId: this.vipUser.id,
tableId: this.table.tableId, tableId: this.table.tableId,
note: this.note.content, note: this.note.content,
postPay: this.postPay, payAfter: this.payAfter,
orderld: this.order.orderId, orderld: this.order.orderId,
}); });
this.isCreateOrder = true; this.isCreateOrder = true;
@ -2282,7 +2286,7 @@ export default {
localStorage.setItem("useType", "takeout"); localStorage.setItem("useType", "takeout");
} else { } else {
// //
useType = `dine-in-${this.postPay ? "after" : "before"}`; useType = `dine-in-${this.payAfter ? "after" : "before"}`;
localStorage.setItem("useType", useType); localStorage.setItem("useType", useType);
} }
this.changeOrderUseType(useType); this.changeOrderUseType(useType);
@ -2290,16 +2294,16 @@ export default {
// //
setPostPay() { setPostPay() {
// //
// postPay true false // payAfter true false
if (this.useTypes.sel == "takeout") { if (this.useTypes.sel == "takeout") {
this.postPay = false; this.payAfter = false;
} else { } else {
//munchies restaurant //munchies restaurant
this.postPay = this.shopInfo.registerType == "munchies" ? false : true; this.payAfter = this.shopInfo.registerType == "munchies" ? false : true;
} }
console.log("this.postPay"); console.log("this.payAfter");
console.log(this.postPay); console.log(this.payAfter);
}, },
// //
async getShopInfo() { async getShopInfo() {
@ -2335,6 +2339,9 @@ export default {
}, },
// //
async onTableChange() { async onTableChange() {
this.order.list = [];
this.order.old.list = [];
console.log("onTableChange");
const perpole = this.perpole || ""; const perpole = this.perpole || "";
const tableRes = await $returnTableDetail({ const tableRes = await $returnTableDetail({
tableId: this.table.tableId, tableId: this.table.tableId,
@ -2342,7 +2349,7 @@ export default {
console.log(tableRes); console.log(tableRes);
const orderId = tableRes.orderId || this.table.orderId; const orderId = tableRes.orderId || this.table.orderId;
if (orderId) { if (orderId) {
this.getOrderData({ orderId: orderId }); return this.getOrderData({ orderId: orderId });
} }
const res = await this.getMasterId(); const res = await this.getMasterId();
this.masterId = res.masterId; this.masterId = res.masterId;
@ -2352,6 +2359,7 @@ export default {
this.table.status == "idle" && this.table.status == "idle" &&
!this.shopInfo.isTableFee !this.shopInfo.isTableFee
) { ) {
this.perpole = 1;
await this.changePerpole(); await this.changePerpole();
} }
// //
@ -2367,22 +2375,11 @@ export default {
this.getCart(); this.getCart();
} }
this.getCacheOrder(); this.getCacheOrder();
console.log(this.isCreateOrder);
this.perpole = perpole || this.perpole; this.perpole = perpole || this.perpole;
if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) { if (!this.shopInfo.isTableFee && this.table.tableId && this.perpole > 0) {
// //
await this.changePerpole(); await this.changePerpole();
} }
// if (this.isCreateOrder) {
// this.toCreateOrder(true);
// }
},
//
async getTableDetail() {
const res = await tbShopTableGet({
qrcode: this.table.tableId,
});
console.log(res);
}, },
// //
printOrder() { printOrder() {
@ -2436,11 +2433,34 @@ export default {
console.log(error); console.log(error);
} }
}, },
async getTableDetail(tableId) {
const res = await $returnTableDetail({
tableId: tableId ? tableId : this.table.tableId,
});
this.table = { tableId, ...res };
return res;
},
async changeTable(item) { async changeTable(item) {
if (this.table || this.order.list.length <= 0) { console.log("changeTable");
console.log(this.table, this.table.tableId);
if (
(this.table && this.table.tableId) ||
(!this.table && !this.tableId && this.order.list.length <= 0)
) {
//
//
this.table = item;
this.tableShow = false;
this.setPostPay();
this.setUseType();
this.onTableChange();
return;
}
if (this.table && this.order.list.length <= 0) {
this.table = item; this.table = item;
this.tableShow = false; this.tableShow = false;
console.log(this.table); console.log(this.table);
this.onTableChange();
return; return;
} }
if (item.status != "idle") { if (item.status != "idle") {
@ -2465,13 +2485,14 @@ export default {
console.log(e); console.log(e);
} }
} }
this.tableShow = false;
await $choseTable({ await $choseTable({
masterId: this.masterId, masterId: this.masterId,
tableId: item.tableId, tableId: item.tableId,
isClear: res1 == "confirm" ? true : false, isClear: res1 == "confirm" ? true : false,
}); });
this.table = item; this.table = item;
this.tableShow = false; this.onTableChange();
}, },
chooseDinersNumberConfirm(e) { chooseDinersNumberConfirm(e) {
this.perpole = e; this.perpole = e;
@ -2586,7 +2607,7 @@ export default {
this.$refs.refMoneyKeyboard.open(); this.$refs.refMoneyKeyboard.open();
}, },
changePostPay(val) { changePostPay(val) {
this.postPay = val; this.payAfter = val;
}, },
// //
changeIsPrint(e) { changeIsPrint(e) {
@ -2760,7 +2781,7 @@ export default {
vipUserId: this.createOrder.data.memberId || this.vipUser.id, vipUserId: this.createOrder.data.memberId || this.vipUser.id,
tableId: this.table.tableId, tableId: this.table.tableId,
note: this.note.content, note: this.note.content,
postPay: this.postPay, payAfter: this.payAfter,
orderld: this.order.orderId, orderld: this.order.orderId,
}); });
this.getOrderData({ orderId: res.id }); this.getOrderData({ orderId: res.id });
@ -2773,7 +2794,7 @@ export default {
this.createOrder.status = "success"; this.createOrder.status = "success";
this.order.list = []; this.order.list = [];
// this.getCart(); // this.getCart();
if (this.postPay && !isNowPay) { if (this.payAfter && !isNowPay) {
this.$notify({ this.$notify({
title: "下单成功", title: "下单成功",
type: "success", type: "success",
@ -2781,8 +2802,7 @@ export default {
return this.close(); return this.close();
} }
if (!this.isPrverOrder) { if (!this.isPrverOrder) {
const { masterId } = await this.getMasterId(); await this.getMasterId();
this.masterId = masterId;
} }
this.isCreateOrder = true; this.isCreateOrder = true;
}, },
@ -2873,7 +2893,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.payAfter) {
this.createOrderClose(); this.createOrderClose();
} }
if (key === "sku") { if (key === "sku") {
@ -3629,16 +3649,13 @@ export default {
key = params.key, key = params.key,
perpoleNumber = params.num || ""; perpoleNumber = params.num || "";
this.key = key; this.key = key;
this.perpole = perpoleNumber;
const shopId = localStorage.getItem("shopId"); const shopId = localStorage.getItem("shopId");
const shopInfo = await tbShopInfo(shopId); const shopInfo = await tbShopInfo(shopId);
for (let i in shopInfo.eatModel) { for (let i in shopInfo.eatModel) {
let model = shopInfo.eatModel[i]; let model = shopInfo.eatModel[i];
model = model == "take-out" ? model.replace(/-/g, "") : model; model = model == "take-out" ? model.replace(/-/g, "") : model;
console.log(model);
const item = this.useTypes.list.find((v) => v.value == model); const item = this.useTypes.list.find((v) => v.value == model);
console.log(item);
if (item) { if (item) {
item.disabled = false; item.disabled = false;
} }
@ -3651,7 +3668,7 @@ export default {
this.masterId = params.masterId; this.masterId = params.masterId;
} }
if (key == "isJieZhang") { if (key == "isJieZhang") {
this.postPay = false; this.payAfter = false;
} else { } else {
this.setPostPay(); this.setPostPay();
} }
@ -3662,7 +3679,6 @@ export default {
console.log(params); console.log(params);
if (key == "isJieZhang") { if (key == "isJieZhang") {
this.table = params.tableId ? { name: item.name } : "";
if (params.orderId) { if (params.orderId) {
const orderRes = await this.getOrderData(params); const orderRes = await this.getOrderData(params);
if (orderRes.status != "unpaid") { if (orderRes.status != "unpaid") {
@ -3675,9 +3691,7 @@ export default {
if (key == "isPayOrder") { if (key == "isPayOrder") {
this.isCreateOrder = true; this.isCreateOrder = true;
} }
if (params.orderId) { this.perpole = perpoleNumber;
const orderRes = await this.getOrderData(params);
}
// this.getCart(); // this.getCart();
// this.getCacheOrder(); // this.getCacheOrder();
@ -3695,6 +3709,9 @@ export default {
} }
this.table = params.tableId ? item : ""; this.table = params.tableId ? item : "";
if (params.tableId) {
this.onTableChange();
}
}, },
async getOrderData(params) { async getOrderData(params) {
@ -3703,6 +3720,15 @@ export default {
const res = await tbOrderInfoDetail( const res = await tbOrderInfoDetail(
params ? params.orderId : this.createOrder.data.id params ? params.orderId : this.createOrder.data.id
); );
this.masterId=res.masterId?res.masterId:this.masterId;
if (res.tableId) {
await this.getTableDetail(res.tableId);
}
//1
if (this.table.tableId && !this.shopInfo.isTableFee) {
this.perpole = res.seatInfo ? res.seatInfo.num : 1;
await this.changePerpole();
}
this.createOrder.data = res; this.createOrder.data = res;
if (res.memberId) { if (res.memberId) {
await this.getCalcUsablePoints(); await this.getCalcUsablePoints();
@ -3732,23 +3758,6 @@ export default {
} }
} }
} }
this.order.seatFee = res.seatInfo
? {
...res.seatInfo,
totalNumber: res.seatInfo.num,
number: res.seatInfo.num,
name: res.seatInfo.productName,
totalAmount: res.seatInfo.priceAmount,
}
: {
name: "客座费",
number: res.seatCount || 0,
totalNumber: res.seatCount || 0,
totalAmount: res.seatAmount || 0,
status: "",
};
console.log(" this.order.seatFee");
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 {