增加商品券抵扣以及商品券抵扣后价格计算过滤不满足满减条件的优惠券,修改部分代客下单逻辑
This commit is contained in:
parent
a9a4efabe9
commit
28fdcd9e5c
|
|
@ -9,7 +9,12 @@
|
||||||
:data="quans.fullReductionCoupon"
|
:data="quans.fullReductionCoupon"
|
||||||
@cell-click="fullReductionCouponClick"
|
@cell-click="fullReductionCouponClick"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" width="80" label="" v-if="quans.fullReductionCoupon.length>0">
|
<el-table-column
|
||||||
|
type="index"
|
||||||
|
width="80"
|
||||||
|
label=""
|
||||||
|
v-if="quans.fullReductionCoupon.length > 0"
|
||||||
|
>
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
@change="fullReductionCouponClick(scope.row)"
|
@change="fullReductionCouponClick(scope.row)"
|
||||||
|
|
@ -21,7 +26,16 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||||
<el-table-column label="券类型" width="80">
|
<el-table-column label="券类型" width="80">
|
||||||
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="discountAmount" label="抵扣">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<span class="color-red">
|
||||||
|
¥{{ scope.row.discountAmount }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="useRestrictions" label="描述">
|
<el-table-column prop="useRestrictions" label="描述">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -39,32 +53,55 @@
|
||||||
<el-table-column type="index" width="50" label="#">
|
<el-table-column type="index" width="50" label="#">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||||
|
<el-table-column label="商品信息">
|
||||||
|
<template v-slot="scope">
|
||||||
|
<div class="u-flex ">
|
||||||
|
<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 label="券类型" width="80">
|
<el-table-column label="券类型" width="80">
|
||||||
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
|
<template v-slot="scope">
|
||||||
|
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="useRestrictions" label="描述">
|
<el-table-column prop="useRestrictions" label="描述">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
||||||
<div v-if="quansSelArr.length > 0">
|
<div v-if="quansSelArr.length > 0">
|
||||||
<div class="font-bold u-m-b-10">已选优惠券</div>
|
<div class="font-bold u-m-b-10">已选优惠券</div>
|
||||||
<el-table
|
<el-table empty-text="未选择优惠券" :data="quansSelArr">
|
||||||
empty-text="未选择优惠券"
|
|
||||||
:data="quansSelArr"
|
|
||||||
>
|
|
||||||
<el-table-column type="index" width="50" label="#">
|
<el-table-column type="index" width="50" label="#">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="name" label="券名称"> </el-table-column>
|
<el-table-column prop="name" label="券名称"> </el-table-column>
|
||||||
<el-table-column label="券类型" width="80">
|
<el-table-column label="券类型" width="80">
|
||||||
<template v-slot="scope"> {{scope.row.type==1?'优惠券':'商品券'}} </template>
|
<template v-slot="scope">
|
||||||
|
{{ 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>
|
||||||
<el-table-column prop="useRestrictions" label="描述">
|
<el-table-column prop="useRestrictions" label="描述">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="u-flex u-row-center u-m-t-50">
|
<div class="u-flex u-row-center u-m-t-50">
|
||||||
<el-button size="medium" @click="close">取消</el-button>
|
<el-button size="medium" @click="close">取消</el-button>
|
||||||
<el-button size="medium" type="primary" @click="confirm"
|
<el-button size="medium" type="primary" @click="confirm"
|
||||||
|
|
@ -77,12 +114,30 @@
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { $activateByOrderId } from "@/api/table";
|
import { $activateByOrderId } from "@/api/table";
|
||||||
|
import {returnProductCouponAllPrice} from '../util'
|
||||||
|
let $originFullReductionCoupon=[]
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "选择优惠券",
|
default: "选择优惠券",
|
||||||
},
|
},
|
||||||
|
goodsArr:{
|
||||||
|
type:Array,
|
||||||
|
default:[]
|
||||||
|
},
|
||||||
|
vipUser:{
|
||||||
|
type:Object,
|
||||||
|
default:()=>{
|
||||||
|
return {
|
||||||
|
isVip:false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
orderPrice:{
|
||||||
|
type:Number,
|
||||||
|
default:0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -103,30 +158,52 @@ export default {
|
||||||
show: false,
|
show: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {},
|
watch: {
|
||||||
methods: {
|
activeName(newval){
|
||||||
productCouponChange(val) {
|
if(newval=='youhui'){
|
||||||
this.productCouponSelArr = val;
|
this.quans.fullReductionCoupon=$originFullReductionCoupon.filter(v=>(this.orderPrice-this.goodsDiscount)>=v.fullAmount)
|
||||||
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) {
|
computed:{
|
||||||
if (this.fullReductionCouponSel.id == row.id) {
|
|
||||||
this.fullReductionCouponSel = { id: "" };
|
|
||||||
this.quansSelArr.shift();
|
|
||||||
|
|
||||||
|
goodsDiscount(){
|
||||||
|
const coupArr=this.productCouponSelArr.filter(v=>v.type==2);
|
||||||
|
return returnProductCouponAllPrice(coupArr,this.goodsArr,this.vipUser)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
productCouponChange(val) {
|
||||||
|
console.log(val)
|
||||||
|
this.productCouponSelArr = val;
|
||||||
|
const dikouQuan=this.quansSelArr[0]
|
||||||
|
if (this.productCouponSelArr.length > 0&&(dikouQuan&&dikouQuan.type==1) ) {
|
||||||
|
for (let i in val) {
|
||||||
|
this.$set(this.quansSelArr, i+1, val[i])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.fullReductionCouponSel = row;
|
if(dikouQuan){
|
||||||
this.quansSelArr.unshift(row);
|
this.quansSelArr=[dikouQuan]
|
||||||
|
}else{
|
||||||
|
this.quansSelArr = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
console.log(this.quansSelArr)
|
console.log(this.quansSelArr)
|
||||||
},
|
},
|
||||||
|
fullReductionCouponClick(row) {
|
||||||
|
if(row.id==this.fullReductionCouponSel.id){
|
||||||
|
this.fullReductionCouponSel={id:''}
|
||||||
|
this.quansSelArr.splice(0,1);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const dikouQuan=this.quansSelArr[0]
|
||||||
|
this.fullReductionCouponSel = row;
|
||||||
|
if(dikouQuan&&dikouQuan.type==1){
|
||||||
|
this.$set(this.quansSelArr, 0, row)
|
||||||
|
}else{
|
||||||
|
this.quansSelArr.unshift(row);
|
||||||
|
}
|
||||||
|
},
|
||||||
handleCurrentChange(val) {
|
handleCurrentChange(val) {
|
||||||
this.currentRow = val;
|
this.currentRow = val;
|
||||||
},
|
},
|
||||||
|
|
@ -154,6 +231,7 @@ export default {
|
||||||
quans.fullReductionCoupon = quans.fullReductionCoupon.filter(
|
quans.fullReductionCoupon = quans.fullReductionCoupon.filter(
|
||||||
(v) => v.use
|
(v) => v.use
|
||||||
);
|
);
|
||||||
|
$originFullReductionCoupon=quans.fullReductionCoupon
|
||||||
quans.productCoupon = quans.productCoupon.filter((v) => v.use);
|
quans.productCoupon = quans.productCoupon.filter((v) => v.use);
|
||||||
this.quans = quans;
|
this.quans = quans;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -856,8 +856,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="forms">
|
<div class="forms" v-if="vipUser.id">
|
||||||
<div class="u-m-b-20 u-m-t-10" v-if="vipUser.id">
|
<div class="u-m-b-20 u-m-t-10" >
|
||||||
<div class="u-flex u-flex-wrap">
|
<div class="u-flex u-flex-wrap">
|
||||||
<span class="font-bold no-wrap u-m-r-20">积分抵扣</span>
|
<span class="font-bold no-wrap u-m-r-20">积分抵扣</span>
|
||||||
<el-radio-group
|
<el-radio-group
|
||||||
|
|
@ -905,7 +905,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="u-flex flex-wrap">
|
<div class="u-flex flex-wrap" >
|
||||||
<span class="font-bold no-wrap">优惠券</span>
|
<span class="font-bold no-wrap">优惠券</span>
|
||||||
<div
|
<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"
|
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"
|
||||||
|
|
@ -932,6 +932,18 @@
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||||
</template>
|
</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>
|
||||||
<el-table-column prop="useRestrictions" label="描述">
|
<el-table-column prop="useRestrictions" label="描述">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
@ -989,11 +1001,11 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="detail_form_item">
|
<!-- <div class="detail_form_item">
|
||||||
<div class="left">满减优惠</div>
|
<div class="left">满减优惠</div>
|
||||||
<div class="right">-¥{{ manjian }}</div>
|
<div class="right">-¥{{ coupdiscount }}</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="detail_form_item">
|
<div class="detail_form_item">
|
||||||
<div class="left">优惠券</div>
|
<div class="left">优惠券</div>
|
||||||
<div class="right">-¥{{ manjian }}</div>
|
<div class="right">-¥{{ coupdiscount }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail_form_item">
|
<div class="detail_form_item">
|
||||||
<div class="left">积分抵扣</div>
|
<div class="left">积分抵扣</div>
|
||||||
|
|
@ -1333,7 +1345,7 @@
|
||||||
<money-discount ref="refDiscount" @confirm="ChangeDiscount">
|
<money-discount ref="refDiscount" @confirm="ChangeDiscount">
|
||||||
</money-discount>
|
</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
|
<choose-diners-number
|
||||||
|
|
@ -1406,6 +1418,7 @@ import {
|
||||||
returnPackFee,
|
returnPackFee,
|
||||||
formatOrderGoodsList,
|
formatOrderGoodsList,
|
||||||
returnVipDiscountPrice,
|
returnVipDiscountPrice,
|
||||||
|
returnCouponAllPrice
|
||||||
} from "./util.js";
|
} from "./util.js";
|
||||||
import { $status } from "@/utils/table.js";
|
import { $status } from "@/utils/table.js";
|
||||||
|
|
||||||
|
|
@ -1641,24 +1654,30 @@ export default {
|
||||||
isShowVipPrice() {
|
isShowVipPrice() {
|
||||||
return this.vipUser.isVip ? true : false;
|
return this.vipUser.isVip ? true : false;
|
||||||
},
|
},
|
||||||
manjian() {
|
coupdiscount() {
|
||||||
let result = 0;
|
return returnCouponAllPrice(this.quansSelArr,this.createOrder.data.detailList||[],this.vipUser)
|
||||||
if (this.quansSelArr.length < 0) {
|
},
|
||||||
result = 0;
|
goodsDisCount(){
|
||||||
}
|
const goodsQuanArr=this.quansSelArr.filter(v=>v.type==2);
|
||||||
const manjianQuan = this.quansSelArr.find((v) => v.type == 1);
|
let result=0;
|
||||||
if (!manjianQuan) {
|
if(goodsQuanArr.length<0){
|
||||||
result = 0;
|
result=0;
|
||||||
} else {
|
}else{
|
||||||
result = manjianQuan.discountAmount;
|
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);
|
return result.toFixed(2);
|
||||||
},
|
},
|
||||||
|
|
||||||
currentPayMoney() {
|
currentPayMoney() {
|
||||||
const amount = this.createOrder.data.amount || 0;
|
const amount = this.createOrder.data.amount || 0;
|
||||||
const discount = this.createOrder.discount || 1;
|
const discount = this.createOrder.discount || 1;
|
||||||
// const total=((amount - this.manjian) * this.createOrder.discount - this.points.toMoney)
|
// const total=((amount - this.coupdiscount) * this.createOrder.discount - this.points.toMoney)
|
||||||
const total = (amount - this.manjian) * this.createOrder.discount;
|
const total = (amount - this.coupdiscount) * this.createOrder.discount;
|
||||||
return total <= 0 ? 0 : total;
|
return total <= 0 ? 0 : total;
|
||||||
},
|
},
|
||||||
yinFuJinE() {
|
yinFuJinE() {
|
||||||
|
|
@ -2531,7 +2550,7 @@ export default {
|
||||||
if (!canDiscount) {
|
if (!canDiscount) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const amount = this.createOrder.data.amount - this.manjian;
|
const amount = this.createOrder.data.amount - this.coupdiscount;
|
||||||
this.refToggle("refDiscount", true, {
|
this.refToggle("refDiscount", true, {
|
||||||
amount,
|
amount,
|
||||||
discount: this.createOrder.discount * 100,
|
discount: this.createOrder.discount * 100,
|
||||||
|
|
@ -2776,6 +2795,7 @@ export default {
|
||||||
if (!this.shopInfo.isTableFee) {
|
if (!this.shopInfo.isTableFee) {
|
||||||
await this.changePerpole();
|
await this.changePerpole();
|
||||||
}
|
}
|
||||||
|
if (this.order.list.length > 0) {
|
||||||
res = await $createOrder({
|
res = await $createOrder({
|
||||||
masterId: this.order.masterId || this.masterId,
|
masterId: this.order.masterId || this.masterId,
|
||||||
vipUserId: this.createOrder.data.memberId || this.vipUser.id,
|
vipUserId: this.createOrder.data.memberId || this.vipUser.id,
|
||||||
|
|
@ -2784,7 +2804,11 @@ export default {
|
||||||
payAfter: this.payAfter,
|
payAfter: this.payAfter,
|
||||||
orderld: this.order.orderId,
|
orderld: this.order.orderId,
|
||||||
});
|
});
|
||||||
this.getOrderData({ orderId: res.id });
|
} else {
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
await this.getOrderData();
|
||||||
|
res = true;
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
this.createOrder.status = "success";
|
this.createOrder.status = "success";
|
||||||
|
|
@ -3720,7 +3744,7 @@ 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;
|
this.masterId = res.masterId ? res.masterId : this.masterId;
|
||||||
if (res.tableId) {
|
if (res.tableId) {
|
||||||
await this.getTableDetail(res.tableId);
|
await this.getTableDetail(res.tableId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,3 +122,39 @@ export function returnVipDiscountPrice() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//计算商品券优惠价格
|
||||||
|
export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
||||||
|
const item = goodsArr.find(v => v.productId == coup.proId);
|
||||||
|
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||||
|
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
|
||||||
|
return price
|
||||||
|
|
||||||
|
}
|
||||||
|
//计算商品券总优惠价格
|
||||||
|
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||||
|
if(coupArr.length == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return coupArr.reduce((a, b) => {
|
||||||
|
const price = returnProductCouponPrice(b, goodsArr, vipUser)
|
||||||
|
return a + price;
|
||||||
|
}, 0).toFixed(2);
|
||||||
|
|
||||||
|
}
|
||||||
|
//计算满减券总优惠价格
|
||||||
|
export function returnFullCutCouponAllPrice(coupArr) {
|
||||||
|
if(coupArr.length == 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return coupArr.filter(v => v.type == 1).reduce((a, b) => {
|
||||||
|
const price = b.discountAmount
|
||||||
|
return a + price;
|
||||||
|
}, 0).toFixed(2);
|
||||||
|
|
||||||
|
}
|
||||||
|
//计算优惠券总价格
|
||||||
|
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||||
|
const poductAllprice=returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
|
||||||
|
const pointAllPrice=returnFullCutCouponAllPrice(coupArr)
|
||||||
|
return (poductAllprice+pointAllPrice).toFixed(2);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue