修改代客下单优惠券,积分抵扣逻辑
This commit is contained in:
parent
8a8de80321
commit
d9c789da8f
|
|
@ -10,6 +10,7 @@
|
||||||
v-for="(item, index) in list"
|
v-for="(item, index) in list"
|
||||||
:key="index"
|
:key="index"
|
||||||
:type="sel === item.payType ? 'primary' : ''"
|
:type="sel === item.payType ? 'primary' : ''"
|
||||||
|
:disabled="disabledPayType.includes(item.payType)"
|
||||||
>
|
>
|
||||||
{{ item.payName }}
|
{{ item.payName }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -30,6 +31,10 @@ export default {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
disabledPayType:{
|
||||||
|
type:Array,
|
||||||
|
default:()=>[]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -38,6 +43,10 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
disabledPayType(){
|
||||||
|
const item = this.list.find(v=>!this.disabledPayType.includes(v.payType))
|
||||||
|
this.sel=item.payType
|
||||||
|
},
|
||||||
sel(newval) {
|
sel(newval) {
|
||||||
console.log(newval);
|
console.log(newval);
|
||||||
this.$emit("input", newval);
|
this.$emit("input", newval);
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,7 @@
|
||||||
:data="quans.fullReductionCoupon"
|
:data="quans.fullReductionCoupon"
|
||||||
@cell-click="fullReductionCouponClick"
|
@cell-click="fullReductionCouponClick"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column type="index" label="">
|
||||||
type="index"
|
|
||||||
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)"
|
||||||
|
|
@ -65,10 +61,7 @@
|
||||||
:data="quans.productCoupon"
|
:data="quans.productCoupon"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column>
|
||||||
label=""
|
|
||||||
v-if="quans.fullReductionCoupon.length > 0"
|
|
||||||
>
|
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-checkbox
|
<el-checkbox
|
||||||
@change="productCouponClick(scope.row)"
|
@change="productCouponClick(scope.row)"
|
||||||
|
|
@ -112,11 +105,11 @@
|
||||||
</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-column prop="useRestrictions" label="是否可用">
|
<!-- <el-table-column prop="useRestrictions" label="是否可用">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
{{ scope.row.use ? "可以" : "不可用" }}
|
{{ scope.row.use ? "可以" : "不可用" }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column> -->
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
@ -232,11 +225,11 @@ export default {
|
||||||
isVip: false,
|
isVip: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
orderPrice:0,
|
orderPrice: 0,
|
||||||
fullReductionCouponSel: {
|
fullReductionCouponSel: {
|
||||||
id: "",
|
id: "",
|
||||||
},
|
},
|
||||||
|
|
@ -297,7 +290,7 @@ export default {
|
||||||
$goodsPayPriceMap[row.proId],
|
$goodsPayPriceMap[row.proId],
|
||||||
index,
|
index,
|
||||||
row.num
|
row.num
|
||||||
);
|
).toFixed(2);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -310,7 +303,8 @@ export default {
|
||||||
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
|
const index = this.quansSelArr.findIndex((item) => item.id == row.id);
|
||||||
if (row.type == 2 && index != -1) {
|
if (row.type == 2 && index != -1) {
|
||||||
this.quansSelArr.splice(index, 1);
|
this.quansSelArr.splice(index, 1);
|
||||||
this.quans.productCoupon[index].checked = false;
|
const proIndex=this.quans.productCoupon.findIndex((v) => v.id == row.id);
|
||||||
|
this.quans.productCoupon[proIndex].checked = false;
|
||||||
}
|
}
|
||||||
if (row.type == 1 && index != -1) {
|
if (row.type == 1 && index != -1) {
|
||||||
this.fullReductionCouponSel = { id: "" };
|
this.fullReductionCouponSel = { id: "" };
|
||||||
|
|
@ -350,16 +344,44 @@ export default {
|
||||||
if (!item.use) {
|
if (!item.use) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const hasSelNum = this.quansSelArr
|
||||||
|
.filter((v) => v.type == 2 && v.proId == item.proId)
|
||||||
|
.reduce((a, b) => {
|
||||||
|
return a + b.num;
|
||||||
|
}, 0);
|
||||||
|
const maxSelNum = $goodsPayPriceMap[item.proId].length;
|
||||||
|
const coupMaxUseNum = Math.min(item.num, maxSelNum - hasSelNum);
|
||||||
|
const canUseNum = Math.min(maxSelNum, coupMaxUseNum);
|
||||||
|
|
||||||
if (this.fullReductionCouponSel.id && !item.checked) {
|
if (this.fullReductionCouponSel.id && !item.checked) {
|
||||||
const goodsQuan = this.quans.productCoupon.filter((v) => v.checked);
|
const goodsQuan = this.quans.productCoupon.filter((v) => v.checked);
|
||||||
const fullReductionCoupon = this.fullReductionCouponSel.id
|
const fullReductionCoupon = this.fullReductionCouponSel.id
|
||||||
? [this.fullReductionCouponSel]
|
? [this.fullReductionCouponSel]
|
||||||
: [];
|
: [];
|
||||||
let coupArr = [...goodsQuan, item];
|
|
||||||
|
let coupArr = [...goodsQuan, { ...item, num: canUseNum }];
|
||||||
const payPrice =
|
const payPrice =
|
||||||
this.orderPrice -
|
this.orderPrice -
|
||||||
returnCouponAllPrice(coupArr, canDikouGoodsArr, this.vipUser);
|
returnCouponAllPrice(coupArr, canDikouGoodsArr, this.vipUser);
|
||||||
console.log(payPrice);
|
console.log(payPrice);
|
||||||
|
if (payPrice <= 0) {
|
||||||
|
return this.$confirm(
|
||||||
|
"选择该商品券后支付金额将为0,继续选择将取消选择的满减券",
|
||||||
|
"提示",
|
||||||
|
{
|
||||||
|
confirmButtonText: "继续选择",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
this.fullReductionCouponSel = {
|
||||||
|
id: "",
|
||||||
|
};
|
||||||
|
this.quansSelArr.splice(0, 1);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}
|
||||||
if (this.fullReductionCouponSel.fullAmount > payPrice) {
|
if (this.fullReductionCouponSel.fullAmount > payPrice) {
|
||||||
this.$confirm(
|
this.$confirm(
|
||||||
"选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券",
|
"选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券",
|
||||||
|
|
@ -379,13 +401,19 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
item.checked = !item.checked;
|
item.checked = !item.checked;
|
||||||
|
if (!item.checked) {
|
||||||
|
console.log(index);
|
||||||
|
const index = this.quansSelArr.findIndex((v) => v.id == item.id);
|
||||||
|
this.quansSelArr.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
this.quansSelArr.push({ ...item, num: canUseNum });
|
||||||
|
}
|
||||||
const CheckedArr = this.quans.productCoupon.filter((v) => v.checked);
|
const CheckedArr = this.quans.productCoupon.filter((v) => v.checked);
|
||||||
this.quansSelArr = [
|
if (CheckedArr.length <= 0) {
|
||||||
...(this.fullReductionCouponSel.id
|
return this.quans.productCoupon.map((v) => {
|
||||||
? [this.fullReductionCouponSel]
|
v.use = true;
|
||||||
: []),
|
});
|
||||||
...CheckedArr,
|
}
|
||||||
];
|
|
||||||
const noCheckedArr = this.quans.productCoupon.filter((v) => !v.checked);
|
const noCheckedArr = this.quans.productCoupon.filter((v) => !v.checked);
|
||||||
noCheckedArr.map((v) => {
|
noCheckedArr.map((v) => {
|
||||||
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
|
v.use = returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
|
||||||
|
|
@ -405,12 +433,12 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
confirm() {
|
confirm() {
|
||||||
this.$emit("confirm", [...this.quansSelArr]);
|
this.$emit("confirm", [...this.quansSelArr], $goodsPayPriceMap);
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
async open(data, propSelCoup) {
|
async open(data, propSelCoup) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
this.orderPrice=data.orderPrice;
|
this.orderPrice = data.orderPrice;
|
||||||
this.quansSelArr = [...propSelCoup];
|
this.quansSelArr = [...propSelCoup];
|
||||||
$goodsPayPriceMap = returnGoodsPayPriceMap(this.goodsArr || []);
|
$goodsPayPriceMap = returnGoodsPayPriceMap(this.goodsArr || []);
|
||||||
if (data.memberId) {
|
if (data.memberId) {
|
||||||
|
|
@ -419,7 +447,7 @@ export default {
|
||||||
memberId: data.memberId,
|
memberId: data.memberId,
|
||||||
});
|
});
|
||||||
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
|
quansRes.fullReductionCoupon = quansRes.fullReductionCoupon.filter(
|
||||||
(v) => v.use && this.orderPrice * 1 >= v.fullAmount * 1
|
(v) =>this.orderPrice<=0?false:(v.use && this.orderPrice * 1 >= v.fullAmount * 1)
|
||||||
);
|
);
|
||||||
const selFullReductionCoupon = this.quansSelArr.find(
|
const selFullReductionCoupon = this.quansSelArr.find(
|
||||||
(v) => v.type == 1
|
(v) => v.type == 1
|
||||||
|
|
@ -442,6 +470,7 @@ export default {
|
||||||
checked: this.quansSelArr.find((selCoup) => selCoup.id == v.id)
|
checked: this.quansSelArr.find((selCoup) => selCoup.id == v.id)
|
||||||
? true
|
? true
|
||||||
: false,
|
: false,
|
||||||
|
use:this.orderPrice<=0?false:calcCoup.use
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter((v) => v.use);
|
.filter((v) => v.use);
|
||||||
|
|
|
||||||
|
|
@ -982,9 +982,14 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="discountAmount" label="抵扣">
|
<el-table-column prop="discountAmount" label="抵扣">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<span class="color-red">
|
<span class="color-red" v-if="scope.row.type == 1">
|
||||||
¥{{ scope.row.discountAmount }}
|
¥{{ scope.row.discountAmount }}
|
||||||
</span>
|
</span>
|
||||||
|
<span class="color-red" v-if="scope.row.type == 2">
|
||||||
|
¥{{
|
||||||
|
returnProDiscount(scope.row, scope.row.index)
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="useRestrictions" label="">
|
<el-table-column prop="useRestrictions" label="">
|
||||||
|
|
@ -1011,6 +1016,7 @@
|
||||||
ref="refPayType"
|
ref="refPayType"
|
||||||
v-model="order.payType"
|
v-model="order.payType"
|
||||||
@itemClick="payTypeItemClick"
|
@itemClick="payTypeItemClick"
|
||||||
|
:disabledPayType="disabledPayType"
|
||||||
>
|
>
|
||||||
</pay-type>
|
</pay-type>
|
||||||
<div style="margin-top: 20px">
|
<div style="margin-top: 20px">
|
||||||
|
|
@ -1094,13 +1100,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="detail_form_item">
|
<div class="detail_form_item">
|
||||||
<div class="left">应付金额</div>
|
<div class="left">应付金额</div>
|
||||||
<div class="right redfont">
|
<div class="right redfont">¥{{ yinFuJinE }}</div>
|
||||||
¥{{
|
|
||||||
currentPayMoney - points.toMoney <= 0
|
|
||||||
? 0
|
|
||||||
: (currentPayMoney - points.toMoney) | to2
|
|
||||||
}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1481,6 +1481,11 @@ import {
|
||||||
returnVipDiscountPrice,
|
returnVipDiscountPrice,
|
||||||
returnCouponAllPrice,
|
returnCouponAllPrice,
|
||||||
} from "./util.js";
|
} from "./util.js";
|
||||||
|
import {
|
||||||
|
returnProductCoupAllPrice
|
||||||
|
} from "./quan_util.js";
|
||||||
|
//商品数量从0到n每一个对应的价格
|
||||||
|
let $goodsPayPriceMap = {};
|
||||||
import { $status } from "@/utils/table.js";
|
import { $status } from "@/utils/table.js";
|
||||||
|
|
||||||
let $originTableList = [];
|
let $originTableList = [];
|
||||||
|
|
@ -1501,6 +1506,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
disabledPayType: [],
|
||||||
//积分抵扣
|
//积分抵扣
|
||||||
points: {
|
points: {
|
||||||
res: {
|
res: {
|
||||||
|
|
@ -1609,7 +1615,7 @@ export default {
|
||||||
total: 0,
|
total: 0,
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
status:'',
|
status: "",
|
||||||
packFee: {
|
packFee: {
|
||||||
totalNumber: 0,
|
totalNumber: 0,
|
||||||
status: "",
|
status: "",
|
||||||
|
|
@ -1715,8 +1721,8 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isShowVipPrice() {
|
isShowVipPrice() {
|
||||||
if(!this.shopInfo.isMemberPrice){
|
if (!this.shopInfo.isMemberPrice) {
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
return this.vipUser.isVip ? true : false;
|
return this.vipUser.isVip ? true : false;
|
||||||
},
|
},
|
||||||
|
|
@ -1972,6 +1978,13 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
yinFuJinE: function (newval) {
|
||||||
|
if (newval <= 0) {
|
||||||
|
this.disabledPayType = ["scanCode", "deposit"];
|
||||||
|
} else {
|
||||||
|
this.disabledPayType = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
"goods.query.categoryId": function (newval) {
|
"goods.query.categoryId": function (newval) {
|
||||||
this.goods.query.page = 1;
|
this.goods.query.page = 1;
|
||||||
this.goods.list = [];
|
this.goods.list = [];
|
||||||
|
|
@ -2039,8 +2052,8 @@ export default {
|
||||||
// this.masterId = masterId;
|
// this.masterId = masterId;
|
||||||
console.log("this.createOrder.data");
|
console.log("this.createOrder.data");
|
||||||
console.log(this.createOrder.data);
|
console.log(this.createOrder.data);
|
||||||
if(this.order.status=='finish'){
|
if (this.order.status == "finish") {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
$setUser({
|
$setUser({
|
||||||
tableId: this.table.tableId,
|
tableId: this.table.tableId,
|
||||||
|
|
@ -2054,8 +2067,8 @@ export default {
|
||||||
this.getOrderData().then(() => {
|
this.getOrderData().then(() => {
|
||||||
this.pointsValueChange(this.points.value);
|
this.pointsValueChange(this.points.value);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
this.getCart()
|
this.getCart();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -2174,6 +2187,21 @@ export default {
|
||||||
this.open(this.$route.query);
|
this.open(this.$route.query);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
returnProDiscount(row) {
|
||||||
|
console.log(row);
|
||||||
|
//相同商品抵扣券数组
|
||||||
|
const arr = this.quansSelArr.filter((v) => v.proId == row.proId);
|
||||||
|
const index = arr.findIndex((v) => v.id == row.id);
|
||||||
|
if (index != -1) {
|
||||||
|
return returnProductCoupAllPrice(
|
||||||
|
$goodsPayPriceMap[row.proId],
|
||||||
|
index,
|
||||||
|
row.num
|
||||||
|
).toFixed(2);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
},
|
||||||
lingshicaiShow() {
|
lingshicaiShow() {
|
||||||
this.$refs.refPopAddCai.open();
|
this.$refs.refPopAddCai.open();
|
||||||
},
|
},
|
||||||
|
|
@ -2234,14 +2262,15 @@ export default {
|
||||||
{
|
{
|
||||||
id: this.createOrder.data.id,
|
id: this.createOrder.data.id,
|
||||||
memberId: this.createOrder.data.memberId || this.vipUser.id,
|
memberId: this.createOrder.data.memberId || this.vipUser.id,
|
||||||
orderPrice:(this.yinFuJinE*1+this.coupdiscount*1).toFixed(2)
|
orderPrice: (this.yinFuJinE * 1 + this.coupdiscount * 1).toFixed(2),
|
||||||
},
|
},
|
||||||
[...this.quansSelArr]
|
[...this.quansSelArr]
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
quansConfirm(e) {
|
quansConfirm(e,goodsPayPriceMap) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
this.quansSelArr = [...e];
|
this.quansSelArr = [...e];
|
||||||
|
$goodsPayPriceMap=goodsPayPriceMap
|
||||||
},
|
},
|
||||||
searchInput(e) {
|
searchInput(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
@ -2837,7 +2866,7 @@ export default {
|
||||||
title: "支付成功",
|
title: "支付成功",
|
||||||
type: "success",
|
type: "success",
|
||||||
});
|
});
|
||||||
this.order.status='finish'
|
this.order.status = "finish";
|
||||||
this.close();
|
this.close();
|
||||||
// this.reset();
|
// this.reset();
|
||||||
},
|
},
|
||||||
|
|
@ -3069,11 +3098,14 @@ export default {
|
||||||
}
|
}
|
||||||
if (key === "returnCart") {
|
if (key === "returnCart") {
|
||||||
console.log(this.order);
|
console.log(this.order);
|
||||||
let selGoods=undefined
|
let selGoods = undefined;
|
||||||
if(this.order.selPlaceNum==-10){
|
if (this.order.selPlaceNum == -10) {
|
||||||
selGoods = {...this.order.seatFee,num:this.order.seatFee.number}
|
selGoods = { ...this.order.seatFee, num: this.order.seatFee.number };
|
||||||
}else{
|
} else {
|
||||||
selGoods = this.order.old.list[this.order.selPlaceNum-1].info[this.order.old.selIndex];
|
selGoods =
|
||||||
|
this.order.old.list[this.order.selPlaceNum - 1].info[
|
||||||
|
this.order.old.selIndex
|
||||||
|
];
|
||||||
}
|
}
|
||||||
console.log(selGoods);
|
console.log(selGoods);
|
||||||
this.refToggle("refReturnCart", true, selGoods);
|
this.refToggle("refReturnCart", true, selGoods);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ export function isTui(item) {
|
||||||
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||||
}
|
}
|
||||||
//是否使用会员价
|
//是否使用会员价
|
||||||
export function isUseMemberPrice(vipUser,goods){
|
export function isUseVipPrice(vipUser,goods){
|
||||||
return vipUser.id&&vipUser.isVip&&goods.isMember
|
return vipUser.id&&vipUser.isVip&&goods.isMember
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||||
const price = item ? (isUseMemberPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||||
return price * coup.num
|
return price * coup.num
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,8 @@ export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
|
||||||
if (selCoupNumber >= findGoodsTotalNumber) {
|
if (selCoupNumber >= findGoodsTotalNumber) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return findGoodsTotalNumber < (coup.num + selCoupNumber) ? false : true
|
console.log(selCoupNumber,findGoodsTotalNumber);
|
||||||
|
return findGoodsTotalNumber < selCoupNumber ? false : true
|
||||||
}
|
}
|
||||||
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
||||||
export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
|
export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
|
||||||
|
|
@ -54,12 +55,13 @@ export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||||
const price = item ? (isUseMemberPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||||
const discountAmount = (price * coup.num).toFixed(2)
|
const discountAmount = (price * coup.num).toFixed(2)
|
||||||
console.log(discountAmount);
|
console.log(discountAmount);
|
||||||
|
|
||||||
const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
|
// const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
|
||||||
// const canUse=discountAmount>0
|
// const canUse=discountAmount>0
|
||||||
|
const canUse=coup.use
|
||||||
return {
|
return {
|
||||||
...coup,
|
...coup,
|
||||||
discountAmount: discountAmount,
|
discountAmount: discountAmount,
|
||||||
|
|
@ -85,7 +87,7 @@ export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
|
||||||
//返回商品实际支付价格
|
//返回商品实际支付价格
|
||||||
export function returnProductPayPrice(goods,vipUser){
|
export function returnProductPayPrice(goods,vipUser){
|
||||||
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
|
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
|
||||||
const price = isUseMemberPrice(vipUser,goods) ? memberPrice : goods.price;
|
const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
|
||||||
return price
|
return price
|
||||||
}
|
}
|
||||||
//返回商品券抵扣的商品价格
|
//返回商品券抵扣的商品价格
|
||||||
|
|
@ -100,6 +102,23 @@ export function returnProductCoupAllPrice(productPriceArr,startIndex,num){
|
||||||
return prve+curPrice
|
return prve+curPrice
|
||||||
},0)
|
},0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回商品券可抵扣的商品数量
|
||||||
|
export function returnProductCanUseNum(productPriceArr,startIndex,num){
|
||||||
|
console.log(productPriceArr);
|
||||||
|
console.log(num);
|
||||||
|
let n=0;
|
||||||
|
for(let i=0;i<num;i++){
|
||||||
|
if(productPriceArr[startIndex*1+i]){
|
||||||
|
n+=1
|
||||||
|
console.log(n);
|
||||||
|
}else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
//返回同类商品券在同类商品价格数组里的开始位置
|
//返回同类商品券在同类商品价格数组里的开始位置
|
||||||
export function returnProCoupStartIndex(coupArr,index){
|
export function returnProCoupStartIndex(coupArr,index){
|
||||||
return coupArr.slice(0,index).reduce((prve,cur)=>{
|
return coupArr.slice(0,index).reduce((prve,cur)=>{
|
||||||
|
|
@ -166,7 +185,9 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||||
}
|
}
|
||||||
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
|
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
|
||||||
console.log(proCoupStartIndex);
|
console.log(proCoupStartIndex);
|
||||||
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coup.num)
|
const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
|
||||||
|
console.log(coupNum);
|
||||||
|
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,6 +219,12 @@ export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
const isfullAmount = payPrice >= v.fullAmount * 1
|
const isfullAmount = payPrice >= v.fullAmount * 1
|
||||||
|
if(payPrice<=0){
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
use: false
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
use: v.use && isfullAmount
|
use: v.use && isfullAmount
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue