|
@@ -27,7 +27,9 @@ import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
*项目名: netflix
|
|
*项目名: netflix
|
|
@@ -105,11 +107,22 @@ public class CouponFrontController {
|
|
|
if (goodsDonSkuView == null) {
|
|
if (goodsDonSkuView == null) {
|
|
|
throw BusinessRuntimeException.getInstance("规格不存在");
|
|
throw BusinessRuntimeException.getInstance("规格不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ BigDecimal skuMoney = goodsDonSkuView.getMoney();
|
|
|
if (goodsDonSkuView.getType() == 2) {
|
|
if (goodsDonSkuView.getType() == 2) {
|
|
|
goodsId = goodsDonSkuView.getGoodsId();
|
|
goodsId = goodsDonSkuView.getGoodsId();
|
|
|
}
|
|
}
|
|
|
- Integer count = couponUserMapper.countAvailableCouponList(goodsId, skuId, userId, isRenew);
|
|
|
|
|
- return GatewayResponse.SUCCESS.newBuilder().toResult(count);
|
|
|
|
|
|
|
+ List<CouponUserView> couponUserViews = couponUserMapper.countAvailableCouponList(goodsId, skuId, userId, isRenew);
|
|
|
|
|
+ Integer total = couponUserViews.size();
|
|
|
|
|
+ if (goodsDonSkuView.getType() == 2) {
|
|
|
|
|
+ List<CouponUserView> collect = couponUserViews.stream().filter(coupon -> {
|
|
|
|
|
+ if (coupon.getType() == Coupon.Type.reduce && skuMoney.compareTo(coupon.getReduceCondition()) < 0) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ total = collect.size();
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(total);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/available/list")
|
|
@GetMapping("/available/list")
|
|
@@ -219,6 +232,7 @@ public class CouponFrontController {
|
|
|
if (goodsDonSkuView == null) {
|
|
if (goodsDonSkuView == null) {
|
|
|
throw BusinessRuntimeException.getInstance("该规格不存在");
|
|
throw BusinessRuntimeException.getInstance("该规格不存在");
|
|
|
}
|
|
}
|
|
|
|
|
+ BigDecimal skuMoney = goodsDonSkuView.getMoney();
|
|
|
if (goodsDonSkuView.getType() == 2) {
|
|
if (goodsDonSkuView.getType() == 2) {
|
|
|
throw BusinessRuntimeException.getInstance("实物不支持使用优惠码");
|
|
throw BusinessRuntimeException.getInstance("实物不支持使用优惠码");
|
|
|
}
|
|
}
|
|
@@ -245,6 +259,11 @@ public class CouponFrontController {
|
|
|
if (couponSku == null) {
|
|
if (couponSku == null) {
|
|
|
throw BusinessRuntimeException.getInstance("该优惠码不适用于该规格");
|
|
throw BusinessRuntimeException.getInstance("该优惠码不适用于该规格");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (goodsDonSkuView.getType() == 2) {
|
|
|
|
|
+ if (dto.getType() == Coupon.Type.reduce && skuMoney.compareTo(dto.getReduceCondition()) < 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance(String.format("满%s可用", dto.getReduceCondition().divide(BigDecimal.valueOf(100))));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dto);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dto);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|