|
|
|
@ -10,6 +10,7 @@ import com.qniao.dam.api.query.product.user.response.*; |
|
|
|
import com.qniao.dam.domain.aggregate.product.entity.Product; |
|
|
|
import com.qniao.dam.domain.aggregate.productspec.entity.ProductSpec; |
|
|
|
import com.qniao.dam.domain.aggregate.productspec.valueobj.ProductSpecTerm; |
|
|
|
import com.qniao.dam.domian.aggregate.product.constant.ProductSubCategoryEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.productspec.constant.ProductSpecTermNameEnum; |
|
|
|
import com.qniao.dam.domian.aggregate.productspec.constant.ProductSpecTermUnitEnum; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.ProductDao; |
|
|
|
@ -78,7 +79,29 @@ public class ProductQueryServiceImpl implements ProductQueryService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<UserPageProductByMatchmakerVo> pageProductByMatchmaker(PageUtil pageUtil, UserPageProductByMatchmakerQueryParam queryParam) { |
|
|
|
return productViewDao.pageProductByMatchmaker(pageUtil.toPageWithoutOrders(),queryParam); |
|
|
|
return productViewDao.pageProductByMatchmaker(pageUtil.toPageWithoutOrders(), queryParam); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Product queryBy(Long userId, Long miId, ProductSubCategoryEnum subCategory) { |
|
|
|
return productDao.selectOne(new LambdaQueryWrapper<Product>() |
|
|
|
.eq(Product::getUserId, userId) |
|
|
|
.eq(Product::getMiId, miId) |
|
|
|
.eq(Product::getSubCategory, subCategory) |
|
|
|
.last("limit 1")); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ProductSpec> listProductSpecBy(Long productId) { |
|
|
|
List<ProductSpec> productSpecList = productSpecDao.selectList(new LambdaQueryWrapper<ProductSpec>() |
|
|
|
.eq(ProductSpec::getProductId, productId)); |
|
|
|
if (CollUtil.isNotEmpty(productSpecList)) { |
|
|
|
productSpecList.forEach(productSpec -> { |
|
|
|
productSpec.setProductSpecTermList(productSpecTermDao.selectList(new LambdaQueryWrapper<ProductSpecTerm>() |
|
|
|
.eq(ProductSpecTerm::getProductSpecId, productSpec.getId()))); |
|
|
|
}); |
|
|
|
} |
|
|
|
return productSpecList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -98,20 +121,20 @@ public class ProductQueryServiceImpl implements ProductQueryService { |
|
|
|
@Override |
|
|
|
public List<UserPageProductByCustomerGroupVo> getPageProductByCustomer() { |
|
|
|
List<UserPageProductByCustomerGroupVo> groupVoList = new ArrayList<>(); |
|
|
|
List<UserPageProductByCustomerExtendVo> extendVos = productViewDao.selectProductByCustomerList(); |
|
|
|
Map<Long,List<UserPageProductByCustomerExtendVo>> extMap = extendVos.stream().collect(Collectors.groupingBy(UserPageProductByCustomerExtendVo::getId)); |
|
|
|
extMap.forEach((k,v)->{ |
|
|
|
List<UserPageProductByCustomerExtendVo> extendVos = productViewDao.selectProductByCustomerList(); |
|
|
|
Map<Long, List<UserPageProductByCustomerExtendVo>> extMap = extendVos.stream().collect(Collectors.groupingBy(UserPageProductByCustomerExtendVo::getId)); |
|
|
|
extMap.forEach((k, v) -> { |
|
|
|
UserPageProductByCustomerExtendVo extendVo = v.get(0); |
|
|
|
if(extendVo.getGroupType() == 0){ |
|
|
|
if (extendVo.getGroupType() == 0) { |
|
|
|
extendVo.setProductName(extendVo.getProductTitle()); |
|
|
|
} |
|
|
|
BigDecimal unitOriginalPrice = v.stream().map(UserPageProductByCustomerExtendVo::getUnitOriginalPrice).reduce(BigDecimal.ZERO,BigDecimal::add); |
|
|
|
BigDecimal unitSellingPrice = v.stream().map(UserPageProductByCustomerExtendVo::getUnitSellingPrice).reduce(BigDecimal.ZERO,BigDecimal::add); |
|
|
|
UserPageProductByCustomerGroupVo vo = TypeConvertUtils.convert(extendVo,UserPageProductByCustomerGroupVo.class); |
|
|
|
BigDecimal unitOriginalPrice = v.stream().map(UserPageProductByCustomerExtendVo::getUnitOriginalPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
BigDecimal unitSellingPrice = v.stream().map(UserPageProductByCustomerExtendVo::getUnitSellingPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
UserPageProductByCustomerGroupVo vo = TypeConvertUtils.convert(extendVo, UserPageProductByCustomerGroupVo.class); |
|
|
|
vo.setActivityId(extendVo.getId()); |
|
|
|
vo.setUnitSellingPrice(unitSellingPrice); |
|
|
|
vo.setUnitOriginalPrice(unitOriginalPrice); |
|
|
|
vo.setProductList(TypeConvertUtils.convert(v,UserPageProductByCustomerVo.class)); |
|
|
|
vo.setProductList(TypeConvertUtils.convert(v, UserPageProductByCustomerVo.class)); |
|
|
|
groupVoList.add(vo); |
|
|
|
}); |
|
|
|
return groupVoList; |
|
|
|
@ -152,7 +175,7 @@ public class ProductQueryServiceImpl implements ProductQueryService { |
|
|
|
return unitEnum; |
|
|
|
} |
|
|
|
|
|
|
|
private ProductSpec queryProductSpecByProductId(Long productId) { |
|
|
|
public ProductSpec queryProductSpecByProductId(Long productId) { |
|
|
|
ProductSpec productSpec = productSpecDao.selectOne(new LambdaQueryWrapper<ProductSpec>() |
|
|
|
.eq(ProductSpec::getProductId, productId) |
|
|
|
.last("limit 1")); |
|
|
|
|