代客下单结账增加积分优惠券支付

This commit is contained in:
YeMingfei666 2024-11-05 16:28:01 +08:00
parent 63ef70ab6a
commit 67a892ac01
7 changed files with 535 additions and 69 deletions

View File

@ -471,4 +471,50 @@ export function $activateByOrderId(data) {
...data ...data
} }
}); });
}
//会员积分列表
export function $returnMemberPointsList(data) {
return request({
url: '/api/points/member-points/page',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}
// 会员积分账户信息
export function $returnMemberPoints(memberId) {
return request({
url: '/api/points/member-points/'+memberId,
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}
//002-获取订单可用积分及抵扣金额(支付页面使用)
export function $calcUsablePoints(data) {
return request({
url: '/api/points/member-points/calc-usable-points',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
}
// 003-根据积分计算可抵扣金额
export function $calcDeDuctionPoints(data) {
return request({
url: '/api/points/member-points/calc-deduction-amount',
method: "get",
params:{
shopId: localStorage.getItem("shopId"),
...data
}
});
} }

View File

@ -30,5 +30,9 @@ export const $status= {
cleaning: { cleaning: {
label: "待清台", label: "待清台",
type: "#FAAD14", type: "#FAAD14",
},
unbind:{
label: "未绑定",
type: "rgb(221,221,221)",
} }
} }

View File

@ -207,21 +207,24 @@ export default {
filters: { filters: {
orderTypeFilter(t) { orderTypeFilter(t) {
if (t) { if (t) {
return t && orderEnum.orderType.find(item => item.key == t).label; const item= orderEnum.orderType.find(item => item.key == t);
return t && item?item.label:'';
} else { } else {
return t; return t;
} }
}, },
sendTypeFilter(t) { sendTypeFilter(t) {
if (t) { if (t) {
return orderEnum.sendType.find(item => item.key == t).label; const item= orderEnum.sendType.find(item => item.key == t);
return item?item.label:'';
} else { } else {
return t; return t;
} }
}, },
statusFilter(t) { statusFilter(t) {
if (t) { if (t) {
return t && orderEnum.status.find(item => item.key == t).label; const item= orderEnum.status.find(item => item.key == t);
return t && item?item.label:'';
} else { } else {
return t; return t;
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<el-dialog title="选择用户" width="850px" :visible.sync="show"> <el-dialog title="选择用户" width="850px" :visible.sync="show" top="20px">
<div class="app-container"> <div class="app-container">
<div class="head-container"> <div class="head-container">
<el-form :model="query" inline> <el-form :model="query" inline>
@ -73,7 +73,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="余额" prop="amount"></el-table-column> <el-table-column label="余额" prop="amount"></el-table-column>
<el-table-column label="积分" prop="totalScore"></el-table-column> <el-table-column label="积分" prop="accountPoints"></el-table-column>
<el-table-column label="操作" width="90" fixed="right"> <el-table-column label="操作" width="90" fixed="right">
<template v-slot="scope"> <template v-slot="scope">
@ -99,6 +99,7 @@
<script> <script>
import { queryAllShopUser, queryAllShopInfo } from "@/api/shop"; import { queryAllShopUser, queryAllShopInfo } from "@/api/shop";
import { $returnMemberPointsList } from "@/api/table";
import dayjs from "dayjs"; import dayjs from "dayjs";
let cacheData = {}; let cacheData = {};
export default { export default {
@ -107,6 +108,7 @@ export default {
show: false, show: false,
query: { query: {
name: "", name: "",
isVip:1
}, },
shopInfo: { shopInfo: {
balanceTotal: 0, balanceTotal: 0,
@ -202,7 +204,6 @@ export default {
this.tableData.page = e - 1; this.tableData.page = e - 1;
this.getTableData(); this.getTableData();
}, },
//
async getTableData() { async getTableData() {
this.tableData.loading = true; this.tableData.loading = true;
try { try {

View File

@ -154,7 +154,7 @@ export default {
} }
if (curretnMoney > money) { if (curretnMoney > money) {
this.$message.error("实收金额不能大于总金额"); this.$message.error("实收金额不能大于总金额");
this.form.curretnMoney = form.money; this.form.curretnMoney = this.form.money;
} }
this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2); this.form.reduceMoney = (money - this.form.curretnMoney).toFixed(2);
this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) ); this.form.discount =toFixedNoRounding( ((this.form.curretnMoney / money) * 100).toFixed(3) );
@ -173,7 +173,7 @@ export default {
}, },
open(data) { open(data) {
console.log(data); console.log(data);
this.form.money = data.amount; this.form.money = data.amount*1;
this.form.discount = data.discount?toFixedNoRounding(data.discount.toFixed(3)):100; this.form.discount = data.discount?toFixedNoRounding(data.discount.toFixed(3)):100;
this.show = true; this.show = true;
this.init(); this.init();

View File

@ -0,0 +1,189 @@
<template>
<el-dialog width="600px" :title="title" :visible.sync="show">
<div class="u-p-15">
<div class="">
<el-tabs v-model="activeName" @tab-click="tabClick">
<el-tab-pane label="优惠券(单选)" name="youhui">
<el-table
empty-text="无可用优惠券"
:data="quans.fullReductionCoupon"
@cell-click="fullReductionCouponClick"
>
<el-table-column type="index" width="80" label="">
<template v-slot="scope">
<el-checkbox
@change="fullReductionCouponClick(scope.row)"
:value="scope.row.id == fullReductionCouponSel.id"
></el-checkbox>
</template>
</el-table-column>
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="商品券(多选)" name="goods">
<el-table
empty-text="无可用商品券"
:data="quans.productCoupon"
tooltip-effect="dark"
style="width: 100%"
@selection-change="productCouponChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<div v-if="quansSelArr.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table
empty-text="未选择优惠券"
:data="quansSelArr"
>
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称"> </el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</div>
<div class="u-flex u-row-center u-m-t-50">
<el-button size="medium" @click="close">取消</el-button>
<el-button size="medium" type="primary" @click="confirm"
>确定</el-button
>
</div>
</div>
</div>
</el-dialog>
</template>
<script>
import { $activateByOrderId } from "@/api/table";
export default {
props: {
title: {
type: String,
default: "选择优惠券",
},
},
data() {
return {
fullReductionCouponSel: {
id: "",
},
productCouponSelArr: [],
quansSelArr: [],
quans: {
fullReductionCoupon: [],
productCoupon: [],
},
currentRow: null,
multipleSelection: null,
fullReductionCouponSelId: "",
activeName: "youhui",
form: {},
show: false,
};
},
watch: {},
methods: {
productCouponChange(val) {
this.productCouponSelArr = val;
if (this.productCouponSelArr.length > 0) {
this.productCouponSelArr.length = val.length + 1;
for (let i in val) {
this.quansSelArr[i + 1] = val[i];
}
} else {
this.quansSelArr = val;
}
},
fullReductionCouponClick(row) {
if (this.fullReductionCouponSel.id == row.id) {
this.fullReductionCouponSel = { id: "" };
this.quansSelArr.shift();
} else {
this.fullReductionCouponSel = row;
this.quansSelArr.unshift(row);
}
console.log(this.quansSelArr)
},
handleCurrentChange(val) {
this.currentRow = val;
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
tabClick() {},
init() {},
changeKey(key, val) {
this[key] = val;
},
confirm() {
this.$emit("confirm", this.quansSelArr);
this.close();
},
async open(data) {
console.log(data);
if (data.memberId) {
let quans = await $activateByOrderId({
orderId: data.id,
memberId: data.memberId,
});
quans.fullReductionCoupon = quans.fullReductionCoupon.filter(
(v) => v.use
);
quans.productCoupon = quans.productCoupon.filter((v) => v.use);
this.quans = quans;
}
this.show = true;
this.init();
},
close() {
this.show = false;
},
},
mounted() {
this.number = `${this.value}`;
},
};
</script>
<style lang="scss" scoped>
.codeImg {
width: 160px;
border: 1px solid rgb(220, 223, 230);
height: 160px;
}
::v-deep .el-input .el-input__inner::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
::v-deep .el-input .el-input__inner::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
</style>

View File

@ -23,7 +23,7 @@
<template v-else> <template v-else>
<div class="flex cur-pointer" @click="refChooseUserOpen"> <div class="flex cur-pointer" @click="refChooseUserOpen">
<img <img
v-if="vipUser.headImg" v-if="vipUser.headImg && vipUser.headImg != 'null'"
class="headimg" class="headimg"
:src="vipUser.headImg" :src="vipUser.headImg"
alt="" alt=""
@ -806,11 +806,13 @@
<div class="cashier_left"> <div class="cashier_left">
<!-- <div class="title">选择优惠</div> --> <!-- <div class="title">选择优惠</div> -->
<div class="detail_box"> <div class="detail_box">
<div class="usercard"> <div class="usercard" @click="refChooseUserOpen">
<span <span
class="el-avatar el-avatar--square" class="el-avatar el-avatar--square"
style="height: 50px; width: 50px; line-height: 50px" style="height: 50px; width: 50px; line-height: 50px"
><img v-if="vipUser.id" :src="vipUser.headImg" ><img
v-if="vipUser.id && vipUser.headImg != 'null'"
:src="vipUser.headImg"
/></span> /></span>
<div class="info"> <div class="info">
<div class="nickname"> <div class="nickname">
@ -820,30 +822,94 @@
</div> </div>
<div class="other_info"> <div class="other_info">
<div class="item">余额{{ vipUser.amount | to2 }}</div> <div class="item">余额{{ vipUser.amount | to2 }}</div>
<div class="item">积分{{ vipUser.totalScore }}</div> <div class="item">
积分{{ vipUser.accountPoints }}
</div>
</div> </div>
</div> </div>
</div> </div>
<div class="forms"> <div class="forms">
<el-form <div class="u-m-b-20 u-m-t-10" v-if="vipUser.id">
ref="form" <div class="u-flex u-flex-wrap">
:model="createOrder.form" <span class="font-bold no-wrap u-m-r-20">积分抵扣</span>
label-width="60px" <el-radio-group
> v-model="points.selected"
<el-form-item label="优惠券"> :disabled="!points.res.usable"
<el-select @input="pointsChange"
style="margin-right: 10px" >
v-model="createOrder.quan.sel" <el-radio :label="1">全部抵扣</el-radio>
placeholder="选择优惠券" <el-radio :label="2">部分抵扣</el-radio>
</el-radio-group>
<div class="u-m-l-20" v-if="points.res.usable">
<el-input-number
@change="pointsValueChange"
v-if="points.selected == 1"
disabled
v-model="points.value"
:min="points.minDeductionPoints"
:max="points.maxUsablePoints"
></el-input-number>
<el-input-number
@change="pointsValueChange"
v-if="points.selected == 2"
v-model="points.value"
:min="points.minDeductionPoints"
:max="points.maxUsablePoints"
></el-input-number>
</div>
</div>
<div class="color-999 u-m-t-10">
<template v-if="points.res.usable">
<span class="color-red">*</span>
<span
>最大抵扣积分{{ points.res.maxUsablePoints }}</span
> >
</el-select> <span
<el-button size="medium " type="text"> >最小抵扣积分{{
查看不可用券 points.res.minDeductionPoints
</el-button> }}</span
</el-form-item> >
</el-form> </template>
<template v-else>
<span class="color-red">*</span>
<span>{{ points.res.unusableReason || "" }}</span>
</template>
</div>
</div> </div>
<div class="u-flex flex-wrap">
<span class="font-bold no-wrap">优惠券</span>
<div
class="border u-p-l-20 cur-pointer u-m-r-20 u-flex no-wrap u-p-t-10 u-p-b-10 border-r-4 selQuan"
@click="showQuan"
>
<span class="color-999 u-p-r-10">选择优惠券</span>
<span
class="el-icon-arrow-down color-999 u-m-r-10"
></span>
</div>
<!-- <el-button size="medium " type="text">
查看不可用券
</el-button> -->
</div>
</div>
<div class="u-p-b-20" v-if="quansSelArr.length > 0">
<div class="font-bold u-m-b-10">已选优惠券</div>
<el-table empty-text="未选择优惠券" :data="quansSelArr">
<el-table-column type="index" width="50" label="#">
</el-table-column>
<el-table-column prop="name" label="券名称">
</el-table-column>
<el-table-column label="券类型" width="80">
<template v-slot="scope">
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
</div>
</div> </div>
<div class="btn_group"> <div class="btn_group">
<el-button size="medium" @click="disCountShow"> <el-button size="medium" @click="disCountShow">
@ -894,13 +960,17 @@
<div class="left">门店优惠</div> <div class="left">门店优惠</div>
<div class="right">-0.00</div> <div class="right">-0.00</div>
</div> </div>
<div class="detail_form_item"> <!-- <div class="detail_form_item">
<div class="left">满减优惠</div> <div class="left">满减优惠</div>
<div class="right">-0.00</div> <div class="right">-{{ manjian }}</div>
</div> </div> -->
<div class="detail_form_item"> <div class="detail_form_item">
<div class="left">优惠券</div> <div class="left">优惠券</div>
<div class="right">-0.00</div> <div class="right">-{{ manjian }}</div>
</div>
<div class="detail_form_item">
<div class="left">积分抵扣</div>
<div class="right">-{{ points.toMoney | to2 }}</div>
</div> </div>
<div class="detail_form_item"> <div class="detail_form_item">
<div class="left">整单改价</div> <div class="left">整单改价</div>
@ -937,7 +1007,9 @@
<div class="left">应付金额</div> <div class="left">应付金额</div>
<div class="right redfont"> <div class="right redfont">
{{ {{
(createOrder.data.amount * createOrder.discount) | to2 currentPayMoney - points.toMoney <= 0
? 0
: (currentPayMoney - points.toMoney) | to2
}} }}
</div> </div>
</div> </div>
@ -1233,6 +1305,9 @@
<!-- 打折 --> <!-- 打折 -->
<money-discount ref="refDiscount" @confirm="ChangeDiscount"> <money-discount ref="refDiscount" @confirm="ChangeDiscount">
</money-discount> </money-discount>
<!-- 优惠券 -->
<quans-pop ref="refQuans" @confirm="quansConfirm"> </quans-pop>
<!-- 选择人数 --> <!-- 选择人数 -->
<choose-diners-number <choose-diners-number
ref="refChooseDinersNumber" ref="refChooseDinersNumber"
@ -1256,6 +1331,7 @@ import chooseTable from "./components/choose-table-master.vue";
import cartItem from "./components/cart-item.vue"; import cartItem from "./components/cart-item.vue";
import scanPay from "./components/scan-pay.vue"; import scanPay from "./components/scan-pay.vue";
import moneyDiscount from "./components/discount.vue"; import moneyDiscount from "./components/discount.vue";
import quansPop from "./components/quans.vue";
import orderNote from "./components/note.vue"; import orderNote from "./components/note.vue";
import chooseDinersNumber from "./components/choose-diners-number.vue"; import chooseDinersNumber from "./components/choose-diners-number.vue";
import returnCart from "./components/return-cart.vue"; import returnCart from "./components/return-cart.vue";
@ -1264,6 +1340,7 @@ import dayjs from "dayjs";
import { tbShopInfo } from "@/api/user"; import { tbShopInfo } from "@/api/user";
import { hasPermission } from "@/utils/limits.js"; import { hasPermission } from "@/utils/limits.js";
import { tbOrderInfoDetail } from "@/api/order"; import { tbOrderInfoDetail } from "@/api/order";
import { queryAllShopUser } from "@/api/shop";
import { import {
getGoodsLists, getGoodsLists,
@ -1287,7 +1364,9 @@ import {
tbShopTableGet, tbShopTableGet,
$changeUseType, $changeUseType,
$returnTableDetail, $returnTableDetail,
$activateByOrderId $activateByOrderId,
$calcUsablePoints,
$calcDeDuctionPoints,
} from "@/api/table"; } from "@/api/table";
import { tbShopCategoryGet } from "@/api/shop"; import { tbShopCategoryGet } from "@/api/shop";
import { import {
@ -1305,6 +1384,7 @@ import { $status } from "@/utils/table.js";
let $originTableList = []; let $originTableList = [];
export default { export default {
components: { components: {
quansPop,
returnCart, returnCart,
chooseUser, chooseUser,
chooseTable, chooseTable,
@ -1318,6 +1398,20 @@ export default {
}, },
data() { data() {
return { return {
//
points: {
res: {
usable: true,
},
selected: "",
minDeductionPoints: 0,
maxUsablePoints: 0,
usable: false,
points: 0,
toMoney: 0,
},
//
quansSelArr: [],
// //
tableSearchText: "", tableSearchText: "",
// //
@ -1516,6 +1610,30 @@ export default {
}; };
}, },
computed: { computed: {
manjian() {
let result = 0;
if (this.quansSelArr.length < 0) {
result = 0;
}
const manjianQuan = this.quansSelArr.find((v) => v.type == 1);
if (!manjianQuan) {
result = 0;
} else {
result = manjianQuan.discountAmount;
}
return result.toFixed(2);
},
currentPayMoney() {
const amount = this.createOrder.data.amount || 0;
const discount = this.createOrder.discount || 1;
// const total=((amount - this.manjian) * this.createOrder.discount - this.points.toMoney)
const total = (amount - this.manjian) * this.createOrder.discount;
return total <= 0 ? 0 : total;
},
yinFuJinE(){
const total=this.currentPayMoney-( this.points.toMoney||0)
return total.toFixed(2);
},
disableTuicai() { disableTuicai() {
return ( return (
this.order.placeNum == 1 || this.order.placeNum == 1 ||
@ -1527,7 +1645,7 @@ export default {
}, },
title() { title() {
// return this.table ? "" + `(${this.table.name})` : ""; // return this.table ? "" + `(${this.table.name})` : "";
return '代客下单' return "代客下单";
}, },
allGiftMoney() { allGiftMoney() {
const nowprice = this.order.list const nowprice = this.order.list
@ -1691,6 +1809,13 @@ export default {
this.goods.status = "loadmore"; this.goods.status = "loadmore";
this.getGoods(); this.getGoods();
}, },
currentPayMoney: function (newval) {
if (this.createOrder.data.memberId||this.vipUser.id) {
this.getCalcUsablePoints().then((res) => {
this.pointsValueChange(this.points.value);
});
}
},
"useTypes.sel": function (newval, oldval) { "useTypes.sel": function (newval, oldval) {
console.log(newval); console.log(newval);
this.setPostPay(); this.setPostPay();
@ -1710,13 +1835,13 @@ 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 = "";
} }
if (newval && newval.tableId) { if (newval && newval.tableId) {
this.createOrder.data.amount = 0; this.createOrder.data.amount = 0;
@ -1746,8 +1871,10 @@ export default {
tableId: this.table.tableId, tableId: this.table.tableId,
masterId: this.masterId, masterId: this.masterId,
vipUserId: val, vipUserId: val,
orderId:this.createOrder.data.id||'', orderId: this.createOrder.data.id || "",
type: val === "" ? 1 : 0, type: val === "" ? 1 : 0,
}).then((res) => {
this.createOrder.data.memberId = val.id;
}); });
}, },
"prveOrder.list.length": function (val) { "prveOrder.list.length": function (val) {
@ -1865,6 +1992,57 @@ export default {
this.open(this.$route.query); this.open(this.$route.query);
}, },
methods: { methods: {
async getCalcUsablePoints() {
const pointsRes = await $calcUsablePoints({
memberId: this.createOrder.data.memberId || this.vipUser.id,
orderAmount: this.currentPayMoney.toFixed(2),
});
this.points.res = pointsRes;
this.points.minDeductionPoints = pointsRes.minDeductionPoints;
this.points.maxUsablePoints = pointsRes.maxUsablePoints;
if(this.points.selected){
this.points.value = Math.min(
this.vipUser.accountPoints,
this.points.res.maxUsablePoints || 0
);
}
return pointsRes;
},
//
pointsValueChange(e) {
console.log(e);
if (e == 0 || !e) {
return (this.points.toMoney = 0);
}
$calcDeDuctionPoints({
memberId: this.createOrder.data.memberId || this.vipUser.id,
orderAmount: this.currentPayMoney.toFixed(2),
points: e,
}).then((res) => {
this.points.toMoney = res * 1;
});
},
//
pointsChange(e) {
console.log(e);
if (e == 1) {
this.points.value = Math.min(
this.vipUser.accountPoints,
this.points.res.maxUsablePoints || 0
);
this.pointsValueChange(this.points.value);
}
},
showQuan() {
this.$refs.refQuans.open({
id: this.createOrder.data.id,
memberId: this.createOrder.data.memberId || this.vipUser.id,
});
},
quansConfirm(e) {
console.log(e);
this.quansSelArr = e;
},
searchInput(e) { searchInput(e) {
console.log(e); console.log(e);
this.tableList = $originTableList.filter((v) => this.tableList = $originTableList.filter((v) =>
@ -1920,7 +2098,7 @@ export default {
if (!canJiesuan) { if (!canJiesuan) {
return; return;
} }
this.$confirm("是否确认已现金收款:" + this.allPrice + "?", "快捷支付", { this.$confirm("是否确认已现金收款:" + this.yinFuJinE + "?", "快捷支付", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
@ -2042,8 +2220,8 @@ export default {
//munchies restaurant //munchies restaurant
this.postPay = this.shopInfo.registerType == "munchies" ? false : true; this.postPay = this.shopInfo.registerType == "munchies" ? false : true;
} }
console.log('this.postPay') console.log("this.postPay");
console.log(this.postPay) console.log(this.postPay);
}, },
// //
async getShopInfo() { async getShopInfo() {
@ -2073,20 +2251,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; this.perpole = res.totalNumber || res.number;
return res; return res;
}, },
// //
async onTableChange() { async 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,
}); });
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 }); this.getOrderData({ orderId: orderId });
} }
const res = await this.getMasterId(); const res = await this.getMasterId();
this.masterId = res.masterId; this.masterId = res.masterId;
@ -2112,7 +2290,7 @@ export default {
} }
this.getCacheOrder(); this.getCacheOrder();
console.log(this.isCreateOrder); 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();
@ -2170,7 +2348,10 @@ export default {
shopId: localStorage.getItem("shopId"), shopId: localStorage.getItem("shopId"),
}); });
this.tableList = content.filter( this.tableList = content.filter(
(v) => v.status != "closed" && v.status != "cleaning" (v) =>
v.status != "closed" &&
v.status != "cleaning" &&
v.status != "unbind"
); );
$originTableList = this.tableList; $originTableList = this.tableList;
} catch (error) { } catch (error) {
@ -2251,7 +2432,7 @@ export default {
if (!canDiscount) { if (!canDiscount) {
return; return;
} }
const { amount } = this.createOrder.data; const amount = this.createOrder.data.amount - this.manjian;
this.refToggle("refDiscount", true, { this.refToggle("refDiscount", true, {
amount, amount,
discount: this.createOrder.discount * 100, discount: this.createOrder.discount * 100,
@ -2386,20 +2567,47 @@ export default {
orderId: this.createOrder.data.id, orderId: this.createOrder.data.id,
payType: this.order.payType, payType: this.order.payType,
}); });
if (this.order.payType == "cash") {
return this.$confirm(
"是否确认已现金收款:" + this.yinFuJinE + "?",
"快捷支付",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}
).then(() => {
this.pays();
});
}
this.pays(); this.pays();
}, },
// //
async pays() { async pays() {
this.loading = true; this.loading = true;
const userCouponInfos = this.quansSelArr.reduce((prve, cur) => {
const index = prve.findIndex((v) => v.userCouponId == cur.couponId);
if (index != -1) {
prve[index].num += 1;
} else {
prve.push({
userCouponId: cur.couponId,
num: 1,
});
}
return prve;
}, []);
try { try {
const res = await $payOrder({ const res = await $payOrder({
tableId: this.table.tableId, tableId: this.table.tableId,
masterId: this.masterId, masterId: this.masterId,
orderId: this.createOrder.data.id, orderId: this.createOrder.data.id,
payType: this.order.payType, payType: this.order.payType,
vipUserId: this.vipUser.id, vipUserId: this.createOrder.data.memberId || this.vipUser.id,
discount: this.createOrder.discount, discount: this.createOrder.discount,
code: this.createOrder.code, code: this.createOrder.code,
userCouponInfos,
pointsNum: this.points.value,
}); });
this.loading = false; this.loading = false;
this.payOrderSuccess(); this.payOrderSuccess();
@ -2471,7 +2679,7 @@ export default {
} }
res = await $createOrder({ res = await $createOrder({
masterId: this.order.masterId || this.masterId, masterId: this.order.masterId || this.masterId,
vipUserId: 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, postPay: this.postPay,
@ -2485,7 +2693,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.postPay && !isNowPay) {
this.$notify({ this.$notify({
@ -2990,7 +3198,7 @@ export default {
} }
} else { } else {
// //
console.log(this.table) console.log(this.table);
res = await addCart({ res = await addCart({
masterId: this.masterId, masterId: this.masterId,
vipUserId: this.vipUser.id, vipUserId: this.vipUser.id,
@ -3141,9 +3349,9 @@ export default {
this.order.seatFee = seatFee this.order.seatFee = seatFee
? { ? {
...seatFee, ...seatFee,
totalNumber: seatFee.num||seatFee.number, totalNumber: seatFee.num || seatFee.number,
num: seatFee.number, num: seatFee.number,
name: seatFee.name|| seatFee.productName, name: seatFee.name || seatFee.productName,
totalAmount: seatFee.priceAmount || seatFee.totalAmount, totalAmount: seatFee.priceAmount || seatFee.totalAmount,
} }
: this.order.seatFee; : this.order.seatFee;
@ -3288,6 +3496,9 @@ export default {
} else { } else {
// //
console.log(item); console.log(item);
if (item.specList.length <= 0) {
return this.$message.error("该商品缺少skuID,skuList是空数组");
}
res = await addCart({ res = await addCart({
masterId: this.masterId, masterId: this.masterId,
vipUserId: this.vipUser.id, vipUserId: this.vipUser.id,
@ -3371,7 +3582,7 @@ export default {
this.getCategory(); this.getCategory();
this.getTable(); this.getTable();
console.log(params); console.log(params);
if (key == "isJieZhang") { if (key == "isJieZhang") {
this.table = params.tableId ? { name: item.name } : ""; this.table = params.tableId ? { name: item.name } : "";
if (params.orderId) { if (params.orderId) {
@ -3383,13 +3594,13 @@ export default {
this.isCreateOrder = true; this.isCreateOrder = true;
return; return;
} }
if( key == "isPayOrder" ){ if (key == "isPayOrder") {
this.isCreateOrder =true this.isCreateOrder = true;
} }
if(params.orderId) { if (params.orderId) {
const orderRes = await this.getOrderData(params); const orderRes = await this.getOrderData(params);
} }
// this.getCart(); // this.getCart();
// this.getCacheOrder(); // this.getCacheOrder();
// if (!params) { // if (!params) {
@ -3404,26 +3615,33 @@ export default {
? item.useType ? item.useType
: item.useType.replace(/-after|-before/g, ""); : item.useType.replace(/-after|-before/g, "");
} }
this.table = params.tableId ? item : ""; this.table = params.tableId ? item : "";
}, },
async getOrderData(params) { async getOrderData(params) {
const orderId= params ? params.orderId : this.createOrder.data.id const orderId = params ? params.orderId : this.createOrder.data.id;
const res = await tbOrderInfoDetail( const res = await tbOrderInfoDetail(
params ? params.orderId : this.createOrder.data.id params ? params.orderId : this.createOrder.data.id
); );
if(res.memberId){ this.createOrder.data = res;
$activateByOrderId({ if (res.memberId) {
orderId,memberId:res.memberId await this.getCalcUsablePoints();
}) queryAllShopUser({ id: res.memberId }).then((res) => {
if (res.content[0]) {
this.vipUser = res.content[0];
this.points.maxUsablePoints = Math.min(
this.points.maxUsablePoints,
this.vipUser.accountPoints || 0
);
}
});
} }
if (res.status != "unpaid") { if (res.status != "unpaid") {
return res; return res;
} }
this.createOrder.data = res;
this.order.packFee.totalAmount = res.seatInfo || { totalAmount: 0 }; this.order.packFee.totalAmount = res.seatInfo || { totalAmount: 0 };
const goodsMap = {}; const goodsMap = {};
for (let i in res.detailList) { for (let i in res.detailList) {
@ -3511,6 +3729,11 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.selQuan {
border: 1px solid #d9d9d9;
border-radius: 4px;
margin-left: 12px;
}
/* 针对所有input type="number" */ /* 针对所有input type="number" */
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { input[type="number"]::-webkit-outer-spin-button {