From 0d45acaf20bdb1019c5a57914737ef7fd8aafa1e Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 15 Oct 2023 22:41:18 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E8=90=A5=E9=94=80=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=EF=BC=9A=E5=AE=8C=E5=96=84=E6=96=87=E7=AB=A0=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=20app=20=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/article/ArticleController.java | 2 +- .../vo/{ => article}/ArticleBaseVO.java | 2 +- .../vo/{ => article}/ArticleCreateReqVO.java | 2 +- .../vo/{ => article}/ArticleExcelVO.java | 2 +- .../vo/{ => article}/ArticleExportReqVO.java | 2 +- .../vo/{ => article}/ArticlePageReqVO.java | 2 +- .../vo/{ => article}/ArticleRespVO.java | 2 +- .../vo/{ => article}/ArticleUpdateReqVO.java | 2 +- .../article/AppArticleCategoryController.java | 24 +++--- .../app/article/AppArticleController.java | 80 ++++++------------- .../article/vo/article/AppArticleRespVO.java | 7 -- .../vo/category/AppArticleCategoryRespVO.java | 7 -- .../article/ArticleCategoryConvert.java | 3 + .../convert/article/ArticleConvert.java | 15 +++- .../dal/mysql/article/ArticleMapper.java | 16 +++- .../service/article/ArticleService.java | 50 ++++++++---- .../service/article/ArticleServiceImpl.java | 19 ++++- .../article/ArticleServiceImplTest.java | 8 +- 18 files changed, 124 insertions(+), 121 deletions(-) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticleBaseVO.java (99%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticleCreateReqVO.java (96%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticleExcelVO.java (99%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticleExportReqVO.java (98%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticlePageReqVO.java (98%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticleRespVO.java (97%) rename yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/{ => article}/ArticleUpdateReqVO.java (97%) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java index 7d6e99c87..ab65cbec3 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.*; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.*; import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import cn.iocoder.yudao.module.promotion.service.article.ArticleService; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleBaseVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java similarity index 99% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleBaseVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java index 1a1f2bdd8..71c38df36 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleBaseVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java similarity index 96% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleCreateReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java index 6de506fbe..d598dd768 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleCreateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExcelVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExcelVO.java similarity index 99% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExcelVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExcelVO.java index cc9523a4c..ea1f51462 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExcelVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExcelVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExportReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExportReqVO.java similarity index 98% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExportReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExportReqVO.java index 7c8e50049..b58e7eacf 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExportReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExportReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticlePageReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java similarity index 98% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticlePageReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java index 4dbd806c6..9c7539585 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticlePageReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java similarity index 97% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleRespVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java index 58653af2f..a1553e471 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleUpdateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java similarity index 97% rename from yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleUpdateReqVO.java rename to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java index c50d5e996..3efd59334 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleUpdateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java index 9d16048da..dbd67289b 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java @@ -1,16 +1,19 @@ package cn.iocoder.yudao.module.promotion.controller.app.article; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; +import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; +import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.ArrayList; +import javax.annotation.Resource; import java.util.List; -import java.util.Random; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -20,20 +23,15 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Validated public class AppArticleCategoryController { + @Resource + private ArticleCategoryService articleCategoryService; + @RequestMapping("/list") @Operation(summary = "获得文章分类列表") - // TODO @芋艿:swagger 注解 public CommonResult> getArticleCategoryList() { - List appArticleRespVOList = new ArrayList<>(); - Random random = new Random(); - for (int i = 0; i < 10; i++) { - AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO(); - appArticleRespVO.setId((long) (i + 1)); - appArticleRespVO.setName("分类 - " + i); - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); - appArticleRespVOList.add(appArticleRespVO); - } - return success(appArticleRespVOList); + List categoryList = articleCategoryService.getArticleCategoryListByStatus( + CommonStatusEnum.ENABLE.getStatus()); + return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java index c794ecdf4..2b53ac614 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleController.java @@ -4,16 +4,19 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; +import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; +import cn.iocoder.yudao.module.promotion.service.article.ArticleService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.time.LocalDateTime; -import java.util.ArrayList; +import javax.annotation.Resource; import java.util.List; -import java.util.Random; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -23,68 +26,33 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Validated public class AppArticleController { + @Resource + private ArticleService articleService; + @RequestMapping("/list") - // TODO @芋艿:swagger 注解 - public CommonResult> getArticleList(@RequestParam(value = "recommendHot", required = false) Boolean recommendHot, - @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { - List appArticleRespVOList = new ArrayList<>(); - Random random = new Random(); - for (int i = 0; i < 10; i++) { - AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); - appArticleRespVO.setId((long) (i + 1)); - appArticleRespVO.setTitle("芋道源码 - " + i + "模块"); - appArticleRespVO.setAuthor("芋道源码"); - appArticleRespVO.setCategoryId((long) random.nextInt(10000)); - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); - appArticleRespVO.setIntroduction("我是简介"); - appArticleRespVO.setDescription("我是详细"); - appArticleRespVO.setCreateTime(LocalDateTime.now()); - appArticleRespVO.setBrowseCount(random.nextInt(10000)); - appArticleRespVO.setSpuId((long) random.nextInt(10000)); - appArticleRespVOList.add(appArticleRespVO); - } - return success(appArticleRespVOList); + @Operation(summary = "获得文章详情列表") + @Parameters({ + @Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章 + @Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章 + }) + public CommonResult> getArticleList( + @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, + @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { + return success(ArticleConvert.INSTANCE.convertList03( + articleService.getArticleCategoryListByRecommendHotAndRecommendBanner(recommendHot, recommendBanner))); } @RequestMapping("/page") - // TODO @芋艿:swagger 注解 + @Operation(summary = "获得文章详情分页") public CommonResult> getArticlePage(AppArticlePageReqVO pageReqVO) { - List appArticleRespVOList = new ArrayList<>(); - Random random = new Random(); - for (int i = 0; i < 10; i++) { - AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); - appArticleRespVO.setId((long) (i + 1)); - appArticleRespVO.setTitle("芋道源码 - " + i + "模块"); - appArticleRespVO.setAuthor("芋道源码"); - appArticleRespVO.setCategoryId((long) random.nextInt(10000)); - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); - appArticleRespVO.setIntroduction("我是简介"); - appArticleRespVO.setDescription("我是详细"); - appArticleRespVO.setCreateTime(LocalDateTime.now()); - appArticleRespVO.setBrowseCount(random.nextInt(10000)); - appArticleRespVO.setSpuId((long) random.nextInt(10000)); - appArticleRespVOList.add(appArticleRespVO); - } - return success(new PageResult<>(appArticleRespVOList, 10L)); + return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO))); } @RequestMapping("/get") - // TODO @芋艿:swagger 注解 + @Operation(summary = "获得文章详情") + @Parameter(name = "id", description = "文章编号", example = "1024") public CommonResult getArticlePage(@RequestParam("id") Long id) { - Random random = new Random(); - AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); - appArticleRespVO.setId((long) (1)); - appArticleRespVO.setTitle("芋道源码 - " + 0 + "模块"); - appArticleRespVO.setAuthor("芋道源码"); - appArticleRespVO.setCategoryId((long) random.nextInt(10000)); - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (0 + 1) + ".png"); - appArticleRespVO.setIntroduction("我是简介"); - appArticleRespVO.setDescription("我是详细"); - appArticleRespVO.setCreateTime(LocalDateTime.now()); - appArticleRespVO.setBrowseCount(random.nextInt(10000)); - appArticleRespVO.setSpuId((long) random.nextInt(10000)); - appArticleRespVO.setSpuId(633L); - return success(appArticleRespVO); + return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id))); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java index 6c4ad614e..8f74776c4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/article/AppArticleRespVO.java @@ -39,11 +39,4 @@ public class AppArticleRespVO { @Schema(description = "关联的商品 SPU 编号", example = "1024") private Long spuId; -// TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回; -// @Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") -// private Boolean recommendHot; -// -// @Schema(description = "是否 Banner 推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") -// private Boolean recommendBanner; - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java index da880dadd..e0f34e95d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/vo/category/AppArticleCategoryRespVO.java @@ -16,11 +16,4 @@ public class AppArticleCategoryRespVO { @Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") private String picUrl; - // TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回; -// @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") -// private Integer status; -// -// @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") -// private Integer sort; - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java index 3762bf8a9..628a451e0 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleCategoryConvert.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.article; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -32,4 +33,6 @@ public interface ArticleCategoryConvert { List convertList03(List list); + List convertList04(List categoryList); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java index 6fb1cf850..fc403b37f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java @@ -1,10 +1,11 @@ package cn.iocoder.yudao.module.promotion.convert.article; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExcelVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleRespVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExcelVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -33,4 +34,10 @@ public interface ArticleConvert { List convertList02(List list); + List convertList03(List list); + + AppArticleRespVO convert01(ArticleDO article); + + PageResult convertPage02(PageResult articlePage); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java index 778c85f7b..47656d5f3 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java @@ -3,8 +3,9 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import org.apache.ibatis.annotations.Mapper; @@ -44,4 +45,15 @@ public interface ArticleMapper extends BaseMapperX { .orderByDesc(ArticleDO::getId)); } + default List selectList(Boolean recommendHot, Boolean recommendBanner) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) + .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); + } + + default PageResult selectPage(AppArticlePageReqVO pageReqVO) { + return selectPage(pageReqVO, new LambdaQueryWrapperX() + .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java index 2828dad2c..013c01a5f 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java @@ -1,10 +1,11 @@ package cn.iocoder.yudao.module.promotion.service.article; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import javax.validation.Valid; @@ -12,14 +13,14 @@ import java.util.Collection; import java.util.List; /** - * 文章管理 Service 接口 + * 文章详情 Service 接口 * * @author HUIHUI */ public interface ArticleService { /** - * 创建文章管理 + * 创建文章详情 * * @param createReqVO 创建信息 * @return 编号 @@ -27,49 +28,66 @@ public interface ArticleService { Long createArticle(@Valid ArticleCreateReqVO createReqVO); /** - * 更新文章管理 + * 更新文章详情 * * @param updateReqVO 更新信息 */ void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); /** - * 删除文章管理 + * 删除文章详情 * * @param id 编号 */ void deleteArticle(Long id); /** - * 获得文章管理 + * 获得文章详情 * * @param id 编号 - * @return 文章管理 + * @return 文章详情 */ ArticleDO getArticle(Long id); /** - * 获得文章管理列表 + * 获得文章详情列表 * * @param ids 编号 - * @return 文章管理列表 + * @return 文章详情列表 */ List getArticleList(Collection ids); /** - * 获得文章管理分页 + * 获得文章详情分页 * * @param pageReqVO 分页查询 - * @return 文章管理分页 + * @return 文章详情分页 */ PageResult getArticlePage(ArticlePageReqVO pageReqVO); /** - * 获得文章管理列表, 用于 Excel 导出 + * 获得文章详情列表, 用于 Excel 导出 * * @param exportReqVO 查询条件 - * @return 文章管理列表 + * @return 文章详情列表 */ List getArticleList(ArticleExportReqVO exportReqVO); + /** + * 获得文章详情列表 + * + * @param recommendHot 是否热门 + * @param recommendBanner 是否轮播图 + * @return 文章详情列表 + */ + List getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner); + + /** + * 获得文章详情分页 + * + * @param pageReqVO 分页查询 + * @return 文章详情分页 + */ + PageResult getArticlePage(AppArticlePageReqVO pageReqVO); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java index 82cf3f38b..b43bf355a 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java @@ -3,10 +3,11 @@ package cn.iocoder.yudao.module.promotion.service.article; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; @@ -87,4 +88,14 @@ public class ArticleServiceImpl implements ArticleService { return articleMapper.selectList(exportReqVO); } + @Override + public List getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner) { + return articleMapper.selectList(recommendHot, recommendBanner); + } + + @Override + public PageResult getArticlePage(AppArticlePageReqVO pageReqVO) { + return articleMapper.selectPage(pageReqVO); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java index d47c54453..cac652cf4 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.promotion.service.article; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; import org.junit.jupiter.api.Disabled; From 4273b8f09cff3d6e20e6d83bc28b6ffd95700b7e Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 16 Oct 2023 18:53:25 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E8=90=A5=E9=94=80=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=EF=BC=9A=E5=AE=8C=E5=96=84=20review=20=E6=8F=90=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../promotion/enums/ErrorCodeConstants.java | 5 +- .../convert/article/ArticleConvert.java | 7 ++ .../CombinationActivityConvert.java | 42 +++++----- .../dal/mysql/article/ArticleMapper.java | 15 ++++ .../combination/CombinationRecordMapper.java | 10 +-- .../article/ArticleCategoryServiceImpl.java | 11 ++- .../service/article/ArticleService.java | 43 +++++++++-- .../service/article/ArticleServiceImpl.java | 35 ++++++++- .../CombinationRecordServiceImpl.java | 76 +++++++++---------- .../article/ArticleServiceImplTest.java | 66 ---------------- .../dal/mysql/order/TradeOrderMapper.java | 3 +- .../service/order/TradeOrderQueryService.java | 2 +- .../order/TradeOrderQueryServiceImpl.java | 4 +- .../handler/TradeCombinationOrderHandler.java | 2 +- 14 files changed, 167 insertions(+), 154 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java index 99c5a17e7..8d519d137 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java @@ -111,9 +111,10 @@ public interface ErrorCodeConstants { ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); // ========== 文章分类 1-013-015-000 ========== - ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "分类不存在"); + ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "文章分类不存在"); + ErrorCode ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES = new ErrorCode(1_013_015_001, "文章分类删除失败,存在关联文章"); // ========== 文章管理 1-013-016-000 ========== - ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章管理不存在"); + ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在"); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java index a8b624c35..7f4867f5d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -30,4 +31,10 @@ public interface ArticleConvert { PageResult convertPage(PageResult page); + AppArticleRespVO convert01(ArticleDO article); + + PageResult convertPage02(PageResult articlePage); + + List convertList03(List articleCategoryListByRecommendHotAndRecommendBanner); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java index 84f7e5d46..40dbe316e 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java @@ -207,31 +207,29 @@ public interface CombinationActivityConvert { /** * 转换生成虚拟成团虚拟记录 * - * @param virtualGroupHeadRecords 虚拟成团团长记录列表 + * @param virtualGroupHeadRecord 虚拟成团团长记录 * @return 虚拟记录列表 */ - default List convertVirtualGroupList(List virtualGroupHeadRecords) { + default List convertVirtualGroupList(CombinationRecordDO virtualGroupHeadRecord) { List createRecords = new ArrayList<>(); - virtualGroupHeadRecords.forEach(headRecord -> { - // 计算需要创建的虚拟成团记录数量 - int count = headRecord.getUserSize() - headRecord.getUserCount(); - for (int i = 0; i < count; i++) { - // 基础信息和团长保持一致 - CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(headRecord.getActivityId()) - .setCombinationPrice(headRecord.getCombinationPrice()).setSpuId(headRecord.getSpuId()).setSpuName(headRecord.getSpuName()) - .setPicUrl(headRecord.getPicUrl()).setSkuId(headRecord.getSkuId()).setHeadId(headRecord.getId()) - .setStatus(headRecord.getStatus()) // 状态保持和创建时一致,创建完成后会接着处理 - .setVirtualGroup(headRecord.getVirtualGroup()).setExpireTime(headRecord.getExpireTime()) - .setStartTime(headRecord.getStartTime()).setUserSize(headRecord.getUserSize()).setUserCount(headRecord.getUserCount()); - // 虚拟信息 - newRecord.setCount(0); - newRecord.setUserId(0L); - newRecord.setNickname(""); - newRecord.setAvatar(""); - newRecord.setOrderId(0L); - createRecords.add(newRecord); - } - }); + // 计算需要创建的虚拟成团记录数量 + int count = virtualGroupHeadRecord.getUserSize() - virtualGroupHeadRecord.getUserCount(); + for (int i = 0; i < count; i++) { + // 基础信息和团长保持一致 + CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(virtualGroupHeadRecord.getActivityId()) + .setCombinationPrice(virtualGroupHeadRecord.getCombinationPrice()).setSpuId(virtualGroupHeadRecord.getSpuId()).setSpuName(virtualGroupHeadRecord.getSpuName()) + .setPicUrl(virtualGroupHeadRecord.getPicUrl()).setSkuId(virtualGroupHeadRecord.getSkuId()).setHeadId(virtualGroupHeadRecord.getId()) + .setStatus(virtualGroupHeadRecord.getStatus()) // 状态保持和创建时一致,创建完成后会接着处理 + .setVirtualGroup(virtualGroupHeadRecord.getVirtualGroup()).setExpireTime(virtualGroupHeadRecord.getExpireTime()) + .setStartTime(virtualGroupHeadRecord.getStartTime()).setUserSize(virtualGroupHeadRecord.getUserSize()).setUserCount(virtualGroupHeadRecord.getUserCount()); + // 虚拟信息 + newRecord.setCount(0); + newRecord.setUserId(0L); + newRecord.setNickname(""); + newRecord.setAvatar(""); + newRecord.setOrderId(0L); + createRecords.add(newRecord); + } return createRecords; } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java index 57b13dfa5..e71f354f6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java @@ -4,9 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * 文章管理 Mapper * @@ -28,4 +31,16 @@ public interface ArticleMapper extends BaseMapperX { .orderByDesc(ArticleDO::getId)); } + default List selectList(Boolean recommendHot, Boolean recommendBanner) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) + .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); + } + + default PageResult selectPage(AppArticlePageReqVO pageReqVO) { + return selectPage(pageReqVO, new LambdaQueryWrapperX() + .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); + } + + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java index f633edc90..29f296cc3 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java @@ -127,11 +127,9 @@ public interface CombinationRecordMapper extends BaseMapperX() - .select("DISTINCT (user_id)") - .groupBy("user_id")); + .select("DISTINCT (user_id)")); } default List selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) { @@ -141,8 +139,8 @@ public interface CombinationRecordMapper extends BaseMapperX selectListByHeadIds(Collection headIds) { - return selectList(new LambdaQueryWrapperX().in(CombinationRecordDO::getHeadId, headIds)); + default List selectListByHeadId(Long headId) { + return selectList(new LambdaQueryWrapperX().eq(CombinationRecordDO::getHeadId, headId)); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java index 1b3fe384d..130a9fd0b 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.promotion.service.article; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -14,6 +16,7 @@ import javax.annotation.Resource; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; /** @@ -27,6 +30,8 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { @Resource private ArticleCategoryMapper articleCategoryMapper; + @Resource + private ArticleService articleService; @Override public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { @@ -50,7 +55,11 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { public void deleteArticleCategory(Long id) { // 校验存在 validateArticleCategoryExists(id); - // TODO @puhui999:需要校验下,是不是存在文章 + // 校验是不是存在关联文章 + List articleList = articleService.getArticleByCategoryId(id); + if (CollUtil.isNotEmpty(articleList)) { + throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); + } // 删除 articleCategoryMapper.deleteById(id); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java index 26662be77..62ff75218 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java @@ -4,19 +4,21 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import javax.validation.Valid; +import java.util.List; /** - * 文章管理 Service 接口 + * 文章详情 Service 接口 * * @author HUIHUI */ public interface ArticleService { /** - * 创建文章管理 + * 创建文章详情 * * @param createReqVO 创建信息 * @return 编号 @@ -24,33 +26,58 @@ public interface ArticleService { Long createArticle(@Valid ArticleCreateReqVO createReqVO); /** - * 更新文章管理 + * 更新文章详情 * * @param updateReqVO 更新信息 */ void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); /** - * 删除文章管理 + * 删除文章详情 * * @param id 编号 */ void deleteArticle(Long id); /** - * 获得文章管理 + * 获得文章详情 * * @param id 编号 - * @return 文章管理 + * @return 文章详情 */ ArticleDO getArticle(Long id); /** - * 获得文章管理分页 + * 获得文章详情分页 * * @param pageReqVO 分页查询 - * @return 文章管理分页 + * @return 文章详情分页 */ PageResult getArticlePage(ArticlePageReqVO pageReqVO); + /** + * 获得文章详情列表 + * + * @param recommendHot 是否热门 + * @param recommendBanner 是否轮播图 + * @return 文章详情列表 + */ + List getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner); + + /** + * 获得文章详情分页 + * + * @param pageReqVO 分页查询 + * @return 文章详情分页 + */ + PageResult getArticlePage(AppArticlePageReqVO pageReqVO); + + /** + * 获得指定分类的文章列表 + * + * @param categoryId 文章分类编号 + * @return 文章列表 + */ + List getArticleByCategoryId(Long categoryId); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java index b1c2b9150..4e7cb8107 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java @@ -4,15 +4,19 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; /** @@ -26,10 +30,14 @@ public class ArticleServiceImpl implements ArticleService { @Resource private ArticleMapper articleMapper; + @Resource + private ArticleCategoryService articleCategoryService; @Override public Long createArticle(ArticleCreateReqVO createReqVO) { - // TODO @puhui999:需要校验分类存在 + // 校验分类存在 + validateArticleCategoryExists(createReqVO.getCategoryId()); + // 插入 ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); articleMapper.insert(article); @@ -41,7 +49,8 @@ public class ArticleServiceImpl implements ArticleService { public void updateArticle(ArticleUpdateReqVO updateReqVO) { // 校验存在 validateArticleExists(updateReqVO.getId()); - // TODO @puhui999:需要校验分类存在 + // 校验分类存在 + validateArticleCategoryExists(updateReqVO.getCategoryId()); // 更新 ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); @@ -62,6 +71,13 @@ public class ArticleServiceImpl implements ArticleService { } } + private void validateArticleCategoryExists(Long categoryId) { + ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(categoryId); + if (articleCategory == null) { + throw exception(ARTICLE_CATEGORY_NOT_EXISTS); + } + } + @Override public ArticleDO getArticle(Long id) { return articleMapper.selectById(id); @@ -72,4 +88,19 @@ public class ArticleServiceImpl implements ArticleService { return articleMapper.selectPage(pageReqVO); } + @Override + public List getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner) { + return articleMapper.selectList(recommendHot, recommendBanner); + } + + @Override + public PageResult getArticlePage(AppArticlePageReqVO pageReqVO) { + return articleMapper.selectPage(pageReqVO); + } + + @Override + public List getArticleByCategoryId(Long categoryId) { + return articleMapper.selectList(ArticleDO::getCategoryId, categoryId); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java index 2d10d1e70..0a887d2e7 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java @@ -247,7 +247,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { @Override public Long getCombinationUserCount() { - return combinationRecordMapper.selectUserDistinctCount(); + return combinationRecordMapper.selectUserCount(); } @Override @@ -351,48 +351,46 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); Map activityMap = convertMap(activities, CombinationActivityDO::getId); - // TODO @puhui999:这里可以改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务; - // 3. 校验是否虚拟成团 - List virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 - for (Iterator iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { - CombinationRecordDO record = iterator.next(); - // 3.1.不匹配,则直接跳过 - CombinationActivityDO activity = activityMap.get(record.getActivityId()); - if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 - continue; + // 3. 改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务; + KeyValue keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 + for (CombinationRecordDO recordDO : headExpireRecords) { + try { + CombinationActivityDO activity = activityMap.get(recordDO.getActivityId()); + if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 + // 3.1. 处理过期的拼团 + getSelf().handleExpireRecord(recordDO); + keyValue.setKey(keyValue.getKey() + 1); + } else { + // 3.2. 处理虚拟成团 + getSelf().handleVirtualGroupRecord(recordDO); + keyValue.setValue(keyValue.getValue() + 1); + } + } catch (Exception ignored) { // 处理异常继续循环 } - // 3.2.匹配,则移除,添加到虚拟成团中,并结束寻找 - virtualGroupHeadRecords.add(record); - iterator.remove(); - break; } - // 4.处理过期的拼团 - getSelf().handleExpireRecord(headExpireRecords); - // 5.虚拟成团 - getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords); - return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size()); + return keyValue; } /** * 处理过期拼团 * - * @param headExpireRecords 过期拼团团长记录列表 + * @param headExpireRecord 过期拼团团长记录列表 */ @Transactional(rollbackFor = Exception.class) - public void handleExpireRecord(List headExpireRecords) { - if (CollUtil.isEmpty(headExpireRecords)) { + public void handleExpireRecord(CombinationRecordDO headExpireRecord) { + if (headExpireRecord == null) { return; } // 1.更新拼团记录 - List headsAndRecords = updateBatchCombinationRecords(headExpireRecords, + List headsAndRecords = updateBatchCombinationRecords(headExpireRecord, CombinationRecordStatusEnum.FAILED); if (headsAndRecords == null) { return; } - // 2.订单取消 TODO 以现在的取消回滚逻辑好像只能循环了 + // 2.订单取消 headsAndRecords.forEach(item -> { tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()); }); @@ -401,36 +399,32 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { /** * 处理虚拟拼团 * - * @param virtualGroupHeadRecords 虚拟成团团长记录列表 + * @param virtualGroupHeadRecord 虚拟成团团长记录列表 */ @Transactional(rollbackFor = Exception.class) - public void handleVirtualGroupRecord(List virtualGroupHeadRecords) { - if (CollUtil.isEmpty(virtualGroupHeadRecords)) { + public void handleVirtualGroupRecord(CombinationRecordDO virtualGroupHeadRecord) { + if (virtualGroupHeadRecord == null) { return; } // 1. 团员补齐 - combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords)); + combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecord)); // 2. 更新拼团记录 - updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS); + updateBatchCombinationRecords(virtualGroupHeadRecord, CombinationRecordStatusEnum.SUCCESS); } - private List updateBatchCombinationRecords(List headRecords, CombinationRecordStatusEnum status) { - // 1. 查询团成员 - List records = combinationRecordMapper.selectListByHeadIds( - convertSet(headRecords, CombinationRecordDO::getId)); + private List updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { + // 1. 查询团成员(包含团长) + List records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); if (CollUtil.isEmpty(records)) { return null; } - Map> recordsMap = convertMultiMap(records, CombinationRecordDO::getHeadId); - headRecords.forEach(item -> { - recordsMap.get(item.getId()).add(item); // 把团长加进团里 - }); + records.add(headRecord);// 把团长加进去 + // 2.批量更新拼团记录 status 和 失败/成团时间 - List headsAndRecords = mergeValuesFromMap(recordsMap); - List updateRecords = new ArrayList<>(headsAndRecords.size()); + List updateRecords = new ArrayList<>(records.size()); LocalDateTime now = LocalDateTime.now(); - headsAndRecords.forEach(item -> { + records.forEach(item -> { CombinationRecordDO record = new CombinationRecordDO().setId(item.getId()) .setStatus(status.getStatus()).setEndTime(now); if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 @@ -439,7 +433,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { updateRecords.add(record); }); combinationRecordMapper.updateBatch(updateRecords); - return headsAndRecords; + return records; } /** diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java index 0c50fe6b8..718651700 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.article; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; @@ -166,68 +164,4 @@ public class ArticleServiceImplTest extends BaseDbUnitTest { assertPojoEquals(dbArticle, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetArticleList() { - // mock 数据 - ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到 - o.setCategoryId(null); - o.setTitle(null); - o.setAuthor(null); - o.setPicUrl(null); - o.setIntroduction(null); - o.setBrowseCount(null); - o.setSort(null); - o.setStatus(null); - o.setSpuId(null); - o.setRecommendHot(null); - o.setRecommendBanner(null); - o.setContent(null); - o.setCreateTime(null); - }); - articleMapper.insert(dbArticle); - // 测试 categoryId 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null))); - // 测试 title 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null))); - // 测试 author 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null))); - // 测试 picUrl 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null))); - // 测试 introduction 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null))); - // 测试 browseCount 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null))); - // 测试 sort 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null))); - // 测试 status 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null))); - // 测试 spuId 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null))); - // 测试 recommendHot 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null))); - // 测试 recommendBanner 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null))); - // 测试 content 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null))); - // 测试 createTime 不匹配 - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null))); - // 准备参数 - ArticleExportReqVO reqVO = new ArticleExportReqVO(); - reqVO.setCategoryId(null); - reqVO.setTitle(null); - reqVO.setAuthor(null); - reqVO.setStatus(null); - reqVO.setSpuId(null); - reqVO.setRecommendHot(null); - reqVO.setRecommendBanner(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - List list = articleService.getArticleList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbArticle, list.get(0)); - } - } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java index 8719730b9..e3665e584 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java @@ -93,7 +93,6 @@ public interface TradeOrderMapper extends BaseMapperX { return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); } - // TODO @puhui999:selectByUserIdAndCombinationActivityIdAndStatus,这样更容易理解哈。 /** * 只针对 combinationActivityId 的查询 * @@ -102,7 +101,7 @@ public interface TradeOrderMapper extends BaseMapperX { * @param status 订单状态 * @return 交易订单 */ - default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { + default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status) { return selectOne(new LambdaQueryWrapperX() .eq(TradeOrderDO::getUserId, userId) .eq(TradeOrderDO::getStatus, status) diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java index c5d369490..45fa32307 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java @@ -46,7 +46,7 @@ public interface TradeOrderQueryService { * @param status 订单状态 * @return 交易订单 */ - TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status); + TradeOrderDO getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status); /** * 获得订单列表 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index c27756e3a..56cd0d041 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -71,8 +71,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { } @Override - public TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { - return tradeOrderMapper.selectByUserIdAndActivityIdAndStatus(userId, activityId, status); + public TradeOrderDO getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status) { + return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, activityId, status); } @Override diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java index 6a530dc89..063feed3a 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/handler/TradeCombinationOrderHandler.java @@ -49,7 +49,7 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { order.getCombinationHeadId(), item.getSkuId(), item.getCount()); // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 - TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus( + TradeOrderDO activityOrder = orderQueryService.getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus( order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); if (activityOrder != null) { throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); From 6fbb7d6d6dca4003c8fb9cfeab2c2cfa88b736db Mon Sep 17 00:00:00 2001 From: owen Date: Mon, 16 Oct 2023 21:01:01 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E7=BB=88=E7=AB=AF=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=94=B9=E4=B8=BA=E4=BB=8EController?= =?UTF-8?q?=E4=BC=A0=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/servlet/ServletUtils.java | 20 ------------------- .../app/order/AppTradeOrderController.java | 5 +++-- .../order/TradeOrderUpdateService.java | 4 +++- .../order/TradeOrderUpdateServiceImpl.java | 10 ++++------ .../order/TradeOrderUpdateServiceTest.java | 2 +- .../app/auth/AppAuthController.java | 5 +++-- .../service/auth/MemberAuthService.java | 6 ++++-- .../service/auth/MemberAuthServiceImpl.java | 7 ++++--- .../service/user/MemberUserService.java | 4 +++- .../service/user/MemberUserServiceImpl.java | 10 ++++------ 10 files changed, 29 insertions(+), 44 deletions(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/servlet/ServletUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/servlet/ServletUtils.java index 368ac738f..446079828 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/servlet/ServletUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/servlet/ServletUtils.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.framework.common.util.servlet; -import cn.hutool.core.convert.Convert; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.servlet.ServletUtil; @@ -89,18 +88,6 @@ public class ServletUtils { return ServletUtil.getClientIP(request); } - public static Integer getTerminal() { - return getHeaderInt("terminal"); - } - - public static String getHeader(String header) { - return getHeader(getRequest(), header); - } - - public static Integer getHeaderInt(String header) { - return Convert.toInt(getHeader(header)); - } - public static boolean isJsonRequest(ServletRequest request) { return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE); } @@ -121,11 +108,4 @@ public class ServletUtils { return ServletUtil.getParamMap(request); } - public static String getHeader(HttpServletRequest request, String header) { - if (request == null) { - return null; - } - return request.getHeader(header); - } - } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java index 3ff9ceec4..905cb6dd0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java @@ -61,8 +61,9 @@ public class AppTradeOrderController { @PostMapping("/create") @Operation(summary = "创建订单") @PreAuthenticated - public CommonResult createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) { - TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO); + public CommonResult createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO, + @RequestHeader Integer terminal) { + TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO, terminal); return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId())); } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java index 42d3e6b65..488e24413 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.trade.service.order; +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO; import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO; @@ -37,9 +38,10 @@ public interface TradeOrderUpdateService { * @param userId 登录用户 * @param userIp 用户 IP 地址 * @param createReqVO 创建交易订单请求模型 + * @param terminal 终端 {@link TerminalEnum} * @return 交易订单的 */ - TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO); + TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal); /** * 更新交易订单已支付 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java index 9951916e4..fcd52050d 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java @@ -11,7 +11,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.module.member.api.address.AddressApi; import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; @@ -159,11 +158,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { @Override @Transactional(rollbackFor = Exception.class) @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE) - public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) { + public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal) { // 1.1 价格计算 TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO); // 1.2 构建订单 - TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO); + TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO, terminal); List orderItems = buildTradeOrderItems(order, calculateRespBO); // 2. 订单创建前的逻辑 @@ -180,15 +179,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { } private TradeOrderDO buildTradeOrder(Long userId, String clientIp, AppTradeOrderCreateReqVO createReqVO, - TradePriceCalculateRespBO calculateRespBO) { + TradePriceCalculateRespBO calculateRespBO, Integer terminal) { TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO); order.setType(calculateRespBO.getType()); order.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX)); order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); - // TODO @疯狂:无状态,terminal 不从 servletuTILS 拿,而是通过 controller 传递给 service; - order.setTerminal(ServletUtils.getTerminal()); + order.setTerminal(terminal); // 支付 + 退款信息 order.setAdjustPrice(0).setPayStatus(false); order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java index 6b58fd9b6..b91e5fcb6 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceTest.java @@ -152,7 +152,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest { }))).thenReturn(1000L); // 调用方法 - TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO); + TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO, null); // 断言 TradeOrderDO 订单 List tradeOrderDOs = tradeOrderMapper.selectList(); assertEquals(tradeOrderDOs.size(), 1); diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java index e55cbc0f0..0765df143 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/auth/AppAuthController.java @@ -65,8 +65,9 @@ public class AppAuthController { @PostMapping("/sms-login") @Operation(summary = "使用手机 + 验证码登录") - public CommonResult smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO) { - return success(authService.smsLogin(reqVO)); + public CommonResult smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO, + @RequestHeader Integer terminal) { + return success(authService.smsLogin(reqVO, terminal)); } @PostMapping("/send-sms-code") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java index c35754e7d..9ab878817 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.member.service.auth; +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.module.member.controller.app.auth.vo.*; import javax.validation.Valid; @@ -31,10 +32,11 @@ public interface MemberAuthService { /** * 手机 + 验证码登陆 * - * @param reqVO 登陆信息 + * @param reqVO 登陆信息 + * @param terminal 终端 {@link TerminalEnum} * @return 登录结果 */ - AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO); + AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO, Integer terminal); /** * 社交登录,使用 code 授权码 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java index e8f816ea6..0b8557e50 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/auth/MemberAuthServiceImpl.java @@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; @@ -78,13 +79,13 @@ public class MemberAuthServiceImpl implements MemberAuthService { @Override @Transactional - public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO) { + public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO, Integer terminal) { // 校验验证码 String userIp = getClientIP(); smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp)); // 获得获得注册用户 - MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp); + MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp, terminal); Assert.notNull(user, "获取用户失败,结果为空"); // 如果 socialType 非空,说明需要绑定社交用户 @@ -128,7 +129,7 @@ public class MemberAuthServiceImpl implements MemberAuthService { throw exception(AUTH_WEIXIN_MINI_APP_PHONE_CODE_ERROR); } // 获得获得注册用户 - MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), getClientIP()); + MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), getClientIP(), TerminalEnum.WECHAT_MINI_PROGRAM.getTerminal()); Assert.notNull(user, "获取用户失败,结果为空"); // 绑定社交用户 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java index 50433a559..8b640c850 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.member.service.user; +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.validation.Mobile; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; @@ -43,9 +44,10 @@ public interface MemberUserService { * * @param mobile 手机号 * @param registerIp 注册 IP + * @param terminal 终端 {@link TerminalEnum} * @return 用户对象 */ - MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp); + MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp, Integer terminal); /** * 更新用户的最后登陆信息 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 504778dde..0d53c388d 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; @@ -81,17 +80,17 @@ public class MemberUserServiceImpl implements MemberUserService { @Override @Transactional(rollbackFor = Exception.class) - public MemberUserDO createUserIfAbsent(String mobile, String registerIp) { + public MemberUserDO createUserIfAbsent(String mobile, String registerIp, Integer terminal) { // 用户已经存在 MemberUserDO user = memberUserMapper.selectByMobile(mobile); if (user != null) { return user; } // 用户不存在,则进行创建 - return createUser(mobile, registerIp); + return createUser(mobile, registerIp, terminal); } - private MemberUserDO createUser(String mobile, String registerIp) { + private MemberUserDO createUser(String mobile, String registerIp, Integer terminal) { // 生成密码 String password = IdUtil.fastSimpleUUID(); // 插入用户 @@ -100,8 +99,7 @@ public class MemberUserServiceImpl implements MemberUserService { user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 user.setPassword(encodePassword(password)); // 加密密码 user.setRegisterIp(registerIp); - // TODO @疯狂:无状态,terminal 不从 servletuTILS 拿,而是通过 controller 传递给 service; - user.setRegisterTerminal(ServletUtils.getTerminal()); + user.setRegisterTerminal(terminal); memberUserMapper.insert(user); // 发送 MQ 消息:用户创建 From 7aa1ecceeb72cee43e03e23bf42def158b7816cb Mon Sep 17 00:00:00 2001 From: owen Date: Mon, 16 Oct 2023 22:03:37 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=9AReview=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/MemberStatisticsController.java | 11 ++--- .../admin/member/vo/MemberCountRespVO.java | 5 +-- .../admin/pay/PayStatisticsController.java | 10 +++-- .../admin/pay/vo/PaySummaryRespVO.java | 13 ++++++ .../trade/TradeStatisticsController.java | 14 +++++-- .../trade/vo/TradeTrendSummaryExcelVO.java | 2 +- .../trade/vo/TradeTrendSummaryRespVO.java | 2 +- .../member/MemberStatisticsConvert.java | 7 ++-- .../convert/pay/PayStatisticsConvert.java | 19 +++++++++ .../convert/trade/TradeStatisticsConvert.java | 20 +++++---- .../trade/TradeOrderStatisticsMapper.java | 9 ++-- .../job/trade/TradeStatisticsJob.java | 6 ++- .../member/MemberStatisticsService.java | 3 +- .../member/MemberStatisticsServiceImpl.java | 12 +++--- .../trade/TradeOrderStatisticsService.java | 9 ++-- .../TradeOrderStatisticsServiceImpl.java | 19 ++++----- .../trade/TradeStatisticsServiceImpl.java | 4 +- .../trade/bo/MemberAreaStatisticsRespBO.java | 41 +++++++++++++++++++ .../trade/TradeOrderStatisticsMapper.xml | 14 ++----- .../mapper/trade/TradeStatisticsMapper.xml | 2 +- 20 files changed, 143 insertions(+), 79 deletions(-) create mode 100644 yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java create mode 100644 yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java create mode 100644 yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java index 59d2dd2b4..f67cd7250 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java @@ -77,8 +77,7 @@ public class MemberStatisticsController { } // TODO 芋艿:已经 review - // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 - @GetMapping("/get-area-statistics-list") + @GetMapping("/area-statistics-list") @Operation(summary = "按照省份,获得会员统计列表") @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getMemberAreaStatisticsList() { @@ -86,8 +85,7 @@ public class MemberStatisticsController { } // TODO 芋艿:已经 review - // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 - @GetMapping("/get-sex-statistics-list") + @GetMapping("/sex-statistics-list") @Operation(summary = "按照性别,获得会员统计列表") @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getMemberSexStatisticsList() { @@ -95,12 +93,11 @@ public class MemberStatisticsController { } // TODO 芋艿:已经 review - // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 - @GetMapping("/get-terminal-statistics-list") + @GetMapping("/terminal-statistics-list") @Operation(summary = "按照终端,获得会员统计列表") @PreAuthorize("@ss.hasPermission('statistics:member:query')") public CommonResult> getMemberTerminalStatisticsList() { - return success(memberStatisticsService.getRegisterTerminalStatisticsList()); + return success(memberStatisticsService.getMemberTerminalStatisticsList()); } @GetMapping("/user-count-comparison") diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java index d44f2ac5e..ce81658cf 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java @@ -10,8 +10,7 @@ public class MemberCountRespVO { @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer visitUserCount; - // TODO @疯狂:要不改成 registerUserCount,注册 - @Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer createUserCount; + @Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Integer registerUserCount; } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java index 0af4dc697..362ec7d57 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.statistics.controller.admin.pay; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; +import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert; import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -24,11 +26,11 @@ public class PayStatisticsController { @Resource private PayWalletStatisticsService payWalletStatisticsService; - // TODO @疯狂:要不搞成 PaySummary?只是目前只有 rechargePrice 充值金额? - @GetMapping("/wallet-recharge-price") + @GetMapping("/summary") @Operation(summary = "获取充值金额") - public CommonResult getWalletRechargePrice() { - return success(payWalletStatisticsService.getRechargePriceSummary()); + public CommonResult getWalletRechargePrice() { + Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary(); + return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice)); } } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java new file mode 100644 index 000000000..01edc24cf --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/vo/PaySummaryRespVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 支付统计 Response VO") +@Data +public class PaySummaryRespVO { + + @Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Integer rechargePrice; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java index 457988986..6c14230af 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java @@ -14,6 +14,8 @@ import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; +import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum; +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; @@ -104,11 +106,15 @@ public class TradeStatisticsController { @PreAuthorize("@ss.hasPermission('statistics:trade:query')") public CommonResult getOrderCount() { // 订单统计 - TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount(); + Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( + TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType()); + Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType( + TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType()); // 售后统计 - vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY)) - .setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING)); - return success(vo); + Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY); + Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING); + // 拼接返回 + return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount)); } // TODO 芋艿:已经 review diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java index 654d75893..928818dd0 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java @@ -40,5 +40,5 @@ public class TradeTrendSummaryExcelVO { private Integer brokerageSettlementPrice; @ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class) - private Integer orderRefundPrice; + private Integer afterSaleRefundPrice; } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java index 2525a9993..9c323327f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java @@ -26,7 +26,7 @@ public class TradeTrendSummaryRespVO { private Integer orderWalletPayPrice; @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderRefundPrice; + private Integer afterSaleRefundPrice; @Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer brokerageSettlementPrice; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java index 14a1bcad8..2d527b0a3 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnaly import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -29,10 +30,10 @@ public interface MemberStatisticsConvert { default List convertList(List areaList, Map userCountMap, - Map orderMap) { + Map orderMap) { return CollectionUtils.convertList(areaList, area -> { - MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())) - .orElseGet(MemberAreaStatisticsRespVO::new); + MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId())) + .orElseGet(MemberAreaStatisticsRespBO::new); return new MemberAreaStatisticsRespVO() .setAreaId(area.getId()).setAreaName(area.getName()) .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java new file mode 100644 index 000000000..08f38005f --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/pay/PayStatisticsConvert.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.statistics.convert.pay; + +import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * 支付统计 Convert + * + * @author owen + */ +@Mapper +public interface PayStatisticsConvert { + + PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class); + + PaySummaryRespVO convert(Integer rechargePrice); + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java index bc519847f..6a6c06817 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.statistics.convert.trade; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; @@ -9,7 +10,9 @@ import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespB import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; +import org.mapstruct.IterableMapping; import org.mapstruct.Mapper; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; import java.time.LocalDateTime; @@ -50,21 +53,22 @@ public interface TradeStatisticsConvert { AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, WalletSummaryRespBO walletSummary); + @IterableMapping(qualifiedByName = "convert") List convertList(List list); - // TODO @疯狂:要不要搞个默认的 convertA 方法,然后这个 convert 去调用 convertA,特殊字段再去 set? + TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics); + + @Named("convert") default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { - return new TradeTrendSummaryRespVO() + TradeTrendSummaryRespVO vo = convertA(tradeStatistics); + return vo .setDate(tradeStatistics.getTime().toLocalDate()) // 营业额 = 商品支付金额 + 充值金额 .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) - .setOrderPayPrice(tradeStatistics.getOrderPayPrice()) - .setRechargePrice(tradeStatistics.getRechargePayPrice()) // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()) - .setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice()) - .setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice()) - .setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice()); + .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); } + TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw); + } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java index 5f8645f5d..43b4c4dfd 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.statistics.dal.mysql.trade; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -20,7 +20,7 @@ import java.util.List; public interface TradeOrderStatisticsMapper extends BaseMapperX { // TODO 芋艿:已经 review - List selectSummaryListByAreaId(); + List selectSummaryListByAreaId(); // TODO 芋艿:已经 review Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, @@ -65,10 +65,7 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX getMemberSexStatisticsList(); - // TODO @疯狂:这个要不要使用 getMemberTerminalStatisticsList;保持统一? /** * 按照终端,获得会员统计列表 * * @return 会员统计列表 */ - List getRegisterTerminalStatisticsList(); + List getMemberTerminalStatisticsList(); // TODO 芋艿:已经 review /** diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java index 0b8f9cb53..7b159059f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java @@ -65,10 +65,10 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), MemberAreaStatisticsRespBO::getUserCount, Integer::sum); // 统计订单 - Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), - vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), - vo -> vo, - (a, b) -> new MemberAreaStatisticsRespVO() + Map orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), + bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE), + bo -> bo, + (a, b) -> new MemberAreaStatisticsRespBO() .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); @@ -105,7 +105,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { } @Override - public List getRegisterTerminalStatisticsList() { + public List getMemberTerminalStatisticsList() { return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); } @@ -129,7 +129,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { return new MemberCountRespVO() - .setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) + .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java index b8bd25e75..982957e24 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.statistics.service.trade; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; import java.time.LocalDateTime; @@ -30,7 +30,7 @@ public interface TradeOrderStatisticsService { * * @return 订单统计结果 */ - List getSummaryListByAreaId(); + List getSummaryListByAreaId(); // TODO 芋艿:已经 review /** @@ -62,13 +62,12 @@ public interface TradeOrderStatisticsService { */ Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); - // TODO 芋艿:已经 review /** - * 获得交易订单数量 + * 根据订单状态、物流类型,获得交易订单数量 * * @return 订单数量 */ - TradeOrderCountRespVO getOrderCount(); + Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType); // TODO 芋艿:已经 review /** diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java index 63655ceec..36131ec96 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java @@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.statistics.service.trade; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.LocalDateTimeUtil; -import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO; +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; -import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -42,7 +42,7 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ } @Override - public List getSummaryListByAreaId() { + public List getSummaryListByAreaId() { return tradeOrderStatisticsMapper.selectSummaryListByAreaId(); } @@ -62,13 +62,8 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ } @Override - public TradeOrderCountRespVO getOrderCount() { - // TODO 疯狂:这个可以根据 status + delivertyType 来过滤呀;ps:是不是搞个 service 方法,交给上层去聚合,这样 TradeOrderCountRespVO 可以更明确返回,不用搞 bo; - Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); - Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus()); - return new TradeOrderCountRespVO() - .setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L)) - .setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L)); + public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) { + return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType); } @Override diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java index b3f625d98..930389152 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java @@ -83,9 +83,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { @Override public String statisticsTrade(Integer days) { LocalDateTime today = LocalDateTime.now(); - // TODO @疯狂:不用并发哈,因为租户可能会丢;然后,一般串行就好,对性能没绝对的要求哈,天数也不会多; return IntStream.rangeClosed(1, days) - .parallel() .mapToObj(day -> statisticsTrade(today.minusDays(day))) .sorted() .collect(Collectors.joining("\n")); @@ -131,7 +129,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, walletSummary); tradeStatisticsMapper.insert(entity); - // TODO @疯狂:这里是不是也要把日期带上?类似 108 那边 + // TODO @疯狂:这里是不是也要把日期带上?类似 108 那边; 110 已经带上了 return stopWatch.prettyPrint(); } diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java new file mode 100644 index 000000000..3d3572f90 --- /dev/null +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/MemberAreaStatisticsRespBO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.statistics.service.trade.bo; + +import lombok.Data; + +/** + * 会员地区统计 Response BO + * + * @author owen + */ +@Data +public class MemberAreaStatisticsRespBO { + + /** + * 省份编号 + */ + private Integer areaId; + /** + * 省份名称 + */ + private String areaName; + + /** + * 会员数量 + */ + private Integer userCount; + + /** + * 下单的会员数量 + */ + private Integer orderCreateUserCount; + /** + * 支付订单的会员数量 + */ + private Integer orderPayUserCount; + + /** + * 订单支付金额,单位:分 + */ + private Integer orderPayPrice; + +} diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml index e054b32b0..c79c639a4 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml @@ -2,9 +2,8 @@ - - SELECT COUNT(1) FROM trade_order WHERE status = #{status} - AND deleted = FALSE - - - diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml index 74cc11ac9..380044e40 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml @@ -22,7 +22,7 @@ SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, SUM(order_wallet_pay_price) AS orderWalletPayPrice, SUM(brokerage_settlement_price) AS brokerageSettlementPrice, - SUM(after_sale_refund_price) AS orderRefundPrice + SUM(after_sale_refund_price) AS afterSaleRefundPrice FROM trade_statistics WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE From b89ae001ad01ef552874b37738d69406011b9f24 Mon Sep 17 00:00:00 2001 From: owen Date: Mon, 16 Oct 2023 22:09:20 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=9Atrade=5Fstatisti?= =?UTF-8?q?cs=20=E5=AD=97=E6=AE=B5=E3=80=90order=5Fwallet=5Fpay=5Fprice?= =?UTF-8?q?=E3=80=91=E6=94=B9=E4=B8=BA=E3=80=90wallet=5Fpay=5Fprice?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/statistics.sql | 2 +- .../admin/trade/vo/TradeTrendSummaryExcelVO.java | 2 +- .../admin/trade/vo/TradeTrendSummaryRespVO.java | 2 +- .../convert/trade/TradeStatisticsConvert.java | 2 +- .../dal/dataobject/trade/TradeStatisticsDO.java | 3 +-- .../pay/PayWalletStatisticsServiceImpl.java | 2 +- .../service/trade/bo/WalletSummaryRespBO.java | 2 +- .../mapper/trade/TradeStatisticsMapper.xml | 16 ++++++++-------- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sql/mysql/statistics.sql b/sql/mysql/statistics.sql index 0decf1ef1..0ec0469e2 100644 --- a/sql/mysql/statistics.sql +++ b/sql/mysql/statistics.sql @@ -7,10 +7,10 @@ CREATE TABLE trade_statistics order_create_count int DEFAULT 0 NOT NULL COMMENT '创建订单数', order_pay_count int DEFAULT 0 NOT NULL COMMENT '支付订单商品数', order_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额,单位:分', - order_wallet_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额(余额),单位:分', after_sale_count int DEFAULT 0 NOT NULL COMMENT '退款订单数', after_sale_refund_price int DEFAULT 0 NOT NULL COMMENT '总退款金额,单位:分', brokerage_settlement_price int DEFAULT 0 NOT NULL COMMENT '佣金金额(已结算),单位:分', + wallet_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额(余额),单位:分', recharge_pay_count int DEFAULT 0 NOT NULL COMMENT '充值订单数', recharge_pay_price int DEFAULT 0 NOT NULL COMMENT '充值金额,单位:分', recharge_refund_count int DEFAULT 0 NOT NULL COMMENT '充值退款订单数', diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java index 928818dd0..5b14fa1d4 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java @@ -34,7 +34,7 @@ public class TradeTrendSummaryExcelVO { private Integer expensePrice; @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) - private Integer orderWalletPayPrice; + private Integer walletPayPrice; @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) private Integer brokerageSettlementPrice; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java index 9c323327f..f76d02e91 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java @@ -23,7 +23,7 @@ public class TradeTrendSummaryRespVO { private Integer orderPayPrice; @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Integer orderWalletPayPrice; + private Integer walletPayPrice; @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer afterSaleRefundPrice; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java index 6a6c06817..7c140628f 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java @@ -66,7 +66,7 @@ public interface TradeStatisticsConvert { // 营业额 = 商品支付金额 + 充值金额 .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); + .setExpensePrice(tradeStatistics.getWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()); } TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw); diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java index b8e26ff35..8efa7f400 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java @@ -63,11 +63,10 @@ public class TradeStatisticsDO extends TenantBaseDO { */ private Integer brokerageSettlementPrice; - // TODO @疯狂:walletPayPrice,钱包支付金额 /** * 总支付金额(余额),单位:分 */ - private Integer orderWalletPayPrice; + private Integer walletPayPrice; /** * 充值订单数 *

diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java index 10f8bdc97..5630b40e9 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java @@ -33,7 +33,7 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween( beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType()); // 拼接 - paySummary.setOrderWalletPayPrice(walletPayPrice) + paySummary.setWalletPayPrice(walletPayPrice) .setRechargeRefundCount(refundSummary.getRechargeRefundCount()) .setRechargeRefundPrice(refundSummary.getRechargeRefundPrice()); return paySummary; diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java index ada494e30..89371f6c1 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/WalletSummaryRespBO.java @@ -13,7 +13,7 @@ public class WalletSummaryRespBO { /** * 总支付金额(余额),单位:分 */ - private Integer orderWalletPayPrice; + private Integer walletPayPrice; /** * 充值订单数 diff --git a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml index 380044e40..2415f6d55 100644 --- a/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml +++ b/yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml @@ -15,14 +15,14 @@ resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> SELECT -- 营业额 = 商品支付金额 + 充值金额 - SUM(order_pay_price + recharge_pay_price) AS turnoverPrice, - SUM(order_pay_price) AS orderPayPrice, - SUM(recharge_pay_price) AS rechargePrice, + SUM(order_pay_price + recharge_pay_price) AS turnoverPrice, + SUM(order_pay_price) AS orderPayPrice, + SUM(recharge_pay_price) AS rechargePrice, -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 - SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, - SUM(order_wallet_pay_price) AS orderWalletPayPrice, - SUM(brokerage_settlement_price) AS brokerageSettlementPrice, - SUM(after_sale_refund_price) AS afterSaleRefundPrice + SUM(wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, + SUM(wallet_pay_price) AS walletPayPrice, + SUM(brokerage_settlement_price) AS brokerageSettlementPrice, + SUM(after_sale_refund_price) AS afterSaleRefundPrice FROM trade_statistics WHERE time BETWEEN #{beginTime} AND #{endTime} AND deleted = FALSE @@ -30,7 +30,7 @@