分销问题修复,订单问题修复
This commit is contained in:
@@ -12,41 +12,41 @@ export function returnGoodsPrice(goods, user, shopInfo, limitTimeDiscount) {
|
||||
if (!goods) {
|
||||
return 0;
|
||||
}
|
||||
//是否可以使用会员价
|
||||
const canUseVipPrice =
|
||||
user && user.isVip && user.isMemberPrice && goods.memberPrice * 1 > 0;
|
||||
// 商家改价
|
||||
if (goods.discount_sale_amount * 1 > 0) {
|
||||
return goods.salePrice;
|
||||
}
|
||||
// 限时折扣
|
||||
if (limitTimeDiscount && limitTimeDiscount.id) {
|
||||
if (
|
||||
limitTimeDiscount.foodType == 1 &&
|
||||
limitTimeDiscount.discountPriority == "limit-time"
|
||||
) {
|
||||
return new BigNumber(goods.salePrice)
|
||||
.times(limitTimeDiscount.discountRate / 100)
|
||||
.decimalPlaces(2, BigNumber.ROUND_UP)
|
||||
.toNumber();
|
||||
}
|
||||
const canUseFoods = limitTimeDiscount.foods.split(",");
|
||||
if (
|
||||
limitTimeDiscount.foodType == 2 &&
|
||||
limitTimeDiscount.discountPriority == "limit-time" &&
|
||||
canUseFoods.includes(`${goods.productId}`)
|
||||
) {
|
||||
const canUseLimit =
|
||||
limitTimeDiscount.foodType == 1 ||
|
||||
canUseFoods.includes(`${goods.productId}`);
|
||||
if (canUseLimit && limitTimeDiscount.discountPriority == "limit-time") {
|
||||
return new BigNumber(goods.salePrice)
|
||||
.times(limitTimeDiscount.discountRate / 100)
|
||||
.decimalPlaces(2, BigNumber.ROUND_UP)
|
||||
.toNumber();
|
||||
}
|
||||
if (
|
||||
canUseLimit &&
|
||||
limitTimeDiscount.discountPriority == "vip-price" &&
|
||||
!canUseVipPrice
|
||||
) {
|
||||
if (canUseVipPrice) {
|
||||
return goods.memberPrice;
|
||||
} else {
|
||||
return new BigNumber(goods.salePrice)
|
||||
.times(limitTimeDiscount.discountRate / 100)
|
||||
.decimalPlaces(2, BigNumber.ROUND_UP)
|
||||
.toNumber();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shopInfo && !shopInfo.isMemberPrice) {
|
||||
return goods.salePrice;
|
||||
}
|
||||
if (
|
||||
user.isVip &&
|
||||
goods.memberPrice * 1 <= goods.salePrice * 1 &&
|
||||
goods.memberPrice * 1 > 0
|
||||
) {
|
||||
if (canUseVipPrice) {
|
||||
return goods.memberPrice;
|
||||
}
|
||||
return goods.salePrice;
|
||||
@@ -124,12 +124,12 @@ export function returnCanDikouGoodsArr(args) {
|
||||
return v;
|
||||
})
|
||||
.filter((v) => {
|
||||
const canUseNum=v.num-(v.returnNum||0)
|
||||
if(canUseNum <= 0||v.is_temporary==1||v.is_gift==1){
|
||||
return false
|
||||
const canUseNum = v.num - (v.returnNum || 0);
|
||||
if (canUseNum <= 0 || v.is_temporary == 1 || v.is_gift == 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true
|
||||
return true;
|
||||
}); // 过滤掉数量<=0的商品,赠菜,临时菜
|
||||
|
||||
return arr;
|
||||
@@ -139,20 +139,19 @@ export function returnCanDikouGoodsArr(args) {
|
||||
* 返回商品是否享用了会员价/会员折扣
|
||||
* @param {*} goods
|
||||
*/
|
||||
function returnGoodsIsUseVipPrice(shopInfo,user,goods) {
|
||||
if(goods.is_time_discount){
|
||||
return false
|
||||
function returnGoodsIsUseVipPrice(shopInfo, user, goods) {
|
||||
if (goods.is_time_discount) {
|
||||
return false;
|
||||
}
|
||||
if(shopInfo.isMemberPrice!=1||user.isVip!=1){
|
||||
return false
|
||||
if (shopInfo.isMemberPrice != 1 || user.isVip != 1) {
|
||||
return false;
|
||||
}
|
||||
if(shopInfo.isMemberPrice==1&&user.isVip==1){
|
||||
if(goods.memberPrice<=0){
|
||||
return false
|
||||
if (shopInfo.isMemberPrice == 1 && user.isVip == 1) {
|
||||
if (goods.memberPrice <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,10 +159,15 @@ function returnGoodsIsUseVipPrice(shopInfo,user,goods) {
|
||||
*/
|
||||
function returnCanCalcGoodsList(canCalcGoodsArr, coupon, shopInfo, user) {
|
||||
return canCalcGoodsArr.filter((goods) => {
|
||||
if (!coupon.discountShare && goods.is_time_discount) {
|
||||
console.log("goods");
|
||||
console.log(goods);
|
||||
if (!coupon.discountShare && (goods.is_time_discount||goods.isTimeDiscount)) {
|
||||
return false;
|
||||
}
|
||||
if(!coupon.vipPriceShare&& returnGoodsIsUseVipPrice(shopInfo,user,goods)){
|
||||
if (
|
||||
!coupon.vipPriceShare &&
|
||||
returnGoodsIsUseVipPrice(shopInfo, user, goods)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -240,6 +244,8 @@ export function returnCouponCanUse(args) {
|
||||
shopInfo,
|
||||
user
|
||||
);
|
||||
console.log("canCalcGoodsArr");
|
||||
console.log(canCalcGoodsArr);
|
||||
fullAmount = canCalcGoodsArr.reduce((pre, cur) => {
|
||||
return (
|
||||
pre + returnGoodsPrice(cur, user, shopInfo, limitTimeDiscount) * cur.num
|
||||
@@ -291,8 +297,8 @@ export function returnCouponCanUse(args) {
|
||||
}
|
||||
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
|
||||
if ([2, 4, 5].includes(coupon.type)) {
|
||||
// 没有符合条件的商品
|
||||
if (isDikouAll && canDikouGoodsArr.length === 0) {
|
||||
// 没有符合条件的商品
|
||||
if (isDikouAll && canDikouGoodsArr.length === 0) {
|
||||
return {
|
||||
canUse: false,
|
||||
reason: "没有符合条件的商品",
|
||||
@@ -304,23 +310,20 @@ export function returnCouponCanUse(args) {
|
||||
reason: "没有符合条件的商品",
|
||||
};
|
||||
}
|
||||
if (coupon.type == 2 ) {
|
||||
if(canCalcGoodsArr.length<=0){
|
||||
if (coupon.type == 2) {
|
||||
if (canCalcGoodsArr.length <= 0) {
|
||||
return {
|
||||
canUse: false,
|
||||
reason: "没有符合计算门槛条件的商品",
|
||||
};
|
||||
}
|
||||
if(fullAmount < coupon.fullAmount){
|
||||
if (fullAmount < coupon.fullAmount) {
|
||||
return {
|
||||
canUse: false,
|
||||
reason: `满${coupon.fullAmount}元可用,当前可参与金额${fullAmount}元`,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//商品兑换券是否达到门槛金额
|
||||
if (coupon.type == 2 && goodsOrderPrice < coupon.fullAmount) {
|
||||
|
||||
Reference in New Issue
Block a user