|
@@ -12,6 +12,7 @@ import edu.travel.commodity.mapper.ShopProductSpecMapper;
|
|
|
import edu.travel.commodity.service.*;
|
|
|
import edu.travel.commodity.vo.ProductSkuVo;
|
|
|
import edu.travel.commodity.vo.ProductSpecVo;
|
|
|
+import edu.travel.commodity.vo.SpecSortVo;
|
|
|
import edu.travel.commodity.vo.SpecValueVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -31,11 +32,14 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProductSpecMappe
|
|
|
private ShopSkuSpecValueService shopSkuSpecValueService;
|
|
|
@Autowired
|
|
|
private ShopSpecService shopSpecService;
|
|
|
+ @Autowired
|
|
|
+ private ShopProductSpecService shopProductSpecService;
|
|
|
|
|
|
@Override
|
|
|
public ProductSpecVo getShopSpec(ProductSpecDto param) {
|
|
|
LambdaQueryChainWrapper<ShopProduct> query = shopProductService.lambdaQuery().eq(ShopProduct::getId, param.getProductId())
|
|
|
.eq(ShopProduct::getCountryId, param.getCountryId());
|
|
|
+ //商品信息
|
|
|
ShopProduct one = shopProductService.getOne(query);
|
|
|
if(ObjectUtil.isEmpty(one)){
|
|
|
return null;
|
|
@@ -48,21 +52,34 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProductSpecMappe
|
|
|
return null;
|
|
|
}
|
|
|
ProductSpecVo bean = BeanUtil.toBean(one, ProductSpecVo.class);
|
|
|
+ //SKU
|
|
|
Set<Long> skus = list1.stream().map(ShopProductSku::getSkuId).collect(Collectors.toSet());
|
|
|
//规格和规格对应的值
|
|
|
List<ShopSkuSpecValue> skuValues = shopSkuSpecValueService.lambdaQuery().eq(ShopSkuSpecValue::getSkuId, skus).list();
|
|
|
//规格值ID
|
|
|
Set<Long> collect = skuValues.stream().map(ShopSkuSpecValue::getSpecValueId).collect(Collectors.toSet());
|
|
|
- List<ShopSpecValue> list2 = shopSpecValueService.list(Wrappers.<ShopSpecValue>lambdaQuery().in(ShopSpecValue::getId, collect));
|
|
|
+ List<ShopSpecValue> list2 = shopSpecValueService.list(Wrappers.<ShopSpecValue>lambdaQuery()
|
|
|
+ .orderByAsc(ShopSpecValue::getSortOrder)
|
|
|
+ .in(ShopSpecValue::getId, collect));
|
|
|
|
|
|
//规格ID
|
|
|
- Set<Long> collect3 = list2.stream().map(ShopSpecValue::getSpecId).collect(Collectors.toSet());
|
|
|
+ List<ShopProductSpec> list = shopProductSpecService.lambdaQuery().eq(ShopProductSpec::getProductId, one.getId())
|
|
|
+ .orderByAsc(ShopProductSpec::getSortOrder).list();
|
|
|
+ Set<Long> collect3 = list.stream().map(ShopProductSpec::getSpecId).collect(Collectors.toSet());
|
|
|
Map<String, ShopSpec> specs = new HashMap<>();
|
|
|
- List<ShopSpec> list = shopSpecService.lambdaQuery().in(ShopSpec::getId, collect3).list();
|
|
|
+ List<ShopSpec> list11 = shopSpecService.lambdaQuery().in(ShopSpec::getId, collect3).list();
|
|
|
|
|
|
- for (ShopSpec spec : list) {
|
|
|
+ for (ShopSpec spec : list11) {
|
|
|
specs.put(spec.getId().toString(), spec);
|
|
|
}
|
|
|
+ List<SpecSortVo> specSortVoList = new ArrayList<>();
|
|
|
+ for (ShopProductSpec shopProductSpec : list) {
|
|
|
+ SpecSortVo specSortVo = new SpecSortVo();
|
|
|
+ specSortVo.setId(shopProductSpec.getSpecId().toString());
|
|
|
+ specSortVo.setSpecName(shopProductSpec.getSpecName());
|
|
|
+ }
|
|
|
+
|
|
|
+ bean.setSpecSortVoList(specSortVoList);
|
|
|
|
|
|
Set<Long> skuIds = skuValues.stream().map(ShopSkuSpecValue::getSkuId).collect(Collectors.toSet());
|
|
|
//SKU -> ShopSpecValue
|