商品模块代码提交
This commit is contained in:
@@ -120,7 +120,7 @@ public class ProductDTO implements Serializable {
|
||||
@NotNull(message = "是否允许临时改价不能为空", groups = DefaultGroup.class)
|
||||
private Integer isAllowTempModifyPrice;
|
||||
/**
|
||||
* 周 数组 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday'
|
||||
* 定时上下架周期 数组 'Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday'
|
||||
*/
|
||||
@NotBlank(message = "定时上下架周期不能为空", groups = DefaultGroup.class)
|
||||
private String days;
|
||||
@@ -206,11 +206,19 @@ public class ProductDTO implements Serializable {
|
||||
/**
|
||||
* 创建开始时间
|
||||
*/
|
||||
private LocalDateTime createBeginTime;
|
||||
private String createBeginTime;
|
||||
/**
|
||||
* 创建结束时间
|
||||
*/
|
||||
private LocalDateTime createEndTime;
|
||||
private String createEndTime;
|
||||
/**
|
||||
* 最低售价
|
||||
*/
|
||||
private BigDecimal lowPrice;
|
||||
/**
|
||||
* 会员最低售价
|
||||
*/
|
||||
private BigDecimal lowMemberPrice;
|
||||
|
||||
public Object getImages() {
|
||||
return JSON.parseArray(Convert.toStr(images, "[]"));
|
||||
|
||||
@@ -29,9 +29,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.czg.product.entity.table.ProductTableDef.PRODUCT;
|
||||
import static com.czg.product.entity.table.ShopProdCategoryTableDef.SHOP_PROD_CATEGORY;
|
||||
@@ -95,7 +94,22 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
@Override
|
||||
public Page<ProductDTO> getProductPage(ProductDTO param) {
|
||||
QueryWrapper queryWrapper = buildFullQueryWrapper(param);
|
||||
return super.pageAs(PageUtil.buildPage(), queryWrapper, ProductDTO.class);
|
||||
Page<ProductDTO> page = super.pageAs(PageUtil.buildPage(), queryWrapper, ProductDTO.class);
|
||||
List<ProductDTO> records = page.getRecords();
|
||||
List<Long> prodIdList = records.stream().map(ProductDTO::getId).distinct().toList();
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().in(ProdSku::getProductId, prodIdList).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
|
||||
Map<Long, List<ProdSkuDTO>> collect = skuList.stream().collect(Collectors.groupingBy(ProdSkuDTO::getProductId));
|
||||
for (ProductDTO record : records) {
|
||||
List<ProdSkuDTO> list = collect.getOrDefault(record.getId(), Collections.emptyList());
|
||||
Optional<BigDecimal> lowPriceIsPresent = list.stream().map(ProdSkuDTO::getSalePrice).min(BigDecimal::compareTo);
|
||||
lowPriceIsPresent.ifPresent(record::setLowPrice);
|
||||
|
||||
Optional<BigDecimal> lowMemberPriceIsPresent = list.stream().map(ProdSkuDTO::getMemberPrice).min(BigDecimal::compareTo);
|
||||
lowMemberPriceIsPresent.ifPresent(record::setLowMemberPrice);
|
||||
|
||||
record.setSkuList(list);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user