mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-02 18:26:38 +08:00
Coupon flow refined
This commit is contained in:
parent
cab59567e8
commit
d6d51f9f5d
@ -251,7 +251,8 @@ export default {
|
||||
promotion: "¥167.00",
|
||||
payment: "¥0.00 ",
|
||||
},
|
||||
discountAmount:0
|
||||
discountAmount:0,
|
||||
discountedItemIndex:undefined,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -266,6 +267,8 @@ export default {
|
||||
if(this.curCoupon.couponId) {
|
||||
//Coupon Calculation
|
||||
let couponUsed=false;
|
||||
let tmpCounter = 0 ;
|
||||
this.discountedItemIndex = 0;
|
||||
for(let itemInCart of this.goldmedal) {
|
||||
if((!this.curCoupon.productCodes || this.curCoupon.productCodes.indexOf(itemInCart.productCode)>-1) && !couponUsed) {
|
||||
if(this.curCoupon.minQuantity && this.curCoupon.minQuantity>itemInCart.buyCount) {
|
||||
@ -280,18 +283,21 @@ export default {
|
||||
case 1: //Amount deduct
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount - this.curCoupon.couponAmount);
|
||||
this.discountAmount = this.curCoupon.couponAmount;
|
||||
this.discountedItemIndex = tmpCounter;
|
||||
couponUsed=true;
|
||||
break;
|
||||
case 2: //Amount deduct with minPrice restriction
|
||||
case 6:
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount) - this.curCoupon.couponAmount;
|
||||
this.discountAmount = this.curCoupon.couponAmount;
|
||||
this.discountedItemIndex = tmpCounter;
|
||||
couponUsed=true;
|
||||
break;
|
||||
case 3: //Limited product % discount
|
||||
case 4: //% discount
|
||||
total = total + (itemInCart.productPrice * itemInCart.buyCount) * this.curCoupon.discount;
|
||||
this.discountAmount = (itemInCart.productPrice * itemInCart.buyCount) * ( 1 - this.curCoupon.discount);
|
||||
this.discountedItemIndex = tmpCounter;
|
||||
couponUsed=true;
|
||||
break;
|
||||
default:
|
||||
@ -303,6 +309,7 @@ export default {
|
||||
} else {
|
||||
total += itemInCart.productPrice * itemInCart.buyCount;
|
||||
}
|
||||
tmpCounter++;
|
||||
}
|
||||
} else {
|
||||
//Normal Calculation
|
||||
@ -320,6 +327,18 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(["checkIsLogin"]),
|
||||
wholeOrderDiscount(){
|
||||
//TODO
|
||||
if(this.curCoupon.minPrice && this.curCoupon.minPrice > this.sumPrice) {
|
||||
if(this.curCoupon.couponAmount && this.curCoupon.couponAmount>0)
|
||||
return this.sumPrice - this.curCoupon.couponAmount;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
qualifiedProductDiscount(){
|
||||
//TODO
|
||||
},
|
||||
async getAddressList() {
|
||||
let memberId = JSON.parse(localStorage.getItem("userInfo")).data.id;
|
||||
let { data } = await memberAddress("getAll", { memberId: memberId });
|
||||
@ -370,7 +389,7 @@ export default {
|
||||
if(valDateToTime && curTime > valDateToTime) {
|
||||
dateChecked=false;
|
||||
}
|
||||
if(dateChecked && myCoupon.status == 0 && (myCoupon.productCodes.indexOf(itemInCart.productCode)>-1 || !myCoupon.productCodes)) {
|
||||
if(dateChecked && myCoupon.activityId != 10 && myCoupon.status == 0 && (myCoupon.productCodes.indexOf(itemInCart.productCode)>-1 || !myCoupon.productCodes)) {
|
||||
_self.drawlist.push(myCoupon);
|
||||
}
|
||||
}
|
||||
@ -459,6 +478,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
let postData = [];
|
||||
let tmpCounter=0;
|
||||
this.goldmedal.forEach((item) => {
|
||||
let basePoint = (item.basePoint?item.basePoint:0);
|
||||
let oneProduct = {
|
||||
@ -483,7 +503,7 @@ export default {
|
||||
addressDetailInfo: orderAddress[0].detailAddress,
|
||||
},
|
||||
};
|
||||
if(this.curCoupon.couponId) {
|
||||
if(this.curCoupon.couponId && tmpCounter == this.discountedItemIndex) {
|
||||
oneProduct.couponId = this.curCoupon.couponId;
|
||||
oneProduct.couponTypeId = this.curCoupon.couponTypeId;
|
||||
oneProduct.couponName = this.curCoupon.couponName;
|
||||
@ -491,6 +511,7 @@ export default {
|
||||
oneProduct.couponAmount = (this.curCoupon.couponAmount?this.curCoupon.couponAmount:this.curCoupon.discount);
|
||||
}
|
||||
postData.push(oneProduct);
|
||||
tmpCounter++;
|
||||
});
|
||||
// let postData = [
|
||||
// {
|
||||
|
@ -551,13 +551,13 @@ export default {
|
||||
if(valDateToTime && curTime > valDateToTime) {
|
||||
dateChecked=false;
|
||||
}
|
||||
if(dateChecked) {
|
||||
if(dateChecked && item.activityId!=10) {
|
||||
if(!item.productCodes) {
|
||||
menualist.push(item);
|
||||
} else {
|
||||
item.productCodes = item.productCodes.split(",");
|
||||
item.productCodes.forEach((element) => {
|
||||
if (element == this.curItem.productCode && item.activityId !== 10) {
|
||||
if (element == this.curItem.productCode) {
|
||||
menualist.push(item);
|
||||
}
|
||||
});
|
||||
@ -655,7 +655,7 @@ export default {
|
||||
this.dialogInfo2 = true;
|
||||
return;
|
||||
} else {
|
||||
this.userdraw(this.usermessage.data.mobile);
|
||||
//this.userdraw(this.usermessage.data.mobile);
|
||||
this.alldrawlist(this.usermessage.data.id);
|
||||
this.dialogInfo1 = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user