Commit 81bcefb5e13d757899dcb95605c64c750a901e5c

Authored by fengliang
1 parent c3fd7de7

update:购物车新增商品时候增加商品状态检测。

etrade-order/src/main/java/com/diligrp/etrade/order/service/impl/ShopCartImpl.java
@@ -185,7 +185,13 @@ public class ShopCartImpl implements IShopCartService { @@ -185,7 +185,13 @@ public class ShopCartImpl implements IShopCartService {
185 shopCartMessageDto.setAmount(amount); 185 shopCartMessageDto.setAmount(amount);
186 //检查商品以及初始化商品信息 186 //检查商品以及初始化商品信息
187 if(checkflag){ 187 if(checkflag){
188 - checkProductDto(shopCartDto.getShopId(),shopCartMessageDto.getProductId(),shopCartMessageDto.getProductName()); 188 + ProductDetailVo productDetailVo = checkProductDto(shopCartDto.getShopId(), shopCartMessageDto.getProductId(), shopCartMessageDto.getProductName());
  189 + if(StringUtils.isBlank(shopCartMessageDto.getProductName())){
  190 + shopCartMessageDto.setProductName(productDetailVo.getAlias());
  191 + }
  192 + if(StringUtils.isBlank(shopCartMessageDto.getUrl())){
  193 + shopCartMessageDto.setUrl(productDetailVo.getImages().get(0).getUrl());
  194 + }
189 shopCartMessageDto.setCheckFlag(ShopCartMessageCheckFlag.CHECK.getCodeInteger()); 195 shopCartMessageDto.setCheckFlag(ShopCartMessageCheckFlag.CHECK.getCodeInteger());
190 } 196 }
191 //没有店铺信息,则对购物车与购物车商品信息进行新增操作 197 //没有店铺信息,则对购物车与购物车商品信息进行新增操作
@@ -336,7 +342,7 @@ public class ShopCartImpl implements IShopCartService { @@ -336,7 +342,7 @@ public class ShopCartImpl implements IShopCartService {
336 return shopCartMessageVo; 342 return shopCartMessageVo;
337 } 343 }
338 344
339 - private void checkProductDto(Long shopId, Long productId,String productName) { 345 + private ProductDetailVo checkProductDto(Long shopId, Long productId,String productName) {
340 Message<ProductDetailVo> detail = productService.detail(productId); 346 Message<ProductDetailVo> detail = productService.detail(productId);
341 if(detail!=null&&detail.getData()!=null){ 347 if(detail!=null&&detail.getData()!=null){
342 if(!(detail.getData().getShopId()!=null&&detail.getData().getShopId().equals(shopId))){ 348 if(!(detail.getData().getShopId()!=null&&detail.getData().getShopId().equals(shopId))){
@@ -348,6 +354,7 @@ public class ShopCartImpl implements IShopCartService { @@ -348,6 +354,7 @@ public class ShopCartImpl implements IShopCartService {
348 }else{ 354 }else{
349 throw new OrderException(OrderErrorCode.PARAM_ERROR,"\""+productName+"\"异常,未找到该商品"); 355 throw new OrderException(OrderErrorCode.PARAM_ERROR,"\""+productName+"\"异常,未找到该商品");
350 } 356 }
  357 + return detail.getData();
351 } 358 }
352 359
353 360