From bb0bb2a4fa16380dad968e3ead36cc456f9b1738 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 25 Jun 2023 11:25:13 +0800 Subject: [PATCH] =?UTF-8?q?mall=20+=20promotion=EF=BC=9A=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/spu/vo/ProductSpuExcelVO.java | 9 ------ .../app/spu/vo/AppProductSpuPageRespVO.java | 6 ++++ .../convert/spu/ProductSpuConvert.java | 28 ++++++++----------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java index 62da2747b..38cbd8472 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuExcelVO.java @@ -44,9 +44,6 @@ public class ProductSpuExcelVO { @ExcelProperty("商品封面图") private String picUrl; - @ExcelProperty("商品轮播图地址") - private String sliderPicUrls; - @ExcelProperty("商品视频") private String videoUrl; @@ -97,15 +94,9 @@ public class ProductSpuExcelVO { @ExcelProperty("赠送积分") private Integer giveIntegral; - @ExcelProperty("赠送的优惠劵编号的数组") - private String giveCouponTemplateIds; - @ExcelProperty("分销类型") private Boolean subCommissionType; - @ExcelProperty("活动显示排序") - private String activityOrders; - @ExcelProperty("商品销量") private Integer salesCount; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java index 7a4d1cf32..c4a66afd2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageRespVO.java @@ -24,6 +24,9 @@ public class AppProductSpuPageRespVO { @Schema(description = "商品轮播图", requiredMode = Schema.RequiredMode.REQUIRED) private List sliderPicUrls; + @Schema(description = "单位名", requiredMode = Schema.RequiredMode.REQUIRED, example = "个") + private String unitName; + // ========== SKU 相关字段 ========= @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @@ -35,6 +38,9 @@ public class AppProductSpuPageRespVO { @Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer marketPrice; + @Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格 + private Integer vipPrice; + @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") private Integer stock; diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index f525f3134..aaad240a4 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java @@ -1,13 +1,12 @@ package cn.iocoder.yudao.module.product.convert.spu; -import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRespVO; import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; @@ -46,20 +45,6 @@ public interface ProductSpuConvert { List convertList02(List list); - /** - * 列表转字符串 - * - * @param list 列表 - * @return 字符串 - */ - @Named("convertListToString") - default String convertListToString(List list) { - return StrUtil.toString(list); - } - - @Mapping(source = "sliderPicUrls", target = "sliderPicUrls", qualifiedByName = "convertListToString") - @Mapping(source = "giveCouponTemplateIds", target = "giveCouponTemplateIds", qualifiedByName = "convertListToString") - @Mapping(source = "activityOrders", target = "activityOrders", qualifiedByName = "convertListToString") @Mapping(target = "price", expression = "java(spu.getPrice() / 100)") @Mapping(target = "marketPrice", expression = "java(spu.getMarketPrice() / 100)") @Mapping(target = "costPrice", expression = "java(spu.getCostPrice() / 100)") @@ -83,7 +68,16 @@ public interface ProductSpuConvert { default List convertListForGetSpuList(List list) { // 处理虚拟销量 list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); - return convertListForGetSpuList0(list); + // 处理 VO 字段 + List voList = convertListForGetSpuList0(list); + for (int i = 0; i < list.size(); i++) { + ProductSpuDO spu = list.get(i); + AppProductSpuPageRespVO spuVO = voList.get(i); + spuVO.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); + // 计算 vip 价格 TODO 芋艿:临时的逻辑,等 vip 支持后 + spuVO.setVipPrice((int) (spuVO.getPrice() * 0.9)); + } + return voList; } @Named("convertListForGetSpuList0") List convertListForGetSpuList0(List list);