修改部分代客下单逻辑

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