|
@@ -392,50 +392,63 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ListingProductVO checkCoupon(String productId, String userId, String code) {
|
|
public ListingProductVO checkCoupon(String productId, String userId, String code) {
|
|
- Prize prize = prizeService.getOne(new LambdaQueryWrapper<Prize>()
|
|
|
|
- .eq(Prize::getCode, code).eq(Prize::getValidFlag, 1));
|
|
|
|
- if (prize == null) {
|
|
|
|
- log.error("优惠券不存在:{}", code);
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_NOT_EXISTS);
|
|
|
|
- }
|
|
|
|
- if (prize.getType() != 1) {
|
|
|
|
- log.error("优惠券类型错误:{}", code);
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_TYPE_ERROR);
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotEmpty(prize.getProductId()) && !prize.getProductId().contains(productId)) {
|
|
|
|
- log.error("优惠券关联产品错误,productId:{}", productId);
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
|
|
- }
|
|
|
|
- if (prize.getValidFlag() != 1) {
|
|
|
|
- log.error("优惠券不可用:{}", code);
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
- }
|
|
|
|
- if (prize.getEndDate().before(new Date()) || prize.getStartDate().after(new Date())) {
|
|
|
|
- log.error("优惠券时间不可用:{}", code);
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
- }
|
|
|
|
List<ListingProductVO> productVOs = this.baseMapper.getProductsByIds(Collections.singletonList(productId));
|
|
List<ListingProductVO> productVOs = this.baseMapper.getProductsByIds(Collections.singletonList(productId));
|
|
ListingProductVO listingProductVO = productVOs.get(0);
|
|
ListingProductVO listingProductVO = productVOs.get(0);
|
|
- if(ObjectUtils.isNotEmpty(listingProductVO.getIsAi())&&listingProductVO.getIsAi().equals(1)){
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(listingProductVO)) {
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_PRODUCT_NOT_EXIST);
|
|
}
|
|
}
|
|
- if(ObjectUtils.isNotEmpty(listingProductVO.getDisplayPrice())){
|
|
|
|
- if (prize.getActivityType().equals("1")){
|
|
|
|
|
|
+ if ("4DDF2-6860-49C".equals(code)) {
|
|
|
|
+ // 运营临时活动优惠,只针对黑五产品
|
|
|
|
+ if (blackFiveProduct.contains(listingProductVO.getCode())) {
|
|
|
|
+ listingProductVO.setDisplayPrice(listingProductVO.getDisplayPrice().subtract(new BigDecimal("20")));
|
|
|
|
+ listingProductVO.setCnyDisplayPrice(listingProductVO.getCnyDisplayPrice().subtract(new BigDecimal("130")));
|
|
|
|
+ } else {
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Prize prize = prizeService.getOne(new LambdaQueryWrapper<Prize>()
|
|
|
|
+ .eq(Prize::getCode, code).eq(Prize::getValidFlag, 1));
|
|
|
|
+ if (prize == null) {
|
|
|
|
+ log.error("优惠券不存在:{}", code);
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_NOT_EXISTS);
|
|
|
|
+ }
|
|
|
|
+ if (prize.getType() != 1) {
|
|
|
|
+ log.error("优惠券类型错误:{}", code);
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_TYPE_ERROR);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(prize.getProductId()) && !prize.getProductId().contains(productId)) {
|
|
|
|
+ log.error("优惠券关联产品错误,productId:{}", productId);
|
|
throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
}
|
|
}
|
|
- listingProductVO.setDisplayPrice(listingProductVO.getDisplayPrice().subtract(prize.getUsdPrice()));
|
|
|
|
- listingProductVO.setCnyDisplayPrice(listingProductVO.getCnyDisplayPrice().subtract(prize.getCnyPrice()));
|
|
|
|
- }else{
|
|
|
|
- if ("1".equals(prize.getActivityType())) {
|
|
|
|
- if (listingProductVO.getDiscountType()==1) {
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
|
|
+ if (prize.getValidFlag() != 1) {
|
|
|
|
+ log.error("优惠券不可用:{}", code);
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
+ }
|
|
|
|
+ if (prize.getEndDate().before(new Date()) || prize.getStartDate().after(new Date())) {
|
|
|
|
+ log.error("优惠券时间不可用:{}", code);
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
+ }
|
|
|
|
+ if(ObjectUtils.isNotEmpty(listingProductVO.getIsAi())&&listingProductVO.getIsAi().equals(1)){
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
|
|
+ }
|
|
|
|
+ if(ObjectUtils.isNotEmpty(listingProductVO.getDisplayPrice())){
|
|
|
|
+ if (prize.getActivityType().equals("1")){
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
}
|
|
}
|
|
- if (listingProductVO.getPrice().compareTo(BigDecimal.valueOf(79.99)) < 0) {
|
|
|
|
- throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_INVALID);
|
|
|
|
|
|
+ listingProductVO.setDisplayPrice(listingProductVO.getDisplayPrice().subtract(prize.getUsdPrice()));
|
|
|
|
+ listingProductVO.setCnyDisplayPrice(listingProductVO.getCnyDisplayPrice().subtract(prize.getCnyPrice()));
|
|
|
|
+ }else{
|
|
|
|
+ if ("1".equals(prize.getActivityType())) {
|
|
|
|
+ if (listingProductVO.getDiscountType()==1) {
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
|
|
+ }
|
|
|
|
+ if (listingProductVO.getPrice().compareTo(BigDecimal.valueOf(79.99)) < 0) {
|
|
|
|
+ throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_COUPON_PRODUCT_ERROR);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ listingProductVO.setDisplayPrice(listingProductVO.getPrice().subtract(prize.getUsdPrice()));
|
|
|
|
+ listingProductVO.setCnyDisplayPrice(listingProductVO.getCnyPrice().subtract(prize.getCnyPrice()));
|
|
}
|
|
}
|
|
- listingProductVO.setDisplayPrice(listingProductVO.getPrice().subtract(prize.getUsdPrice()));
|
|
|
|
- listingProductVO.setCnyDisplayPrice(listingProductVO.getCnyPrice().subtract(prize.getCnyPrice()));
|
|
|
|
}
|
|
}
|
|
return listingProductVO;
|
|
return listingProductVO;
|
|
}
|
|
}
|