|
@@ -1,16 +1,19 @@
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.chelvc.cloud.vehicle.api.dto.CartPromotionItemDTO;
|
|
import com.chelvc.cloud.vehicle.api.dto.CartPromotionItemDTO;
|
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.MerchantCartItemDTO;
|
|
import com.chelvc.cloud.vehicle.api.dto.OmsCartItemDTO;
|
|
import com.chelvc.cloud.vehicle.api.dto.OmsCartItemDTO;
|
|
import com.chelvc.cloud.vehicle.api.param.OmsCartItemModifyParam;
|
|
import com.chelvc.cloud.vehicle.api.param.OmsCartItemModifyParam;
|
|
import com.chelvc.cloud.vehicle.server.copier.CartItemCopier;
|
|
import com.chelvc.cloud.vehicle.server.copier.CartItemCopier;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.copier.MerchantCopier;
|
|
import com.chelvc.cloud.vehicle.server.dao.OmsCartItemMapper;
|
|
import com.chelvc.cloud.vehicle.server.dao.OmsCartItemMapper;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.entity.Merchant;
|
|
import com.chelvc.cloud.vehicle.server.entity.OmsCartItem;
|
|
import com.chelvc.cloud.vehicle.server.entity.OmsCartItem;
|
|
|
|
+import com.chelvc.cloud.vehicle.server.service.MerchantService;
|
|
import com.chelvc.cloud.vehicle.server.service.OmsCartItemService;
|
|
import com.chelvc.cloud.vehicle.server.service.OmsCartItemService;
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
-import org.apache.commons.lang.ObjectUtils;
|
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -28,6 +31,8 @@ import java.util.stream.Collectors;
|
|
@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.OmsCartItemService.class)
|
|
@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.OmsCartItemService.class)
|
|
public class OmsCartItemServiceImpl extends ServiceImpl<OmsCartItemMapper, OmsCartItem> implements OmsCartItemService,
|
|
public class OmsCartItemServiceImpl extends ServiceImpl<OmsCartItemMapper, OmsCartItem> implements OmsCartItemService,
|
|
com.chelvc.cloud.vehicle.api.service.OmsCartItemService {
|
|
com.chelvc.cloud.vehicle.api.service.OmsCartItemService {
|
|
|
|
+
|
|
|
|
+ private final MerchantService merchantService;
|
|
@Override
|
|
@Override
|
|
public int add(OmsCartItemModifyParam cartItem) {
|
|
public int add(OmsCartItemModifyParam cartItem) {
|
|
int count;
|
|
int count;
|
|
@@ -72,12 +77,23 @@ public class OmsCartItemServiceImpl extends ServiceImpl<OmsCartItemMapper, OmsCa
|
|
return omsCartItemList;
|
|
return omsCartItemList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public List<OmsCartItemDTO> listCartItem(List<Long> cartIds) {
|
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
|
+ OmsCartItem omsCartItem = new OmsCartItem();
|
|
|
|
+ omsCartItem.setUserId(userId);
|
|
|
|
+ List<OmsCartItem> cartItemList = this.lambdaQuery()
|
|
|
|
+ .eq(OmsCartItem::getUserId, userId)
|
|
|
|
+ .in(OmsCartItem::getGoodsId,cartIds).list();
|
|
|
|
+ List<OmsCartItemDTO> omsCartItemList = CartItemCopier.INSTANCE.copying(cartItemList);
|
|
|
|
+ return omsCartItemList;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<OmsCartItemDTO> listPromotion(List<Long> cartIds) {
|
|
public List<OmsCartItemDTO> listPromotion(List<Long> cartIds) {
|
|
- List<OmsCartItemDTO> cartItemList = listCartItem();
|
|
|
|
- if (!CollectionUtils.isEmpty(cartIds)) {
|
|
|
|
- cartItemList = cartItemList.stream().filter(item -> cartIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(cartIds)) {
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
+ List<OmsCartItemDTO> cartItemList = listCartItem(cartIds);
|
|
List<CartPromotionItemDTO> cartPromotionItemList = new ArrayList<>();
|
|
List<CartPromotionItemDTO> cartPromotionItemList = new ArrayList<>();
|
|
if (!CollectionUtils.isEmpty(cartItemList)) {
|
|
if (!CollectionUtils.isEmpty(cartItemList)) {
|
|
// cartPromotionItemList.add(cartItemList);
|
|
// cartPromotionItemList.add(cartItemList);
|
|
@@ -91,8 +107,8 @@ public class OmsCartItemServiceImpl extends ServiceImpl<OmsCartItemMapper, OmsCa
|
|
Long userId = SessionContextHolder.getId();
|
|
Long userId = SessionContextHolder.getId();
|
|
OmsCartItem cartItem = this.lambdaQuery()
|
|
OmsCartItem cartItem = this.lambdaQuery()
|
|
.eq(OmsCartItem::getUserId, userId).eq(
|
|
.eq(OmsCartItem::getUserId, userId).eq(
|
|
- OmsCartItem::getGoodsId, id
|
|
|
|
- ).getEntity();
|
|
|
|
|
|
+ OmsCartItem::getId, id
|
|
|
|
+ ).one();
|
|
cartItem.setQuantity(quantity);
|
|
cartItem.setQuantity(quantity);
|
|
cartItem.setDeleteStatus(0);
|
|
cartItem.setDeleteStatus(0);
|
|
return this.baseMapper.updateById(cartItem);
|
|
return this.baseMapper.updateById(cartItem);
|
|
@@ -104,10 +120,12 @@ public class OmsCartItemServiceImpl extends ServiceImpl<OmsCartItemMapper, OmsCa
|
|
for (Long id : ids) {
|
|
for (Long id : ids) {
|
|
OmsCartItem cartItem = this.lambdaQuery()
|
|
OmsCartItem cartItem = this.lambdaQuery()
|
|
.eq(OmsCartItem::getUserId, userId).eq(
|
|
.eq(OmsCartItem::getUserId, userId).eq(
|
|
- OmsCartItem::getGoodsId, id
|
|
|
|
- ).getEntity();
|
|
|
|
- cartItem.setDeleteStatus(1);
|
|
|
|
- this.baseMapper.updateById(cartItem);
|
|
|
|
|
|
+ OmsCartItem::getId, id
|
|
|
|
+ ).one();
|
|
|
|
+ if (cartItem != null){
|
|
|
|
+ cartItem.setDeleteStatus(1);
|
|
|
|
+ this.baseMapper.updateById(cartItem);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -153,4 +171,22 @@ public class OmsCartItemServiceImpl extends ServiceImpl<OmsCartItemMapper, OmsCa
|
|
this.baseMapper.updateById(omsCartItem);
|
|
this.baseMapper.updateById(omsCartItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public MerchantCartItemDTO listCartItem(Long merchantId) {
|
|
|
|
+ Long userId = SessionContextHolder.getId();
|
|
|
|
+ OmsCartItem omsCartItem = new OmsCartItem();
|
|
|
|
+ omsCartItem.setUserId(userId);
|
|
|
|
+ List<OmsCartItem> cartItemList = this.lambdaQuery()
|
|
|
|
+ .eq(OmsCartItem::getUserId, userId)
|
|
|
|
+ .eq(OmsCartItem :: getMerchantId,merchantId)
|
|
|
|
+ .eq(OmsCartItem::getDeleteStatus,"0").list();
|
|
|
|
+ List<OmsCartItemDTO> omsCartItemList = CartItemCopier.INSTANCE.copying(cartItemList);
|
|
|
|
+ Merchant merchant = this.merchantService.getById(merchantId);
|
|
|
|
+ MerchantCartItemDTO merchantCartItemDTO = new MerchantCartItemDTO();
|
|
|
|
+ merchantCartItemDTO.setCartItems(omsCartItemList);
|
|
|
|
+ merchantCartItemDTO.setMerchantDTO(MerchantCopier.INSTANCE.copying(merchant));
|
|
|
|
+ return merchantCartItemDTO;
|
|
|
|
+ }
|
|
}
|
|
}
|