|
@@ -20,6 +20,7 @@ import edu.travel.commodity.utils.TokenData;
|
|
|
import edu.travel.remote.dto.AddShopCartDto;
|
|
|
import edu.travel.remote.dto.BaseDto;
|
|
|
import edu.travel.exception.BaseException;
|
|
|
+import edu.travel.remote.dto.UpdateShopCarDto;
|
|
|
import edu.travel.remote.vo.ShopCartListVo;
|
|
|
import edu.travel.remote.vo.ShopSkuSpecValueVo;
|
|
|
import edu.travel.remote.vo.SpecValueVo;
|
|
@@ -42,6 +43,9 @@ public class ShopShoppingCartServiceImpl extends ServiceImpl<ShopShoppingCartMap
|
|
|
private ShopProductSpecMapper shopProductSpecMapper;
|
|
|
@Override
|
|
|
public Boolean addShopCart(AddShopCartDto params) {
|
|
|
+ if(params.getQuantity()<=0){
|
|
|
+ throw new BaseException("数量有误,请重新选择");
|
|
|
+ }
|
|
|
// 获取用户id
|
|
|
String userId = TokenData.getUserId();
|
|
|
ShopProduct byId = shopProductService.getById(params.getProductId());
|
|
@@ -51,11 +55,11 @@ public class ShopShoppingCartServiceImpl extends ServiceImpl<ShopShoppingCartMap
|
|
|
if(byId==null||byId.getStatus().equals(BaseConstant.BASIC_STATUS_YES_NUM)||one==null){
|
|
|
throw new BaseException("商品已经下架");
|
|
|
}
|
|
|
-
|
|
|
ShopShoppingCart shopShoppingCart = new ShopShoppingCart();
|
|
|
shopShoppingCart.setProductSkuId(one.getId());
|
|
|
shopShoppingCart.setUserId(Long.valueOf(userId));
|
|
|
shopShoppingCart.setQuantity(params.getQuantity());
|
|
|
+ shopShoppingCart.setProductId(one.getProductId());
|
|
|
return save(shopShoppingCart);
|
|
|
}
|
|
|
|
|
@@ -91,7 +95,9 @@ public class ShopShoppingCartServiceImpl extends ServiceImpl<ShopShoppingCartMap
|
|
|
String project = request.getHeader("project");
|
|
|
List<ShopSkuSpecValueVo> skuValue = shopProductSpecMapper.getSkuValue(skus, project);
|
|
|
Map<String, List<ShopSkuSpecValueVo>> sku = skuValue.stream().collect(Collectors.groupingBy(ShopSkuSpecValueVo::getSkuId));
|
|
|
-
|
|
|
+ if(ObjectUtil.isEmpty(collect)){
|
|
|
+ return pageEntity;
|
|
|
+ }
|
|
|
|
|
|
List<ShopProduct> shopProducts = shopProductService.listByIds(collect);
|
|
|
HashMap<String, ShopProduct> map = new HashMap<>();
|
|
@@ -111,6 +117,8 @@ public class ShopShoppingCartServiceImpl extends ServiceImpl<ShopShoppingCartMap
|
|
|
record.setPrice(shopProductSku.getPrice());
|
|
|
record.setInventory(shopProductSku.getInventory());
|
|
|
record.setSkuId(shopProductSku.getSkuId().toString());
|
|
|
+ //0 上架 1 下架
|
|
|
+ record.setState(shopProductSku.getStatus().toString());
|
|
|
}
|
|
|
String skuId = record.getSkuId();
|
|
|
if(ObjectUtil.isEmpty(skuId))continue;
|
|
@@ -124,5 +132,25 @@ public class ShopShoppingCartServiceImpl extends ServiceImpl<ShopShoppingCartMap
|
|
|
return pageEntity;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean updateCart(UpdateShopCarDto params) {
|
|
|
+ ShopShoppingCart cart = getById(params.getId());
|
|
|
+ if(cart==null){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(!ObjectUtil.isEmpty(params.getQuery())&¶ms.getQuery()>0){
|
|
|
+ cart.setQuantity(params.getQuery());
|
|
|
+ }
|
|
|
+ if(!ObjectUtil.isEmpty(params.getSkuId())){
|
|
|
+ cart.setProductSkuId(Long.valueOf(params.getSkuId()));
|
|
|
+ }
|
|
|
+ return updateById(cart);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer delCart(Set<String> ids) {
|
|
|
+ return baseMapper.deleteBatchIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|