修改代客下单相关逻辑
This commit is contained in:
parent
8403afd685
commit
924f296ad1
|
|
@ -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(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();
|
||||
|
|
@ -1916,7 +1925,7 @@ export default {
|
|||
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.isCreateOrder = true;
|
||||
this.order.old.list = formatOrderGoodsList(res.detailList || []);
|
||||
this.getOrderData({orderId:res.id})
|
||||
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;
|
||||
|
|
@ -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() {
|
||||
|
|
@ -2135,7 +2147,7 @@ export default {
|
|||
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,
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -3414,7 +3433,6 @@ export default {
|
|||
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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue