Commit 3e2bfd8b by xiaoer.li@freemud.com

Add:新品限购

parent 7cda9577
......@@ -178,7 +178,8 @@ public enum ResponseResult {
/**
* coco验证券错误
*/
COCO_COUPON_VALIDATOR_FAIL("49000", "优惠券验证错误")
COCO_COUPON_VALIDATOR_FAIL("49000", "优惠券验证错误"),
NEW_PURCHASE("49001", "超过限购数量了")
;
......
......@@ -1059,6 +1059,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discountDTO = result.getDiscounts().stream().filter(d -> 221 == d.getType()).findFirst().get();
convert2SendPoint(result, discountDTO);
}
this.checkPurchase(result);
result.setValidCouponMap(validCouponMap);
result.setDeliveryAmount(distributionFee);
result.setDistributionFee(result.getDistributionFee());
......@@ -1077,7 +1078,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
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) {
SendPoint sendPointNew = new SendPoint();
......
......@@ -198,6 +198,7 @@ public class CalculationSharingDiscountService {
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discountDTO = result.getDiscounts().stream().filter(d -> 221 == d.getType()).findFirst().get();
convert2SendPoint(result, discountDTO);
}
this.checkPurchase(result);
result.setValidCouponMap(validCouponMap);
result.setDeliveryAmount(deliveryAmount);
result.setDistributionFee(result.getDistributionFee());
......@@ -214,6 +215,21 @@ public class CalculationSharingDiscountService {
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) {
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