From 7728cc456aebdf95888c05967ae823f6f58d2a36 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Fri, 27 Sep 2024 13:55:01 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B-=E5=8C=85=E6=8B=AC=E4=BF=83=E9=94=80?= =?UTF-8?q?=E6=8E=A8=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-vue3/.vscode/settings.json | 2 +- .../views/mall/product/spu/form/SkuForm.vue | 42 +++++++++++++++++ .../src/views/mall/product/spu/form/index.vue | 6 +++ .../product/enums/ErrorCodeConstants.java | 2 + .../admin/spu/ProductSpuController.java | 11 ++++- .../admin/spu/vo/ProductSpuRespVO.java | 20 ++++++++ .../admin/spu/vo/ProductSpuSaveReqVO.java | 19 ++++++++ .../app/spu/AppProductSpuController.java | 46 +++++++++++++++++++ .../vo/AppProductSpuRecommendPageReqVo.java | 26 +++++++++++ .../dal/dataobject/spu/ProductSpuDO.java | 27 +++++++++++ .../service/spu/ProductSpuService.java | 7 +++ .../service/spu/ProductSpuServiceImpl.java | 31 +++++++++++++ 12 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java diff --git a/yudao-admin-vue3/.vscode/settings.json b/yudao-admin-vue3/.vscode/settings.json index 54be7d8..e4ec7cd 100644 --- a/yudao-admin-vue3/.vscode/settings.json +++ b/yudao-admin-vue3/.vscode/settings.json @@ -86,7 +86,7 @@ "source.fixAll.eslint": "explicit" }, "[vue]": { - "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" + "editor.defaultFormatter": "Vue.volar" }, "i18n-ally.localesPaths": ["src/locales"], "i18n-ally.keystyle": "nested", diff --git a/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue b/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue index 9cc6192..89f3008 100644 --- a/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue +++ b/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue @@ -17,6 +17,43 @@ 多规格 + + + 热卖单品 + + + 促销单品 + + + 精品推荐 + + + 新品单品 + + + 优品推荐 + + ({ specType: false, // 商品规格 subCommissionType: false, // 分销类型 + recommendHot: 0, // 热卖推荐 + recommendBenefit: 0, // 优惠推荐 + recommendBest: 0, // 精品推荐 + recommendNew: 0, // 新品推荐 + recommendGood: 0, // 优品推荐 skus: [] }) const rules = reactive({ diff --git a/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue b/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue index e4bef3d..1ba5f5e 100644 --- a/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue +++ b/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue @@ -92,6 +92,11 @@ const formData = ref({ brandId: undefined, // 商品品牌 specType: false, // 商品规格 subCommissionType: false, // 分销类型 + recommendHot: 0, // 热卖推荐 + recommendBenefit: 0, // 优惠推荐 + recommendBest: 0, // 精品推荐 + recommendNew: 0, // 新品推荐 + recommendGood: 0, // 优品推荐 skus: [ { price: 0, // 商品价格 @@ -141,6 +146,7 @@ const getDetail = async () => { } }) formData.value = res + } finally { formLoading.value = false } diff --git a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java index 1d0ea18..7d32aad 100644 --- a/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-product-api/src/main/java/cn/iocoder/yudao/module/product/enums/ErrorCodeConstants.java @@ -53,4 +53,6 @@ public interface ErrorCodeConstants { ErrorCode FAVORITE_EXISTS = new ErrorCode(1_008_008_000, "该商品已经被收藏"); ErrorCode FAVORITE_NOT_EXISTS = new ErrorCode(1_008_008_001, "商品收藏不存在"); + ErrorCode PARAMETER_ERROR = new ErrorCode(1_008_008_002, "参数错误"); + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index 0c30897..e8d00f9 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java @@ -6,6 +6,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; +import cn.iocoder.yudao.module.product.controller.app.spu.AppProductSpuController; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; @@ -87,7 +90,13 @@ public class ProductSpuController { } // 查询商品 SKU List skus = productSkuService.getSkuListBySpuId(spu.getId()); - return success(ProductSpuConvert.INSTANCE.convert(spu, skus)); + ProductSpuRespVO convert = ProductSpuConvert.INSTANCE.convert(spu, skus); + convert.setRecommendHot(spu.getRecommendHot()); + convert.setRecommendBenefit(spu.getRecommendBenefit()); + convert.setRecommendBest(spu.getRecommendBest()); + convert.setRecommendNew(spu.getRecommendNew()); + convert.setRecommendGood(spu.getRecommendGood()); + return success(convert); } @GetMapping("/list-all-simple") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java index 20a541c..1fe90eb 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java @@ -9,6 +9,7 @@ import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import javax.validation.Valid; import java.time.LocalDateTime; import java.util.List; @@ -65,6 +66,25 @@ public class ProductSpuRespVO { @ExcelProperty("创建时间") private LocalDateTime createTime; + @Schema(description = "是否热卖推荐") + @ExcelProperty("是否热卖推荐") + private Integer recommendHot; + + @Schema(description = "是否促销推荐") + @ExcelProperty("是否优惠推荐") + private Integer recommendBenefit; + + @Schema(description = "是否精品推荐") + @ExcelProperty("是否精品推荐") + private Integer recommendBest; + + @Schema(description = "是否新品推荐") + @ExcelProperty("是否新品推荐") + private Integer recommendNew; + + @Schema(description = "是否优品推荐") + @ExcelProperty("是否优品推荐") + private Integer recommendGood; // ========== SKU 相关字段 ========= @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java index c5805f6..d3798b2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java @@ -99,4 +99,23 @@ public class ProductSpuSaveReqVO { @Valid private List skus; + @Schema(description = "是否热卖推荐") + @Valid + private Integer recommendHot; + + @Schema(description = "是否促销推荐") + @Valid + private Integer recommendBenefit; + + @Schema(description = "是否精品推荐") + @Valid + private Integer recommendBest; + + @Schema(description = "是否新品推荐") + @Valid + private Integer recommendNew; + + @Schema(description = "是否优品推荐") + @Valid + private Integer recommendGood; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java index f64e6f5..7706e1c 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java @@ -10,16 +10,21 @@ import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; +import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.history.ProductBrowseHistoryService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; +import cn.iocoder.yudao.module.product.service.spu.ProductSpuServiceImpl; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.math3.stat.descriptive.summary.Product; +import org.apache.poi.ss.formula.functions.T; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -33,6 +38,7 @@ import java.util.List; import java.util.Set; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; @@ -91,6 +97,23 @@ public class AppProductSpuController { return success(voPageResult); } + @GetMapping("/get-recommend-page") + @Operation(summary = "获得推荐类型对应的商品 SPU 分页") + public CommonResult> getRecommendPage(@Valid AppProductSpuRecommendPageReqVo recommendPageVo){ + List recommendProductList = productSpuService.getRecommendProductIdList(recommendPageVo); + PageResult pageResult = getPaginatedList(recommendProductList, recommendPageVo.getPageNo(), recommendPageVo.getPageSize()); + if (CollUtil.isEmpty(pageResult.getList())) { + return success(PageResult.empty(pageResult.getTotal())); + } + // 拼接返回 + pageResult.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); + PageResult voPageResult = BeanUtils.toBean(pageResult, AppProductSpuRespVO.class); + // 处理 vip 价格 + MemberLevelRespDTO memberLevel = getMemberLevel(); + voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); + return success(voPageResult); + } + @GetMapping("/get-detail") @Operation(summary = "获得商品 SPU 明细") @Parameter(name = "id", description = "编号", required = true) @@ -148,5 +171,28 @@ public class AppProductSpuController { return price - newPrice; } + /** + * 逻辑分页 + * @param list + * @param pageSize + * @param pageNumber + * @return java.util.List + */ + private PageResult getPaginatedList(List list, int pageNumber, int pageSize) { + // 计算起始索引 + int fromIndex = (pageNumber - 1) * pageSize; + // 计算结束索引 + int toIndex = Math.min(fromIndex + pageSize, list.size()); + PageResult pageResult = new PageResult<>(); + pageResult.setTotal((long)list.size()); + // 如果起始索引超出范围,返回空列表 + if (fromIndex >= list.size() || fromIndex < 0) { + return pageResult; + } + // 逻辑分页 + List result = list.subList(fromIndex, toIndex); + pageResult.setList(result); + return pageResult; + } // TODO 芋艿:商品的浏览记录; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java new file mode 100644 index 0000000..c2d6858 --- /dev/null +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.product.controller.app.spu.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.List; + +@Schema(description = "用户 App - 推荐商品 SPU 分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class AppProductSpuRecommendPageReqVo extends PageParam { + @Schema(description = "热卖推荐", example = "1") + private Integer recommendHot; + @Schema(description = "促销推荐", example = "1") + private Integer recommendBenefit; + @Schema(description = "精品推荐", example = "1") + private Integer recommendBest; + @Schema(description = "新品推荐", example = "1") + private Integer recommendNew; + @Schema(description = "优品推荐", example = "1") + private Integer recommendGood; +} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java index 0c017f2..03ba4db 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java @@ -6,11 +6,13 @@ import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; +import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.List; @@ -88,6 +90,31 @@ public class ProductSpuDO extends BaseDO { */ private Integer status; + /** + * 是否热卖推荐 + */ + private Integer recommendHot; + + /** + * 是否优惠推荐 + */ + private Integer recommendBenefit; + + /** + * 是否精品推荐 + */ + private Integer recommendBest; + + /** + * 是否新品推荐 + */ + private Integer recommendNew; + + /** + * 是否优品推荐 + */ + private Integer recommendGood; + // ========== SKU 相关字段 ========= /** diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index 63b5dd6..635091d 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReq import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import org.springframework.scheduling.annotation.Async; @@ -131,4 +132,10 @@ public interface ProductSpuService { @Async void updateBrowseCount(Long id, int incrCount); + /** + * 获取推荐类型的 SPU ID列表 + * @param pageVo + * @return + */ + List getRecommendProductIdList(AppProductSpuRecommendPageReqVo pageVo); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 9b145b0..bc2df3a 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -6,12 +6,15 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSkuSaveReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReqVO; import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; @@ -160,6 +163,34 @@ public class ProductSpuServiceImpl implements ProductSpuService { productSpuMapper.updateBrowseCount(id , incrCount); } + @Override + public List getRecommendProductIdList(AppProductSpuRecommendPageReqVo pageVo) { + LambdaQueryWrapperX wrapperX = new LambdaQueryWrapperX<>(); + Integer recommendHot = pageVo.getRecommendHot(); + Integer recommendBenefit = pageVo.getRecommendBenefit(); + Integer recommendBest = pageVo.getRecommendBest(); + Integer recommendNew = pageVo.getRecommendNew(); + Integer recommendGood = pageVo.getRecommendGood(); + if (recommendHot != null && recommendHot != 0){ + wrapperX.eq(ProductSpuDO::getRecommendHot, recommendHot); + } + if (recommendBenefit != null && recommendBenefit != 0){ + wrapperX.eq(ProductSpuDO::getRecommendBenefit, recommendBenefit); + } + if (recommendBest != null && recommendBest != 0){ + wrapperX.eq(ProductSpuDO::getRecommendBest, recommendBest); + } + if (recommendNew != null && recommendNew != 0){ + wrapperX.eq(ProductSpuDO::getRecommendNew, recommendNew); + } + if (recommendGood != null && recommendGood != 0){ + wrapperX.eq(ProductSpuDO::getRecommendGood, recommendGood); + } + wrapperX.eq(ProductSpuDO::getStatus, 1); + wrapperX.last(" ORDER BY (sales_count + virtual_sales_count) DESC, sort DESC, id DESC"); + return productSpuMapper.selectList(wrapperX); + } + @Override @Transactional(rollbackFor = Exception.class) public void deleteSpu(Long id) { -- 2.45.2 From 7a73b09b4cb88db8e84eb14fd461d52d573b1d54 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Fri, 27 Sep 2024 15:57:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=95=86=E5=93=81=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E5=92=8C=E4=BB=98=E8=B4=B9=E4=BC=9A=E5=91=98=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=B0=E8=90=A5=E9=94=80=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/product/spu/form/MarketingForm.vue | 126 ++++++++++++++++++ .../views/mall/product/spu/form/SkuForm.vue | 42 ------ .../src/views/mall/product/spu/form/index.vue | 13 ++ 3 files changed, 139 insertions(+), 42 deletions(-) create mode 100644 yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue diff --git a/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue b/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue new file mode 100644 index 0000000..093f20a --- /dev/null +++ b/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue @@ -0,0 +1,126 @@ + + + diff --git a/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue b/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue index 89f3008..9cc6192 100644 --- a/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue +++ b/yudao-admin-vue3/src/views/mall/product/spu/form/SkuForm.vue @@ -17,43 +17,6 @@ 多规格 - - - 热卖单品 - - - 促销单品 - - - 精品推荐 - - - 新品单品 - - - 优品推荐 - - ({ specType: false, // 商品规格 subCommissionType: false, // 分销类型 - recommendHot: 0, // 热卖推荐 - recommendBenefit: 0, // 优惠推荐 - recommendBest: 0, // 精品推荐 - recommendNew: 0, // 新品推荐 - recommendGood: 0, // 优品推荐 skus: [] }) const rules = reactive({ diff --git a/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue b/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue index 1ba5f5e..5f1c02d 100644 --- a/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue +++ b/yudao-admin-vue3/src/views/mall/product/spu/form/index.vue @@ -33,6 +33,14 @@ :propFormData="formData" /> + + + + @@ -61,6 +70,7 @@ import DescriptionForm from './DescriptionForm.vue' import OtherForm from './OtherForm.vue' import SkuForm from './SkuForm.vue' import DeliveryForm from './DeliveryForm.vue' +import MarketingForm from './MarketingForm.vue' import { convertToInteger, floatToFixed2, formatToFraction } from '@/utils' defineOptions({ name: 'ProductSpuForm' }) @@ -79,6 +89,7 @@ const skuRef = ref() // 商品规格 Ref const deliveryRef = ref() // 物流设置 Ref const descriptionRef = ref() // 商品详情 Ref const otherRef = ref() // 其他设置 Ref +const marketingRef = ref() // 营销设置 Ref // SPU 表单数据 const formData = ref({ name: '', // 商品名称 @@ -97,6 +108,7 @@ const formData = ref({ recommendBest: 0, // 精品推荐 recommendNew: 0, // 新品推荐 recommendGood: 0, // 优品推荐 + onlyPaidMemberView: 0, // 仅限付费会员可见 skus: [ { price: 0, // 商品价格 @@ -164,6 +176,7 @@ const submitForm = async () => { await unref(deliveryRef)?.validate() await unref(descriptionRef)?.validate() await unref(otherRef)?.validate() + await unref(marketingRef)?.validate() // 深拷贝一份, 这样最终 server 端不满足,不需要影响原始数据 const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu deepCopyFormData.skus!.forEach((item) => { -- 2.45.2 From 88ac93c477a7e9388756c17a0589db9e2f861cf3 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Fri, 27 Sep 2024 15:57:40 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=95=86=E5=93=81=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BB=85=E4=BC=9A=E5=91=98=E6=9F=A5=E7=9C=8B=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/controller/admin/spu/vo/ProductSpuRespVO.java | 4 ++++ .../controller/admin/spu/vo/ProductSpuSaveReqVO.java | 4 ++++ .../module/product/dal/dataobject/spu/ProductSpuDO.java | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java index 1fe90eb..d5850f2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java @@ -85,6 +85,10 @@ public class ProductSpuRespVO { @Schema(description = "是否优品推荐") @ExcelProperty("是否优品推荐") private Integer recommendGood; + + @Schema(description = "是否仅付费会员可见") + @ExcelProperty("是否仅付费会员可见") + private Integer onlyPaidMemberView; // ========== SKU 相关字段 ========= @Schema(description = "规格类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java index d3798b2..75a38b4 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSaveReqVO.java @@ -118,4 +118,8 @@ public class ProductSpuSaveReqVO { @Schema(description = "是否优品推荐") @Valid private Integer recommendGood; + + @Schema(description = "是否仅付费会员可见") + @Valid + private Integer onlyPaidMemberView; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java index 03ba4db..99843dd 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java @@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; +import javax.validation.Valid; import java.util.List; /** @@ -115,6 +116,11 @@ public class ProductSpuDO extends BaseDO { */ private Integer recommendGood; + /** + * 是否仅付费会员可见 + */ + private Integer onlyPaidMemberView; + // ========== SKU 相关字段 ========= /** -- 2.45.2 From 95ae012aaba6aa395ba60e77a2ea7b8b0410fe93 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Fri, 27 Sep 2024 17:51:44 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=95=86=E5=93=81=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=96=B0=E5=A2=9E=20=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E4=BB=98=E8=B4=B9=E4=BC=9A=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/controller/admin/spu/vo/ProductSpuPageReqVO.java | 4 ++++ .../controller/app/spu/vo/AppProductSpuPageReqVO.java | 3 +++ .../app/spu/vo/AppProductSpuRecommendPageReqVo.java | 2 ++ .../yudao/module/product/dal/mysql/spu/ProductSpuMapper.java | 5 ++++- .../module/product/service/spu/ProductSpuServiceImpl.java | 3 +++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java index 81cff42..c985970 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java @@ -51,8 +51,12 @@ public class ProductSpuPageReqVO extends PageParam { @Schema(description = "商品分类编号", example = "1") private Long categoryId; + @Schema(description = "是否是付费会员", example = "1") + private Integer isPaidMember; + @Schema(description = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java index 1584dc6..f478295 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java @@ -39,6 +39,9 @@ public class AppProductSpuPageReqVO extends PageParam { @Schema(description = "排序方式", example = "true") private Boolean sortAsc; + @Schema(description = "是否是付费会员", example = "1") + private Integer isPaidMember; + @AssertTrue(message = "排序字段不合法") @JsonIgnore public boolean isSortFieldValid() { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java index c2d6858..bfa02c5 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuRecommendPageReqVo.java @@ -23,4 +23,6 @@ public class AppProductSpuRecommendPageReqVo extends PageParam { private Integer recommendNew; @Schema(description = "优品推荐", example = "1") private Integer recommendGood; + @Schema(description = "是否是付费会员", example = "1") + private Integer isPaidMember; } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java index cf8ae64..678fd81 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/spu/ProductSpuMapper.java @@ -31,6 +31,7 @@ public interface ProductSpuMapper extends BaseMapperX { .eqIfPresent(ProductSpuDO::getCategoryId, reqVO.getCategoryId()) .betweenIfPresent(ProductSpuDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(ProductSpuDO::getSort) + .eqIfPresent(ProductSpuDO::getOnlyPaidMemberView, reqVO.getIsPaidMember()) .orderByDesc(ProductSpuDO::getId); appendTabQuery(tabType, queryWrapper); return selectPage(reqVO, queryWrapper); @@ -61,7 +62,9 @@ public interface ProductSpuMapper extends BaseMapperX { .inIfPresent(ProductSpuDO::getCategoryId, categoryIds); // 上架状态 且有库存 query.eq(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()); - + if (pageReqVO.getIsPaidMember() == null || pageReqVO.getIsPaidMember() == 0) { + query.eq(ProductSpuDO::getOnlyPaidMemberView, 0); + } // 排序逻辑 if (Objects.equals(pageReqVO.getSortField(), AppProductSpuPageReqVO.SORT_FIELD_SALES_COUNT)) { query.last(String.format(" ORDER BY (sales_count + virtual_sales_count) %s, sort DESC, id DESC", diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index bc2df3a..64ed2eb 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -186,6 +186,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { if (recommendGood != null && recommendGood != 0){ wrapperX.eq(ProductSpuDO::getRecommendGood, recommendGood); } + if (pageVo.getIsPaidMember() == null || pageVo.getIsPaidMember() == 0){ + wrapperX.eq(ProductSpuDO::getOnlyPaidMemberView, 0); + } wrapperX.eq(ProductSpuDO::getStatus, 1); wrapperX.last(" ORDER BY (sales_count + virtual_sales_count) DESC, sort DESC, id DESC"); return productSpuMapper.selectList(wrapperX); -- 2.45.2 From 0b8897ecc46874a7412745ba6de2ec4c5dd38128 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Fri, 27 Sep 2024 17:52:33 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=90=8E=E5=8F=B0-=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=96=B0=E5=A2=9E=E6=98=AF=E5=90=A6=E4=BB=85?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=8F=AF=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-vue3/src/utils/dict.ts | 5 ++++- .../mall/product/spu/form/MarketingForm.vue | 2 +- .../src/views/mall/product/spu/index.vue | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/yudao-admin-vue3/src/utils/dict.ts b/yudao-admin-vue3/src/utils/dict.ts index c23e726..c4c2f91 100644 --- a/yudao-admin-vue3/src/utils/dict.ts +++ b/yudao-admin-vue3/src/utils/dict.ts @@ -242,5 +242,8 @@ export enum DICT_TYPE { AI_WRITE_LENGTH = 'ai_write_length', // AI 写作长度 AI_WRITE_FORMAT = 'ai_write_format', // AI 写作格式 AI_WRITE_TONE = 'ai_write_tone', // AI 写作语气 - AI_WRITE_LANGUAGE = 'ai_write_language' // AI 写作语言 + AI_WRITE_LANGUAGE = 'ai_write_language', // AI 写作语言 + + // ========== 通用模块 ========== + ZERO_OR_ONE = 'zero_or_one' } diff --git a/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue b/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue index 093f20a..de60acc 100644 --- a/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue +++ b/yudao-admin-vue3/src/views/mall/product/spu/form/MarketingForm.vue @@ -1,7 +1,7 @@