Commit fe1ae23b71d68ad6b1762ea93a79cb51a3383f57
1 parent
fac3e7c7
trade:增加管理后台的订单分页接口
Showing
24 changed files
with
309 additions
and
48 deletions
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApi.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.api.property; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 4 | + | ||
| 5 | +import java.util.Collection; | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 商品属性值 API 接口 | ||
| 10 | + * | ||
| 11 | + * @author 芋道源码 | ||
| 12 | + */ | ||
| 13 | +public interface ProductPropertyValueApi { | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 根据编号数组,获得属性值列表 | ||
| 17 | + * | ||
| 18 | + * @param ids 编号数组 | ||
| 19 | + * @return 属性值明细列表 | ||
| 20 | + */ | ||
| 21 | + List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids); | ||
| 22 | + | ||
| 23 | +} |
yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/api/property/dto/ProductPropertyValueDetailRespDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.api.property.dto; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 商品属性项的明细 Response DTO | ||
| 7 | + * | ||
| 8 | + * @author 芋道源码 | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class ProductPropertyValueDetailRespDTO { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 属性的编号 | ||
| 15 | + */ | ||
| 16 | + private Long propertyId; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 属性的名称 | ||
| 20 | + */ | ||
| 21 | + private String propertyName; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 属性值的编号 | ||
| 25 | + */ | ||
| 26 | + private Long valueId; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 属性值的名称 | ||
| 30 | + */ | ||
| 31 | + private String valueName; | ||
| 32 | + | ||
| 33 | +} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/api/property/ProductPropertyValueApiImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.product.api.property; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 4 | +import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; | ||
| 5 | +import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; | ||
| 6 | +import org.springframework.stereotype.Service; | ||
| 7 | +import org.springframework.validation.annotation.Validated; | ||
| 8 | + | ||
| 9 | +import javax.annotation.Resource; | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 商品属性值 API 实现类 | ||
| 15 | + * | ||
| 16 | + * @author 芋道源码 | ||
| 17 | + */ | ||
| 18 | +@Service | ||
| 19 | +@Validated | ||
| 20 | +public class ProductPropertyValueApiImpl implements ProductPropertyValueApi { | ||
| 21 | + | ||
| 22 | + @Resource | ||
| 23 | + private ProductPropertyValueService productPropertyValueService; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public List<ProductPropertyValueDetailRespDTO> getPropertyValueDetailList(Collection<Long> ids) { | ||
| 27 | + return ProductPropertyValueConvert.INSTANCE.convertList02( | ||
| 28 | + productPropertyValueService.getPropertyValueDetailList(ids)); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
| @@ -63,7 +63,7 @@ public class ProductPropertyController { | @@ -63,7 +63,7 @@ public class ProductPropertyController { | ||
| 63 | @ApiOperation("获得属性项列表") | 63 | @ApiOperation("获得属性项列表") |
| 64 | @PreAuthorize("@ss.hasPermission('product:property:query')") | 64 | @PreAuthorize("@ss.hasPermission('product:property:query')") |
| 65 | public CommonResult<List<ProductPropertyRespVO>> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) { | 65 | public CommonResult<List<ProductPropertyRespVO>> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) { |
| 66 | - return success(productPropertyService.getPropertyList(listReqVO)); | 66 | + return success(productPropertyService.getPropertyVOList(listReqVO)); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | @GetMapping("/page") | 69 | @GetMapping("/page") |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/propertyvalue/ProductPropertyValueConvert.java
| 1 | package cn.iocoder.yudao.module.product.convert.propertyvalue; | 1 | package cn.iocoder.yudao.module.product.convert.propertyvalue; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 6 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; |
| 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; | 8 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; | 9 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; |
| 10 | +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | ||
| 7 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; |
| 12 | +import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | ||
| 8 | import org.mapstruct.Mapper; | 13 | import org.mapstruct.Mapper; |
| 9 | import org.mapstruct.factory.Mappers; | 14 | import org.mapstruct.factory.Mappers; |
| 10 | 15 | ||
| 11 | import java.util.List; | 16 | import java.util.List; |
| 17 | +import java.util.Map; | ||
| 18 | + | ||
| 19 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 12 | 20 | ||
| 13 | /** | 21 | /** |
| 14 | * 属性值 Convert | 22 | * 属性值 Convert |
| @@ -30,6 +38,18 @@ public interface ProductPropertyValueConvert { | @@ -30,6 +38,18 @@ public interface ProductPropertyValueConvert { | ||
| 30 | 38 | ||
| 31 | PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page); | 39 | PageResult<ProductPropertyValueRespVO> convertPage(PageResult<ProductPropertyValueDO> page); |
| 32 | 40 | ||
| 33 | - List<ProductPropertyValueDO> convertList03(List<ProductPropertyValueCreateReqVO> list); | 41 | + default List<ProductPropertyValueDetailRespBO> convertList(List<ProductPropertyValueDO> values, List<ProductPropertyDO> keys) { |
| 42 | + Map<Long, ProductPropertyDO> keyMap = convertMap(keys, ProductPropertyDO::getId); | ||
| 43 | + return CollectionUtils.convertList(values, value -> { | ||
| 44 | + ProductPropertyValueDetailRespBO valueDetail = new ProductPropertyValueDetailRespBO() | ||
| 45 | + .setValueId(value.getId()).setValueName(value.getName()); | ||
| 46 | + // 设置属性项 | ||
| 47 | + MapUtils.findAndThen(keyMap, value.getPropertyId(), | ||
| 48 | + key -> valueDetail.setPropertyId(key.getId()).setPropertyName(key.getName())); | ||
| 49 | + return valueDetail; | ||
| 50 | + }); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + List<ProductPropertyValueDetailRespDTO> convertList02(List<ProductPropertyValueDetailRespBO> list); | ||
| 34 | 54 | ||
| 35 | } | 55 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyService.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.property; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.product.service.property; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*; | 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.property.*; |
| 5 | +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | ||
| 5 | 6 | ||
| 6 | import javax.validation.Valid; | 7 | import javax.validation.Valid; |
| 7 | import java.util.Collection; | 8 | import java.util.Collection; |
| @@ -41,7 +42,7 @@ public interface ProductPropertyService { | @@ -41,7 +42,7 @@ public interface ProductPropertyService { | ||
| 41 | * @param listReqVO 集合查询 | 42 | * @param listReqVO 集合查询 |
| 42 | * @return 属性项集合 | 43 | * @return 属性项集合 |
| 43 | */ | 44 | */ |
| 44 | - List<ProductPropertyRespVO> getPropertyList(ProductPropertyListReqVO listReqVO); | 45 | + List<ProductPropertyRespVO> getPropertyVOList(ProductPropertyListReqVO listReqVO); |
| 45 | 46 | ||
| 46 | /** | 47 | /** |
| 47 | * 获取属性名称分页 | 48 | * 获取属性名称分页 |
| @@ -65,7 +66,15 @@ public interface ProductPropertyService { | @@ -65,7 +66,15 @@ public interface ProductPropertyService { | ||
| 65 | * @param ids 属性项的编号的集合 | 66 | * @param ids 属性项的编号的集合 |
| 66 | * @return 属性项数组 | 67 | * @return 属性项数组 |
| 67 | */ | 68 | */ |
| 68 | - List<ProductPropertyRespVO> getPropertyList(Collection<Long> ids); | 69 | + List<ProductPropertyDO> getPropertyList(Collection<Long> ids); |
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * 根据属性项的编号的集合,获得对应的属性项数组 | ||
| 73 | + * | ||
| 74 | + * @param ids 属性项的编号的集合 | ||
| 75 | + * @return 属性项数组 | ||
| 76 | + */ | ||
| 77 | + List<ProductPropertyRespVO> getPropertyVOList(Collection<Long> ids); | ||
| 69 | 78 | ||
| 70 | /** | 79 | /** |
| 71 | * 获得属性项 + 值的列表 | 80 | * 获得属性项 + 值的列表 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyServiceImpl.java
| @@ -83,7 +83,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { | @@ -83,7 +83,7 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { | ||
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | @Override | 85 | @Override |
| 86 | - public List<ProductPropertyRespVO> getPropertyList(ProductPropertyListReqVO listReqVO) { | 86 | + public List<ProductPropertyRespVO> getPropertyVOList(ProductPropertyListReqVO listReqVO) { |
| 87 | return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectList(new LambdaQueryWrapperX<ProductPropertyDO>() | 87 | return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectList(new LambdaQueryWrapperX<ProductPropertyDO>() |
| 88 | .likeIfPresent(ProductPropertyDO::getName, listReqVO.getName()) | 88 | .likeIfPresent(ProductPropertyDO::getName, listReqVO.getName()) |
| 89 | .eqIfPresent(ProductPropertyDO::getStatus, listReqVO.getStatus()))); | 89 | .eqIfPresent(ProductPropertyDO::getStatus, listReqVO.getStatus()))); |
| @@ -101,16 +101,21 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { | @@ -101,16 +101,21 @@ public class ProductPropertyServiceImpl implements ProductPropertyService { | ||
| 101 | return ProductPropertyConvert.INSTANCE.convert(property); | 101 | return ProductPropertyConvert.INSTANCE.convert(property); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | + @Override | ||
| 105 | + public List<ProductPropertyDO> getPropertyList(Collection<Long> ids) { | ||
| 106 | + return productPropertyMapper.selectBatchIds(ids); | ||
| 107 | + } | ||
| 108 | + | ||
| 104 | // TODO @芋艿:丢到 Controller | 109 | // TODO @芋艿:丢到 Controller |
| 105 | @Override | 110 | @Override |
| 106 | - public List<ProductPropertyRespVO> getPropertyList(Collection<Long> ids) { | 111 | + public List<ProductPropertyRespVO> getPropertyVOList(Collection<Long> ids) { |
| 107 | return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(ids)); | 112 | return ProductPropertyConvert.INSTANCE.convertList(productPropertyMapper.selectBatchIds(ids)); |
| 108 | } | 113 | } |
| 109 | 114 | ||
| 110 | // TODO @芋艿:丢到 Controller | 115 | // TODO @芋艿:丢到 Controller |
| 111 | @Override | 116 | @Override |
| 112 | public List<ProductPropertyAndValueRespVO> getPropertyAndValueList(ProductPropertyListReqVO listReqVO) { | 117 | public List<ProductPropertyAndValueRespVO> getPropertyAndValueList(ProductPropertyListReqVO listReqVO) { |
| 113 | - List<ProductPropertyRespVO> propertyList = getPropertyList(listReqVO); | 118 | + List<ProductPropertyRespVO> propertyList = getPropertyVOList(listReqVO); |
| 114 | 119 | ||
| 115 | // 查询属性值 | 120 | // 查询属性值 |
| 116 | List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId)); | 121 | List<ProductPropertyValueDO> valueDOList = productPropertyValueMapper.selectListByPropertyId(CollectionUtils.convertList(propertyList, ProductPropertyRespVO::getId)); |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueService.java
| @@ -5,7 +5,9 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc | @@ -5,7 +5,9 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc | ||
| 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; |
| 8 | +import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | ||
| 8 | 9 | ||
| 10 | +import java.util.Collection; | ||
| 9 | import java.util.List; | 11 | import java.util.List; |
| 10 | 12 | ||
| 11 | /** | 13 | /** |
| @@ -46,6 +48,14 @@ public interface ProductPropertyValueService { | @@ -46,6 +48,14 @@ public interface ProductPropertyValueService { | ||
| 46 | ProductPropertyValueRespVO getPropertyValue(Long id); | 48 | ProductPropertyValueRespVO getPropertyValue(Long id); |
| 47 | 49 | ||
| 48 | /** | 50 | /** |
| 51 | + * 根据编号数组,获得属性值列表 | ||
| 52 | + * | ||
| 53 | + * @param ids 编号数组 | ||
| 54 | + * @return 属性值明细列表 | ||
| 55 | + */ | ||
| 56 | + List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids); | ||
| 57 | + | ||
| 58 | + /** | ||
| 49 | * 获得属性值 | 59 | * 获得属性值 |
| 50 | * | 60 | * |
| 51 | * @param id 编号 | 61 | * @param id 编号 |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/property/ProductPropertyValueServiceImpl.java
| 1 | package cn.iocoder.yudao.module.product.service.property; | 1 | package cn.iocoder.yudao.module.product.service.property; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; | 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueCreateReqVO; |
| 5 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; | 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValuePageReqVO; |
| 6 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; | 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueRespVO; |
| 7 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; | 8 | import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO; |
| 8 | import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; | 9 | import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert; |
| 10 | +import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | ||
| 9 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; | 11 | import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; |
| 10 | import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; | 12 | import cn.iocoder.yudao.module.product.dal.mysql.property.ProductPropertyValueMapper; |
| 13 | +import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | ||
| 11 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 14 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 15 | +import org.springframework.context.annotation.Lazy; | ||
| 12 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 13 | import org.springframework.validation.annotation.Validated; | 17 | import org.springframework.validation.annotation.Validated; |
| 14 | 18 | ||
| 15 | import javax.annotation.Resource; | 19 | import javax.annotation.Resource; |
| 20 | +import java.util.Collection; | ||
| 21 | +import java.util.Collections; | ||
| 16 | import java.util.List; | 22 | import java.util.List; |
| 17 | 23 | ||
| 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 24 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 25 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 19 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; | 26 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.PROPERTY_VALUE_EXISTS; |
| 20 | 27 | ||
| 21 | /** | 28 | /** |
| @@ -30,6 +37,10 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ | @@ -30,6 +37,10 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ | ||
| 30 | @Resource | 37 | @Resource |
| 31 | private ProductPropertyValueMapper productPropertyValueMapper; | 38 | private ProductPropertyValueMapper productPropertyValueMapper; |
| 32 | 39 | ||
| 40 | + @Resource | ||
| 41 | + @Lazy // 延迟加载,避免循环依赖 | ||
| 42 | + private ProductPropertyService productPropertyService; | ||
| 43 | + | ||
| 33 | @Override | 44 | @Override |
| 34 | public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { | 45 | public Long createPropertyValue(ProductPropertyValueCreateReqVO createReqVO) { |
| 35 | if (productPropertyValueMapper.selectByName(createReqVO.getPropertyId(), createReqVO.getName()) != null) { | 46 | if (productPropertyValueMapper.selectByName(createReqVO.getPropertyId(), createReqVO.getName()) != null) { |
| @@ -63,6 +74,23 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ | @@ -63,6 +74,23 @@ public class ProductPropertyValueServiceImpl implements ProductPropertyValueServ | ||
| 63 | } | 74 | } |
| 64 | 75 | ||
| 65 | @Override | 76 | @Override |
| 77 | + public List<ProductPropertyValueDetailRespBO> getPropertyValueDetailList(Collection<Long> ids) { | ||
| 78 | + // 获得属性值列表 | ||
| 79 | + if (CollUtil.isEmpty(ids)) { | ||
| 80 | + return Collections.emptyList(); | ||
| 81 | + } | ||
| 82 | + List<ProductPropertyValueDO> values = productPropertyValueMapper.selectBatchIds(ids); | ||
| 83 | + if (CollUtil.isEmpty(values)) { | ||
| 84 | + return Collections.emptyList(); | ||
| 85 | + } | ||
| 86 | + // 获得属性项列表 | ||
| 87 | + List<ProductPropertyDO> keys = productPropertyService.getPropertyList( | ||
| 88 | + convertSet(values, ProductPropertyValueDO::getPropertyId)); | ||
| 89 | + // 组装明细 | ||
| 90 | + return ProductPropertyValueConvert.INSTANCE.convertList(values, keys); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + @Override | ||
| 66 | public List<ProductPropertyValueRespVO> getPropertyValueListByPropertyId(List<Long> id) { | 94 | public List<ProductPropertyValueRespVO> getPropertyValueListByPropertyId(List<Long> id) { |
| 67 | return ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueMapper.selectList("property_id", id)); | 95 | return ProductPropertyValueConvert.INSTANCE.convertList(productPropertyValueMapper.selectList("property_id", id)); |
| 68 | } | 96 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| @@ -89,7 +89,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | @@ -89,7 +89,7 @@ public class ProductSkuServiceImpl implements ProductSkuService { | ||
| 89 | .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 | 89 | .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 |
| 90 | .map(ProductSkuBaseVO.Property::getPropertyId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 | 90 | .map(ProductSkuBaseVO.Property::getPropertyId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 |
| 91 | .collect(Collectors.toSet()); | 91 | .collect(Collectors.toSet()); |
| 92 | - List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyList(propertyIds); | 92 | + List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyVOList(propertyIds); |
| 93 | if (propertyList.size() != propertyIds.size()) { | 93 | if (propertyList.size() != propertyIds.size()) { |
| 94 | throw exception(PROPERTY_NOT_EXISTS); | 94 | throw exception(PROPERTY_NOT_EXISTS); |
| 95 | } | 95 | } |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| @@ -142,7 +142,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -142,7 +142,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 142 | Map<Long, List<ProductSkuBaseVO.Property>> propertyMaps = properties.stream().collect(Collectors.groupingBy(ProductSkuBaseVO.Property::getPropertyId)); | 142 | Map<Long, List<ProductSkuBaseVO.Property>> propertyMaps = properties.stream().collect(Collectors.groupingBy(ProductSkuBaseVO.Property::getPropertyId)); |
| 143 | 143 | ||
| 144 | List<ProductPropertyValueRespVO> propertyValueList = productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(propertyMaps.keySet())); | 144 | List<ProductPropertyValueRespVO> propertyValueList = productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(propertyMaps.keySet())); |
| 145 | - List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyList(new ArrayList<>(propertyMaps.keySet())); | 145 | + List<ProductPropertyRespVO> propertyList = productPropertyService.getPropertyVOList(new ArrayList<>(propertyMaps.keySet())); |
| 146 | // 装载组装过后的属性 | 146 | // 装载组装过后的属性 |
| 147 | List<ProductPropertyViewRespVO> productPropertyViews = new ArrayList<>(); | 147 | List<ProductPropertyViewRespVO> productPropertyViews = new ArrayList<>(); |
| 148 | propertyList.forEach(p -> { | 148 | propertyList.forEach(p -> { |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImplTest.java
| @@ -188,7 +188,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | @@ -188,7 +188,7 @@ public class ProductSpuServiceImplTest extends BaseDbUnitTest { | ||
| 188 | 188 | ||
| 189 | Mockito.when(productSkuService.getSkusBySpuId(createReqVO.getId())).thenReturn(productSkuDOS); | 189 | Mockito.when(productSkuService.getSkusBySpuId(createReqVO.getId())).thenReturn(productSkuDOS); |
| 190 | Mockito.when(productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyValueRespVO); | 190 | Mockito.when(productPropertyValueService.getPropertyValueListByPropertyId(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyValueRespVO); |
| 191 | - Mockito.when(productPropertyService.getPropertyList(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyRespVOS); | 191 | + Mockito.when(productPropertyService.getPropertyVOList(new ArrayList<>(collect.keySet()))).thenReturn(productPropertyRespVOS); |
| 192 | 192 | ||
| 193 | // 调用 | 193 | // 调用 |
| 194 | ProductSpuDetailRespVO spuDetail = productSpuService.getSpuDetail(createReqVO.getId()); | 194 | ProductSpuDetailRespVO spuDetail = productSpuService.getSpuDetail(createReqVO.getId()); |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.http
0 → 100644
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/TradeAfterSaleController.java
| @@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | @@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | 6 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 7 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | 7 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 8 | +import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; | ||
| 9 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 8 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; | 10 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO; |
| 9 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; | 11 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSalePageReqVO; |
| 10 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO; | 12 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRefuseReqVO; |
| @@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*; | @@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*; | ||
| 22 | 24 | ||
| 23 | import javax.annotation.Resource; | 25 | import javax.annotation.Resource; |
| 24 | import javax.validation.Valid; | 26 | import javax.validation.Valid; |
| 27 | +import java.util.List; | ||
| 25 | import java.util.Map; | 28 | import java.util.Map; |
| 26 | 29 | ||
| 27 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -41,20 +44,26 @@ public class TradeAfterSaleController { | @@ -41,20 +44,26 @@ public class TradeAfterSaleController { | ||
| 41 | 44 | ||
| 42 | @Resource | 45 | @Resource |
| 43 | private MemberUserApi memberUserApi; | 46 | private MemberUserApi memberUserApi; |
| 47 | + @Resource | ||
| 48 | + private ProductPropertyValueApi productPropertyValueApi; | ||
| 44 | 49 | ||
| 45 | @GetMapping("/page") | 50 | @GetMapping("/page") |
| 46 | @ApiOperation("获得交易售后分页") | 51 | @ApiOperation("获得交易售后分页") |
| 47 | @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") | 52 | @PreAuthorize("@ss.hasPermission('trade:after-sale:query')") |
| 48 | public CommonResult<PageResult<TradeAfterSaleRespPageItemVO>> getAfterSalePage(@Valid TradeAfterSalePageReqVO pageVO) { | 53 | public CommonResult<PageResult<TradeAfterSaleRespPageItemVO>> getAfterSalePage(@Valid TradeAfterSalePageReqVO pageVO) { |
| 54 | + // 查询售后 | ||
| 49 | PageResult<TradeAfterSaleDO> pageResult = afterSaleService.getAfterSalePage(pageVO); | 55 | PageResult<TradeAfterSaleDO> pageResult = afterSaleService.getAfterSalePage(pageVO); |
| 50 | if (CollUtil.isEmpty(pageResult.getList())) { | 56 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 51 | return success(PageResult.empty()); | 57 | return success(PageResult.empty()); |
| 52 | } | 58 | } |
| 53 | 59 | ||
| 54 | - // 拼接数据 | 60 | + // 查询商品属性 |
| 61 | + List<ProductPropertyValueDetailRespDTO> propertyValueDetails = productPropertyValueApi | ||
| 62 | + .getPropertyValueDetailList(TradeAfterSaleConvert.INSTANCE.convertPropertyValueIds(pageResult.getList())); | ||
| 63 | + // 查询会员 | ||
| 55 | Map<Long, MemberUserRespDTO> memberUsers = memberUserApi.getUserMap( | 64 | Map<Long, MemberUserRespDTO> memberUsers = memberUserApi.getUserMap( |
| 56 | convertSet(pageResult.getList(), TradeAfterSaleDO::getUserId)); | 65 | convertSet(pageResult.getList(), TradeAfterSaleDO::getUserId)); |
| 57 | - return success(TradeAfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers)); | 66 | + return success(TradeAfterSaleConvert.INSTANCE.convertPage(pageResult, memberUsers, propertyValueDetails)); |
| 58 | } | 67 | } |
| 59 | 68 | ||
| 60 | @PutMapping("/agree") | 69 | @PutMapping("/agree") |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleBaseVO.java
| 1 | package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; | 1 | package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; | ||
| 4 | import io.swagger.annotations.ApiModelProperty; | 3 | import io.swagger.annotations.ApiModelProperty; |
| 5 | import lombok.Data; | 4 | import lombok.Data; |
| 6 | import org.springframework.format.annotation.DateTimeFormat; | 5 | import org.springframework.format.annotation.DateTimeFormat; |
| @@ -72,9 +71,6 @@ public class TradeAfterSaleBaseVO { | @@ -72,9 +71,6 @@ public class TradeAfterSaleBaseVO { | ||
| 72 | @NotNull(message = "商品 SKU 编号不能为空") | 71 | @NotNull(message = "商品 SKU 编号不能为空") |
| 73 | private Long skuId; | 72 | private Long skuId; |
| 74 | 73 | ||
| 75 | - @ApiModelProperty(value = "商品属性数组") | ||
| 76 | - private List<ProductPropertyValueDetailRespVO> properties; | ||
| 77 | - | ||
| 78 | @ApiModelProperty(value = "商品图片", example = "https://www.iocoder.cn/2.png") | 74 | @ApiModelProperty(value = "商品图片", example = "https://www.iocoder.cn/2.png") |
| 79 | private String picUrl; | 75 | private String picUrl; |
| 80 | 76 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/aftersale/vo/TradeAfterSaleRespPageItemVO.java
| 1 | package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; | 1 | package cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; | 3 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; | ||
| 4 | import io.swagger.annotations.ApiModel; | 5 | import io.swagger.annotations.ApiModel; |
| 5 | import io.swagger.annotations.ApiModelProperty; | 6 | import io.swagger.annotations.ApiModelProperty; |
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -8,6 +9,7 @@ import lombok.EqualsAndHashCode; | @@ -8,6 +9,7 @@ import lombok.EqualsAndHashCode; | ||
| 8 | import lombok.ToString; | 9 | import lombok.ToString; |
| 9 | 10 | ||
| 10 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
| 12 | +import java.util.List; | ||
| 11 | 13 | ||
| 12 | @ApiModel("管理后台 - 交易售后分页的每一条记录 Response VO") | 14 | @ApiModel("管理后台 - 交易售后分页的每一条记录 Response VO") |
| 13 | @Data | 15 | @Data |
| @@ -22,6 +24,11 @@ public class TradeAfterSaleRespPageItemVO extends TradeAfterSaleBaseVO { | @@ -22,6 +24,11 @@ public class TradeAfterSaleRespPageItemVO extends TradeAfterSaleBaseVO { | ||
| 22 | private LocalDateTime createTime; | 24 | private LocalDateTime createTime; |
| 23 | 25 | ||
| 24 | /** | 26 | /** |
| 27 | + * 商品属性数组 | ||
| 28 | + */ | ||
| 29 | + private List<ProductPropertyValueDetailRespVO> properties; | ||
| 30 | + | ||
| 31 | + /** | ||
| 25 | * 用户信息 | 32 | * 用户信息 |
| 26 | */ | 33 | */ |
| 27 | private MemberUserRespVO user; | 34 | private MemberUserRespVO user; |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.http
0 → 100644
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/TradeOrderController.java
| @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.controller.admin.order; | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.controller.admin.order; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.module.product.api.property.ProductPropertyValueApi; | ||
| 7 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 6 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; | 8 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; |
| 7 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; | 9 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; |
| 8 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; | 10 | import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageReqVO; |
| @@ -19,7 +21,6 @@ import org.springframework.web.bind.annotation.*; | @@ -19,7 +21,6 @@ import org.springframework.web.bind.annotation.*; | ||
| 19 | 21 | ||
| 20 | import javax.annotation.Resource; | 22 | import javax.annotation.Resource; |
| 21 | import java.util.List; | 23 | import java.util.List; |
| 22 | -import java.util.Set; | ||
| 23 | 24 | ||
| 24 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 25 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 26 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| @@ -35,6 +36,9 @@ public class TradeOrderController { | @@ -35,6 +36,9 @@ public class TradeOrderController { | ||
| 35 | @Resource | 36 | @Resource |
| 36 | private TradeOrderService tradeOrderService; | 37 | private TradeOrderService tradeOrderService; |
| 37 | 38 | ||
| 39 | + @Resource | ||
| 40 | + private ProductPropertyValueApi productPropertyValueApi; | ||
| 41 | + | ||
| 38 | @GetMapping("/page") | 42 | @GetMapping("/page") |
| 39 | @ApiOperation("获得交易订单分页") | 43 | @ApiOperation("获得交易订单分页") |
| 40 | @PreAuthorize("@ss.hasPermission('trade:order:query')") | 44 | @PreAuthorize("@ss.hasPermission('trade:order:query')") |
| @@ -44,15 +48,14 @@ public class TradeOrderController { | @@ -44,15 +48,14 @@ public class TradeOrderController { | ||
| 44 | if (CollUtil.isEmpty(pageResult.getList())) { | 48 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 45 | return success(PageResult.empty()); | 49 | return success(PageResult.empty()); |
| 46 | } | 50 | } |
| 47 | - | ||
| 48 | // 查询订单项 | 51 | // 查询订单项 |
| 49 | - List<TradeOrderItemDO> orderItems = tradeOrderService.getOrderItems( | 52 | + List<TradeOrderItemDO> orderItems = tradeOrderService.getOrderItemListByOrderId( |
| 50 | convertSet(pageResult.getList(), TradeOrderDO::getId)); | 53 | convertSet(pageResult.getList(), TradeOrderDO::getId)); |
| 51 | - // 查询属性 | ||
| 52 | - Set<Long> propertyValueIds = TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems); | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - return success(null); | 54 | + // 查询商品属性 |
| 55 | + List<ProductPropertyValueDetailRespDTO> propertyValueDetails = productPropertyValueApi | ||
| 56 | + .getPropertyValueDetailList(TradeOrderConvert.INSTANCE.convertPropertyValueIds(orderItems)); | ||
| 57 | + // 最终组合 | ||
| 58 | + return success(TradeOrderConvert.INSTANCE.convertPage(pageResult, orderItems, propertyValueDetails)); | ||
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | @PostMapping("/delivery") | 61 | @PostMapping("/delivery") |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/order/vo/TradeOrderPageItemRespVO.java
| @@ -8,7 +8,7 @@ import java.util.List; | @@ -8,7 +8,7 @@ import java.util.List; | ||
| 8 | 8 | ||
| 9 | @ApiModel("管理后台 - 交易订单的分页项 Response VO") | 9 | @ApiModel("管理后台 - 交易订单的分页项 Response VO") |
| 10 | @Data | 10 | @Data |
| 11 | -public class TradeOrderPageItemRespVO { | 11 | +public class TradeOrderPageItemRespVO extends TradeOrderBaseVO { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | * 订单项列表 | 14 | * 订单项列表 |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/aftersale/TradeAfterSaleConvert.java
| 1 | package cn.iocoder.yudao.module.trade.convert.aftersale; | 1 | package cn.iocoder.yudao.module.trade.convert.aftersale; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | 5 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 5 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; | 6 | import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; |
| 7 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 6 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO; | 8 | import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleRespPageItemVO; |
| 7 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; | 9 | import cn.iocoder.yudao.module.trade.controller.admin.base.member.user.MemberUserRespVO; |
| 10 | +import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; | ||
| 8 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; | 11 | import cn.iocoder.yudao.module.trade.controller.app.aftersale.vo.AppTradeAfterSaleCreateReqVO; |
| 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; | 12 | import cn.iocoder.yudao.module.trade.dal.dataobject.aftersale.TradeAfterSaleDO; |
| 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | 13 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| @@ -14,7 +17,10 @@ import org.mapstruct.Mapping; | @@ -14,7 +17,10 @@ import org.mapstruct.Mapping; | ||
| 14 | import org.mapstruct.Mappings; | 17 | import org.mapstruct.Mappings; |
| 15 | import org.mapstruct.factory.Mappers; | 18 | import org.mapstruct.factory.Mappers; |
| 16 | 19 | ||
| 17 | -import java.util.Map; | 20 | +import java.util.*; |
| 21 | +import java.util.stream.Collectors; | ||
| 22 | + | ||
| 23 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 18 | 24 | ||
| 19 | @Mapper | 25 | @Mapper |
| 20 | public interface TradeAfterSaleConvert { | 26 | public interface TradeAfterSaleConvert { |
| @@ -43,10 +49,41 @@ public interface TradeAfterSaleConvert { | @@ -43,10 +49,41 @@ public interface TradeAfterSaleConvert { | ||
| 43 | PageResult<TradeAfterSaleRespPageItemVO> convertPage(PageResult<TradeAfterSaleDO> page); | 49 | PageResult<TradeAfterSaleRespPageItemVO> convertPage(PageResult<TradeAfterSaleDO> page); |
| 44 | 50 | ||
| 45 | default PageResult<TradeAfterSaleRespPageItemVO> convertPage(PageResult<TradeAfterSaleDO> pageResult, | 51 | default PageResult<TradeAfterSaleRespPageItemVO> convertPage(PageResult<TradeAfterSaleDO> pageResult, |
| 46 | - Map<Long, MemberUserRespDTO> memberUsers) { | 52 | + Map<Long, MemberUserRespDTO> memberUsers, List<ProductPropertyValueDetailRespDTO> propertyValueDetails) { |
| 47 | PageResult<TradeAfterSaleRespPageItemVO> pageVOResult = convertPage(pageResult); | 53 | PageResult<TradeAfterSaleRespPageItemVO> pageVOResult = convertPage(pageResult); |
| 48 | - pageVOResult.getList().forEach(item -> item.setUser(convert(memberUsers.get(item.getUserId())))); | 54 | + // 处理会员 + 商品属性等关联信息 |
| 55 | + Map<Long, ProductPropertyValueDetailRespDTO> propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); | ||
| 56 | + for (int i = 0; i < pageResult.getList().size(); i++) { | ||
| 57 | + TradeAfterSaleRespPageItemVO afterSaleVO = pageVOResult.getList().get(i); | ||
| 58 | + TradeAfterSaleDO afterSaleDO = pageResult.getList().get(i); | ||
| 59 | + // 会员 | ||
| 60 | + afterSaleVO.setUser(convert(memberUsers.get(afterSaleDO.getUserId()))); | ||
| 61 | + // 商品属性 | ||
| 62 | + if (CollUtil.isNotEmpty(afterSaleDO.getProperties())) { | ||
| 63 | + afterSaleVO.setProperties(new ArrayList<>(afterSaleDO.getProperties().size())); | ||
| 64 | + // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 | ||
| 65 | + afterSaleDO.getProperties().forEach(property -> { | ||
| 66 | + ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); | ||
| 67 | + if (propertyValueDetail == null) { | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + afterSaleVO.getProperties().add(convert(propertyValueDetail)); | ||
| 71 | + }); | ||
| 72 | + } | ||
| 73 | + } | ||
| 49 | return pageVOResult; | 74 | return pageVOResult; |
| 50 | } | 75 | } |
| 51 | 76 | ||
| 77 | + ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); | ||
| 78 | + | ||
| 79 | + default Set<Long> convertPropertyValueIds(List<TradeAfterSaleDO> list) { | ||
| 80 | + if (CollUtil.isEmpty(list)) { | ||
| 81 | + return new HashSet<>(); | ||
| 82 | + } | ||
| 83 | + return list.stream().filter(item -> item.getProperties() != null) | ||
| 84 | + .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 | ||
| 85 | + .map(TradeOrderItemDO.Property::getValueId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 | ||
| 86 | + .collect(Collectors.toSet()); | ||
| 87 | + } | ||
| 88 | + | ||
| 52 | } | 89 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
| 1 | package cn.iocoder.yudao.module.trade.convert.order; | 1 | package cn.iocoder.yudao.module.trade.convert.order; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; | 6 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| 6 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; | 7 | import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; |
| 8 | +import cn.iocoder.yudao.module.product.api.property.dto.ProductPropertyValueDetailRespDTO; | ||
| 7 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | 9 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 8 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; | 10 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; |
| 9 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | 11 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 10 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; | 12 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; |
| 11 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; | 13 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; |
| 14 | +import cn.iocoder.yudao.module.trade.controller.admin.base.product.property.ProductPropertyValueDetailRespVO; | ||
| 15 | +import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderPageItemRespVO; | ||
| 12 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; | 16 | import cn.iocoder.yudao.module.trade.controller.app.order.vo.AppTradeOrderCreateReqVO; |
| 13 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; | 17 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 14 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | 18 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| @@ -19,13 +23,11 @@ import org.mapstruct.Mapping; | @@ -19,13 +23,11 @@ import org.mapstruct.Mapping; | ||
| 19 | import org.mapstruct.Mappings; | 23 | import org.mapstruct.Mappings; |
| 20 | import org.mapstruct.factory.Mappers; | 24 | import org.mapstruct.factory.Mappers; |
| 21 | 25 | ||
| 22 | -import java.util.HashSet; | ||
| 23 | -import java.util.List; | ||
| 24 | -import java.util.Map; | ||
| 25 | -import java.util.Set; | 26 | +import java.util.*; |
| 26 | import java.util.stream.Collectors; | 27 | import java.util.stream.Collectors; |
| 27 | 28 | ||
| 28 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | 29 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; | ||
| 29 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; | 31 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; |
| 30 | 32 | ||
| 31 | @Mapper | 33 | @Mapper |
| @@ -92,14 +94,50 @@ public interface TradeOrderConvert { | @@ -92,14 +94,50 @@ public interface TradeOrderConvert { | ||
| 92 | return createReqDTO; | 94 | return createReqDTO; |
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | - default Set<Long> convertPropertyValueIds(List<TradeOrderItemDO> orderItems) { | ||
| 96 | - if (CollUtil.isEmpty(orderItems)) { | 97 | + default Set<Long> convertPropertyValueIds(List<TradeOrderItemDO> list) { |
| 98 | + if (CollUtil.isEmpty(list)) { | ||
| 97 | return new HashSet<>(); | 99 | return new HashSet<>(); |
| 98 | } | 100 | } |
| 99 | - return orderItems.stream().filter(item -> item.getProperties() != null) | 101 | + return list.stream().filter(item -> item.getProperties() != null) |
| 100 | .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 | 102 | .flatMap(p -> p.getProperties().stream()) // 遍历多个 Property 属性 |
| 101 | .map(TradeOrderItemDO.Property::getValueId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 | 103 | .map(TradeOrderItemDO.Property::getValueId) // 将每个 Property 转换成对应的 propertyId,最后形成集合 |
| 102 | .collect(Collectors.toSet()); | 104 | .collect(Collectors.toSet()); |
| 103 | } | 105 | } |
| 104 | 106 | ||
| 107 | + default PageResult<TradeOrderPageItemRespVO> convertPage(PageResult<TradeOrderDO> pageResult, List<TradeOrderItemDO> orderItems, | ||
| 108 | + List<ProductPropertyValueDetailRespDTO> propertyValueDetails) { | ||
| 109 | + Map<Long, List<TradeOrderItemDO>> orderItemMap = convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); | ||
| 110 | + Map<Long, ProductPropertyValueDetailRespDTO> propertyValueDetailMap = convertMap(propertyValueDetails, ProductPropertyValueDetailRespDTO::getValueId); | ||
| 111 | + // 转化 List | ||
| 112 | + List<TradeOrderPageItemRespVO> orderVOs = CollectionUtils.convertList(pageResult.getList(), order -> { | ||
| 113 | + List<TradeOrderItemDO> xOrderItems = orderItemMap.get(order.getId()); | ||
| 114 | + TradeOrderPageItemRespVO orderVO = convert(order, xOrderItems); | ||
| 115 | + if (CollUtil.isNotEmpty(xOrderItems)) { | ||
| 116 | + // 处理商品属性 | ||
| 117 | + for (int i = 0; i < xOrderItems.size(); i++) { | ||
| 118 | + List<TradeOrderItemDO.Property> properties = xOrderItems.get(i).getProperties(); | ||
| 119 | + if (CollUtil.isEmpty(properties)) { | ||
| 120 | + continue; | ||
| 121 | + } | ||
| 122 | + TradeOrderPageItemRespVO.Item item = orderVO.getItems().get(i); | ||
| 123 | + item.setProperties(new ArrayList<>(properties.size())); | ||
| 124 | + // 遍历每个 properties,设置到 TradeOrderPageItemRespVO.Item 中 | ||
| 125 | + properties.forEach(property -> { | ||
| 126 | + ProductPropertyValueDetailRespDTO propertyValueDetail = propertyValueDetailMap.get(property.getValueId()); | ||
| 127 | + if (propertyValueDetail == null) { | ||
| 128 | + return; | ||
| 129 | + } | ||
| 130 | + item.getProperties().add(convert(propertyValueDetail)); | ||
| 131 | + }); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + return orderVO; | ||
| 135 | + }); | ||
| 136 | + return new PageResult<>(orderVOs, pageResult.getTotal()); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + TradeOrderPageItemRespVO convert(TradeOrderDO order, List<TradeOrderItemDO> items); | ||
| 140 | + | ||
| 141 | + ProductPropertyValueDetailRespVO convert(ProductPropertyValueDetailRespDTO bean); | ||
| 142 | + | ||
| 105 | } | 143 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderItemMapper.java
| @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | ||
| 5 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 5 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 6 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 7 | ||
| 8 | +import java.util.Collection; | ||
| 8 | import java.util.List; | 9 | import java.util.List; |
| 9 | 10 | ||
| 10 | @Mapper | 11 | @Mapper |
| @@ -19,4 +20,8 @@ public interface TradeOrderItemMapper extends BaseMapperX<TradeOrderItemDO> { | @@ -19,4 +20,8 @@ public interface TradeOrderItemMapper extends BaseMapperX<TradeOrderItemDO> { | ||
| 19 | return selectList(TradeOrderItemDO::getOrderId, orderId); | 20 | return selectList(TradeOrderItemDO::getOrderId, orderId); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | + default List<TradeOrderItemDO> selectListByOrderId(Collection<Long> orderIds) { | ||
| 24 | + return selectList(TradeOrderItemDO::getOrderId, orderIds); | ||
| 25 | + } | ||
| 26 | + | ||
| 22 | } | 27 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderService.java
| @@ -9,9 +9,6 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | @@ -9,9 +9,6 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; | ||
| 9 | 9 | ||
| 10 | import java.util.Collection; | 10 | import java.util.Collection; |
| 11 | import java.util.List; | 11 | import java.util.List; |
| 12 | -import java.util.Map; | ||
| 13 | - | ||
| 14 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap; | ||
| 15 | 12 | ||
| 16 | /** | 13 | /** |
| 17 | * 交易订单 Service 接口 | 14 | * 交易订单 Service 接口 |
| @@ -97,22 +94,19 @@ public interface TradeOrderService { | @@ -97,22 +94,19 @@ public interface TradeOrderService { | ||
| 97 | Integer newAfterSaleStatus, Integer refundPrice); | 94 | Integer newAfterSaleStatus, Integer refundPrice); |
| 98 | 95 | ||
| 99 | /** | 96 | /** |
| 100 | - * 查询交易订单项 | 97 | + * 根据交易订单项编号数组,查询交易订单项 |
| 101 | * | 98 | * |
| 102 | * @param ids 交易订单项编号数组 | 99 | * @param ids 交易订单项编号数组 |
| 103 | * @return 交易订单项数组 | 100 | * @return 交易订单项数组 |
| 104 | */ | 101 | */ |
| 105 | - List<TradeOrderItemDO> getOrderItems(Collection<Long> ids); | 102 | + List<TradeOrderItemDO> getOrderItemList(Collection<Long> ids); |
| 106 | 103 | ||
| 107 | /** | 104 | /** |
| 108 | - * 查询交易订单项 Map | 105 | + * 根据交易订单编号数组,查询交易订单项 |
| 109 | * | 106 | * |
| 110 | - * @param ids 交易订单项编号数组 | ||
| 111 | - * @return 交易订单项 Map | 107 | + * @param orderIds 交易订单编号数组 |
| 108 | + * @return 交易订单项数组 | ||
| 112 | */ | 109 | */ |
| 113 | - default Map<Long, List<TradeOrderItemDO>> getOrderItemMap(Collection<Long> ids) { | ||
| 114 | - List<TradeOrderItemDO> orderItems = getOrderItems(ids); | ||
| 115 | - return convertMultiMap(orderItems, TradeOrderItemDO::getOrderId); | ||
| 116 | - } | 110 | + List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds); |
| 117 | 111 | ||
| 118 | } | 112 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java
| @@ -473,10 +473,15 @@ public class TradeOrderServiceImpl implements TradeOrderService { | @@ -473,10 +473,15 @@ public class TradeOrderServiceImpl implements TradeOrderService { | ||
| 473 | } | 473 | } |
| 474 | 474 | ||
| 475 | @Override | 475 | @Override |
| 476 | - public List<TradeOrderItemDO> getOrderItems(Collection<Long> ids) { | 476 | + public List<TradeOrderItemDO> getOrderItemList(Collection<Long> ids) { |
| 477 | return tradeOrderItemMapper.selectBatchIds(ids); | 477 | return tradeOrderItemMapper.selectBatchIds(ids); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | + @Override | ||
| 481 | + public List<TradeOrderItemDO> getOrderItemListByOrderId(Collection<Long> orderIds) { | ||
| 482 | + return tradeOrderItemMapper.selectListByOrderId(orderIds); | ||
| 483 | + } | ||
| 484 | + | ||
| 480 | /** | 485 | /** |
| 481 | * 判断指定订单的所有订单项,是不是都售后成功 | 486 | * 判断指定订单的所有订单项,是不是都售后成功 |
| 482 | * | 487 | * |