|
|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
@@ -13,6 +14,7 @@ import com.cyksj.mapper.manage.coupon.CouponRecommendMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponSkuMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponUserMapper;
|
|
|
import com.cyksj.model.dto.CouponPopularizeDto;
|
|
|
+import com.cyksj.model.entity.Coupon;
|
|
|
import com.cyksj.model.entity.CouponUser;
|
|
|
import com.cyksj.model.request.CouponCollectReq;
|
|
|
import com.cyksj.model.views.*;
|
|
|
@@ -25,6 +27,10 @@ import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/*
|
|
|
*项目名: netflix
|
|
|
*文件名: CouponFrontController
|
|
|
@@ -187,11 +193,23 @@ public class CouponFrontController {
|
|
|
* 优惠码详情
|
|
|
*/
|
|
|
@GetMapping("/get/exCode/detail")
|
|
|
- public Result<CouponPopularizeDto> getExCodeDetail(String exCode) {
|
|
|
+ public Result<CouponPopularizeDto> getExCodeDetail(Long skuId, String exCode) throws Exception {
|
|
|
+ GoodsDonSkuView goodsDonSkuView = beanSearcher.searchFirst(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getSkuId, skuId).op(Operator.Equal).build());
|
|
|
+ if (goodsDonSkuView == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该规格不存在");
|
|
|
+ }
|
|
|
+ if (goodsDonSkuView.getType() == 2) {
|
|
|
+ throw BusinessRuntimeException.getInstance("实物不支持使用优惠码");
|
|
|
+ }
|
|
|
CouponPopularizeDto dto = couponMapper.checkExCode(exCode);
|
|
|
if (dto == null) {
|
|
|
throw BusinessRuntimeException.getInstance("该优惠码不存在");
|
|
|
}
|
|
|
+ List<Coupon.CouponGoodsSku> skuIds = Jsons.parseList(dto.getGoodsSkuIds(), Coupon.CouponGoodsSku.class);
|
|
|
+ Set<Long> collect = skuIds.stream().map(Coupon.CouponGoodsSku::getSkuId).collect(Collectors.toSet());
|
|
|
+ if (!collect.contains(skuId)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("该优惠码不适用于该规格");
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(dto);
|
|
|
}
|
|
|
}
|