Commit 2b13053f by xiaoer.li@freemud.com

Merge remote-tracking branch 'origin/feature/2.1.13-新品限购' into qa

parents 9794319e 3e2bfd8b
...@@ -179,7 +179,8 @@ public enum ResponseResult { ...@@ -179,7 +179,8 @@ public enum ResponseResult {
/** /**
* coco验证券错误 * coco验证券错误
*/ */
COCO_COUPON_VALIDATOR_FAIL("49000", "优惠券验证错误") COCO_COUPON_VALIDATOR_FAIL("49000", "优惠券验证错误"),
NEW_PURCHASE("49001", "超过限购数量了")
; ;
......
...@@ -1234,6 +1234,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1234,6 +1234,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discountDTO = result.getDiscounts().stream().filter(d -> 221 == d.getType()).findFirst().get(); ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discountDTO = result.getDiscounts().stream().filter(d -> 221 == d.getType()).findFirst().get();
convert2SendPoint(result, discountDTO); convert2SendPoint(result, discountDTO);
} }
this.checkPurchase(result);
result.setValidCouponMap(validCouponMap); result.setValidCouponMap(validCouponMap);
result.setDeliveryAmount(distributionFee); result.setDeliveryAmount(distributionFee);
result.setDistributionFee(result.getDistributionFee()); result.setDistributionFee(result.getDistributionFee());
...@@ -1252,7 +1253,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1252,7 +1253,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
} }
private void checkPurchase(ActivityCalculationDiscountResponseDto.CalculationDiscountResult result) {
if (CollectionUtils.isEmpty(result.getGoods())) {
return;
}
Integer type = 16;
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods good : result.getGoods()) {
if (CollectionUtils.isNotEmpty(good.getDiscounts())) {
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount : good.getDiscounts()) {
if (type.equals(discount.getType()) && good.getGoodsQuantity()>=discount.getActualGoodsNumber()) {
throw new ServiceException(ResponseResult.NEW_PURCHASE);
}
}
}
}
}
private void convert2SendPoint(ActivityCalculationDiscountResponseDto.CalculationDiscountResult result, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discountDTO) { private void convert2SendPoint(ActivityCalculationDiscountResponseDto.CalculationDiscountResult result, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discountDTO) {
SendPoint sendPointNew = new SendPoint(); SendPoint sendPointNew = new SendPoint();
......
...@@ -193,6 +193,7 @@ public class CalculationSharingDiscountService { ...@@ -193,6 +193,7 @@ public class CalculationSharingDiscountService {
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discountDTO = result.getDiscounts().stream().filter(d -> 221 == d.getType()).findFirst().get(); CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discountDTO = result.getDiscounts().stream().filter(d -> 221 == d.getType()).findFirst().get();
convert2SendPoint(result, discountDTO); convert2SendPoint(result, discountDTO);
} }
this.checkPurchase(result);
result.setValidCouponMap(validCouponMap); result.setValidCouponMap(validCouponMap);
result.setDeliveryAmount(deliveryAmount); result.setDeliveryAmount(deliveryAmount);
result.setDistributionFee(result.getDistributionFee()); result.setDistributionFee(result.getDistributionFee());
...@@ -209,6 +210,21 @@ public class CalculationSharingDiscountService { ...@@ -209,6 +210,21 @@ public class CalculationSharingDiscountService {
return null; return null;
} }
private void checkPurchase(CalculationSharingDiscountResponseDto.CalculationDiscountResult result) {
if (CollectionUtils.isEmpty(result.getGoods())) {
return;
}
Integer type = 16;
for (CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods good : result.getGoods()) {
if (CollectionUtils.isNotEmpty(good.getDiscounts())) {
for (CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount : good.getDiscounts()) {
if (type.equals(discount.getType()) && good.getGoodsQuantity()>=discount.getActualGoodsNumber()) {
throw new ServiceException(ResponseResult.NEW_PURCHASE);
}
}
}
}
}
private void convert2SendPoint(CalculationSharingDiscountResponseDto.CalculationDiscountResult result, CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discountDTO) { private void convert2SendPoint(CalculationSharingDiscountResponseDto.CalculationDiscountResult result, CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discountDTO) {
SendPoint sendPointNew = new SendPoint(); SendPoint sendPointNew = new SendPoint();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment