增加商品券抵扣以及商品券抵扣后价格计算过滤不满足满减条件的优惠券,修改部分代客下单逻辑

This commit is contained in:
2024-11-07 17:04:00 +08:00
parent a9a4efabe9
commit 28fdcd9e5c
3 changed files with 196 additions and 58 deletions

View File

@@ -856,8 +856,8 @@
</div>
</div>
<div class="forms">
<div class="u-m-b-20 u-m-t-10" v-if="vipUser.id">
<div class="forms" v-if="vipUser.id">
<div class="u-m-b-20 u-m-t-10" >
<div class="u-flex u-flex-wrap">
<span class="font-bold no-wrap u-m-r-20">积分抵扣</span>
<el-radio-group
@@ -905,7 +905,7 @@
</div>
</div>
<div class="u-flex flex-wrap">
<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"
@@ -933,6 +933,18 @@
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
</template>
</el-table-column>
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="u-flex " v-if="scope.row.type == 2">
<el-image
:src="scope.row.productCover"
style="width: 40px; height: 40px"
:preview-src-list="[scope.row.productCover]"
></el-image>
<div class="u-m-l-10">{{ scope.row.productName }}</div>
</div>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="描述">
</el-table-column>
</el-table>
@@ -989,11 +1001,11 @@
</div>
<!-- <div class="detail_form_item">
<div class="left">满减优惠</div>
<div class="right">-¥{{ manjian }}</div>
<div class="right">-¥{{ coupdiscount }}</div>
</div> -->
<div class="detail_form_item">
<div class="left">优惠券</div>
<div class="right">-¥{{ manjian }}</div>
<div class="right">-¥{{ coupdiscount }}</div>
</div>
<div class="detail_form_item">
<div class="left">积分抵扣</div>
@@ -1333,7 +1345,7 @@
<money-discount ref="refDiscount" @confirm="ChangeDiscount">
</money-discount>
<!-- 优惠券 -->
<quans-pop ref="refQuans" @confirm="quansConfirm"> </quans-pop>
<quans-pop ref="refQuans" :vipUser="vipUser" :orderPrice="currentPayMoney" :goodsArr="createOrder.data.detailList||[]" @confirm="quansConfirm"> </quans-pop>
<!-- 选择人数 -->
<choose-diners-number
@@ -1406,6 +1418,7 @@ import {
returnPackFee,
formatOrderGoodsList,
returnVipDiscountPrice,
returnCouponAllPrice
} from "./util.js";
import { $status } from "@/utils/table.js";
@@ -1641,24 +1654,30 @@ export default {
isShowVipPrice() {
return this.vipUser.isVip ? true : false;
},
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;
coupdiscount() {
return returnCouponAllPrice(this.quansSelArr,this.createOrder.data.detailList||[],this.vipUser)
},
goodsDisCount(){
const goodsQuanArr=this.quansSelArr.filter(v=>v.type==2);
let result=0;
if(goodsQuanArr.length<0){
result=0;
}else{
result=goodsQuanArr.reduce((a,b)=>{
const item=this.createOrder.data.detailList.find(v=>v.productId==b.proId);
const memberPrice=item.memberPrice?item.memberPrice:item.price;
const price=item?(this.vipUser.isVip?memberPrice:item.price):0;
return a+price;
},0);
}
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;
// const total=((amount - this.coupdiscount) * this.createOrder.discount - this.points.toMoney)
const total = (amount - this.coupdiscount) * this.createOrder.discount;
return total <= 0 ? 0 : total;
},
yinFuJinE() {
@@ -2531,7 +2550,7 @@ export default {
if (!canDiscount) {
return;
}
const amount = this.createOrder.data.amount - this.manjian;
const amount = this.createOrder.data.amount - this.coupdiscount;
this.refToggle("refDiscount", true, {
amount,
discount: this.createOrder.discount * 100,
@@ -2776,15 +2795,20 @@ export default {
if (!this.shopInfo.isTableFee) {
await this.changePerpole();
}
res = await $createOrder({
masterId: this.order.masterId || this.masterId,
vipUserId: this.createOrder.data.memberId || this.vipUser.id,
tableId: this.table.tableId,
note: this.note.content,
payAfter: this.payAfter,
orderld: this.order.orderId,
});
this.getOrderData({ orderId: res.id });
if (this.order.list.length > 0) {
res = await $createOrder({
masterId: this.order.masterId || this.masterId,
vipUserId: this.createOrder.data.memberId || this.vipUser.id,
tableId: this.table.tableId,
note: this.note.content,
payAfter: this.payAfter,
orderld: this.order.orderId,
});
} else {
res = true;
}
await this.getOrderData();
res = true;
} catch (error) {}
if (!res) {
this.createOrder.status = "success";
@@ -3720,7 +3744,7 @@ export default {
const res = await tbOrderInfoDetail(
params ? params.orderId : this.createOrder.data.id
);
this.masterId=res.masterId?res.masterId:this.masterId;
this.masterId = res.masterId ? res.masterId : this.masterId;
if (res.tableId) {
await this.getTableDetail(res.tableId);
}