Commit b4200483 by 王世昌

Merge branch 'feature/20210608-修复频次券可用门店判断' into develop

parents 7c787849 e9f6cb39
...@@ -766,7 +766,8 @@ public class CouponServiceImpl implements CouponService { ...@@ -766,7 +766,8 @@ public class CouponServiceImpl implements CouponService {
return null; return null;
} }
//校验商品券是否可用 //校验商品券是否可用
if (!Objects.equals(couponDetailResponseDto.getDetails().get(0).getStatus(), CouponStatus.STATUS_0.getCode())) { if (!Objects.equals(couponDetailResponseDto.getDetails().get(0).getStatus(), CouponStatus.STATUS_0.getCode())
&& !Objects.equals(couponDetailResponseDto.getDetails().get(0).getStatus(), CouponStatus.STATUS_2.getCode())) {
return null; return null;
} }
List<String> couPonstoreIds = Lists.newArrayList(); List<String> couPonstoreIds = Lists.newArrayList();
...@@ -940,14 +941,14 @@ public class CouponServiceImpl implements CouponService { ...@@ -940,14 +941,14 @@ public class CouponServiceImpl implements CouponService {
return null; return null;
} }
//TODO 判断该券是否在这个门店下(一个券可以在多个门店下使用) //TODO 判断该券是否在这个门店下(一个券可以在多个门店下使用)
List<String> couPonstoreIds = Lists.newArrayList(); List<String> couponStoreIds = Lists.newArrayList();
for (GetCouponDetailResponseDto.Details detail : couponDetailResponseDto.getDetails()) { for (GetCouponDetailResponseDto.Details detail : couponDetailResponseDto.getDetails()) {
if (!CouponStatus.STATUS_0.getCode().equals(detail.getStatus())) continue; if (!CouponStatus.STATUS_0.getCode().equals(detail.getStatus()) && !CouponStatus.STATUS_2.getCode().equals(detail.getStatus())) continue;
for (GetCouponDetailResponseDto.ActiveRestrictionVOS activeRestrictionVO : detail.getActiveRestrictionVOS()) { for (GetCouponDetailResponseDto.ActiveRestrictionVOS activeRestrictionVO : detail.getActiveRestrictionVOS()) {
couPonstoreIds.add(activeRestrictionVO.getStoreIdPartner()); couponStoreIds.add(activeRestrictionVO.getStoreIdPartner());
} }
} }
if (CollectionUtils.isNotEmpty(couPonstoreIds) && !couPonstoreIds.contains(storeId)) { if (CollectionUtils.isNotEmpty(couponStoreIds) && !couponStoreIds.contains(storeId)) {
return null; return null;
} }
......
...@@ -590,15 +590,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -590,15 +590,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
requestDto.setStoreId(storeId); requestDto.setStoreId(storeId);
requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId()))); requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId())));
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto); GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if ((availableStocks != null) && (ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()))) { if (availableStocks == null || !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (availableStocks.getResult().get(0).getQty() != null && throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
qty > availableStocks.getResult().get(0).getQty())) { }
Integer stock = 0; int stock = CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null ? 0 :
if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) { availableStocks.getResult().get(0).getQty();
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了"); if (stock <= 0) {
} throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); } else if (stock < qty) {
} throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
} }
} }
...@@ -1968,35 +1968,39 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1968,35 +1968,39 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
private void queryManyGoodsStocks(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<Long> productIds private void queryManyGoodsStocks(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<Long> productIds
, List<ProductBean> productBeanListSpuClass, String skuId, Integer qty) { , List<ProductBean> productBeanListSpuClass, String skuId, Integer qty) {
GetProductStockRequestDto requestDto = new GetProductStockRequestDto(); boolean isLimit = false;
requestDto.setChannel(BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
requestDto.setPartnerId(addShoppingCartGoodsRequestVo.getPartnerId());
requestDto.setStoreId(addShoppingCartGoodsRequestVo.getShopId());
requestDto.setProductIds(productIds);
GetProductStockResponseDto availableStocks = null;
if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode() if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode()
&& productBeanListSpuClass.get(0).getStockLimit() == 1) { && productBeanListSpuClass.get(0).getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto); isLimit = true;
} else { } else {
for (ProductBean.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) { for (ProductBean.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) { if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto); isLimit = true;
break; break;
} }
} }
} }
if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) { // 不限制库存
if (!isLimit){
return;
}
GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
requestDto.setPartnerId(addShoppingCartGoodsRequestVo.getPartnerId());
requestDto.setStoreId(addShoppingCartGoodsRequestVo.getShopId());
requestDto.setProductIds(productIds);
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if (availableStocks == null || !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
} }
if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) && int stock = CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null ? 0 :
(CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null availableStocks.getResult().get(0).getQty();
|| availableStocks.getResult().get(0).getQty() < qty)) { if (stock <= 0) {
Integer stock = 0;
if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
}
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
} else if (stock < qty) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
} }
} }
/** /**
......
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