mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 02:06:38 +08:00
Combined product Coupon amount calculating issue fixed
This commit is contained in:
parent
037201858f
commit
cf90ce9009
@ -306,9 +306,17 @@ export default {
|
|||||||
let total = 0;
|
let total = 0;
|
||||||
let couponUsed = false;
|
let couponUsed = false;
|
||||||
let tmpShoppingCartList = this.arrSort(this.goldmedal);
|
let tmpShoppingCartList = this.arrSort(this.goldmedal);
|
||||||
|
let qualifiedProductAmount = 0;
|
||||||
|
let skipQualifiedProductAmountCalculating = false;
|
||||||
|
|
||||||
for(let itemInCart of tmpShoppingCartList) {
|
for(let itemInCart of tmpShoppingCartList) {
|
||||||
if((!this.curCoupon.productCodes || this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) && !couponUsed) {
|
if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||||
|
qualifiedProductAmount += (itemInCart.productPrice * itemInCart.buyCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(let itemInCart of tmpShoppingCartList) {
|
||||||
|
if(this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1 && !couponUsed) {
|
||||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity>itemInCart.buyCount) {
|
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity>itemInCart.buyCount) {
|
||||||
//Check minQuantity
|
//Check minQuantity
|
||||||
total+=(itemInCart.buyCount * itemInCart.productPrice);
|
total+=(itemInCart.buyCount * itemInCart.productPrice);
|
||||||
@ -318,7 +326,8 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
//Into coupon discount calculation
|
//Into coupon discount calculation
|
||||||
switch(this.curCoupon.couponTypeId) {
|
switch(this.curCoupon.couponTypeId) {
|
||||||
case 1: //Amount deduct
|
case 1: //Amount deduct
|
||||||
|
/*
|
||||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) {
|
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) {
|
||||||
total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount);
|
total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount);
|
||||||
this.discountAmount = this.curCoupon.couponAmount;
|
this.discountAmount = this.curCoupon.couponAmount;
|
||||||
@ -330,14 +339,16 @@ export default {
|
|||||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
case 2: //Amount deduct with minPrice restriction
|
case 2: //Amount deduct with minPrice restriction
|
||||||
case 6:
|
case 6:
|
||||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= (itemInCart.productPrice * itemInCart.buyCount)) {
|
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount <= qualifiedProductAmount && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||||
total = total + (itemInCart.productPrice * itemInCart.buyCount) - this.curCoupon.couponAmount;
|
total = total + qualifiedProductAmount - this.curCoupon.couponAmount;
|
||||||
this.discountAmount = this.curCoupon.couponAmount;
|
this.discountAmount = this.curCoupon.couponAmount;
|
||||||
this.discountedProductCode = itemInCart.productCode;
|
this.discountedProductCode = itemInCart.productCode;
|
||||||
|
skipQualifiedProductAmountCalculating = true;
|
||||||
couponUsed=true;
|
couponUsed=true;
|
||||||
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > (itemInCart.productPrice * itemInCart.buyCount)) {
|
} else if(this.curCoupon.couponAmount && this.curCoupon.couponAmount > qualifiedProductAmount) {
|
||||||
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
total = total + itemInCart.productPrice * itemInCart.buyCount;
|
||||||
this.discountAmount = 0;
|
this.discountAmount = 0;
|
||||||
this.curCoupon = {couponName:'未能使用该优惠券'};
|
this.curCoupon = {couponName:'未能使用该优惠券'};
|
||||||
@ -357,7 +368,11 @@ export default {
|
|||||||
//Into coupon discount calculation end
|
//Into coupon discount calculation end
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
total += itemInCart.productPrice * itemInCart.buyCount;
|
if(skipQualifiedProductAmountCalculating && this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
|
Loading…
Reference in New Issue
Block a user