Commit 34210d35345e048b038c92db8073b606390e39d5
Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
Showing
92 changed files
with
1239 additions
and
873 deletions
sql/mysql/mall.sql
0 → 100644
sql/mysql/member.sql
0 → 100644
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/servlet/ServletUtils.java
| 1 | 1 | package cn.iocoder.yudao.framework.common.util.servlet; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.convert.Convert; | |
| 3 | 4 | import cn.hutool.core.io.IoUtil; |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | 6 | import cn.hutool.extra.servlet.ServletUtil; |
| ... | ... | @@ -27,7 +28,7 @@ public class ServletUtils { |
| 27 | 28 | * 返回 JSON 字符串 |
| 28 | 29 | * |
| 29 | 30 | * @param response 响应 |
| 30 | - * @param object 对象,会序列化成 JSON 字符串 | |
| 31 | + * @param object 对象,会序列化成 JSON 字符串 | |
| 31 | 32 | */ |
| 32 | 33 | @SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码 |
| 33 | 34 | public static void writeJSON(HttpServletResponse response, Object object) { |
| ... | ... | @@ -40,7 +41,7 @@ public class ServletUtils { |
| 40 | 41 | * |
| 41 | 42 | * @param response 响应 |
| 42 | 43 | * @param filename 文件名 |
| 43 | - * @param content 附件内容 | |
| 44 | + * @param content 附件内容 | |
| 44 | 45 | */ |
| 45 | 46 | public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException { |
| 46 | 47 | // 设置 header 和 contentType |
| ... | ... | @@ -88,6 +89,18 @@ public class ServletUtils { |
| 88 | 89 | return ServletUtil.getClientIP(request); |
| 89 | 90 | } |
| 90 | 91 | |
| 92 | + public static Integer getTerminal() { | |
| 93 | + return getHeaderInt("terminal"); | |
| 94 | + } | |
| 95 | + | |
| 96 | + public static String getHeader(String header) { | |
| 97 | + return getHeader(getRequest(), header); | |
| 98 | + } | |
| 99 | + | |
| 100 | + public static Integer getHeaderInt(String header) { | |
| 101 | + return Convert.toInt(getHeader(header)); | |
| 102 | + } | |
| 103 | + | |
| 91 | 104 | public static boolean isJsonRequest(ServletRequest request) { |
| 92 | 105 | return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE); |
| 93 | 106 | } |
| ... | ... | @@ -107,4 +120,12 @@ public class ServletUtils { |
| 107 | 120 | public static Map<String, String> getParamMap(HttpServletRequest request) { |
| 108 | 121 | return ServletUtil.getParamMap(request); |
| 109 | 122 | } |
| 123 | + | |
| 124 | + public static String getHeader(HttpServletRequest request, String header) { | |
| 125 | + if (request == null) { | |
| 126 | + return null; | |
| 127 | + } | |
| 128 | + return request.getHeader(header); | |
| 129 | + } | |
| 130 | + | |
| 110 | 131 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
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 { |
| 111 | 111 | ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); |
| 112 | 112 | |
| 113 | 113 | // ========== 文章分类 1-013-015-000 ========== |
| 114 | - ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "分类不存在"); | |
| 114 | + ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "文章分类不存在"); | |
| 115 | + ErrorCode ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES = new ErrorCode(1_013_015_001, "文章分类删除失败,存在关联文章"); | |
| 115 | 116 | |
| 116 | 117 | // ========== 文章管理 1-013-016-000 ========== |
| 117 | - ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章管理不存在"); | |
| 118 | + ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在"); | |
| 118 | 119 | |
| 119 | 120 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleCategoryController.java
| ... | ... | @@ -3,8 +3,6 @@ package cn.iocoder.yudao.module.promotion.controller.admin.article; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 7 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 8 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; |
| 9 | 7 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; |
| 10 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| ... | ... | @@ -17,15 +15,11 @@ import org.springframework.validation.annotation.Validated; |
| 17 | 15 | import org.springframework.web.bind.annotation.*; |
| 18 | 16 | |
| 19 | 17 | import javax.annotation.Resource; |
| 20 | -import javax.servlet.http.HttpServletResponse; | |
| 21 | 18 | import javax.validation.Valid; |
| 22 | -import java.io.IOException; | |
| 23 | -import java.util.Collection; | |
| 24 | 19 | import java.util.Comparator; |
| 25 | 20 | import java.util.List; |
| 26 | 21 | |
| 27 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 28 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 29 | 23 | |
| 30 | 24 | @Tag(name = "管理后台 - 文章分类") |
| 31 | 25 | @RestController |
| ... | ... | @@ -65,23 +59,14 @@ public class ArticleCategoryController { |
| 65 | 59 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 66 | 60 | @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") |
| 67 | 61 | public CommonResult<ArticleCategoryRespVO> getArticleCategory(@RequestParam("id") Long id) { |
| 68 | - ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(id); | |
| 69 | - return success(ArticleCategoryConvert.INSTANCE.convert(articleCategory)); | |
| 70 | - } | |
| 71 | - | |
| 72 | - @GetMapping("/list") | |
| 73 | - @Operation(summary = "获得文章分类列表") | |
| 74 | - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | |
| 75 | - @PreAuthorize("@ss.hasPermission('promotion:article-category:query')") | |
| 76 | - public CommonResult<List<ArticleCategoryRespVO>> getArticleCategoryList(@RequestParam("ids") Collection<Long> ids) { | |
| 77 | - List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(ids); | |
| 78 | - return success(ArticleCategoryConvert.INSTANCE.convertList(list)); | |
| 62 | + ArticleCategoryDO category = articleCategoryService.getArticleCategory(id); | |
| 63 | + return success(ArticleCategoryConvert.INSTANCE.convert(category)); | |
| 79 | 64 | } |
| 80 | 65 | |
| 81 | 66 | @GetMapping("/list-all-simple") |
| 82 | 67 | @Operation(summary = "获取文章分类精简信息列表", description = "只包含被开启的文章分类,主要用于前端的下拉选项") |
| 83 | 68 | public CommonResult<List<ArticleCategorySimpleRespVO>> getSimpleDeptList() { |
| 84 | - // 获得部门列表,只要开启状态的 | |
| 69 | + // 获得分类列表,只要开启状态的 | |
| 85 | 70 | List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 86 | 71 | // 降序排序后,返回给前端 |
| 87 | 72 | list.sort(Comparator.comparing(ArticleCategoryDO::getSort).reversed()); |
| ... | ... | @@ -96,16 +81,4 @@ public class ArticleCategoryController { |
| 96 | 81 | return success(ArticleCategoryConvert.INSTANCE.convertPage(pageResult)); |
| 97 | 82 | } |
| 98 | 83 | |
| 99 | - @GetMapping("/export-excel") | |
| 100 | - @Operation(summary = "导出文章分类 Excel") | |
| 101 | - @PreAuthorize("@ss.hasPermission('promotion:article-category:export')") | |
| 102 | - @OperateLog(type = EXPORT) | |
| 103 | - public void exportArticleCategoryExcel(@Valid ArticleCategoryExportReqVO exportReqVO, | |
| 104 | - HttpServletResponse response) throws IOException { | |
| 105 | - List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(exportReqVO); | |
| 106 | - // 导出 Excel | |
| 107 | - List<ArticleCategoryExcelVO> datas = ArticleCategoryConvert.INSTANCE.convertList02(list); | |
| 108 | - ExcelUtils.write(response, "文章分类.xls", "数据", ArticleCategoryExcelVO.class, datas); | |
| 109 | - } | |
| 110 | - | |
| 111 | 84 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java
| ... | ... | @@ -2,9 +2,10 @@ package cn.iocoder.yudao.module.promotion.controller.admin.article; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.*; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | |
| 8 | 9 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; |
| 9 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | 11 | import cn.iocoder.yudao.module.promotion.service.article.ArticleService; |
| ... | ... | @@ -16,14 +17,9 @@ import org.springframework.validation.annotation.Validated; |
| 16 | 17 | import org.springframework.web.bind.annotation.*; |
| 17 | 18 | |
| 18 | 19 | import javax.annotation.Resource; |
| 19 | -import javax.servlet.http.HttpServletResponse; | |
| 20 | 20 | import javax.validation.Valid; |
| 21 | -import java.io.IOException; | |
| 22 | -import java.util.Collection; | |
| 23 | -import java.util.List; | |
| 24 | 21 | |
| 25 | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 27 | 23 | |
| 28 | 24 | @Tag(name = "管理后台 - 文章管理") |
| 29 | 25 | @RestController |
| ... | ... | @@ -67,15 +63,6 @@ public class ArticleController { |
| 67 | 63 | return success(ArticleConvert.INSTANCE.convert(article)); |
| 68 | 64 | } |
| 69 | 65 | |
| 70 | - @GetMapping("/list") | |
| 71 | - @Operation(summary = "获得文章管理列表") | |
| 72 | - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") | |
| 73 | - @PreAuthorize("@ss.hasPermission('promotion:article:query')") | |
| 74 | - public CommonResult<List<ArticleRespVO>> getArticleList(@RequestParam("ids") Collection<Long> ids) { | |
| 75 | - List<ArticleDO> list = articleService.getArticleList(ids); | |
| 76 | - return success(ArticleConvert.INSTANCE.convertList(list)); | |
| 77 | - } | |
| 78 | - | |
| 79 | 66 | @GetMapping("/page") |
| 80 | 67 | @Operation(summary = "获得文章管理分页") |
| 81 | 68 | @PreAuthorize("@ss.hasPermission('promotion:article:query')") |
| ... | ... | @@ -84,16 +71,4 @@ public class ArticleController { |
| 84 | 71 | return success(ArticleConvert.INSTANCE.convertPage(pageResult)); |
| 85 | 72 | } |
| 86 | 73 | |
| 87 | - @GetMapping("/export-excel") | |
| 88 | - @Operation(summary = "导出文章管理 Excel") | |
| 89 | - @PreAuthorize("@ss.hasPermission('promotion:article:export')") | |
| 90 | - @OperateLog(type = EXPORT) | |
| 91 | - public void exportArticleExcel(@Valid ArticleExportReqVO exportReqVO, | |
| 92 | - HttpServletResponse response) throws IOException { | |
| 93 | - List<ArticleDO> list = articleService.getArticleList(exportReqVO); | |
| 94 | - // 导出 Excel | |
| 95 | - List<ArticleExcelVO> datas = ArticleConvert.INSTANCE.convertList02(list); | |
| 96 | - ExcelUtils.write(response, "文章管理.xls", "数据", ArticleExcelVO.class, datas); | |
| 97 | - } | |
| 98 | - | |
| 99 | 74 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | |
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 7 | -import lombok.Data; | |
| 8 | - | |
| 9 | -import java.time.LocalDateTime; | |
| 10 | - | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 文章管理 Excel VO | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 17 | -@Data | |
| 18 | -public class ArticleExcelVO { | |
| 19 | - | |
| 20 | - @ExcelProperty("文章编号") | |
| 21 | - private Long id; | |
| 22 | - | |
| 23 | - @ExcelProperty("文章分类编号") | |
| 24 | - private Long categoryId; | |
| 25 | - | |
| 26 | - @ExcelProperty("关联商品编号") | |
| 27 | - private Long spuId; | |
| 28 | - | |
| 29 | - @ExcelProperty("文章标题") | |
| 30 | - private String title; | |
| 31 | - | |
| 32 | - @ExcelProperty("文章作者") | |
| 33 | - private String author; | |
| 34 | - | |
| 35 | - @ExcelProperty("文章封面图片地址") | |
| 36 | - private String picUrl; | |
| 37 | - | |
| 38 | - @ExcelProperty("文章简介") | |
| 39 | - private String introduction; | |
| 40 | - | |
| 41 | - @ExcelProperty("浏览次数") | |
| 42 | - private String browseCount; | |
| 43 | - | |
| 44 | - @ExcelProperty("排序") | |
| 45 | - private Integer sort; | |
| 46 | - | |
| 47 | - @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 48 | - @DictFormat(DictTypeConstants.COMMON_STATUS) | |
| 49 | - private Integer status; | |
| 50 | - | |
| 51 | - @ExcelProperty("是否热门(小程序)") | |
| 52 | - private Boolean recommendHot; | |
| 53 | - | |
| 54 | - @ExcelProperty("是否轮播图(小程序)") | |
| 55 | - private Boolean recommendBanner; | |
| 56 | - | |
| 57 | - @ExcelProperty("文章内容") | |
| 58 | - private String content; | |
| 59 | - | |
| 60 | - @ExcelProperty("创建时间") | |
| 61 | - private LocalDateTime createTime; | |
| 62 | - | |
| 63 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | - | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | - | |
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | - | |
| 11 | -@Schema(description = "管理后台 - 文章管理 Excel 导出 Request VO,参数和 ArticlePageReqVO 是一致的") | |
| 12 | -@Data | |
| 13 | -public class ArticleExportReqVO { | |
| 14 | - | |
| 15 | - @Schema(description = "文章分类编号", example = "15458") | |
| 16 | - private Long categoryId; | |
| 17 | - | |
| 18 | - @Schema(description = "关联商品编号", example = "22378") | |
| 19 | - private Long spuId; | |
| 20 | - | |
| 21 | - @Schema(description = "文章标题") | |
| 22 | - private String title; | |
| 23 | - | |
| 24 | - @Schema(description = "文章作者") | |
| 25 | - private String author; | |
| 26 | - | |
| 27 | - @Schema(description = "状态", example = "2") | |
| 28 | - private Integer status; | |
| 29 | - | |
| 30 | - @Schema(description = "是否热门(小程序)") | |
| 31 | - private Boolean recommendHot; | |
| 32 | - | |
| 33 | - @Schema(description = "是否轮播图(小程序)") | |
| 34 | - private Boolean recommendBanner; | |
| 35 | - | |
| 36 | - @Schema(description = "创建时间") | |
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 38 | - private LocalDateTime[] createTime; | |
| 39 | - | |
| 40 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleBaseVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleBaseVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo; | |
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| ... | ... | @@ -34,6 +34,7 @@ public class ArticleBaseVO { |
| 34 | 34 | @Schema(description = "文章简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "这是一个简介") |
| 35 | 35 | private String introduction; |
| 36 | 36 | |
| 37 | + // TODO @puhui999:浏览量的字段,应该不是后端新增设置的哈; | |
| 37 | 38 | @Schema(description = "浏览次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "111") |
| 38 | 39 | private String browseCount; |
| 39 | 40 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleCreateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleCreateReqVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticlePageReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticlePageReqVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleRespVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleRespVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/ArticleUpdateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleUpdateReqVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; | |
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 7 | -import lombok.Data; | |
| 8 | - | |
| 9 | -import java.time.LocalDateTime; | |
| 10 | - | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 文章分类 Excel VO | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 17 | -@Data | |
| 18 | -public class ArticleCategoryExcelVO { | |
| 19 | - | |
| 20 | - @ExcelProperty("文章分类编号") | |
| 21 | - private Long id; | |
| 22 | - | |
| 23 | - @ExcelProperty("文章分类名称") | |
| 24 | - private String name; | |
| 25 | - | |
| 26 | - @ExcelProperty("图标地址") | |
| 27 | - private String picUrl; | |
| 28 | - | |
| 29 | - @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 30 | - @DictFormat(DictTypeConstants.COMMON_STATUS) | |
| 31 | - private Integer status; | |
| 32 | - | |
| 33 | - @ExcelProperty("排序") | |
| 34 | - private Integer sort; | |
| 35 | - | |
| 36 | - @ExcelProperty("创建时间") | |
| 37 | - private LocalDateTime createTime; | |
| 38 | - | |
| 39 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | - | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | - | |
| 9 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | - | |
| 11 | -@Schema(description = "管理后台 - 文章分类 Excel 导出 Request VO,参数和 ArticleCategoryPageReqVO 是一致的") | |
| 12 | -@Data | |
| 13 | -public class ArticleCategoryExportReqVO { | |
| 14 | - | |
| 15 | - @Schema(description = "文章分类名称", example = "秒杀") | |
| 16 | - private String name; | |
| 17 | - | |
| 18 | - @Schema(description = "状态", example = "1") | |
| 19 | - private Integer status; | |
| 20 | - | |
| 21 | - @Schema(description = "创建时间") | |
| 22 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 23 | - private LocalDateTime[] createTime; | |
| 24 | - | |
| 25 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationRecordController.java
| ... | ... | @@ -40,8 +40,6 @@ public class CombinationRecordController { |
| 40 | 40 | @Lazy |
| 41 | 41 | private CombinationRecordService combinationRecordService; |
| 42 | 42 | |
| 43 | - // 然后如果 headId 非空,并且第一页,单独多查询一条 head ;放到第 0 个位置;相当于说,第一页特殊一点; | |
| 44 | - | |
| 45 | 43 | @GetMapping("/page") |
| 46 | 44 | @Operation(summary = "获得拼团记录分页") |
| 47 | 45 | @PreAuthorize("@ss.hasPermission('promotion:combination-record:query')") | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/article/AppArticleCategoryController.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.app.article; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; |
| 6 | +import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; | |
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService; | |
| 5 | 9 | import io.swagger.v3.oas.annotations.Operation; |
| 6 | 10 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 7 | 11 | import org.springframework.validation.annotation.Validated; |
| 8 | 12 | import org.springframework.web.bind.annotation.RequestMapping; |
| 9 | 13 | import org.springframework.web.bind.annotation.RestController; |
| 10 | 14 | |
| 11 | -import java.util.ArrayList; | |
| 15 | +import javax.annotation.Resource; | |
| 12 | 16 | import java.util.List; |
| 13 | -import java.util.Random; | |
| 14 | 17 | |
| 15 | 18 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 16 | 19 | |
| ... | ... | @@ -20,20 +23,15 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 20 | 23 | @Validated |
| 21 | 24 | public class AppArticleCategoryController { |
| 22 | 25 | |
| 26 | + @Resource | |
| 27 | + private ArticleCategoryService articleCategoryService; | |
| 28 | + | |
| 23 | 29 | @RequestMapping("/list") |
| 24 | 30 | @Operation(summary = "获得文章分类列表") |
| 25 | - // TODO @芋艿:swagger 注解 | |
| 26 | 31 | public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() { |
| 27 | - List<AppArticleCategoryRespVO> appArticleRespVOList = new ArrayList<>(); | |
| 28 | - Random random = new Random(); | |
| 29 | - for (int i = 0; i < 10; i++) { | |
| 30 | - AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO(); | |
| 31 | - appArticleRespVO.setId((long) (i + 1)); | |
| 32 | - appArticleRespVO.setName("分类 - " + i); | |
| 33 | - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); | |
| 34 | - appArticleRespVOList.add(appArticleRespVO); | |
| 35 | - } | |
| 36 | - return success(appArticleRespVOList); | |
| 32 | + List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus( | |
| 33 | + CommonStatusEnum.ENABLE.getStatus()); | |
| 34 | + return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList)); | |
| 37 | 35 | } |
| 38 | 36 | |
| 39 | 37 | } | ... | ... |
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; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; |
| 7 | +import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; | |
| 8 | +import cn.iocoder.yudao.module.promotion.service.article.ArticleService; | |
| 9 | +import io.swagger.v3.oas.annotations.Operation; | |
| 10 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 11 | +import io.swagger.v3.oas.annotations.Parameters; | |
| 7 | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 8 | 13 | import org.springframework.validation.annotation.Validated; |
| 9 | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | 15 | import org.springframework.web.bind.annotation.RequestParam; |
| 11 | 16 | import org.springframework.web.bind.annotation.RestController; |
| 12 | 17 | |
| 13 | -import java.time.LocalDateTime; | |
| 14 | -import java.util.ArrayList; | |
| 18 | +import javax.annotation.Resource; | |
| 15 | 19 | import java.util.List; |
| 16 | -import java.util.Random; | |
| 17 | 20 | |
| 18 | 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 19 | 22 | |
| ... | ... | @@ -23,68 +26,33 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 23 | 26 | @Validated |
| 24 | 27 | public class AppArticleController { |
| 25 | 28 | |
| 29 | + @Resource | |
| 30 | + private ArticleService articleService; | |
| 31 | + | |
| 26 | 32 | @RequestMapping("/list") |
| 27 | - // TODO @芋艿:swagger 注解 | |
| 28 | - public CommonResult<List<AppArticleRespVO>> getArticleList(@RequestParam(value = "recommendHot", required = false) Boolean recommendHot, | |
| 29 | - @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { | |
| 30 | - List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>(); | |
| 31 | - Random random = new Random(); | |
| 32 | - for (int i = 0; i < 10; i++) { | |
| 33 | - AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); | |
| 34 | - appArticleRespVO.setId((long) (i + 1)); | |
| 35 | - appArticleRespVO.setTitle("芋道源码 - " + i + "模块"); | |
| 36 | - appArticleRespVO.setAuthor("芋道源码"); | |
| 37 | - appArticleRespVO.setCategoryId((long) random.nextInt(10000)); | |
| 38 | - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); | |
| 39 | - appArticleRespVO.setIntroduction("我是简介"); | |
| 40 | - appArticleRespVO.setDescription("我是详细"); | |
| 41 | - appArticleRespVO.setCreateTime(LocalDateTime.now()); | |
| 42 | - appArticleRespVO.setBrowseCount(random.nextInt(10000)); | |
| 43 | - appArticleRespVO.setSpuId((long) random.nextInt(10000)); | |
| 44 | - appArticleRespVOList.add(appArticleRespVO); | |
| 45 | - } | |
| 46 | - return success(appArticleRespVOList); | |
| 33 | + @Operation(summary = "获得文章详情列表") | |
| 34 | + @Parameters({ | |
| 35 | + @Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章 | |
| 36 | + @Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章 | |
| 37 | + }) | |
| 38 | + public CommonResult<List<AppArticleRespVO>> getArticleList( | |
| 39 | + @RequestParam(value = "recommendHot", required = false) Boolean recommendHot, | |
| 40 | + @RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) { | |
| 41 | + return success(ArticleConvert.INSTANCE.convertList03( | |
| 42 | + articleService.getArticleCategoryListByRecommendHotAndRecommendBanner(recommendHot, recommendBanner))); | |
| 47 | 43 | } |
| 48 | 44 | |
| 49 | 45 | @RequestMapping("/page") |
| 50 | - // TODO @芋艿:swagger 注解 | |
| 46 | + @Operation(summary = "获得文章详情分页") | |
| 51 | 47 | public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) { |
| 52 | - List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>(); | |
| 53 | - Random random = new Random(); | |
| 54 | - for (int i = 0; i < 10; i++) { | |
| 55 | - AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); | |
| 56 | - appArticleRespVO.setId((long) (i + 1)); | |
| 57 | - appArticleRespVO.setTitle("芋道源码 - " + i + "模块"); | |
| 58 | - appArticleRespVO.setAuthor("芋道源码"); | |
| 59 | - appArticleRespVO.setCategoryId((long) random.nextInt(10000)); | |
| 60 | - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png"); | |
| 61 | - appArticleRespVO.setIntroduction("我是简介"); | |
| 62 | - appArticleRespVO.setDescription("我是详细"); | |
| 63 | - appArticleRespVO.setCreateTime(LocalDateTime.now()); | |
| 64 | - appArticleRespVO.setBrowseCount(random.nextInt(10000)); | |
| 65 | - appArticleRespVO.setSpuId((long) random.nextInt(10000)); | |
| 66 | - appArticleRespVOList.add(appArticleRespVO); | |
| 67 | - } | |
| 68 | - return success(new PageResult<>(appArticleRespVOList, 10L)); | |
| 48 | + return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO))); | |
| 69 | 49 | } |
| 70 | 50 | |
| 71 | 51 | @RequestMapping("/get") |
| 72 | - // TODO @芋艿:swagger 注解 | |
| 52 | + @Operation(summary = "获得文章详情") | |
| 53 | + @Parameter(name = "id", description = "文章编号", example = "1024") | |
| 73 | 54 | public CommonResult<AppArticleRespVO> getArticlePage(@RequestParam("id") Long id) { |
| 74 | - Random random = new Random(); | |
| 75 | - AppArticleRespVO appArticleRespVO = new AppArticleRespVO(); | |
| 76 | - appArticleRespVO.setId((long) (1)); | |
| 77 | - appArticleRespVO.setTitle("芋道源码 - " + 0 + "模块"); | |
| 78 | - appArticleRespVO.setAuthor("芋道源码"); | |
| 79 | - appArticleRespVO.setCategoryId((long) random.nextInt(10000)); | |
| 80 | - appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (0 + 1) + ".png"); | |
| 81 | - appArticleRespVO.setIntroduction("我是简介"); | |
| 82 | - appArticleRespVO.setDescription("我是详细"); | |
| 83 | - appArticleRespVO.setCreateTime(LocalDateTime.now()); | |
| 84 | - appArticleRespVO.setBrowseCount(random.nextInt(10000)); | |
| 85 | - appArticleRespVO.setSpuId((long) random.nextInt(10000)); | |
| 86 | - appArticleRespVO.setSpuId(633L); | |
| 87 | - return success(appArticleRespVO); | |
| 55 | + return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id))); | |
| 88 | 56 | } |
| 89 | 57 | |
| 90 | 58 | } | ... | ... |
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 { |
| 39 | 39 | @Schema(description = "关联的商品 SPU 编号", example = "1024") |
| 40 | 40 | private Long spuId; |
| 41 | 41 | |
| 42 | -// TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回; | |
| 43 | -// @Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 44 | -// private Boolean recommendHot; | |
| 45 | -// | |
| 46 | -// @Schema(description = "是否 Banner 推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 47 | -// private Boolean recommendBanner; | |
| 48 | - | |
| 49 | 42 | } | ... | ... |
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 { |
| 16 | 16 | @Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") |
| 17 | 17 | private String picUrl; |
| 18 | 18 | |
| 19 | - // TODO 芋艿:下面 2 个字段,后端要存储,前端不用返回; | |
| 20 | -// @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 21 | -// private Integer status; | |
| 22 | -// | |
| 23 | -// @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 24 | -// private Integer sort; | |
| 25 | - | |
| 26 | 19 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationRecordController.java
| ... | ... | @@ -47,13 +47,13 @@ public class AppCombinationRecordController { |
| 47 | 47 | public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() { |
| 48 | 48 | AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO(); |
| 49 | 49 | // 1. 获得拼团参与用户数量 |
| 50 | - Long count = combinationRecordService.getCombinationUserCount(); | |
| 51 | - if (count == 0) { | |
| 50 | + Long userCount = combinationRecordService.getCombinationUserCount(); | |
| 51 | + if (userCount == 0) { | |
| 52 | 52 | summary.setAvatars(Collections.emptyList()); |
| 53 | - summary.setUserCount(count); | |
| 53 | + summary.setUserCount(userCount); | |
| 54 | 54 | return success(summary); |
| 55 | 55 | } |
| 56 | - summary.setUserCount(count); | |
| 56 | + summary.setUserCount(userCount); | |
| 57 | 57 | |
| 58 | 58 | // 2. 获得拼团记录头像 |
| 59 | 59 | List<CombinationRecordDO> records = combinationRecordService.getLatestCombinationRecordList( | ... | ... |
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; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; | |
| 5 | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| 6 | 7 | import org.mapstruct.Mapper; |
| 7 | 8 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -28,8 +29,8 @@ public interface ArticleCategoryConvert { |
| 28 | 29 | |
| 29 | 30 | PageResult<ArticleCategoryRespVO> convertPage(PageResult<ArticleCategoryDO> page); |
| 30 | 31 | |
| 31 | - List<ArticleCategoryExcelVO> convertList02(List<ArticleCategoryDO> list); | |
| 32 | - | |
| 33 | 32 | List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list); |
| 34 | 33 | |
| 34 | + List<AppArticleCategoryRespVO> convertList04(List<ArticleCategoryDO> categoryList); | |
| 35 | + | |
| 35 | 36 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.convert.article; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExcelVO; | |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleRespVO; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 9 | 9 | import org.mapstruct.Mapper; |
| 10 | 10 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -31,6 +31,10 @@ public interface ArticleConvert { |
| 31 | 31 | |
| 32 | 32 | PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page); |
| 33 | 33 | |
| 34 | - List<ArticleExcelVO> convertList02(List<ArticleDO> list); | |
| 34 | + AppArticleRespVO convert01(ArticleDO article); | |
| 35 | + | |
| 36 | + PageResult<AppArticleRespVO> convertPage02(PageResult<ArticleDO> articlePage); | |
| 37 | + | |
| 38 | + List<AppArticleRespVO> convertList03(List<ArticleDO> articleCategoryListByRecommendHotAndRecommendBanner); | |
| 35 | 39 | |
| 36 | 40 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -192,7 +192,6 @@ public interface CombinationActivityConvert { |
| 192 | 192 | return result; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - | |
| 196 | 195 | default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List<CombinationRecordDO> memberRecords) { |
| 197 | 196 | AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO() |
| 198 | 197 | .setHeadRecord(convert(headRecord)).setMemberRecords(convertList3(memberRecords)); |
| ... | ... | @@ -208,31 +207,29 @@ public interface CombinationActivityConvert { |
| 208 | 207 | /** |
| 209 | 208 | * 转换生成虚拟成团虚拟记录 |
| 210 | 209 | * |
| 211 | - * @param virtualGroupHeadRecords 虚拟成团团长记录列表 | |
| 210 | + * @param virtualGroupHeadRecord 虚拟成团团长记录 | |
| 212 | 211 | * @return 虚拟记录列表 |
| 213 | 212 | */ |
| 214 | - default List<CombinationRecordDO> convertVirtualGroupList(List<CombinationRecordDO> virtualGroupHeadRecords) { | |
| 213 | + default List<CombinationRecordDO> convertVirtualGroupList(CombinationRecordDO virtualGroupHeadRecord) { | |
| 215 | 214 | List<CombinationRecordDO> createRecords = new ArrayList<>(); |
| 216 | - virtualGroupHeadRecords.forEach(headRecord -> { | |
| 217 | - // 计算需要创建的虚拟成团记录数量 | |
| 218 | - int count = headRecord.getUserSize() - headRecord.getUserCount(); | |
| 219 | - for (int i = 0; i < count; i++) { | |
| 220 | - // 基础信息和团长保持一致 | |
| 221 | - CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(headRecord.getActivityId()) | |
| 222 | - .setCombinationPrice(headRecord.getCombinationPrice()).setSpuId(headRecord.getSpuId()).setSpuName(headRecord.getSpuName()) | |
| 223 | - .setPicUrl(headRecord.getPicUrl()).setSkuId(headRecord.getSkuId()).setHeadId(headRecord.getId()) | |
| 224 | - .setStatus(headRecord.getStatus()) // 状态保持和创建时一致,创建完成后会接着处理 | |
| 225 | - .setVirtualGroup(headRecord.getVirtualGroup()).setExpireTime(headRecord.getExpireTime()) | |
| 226 | - .setStartTime(headRecord.getStartTime()).setUserSize(headRecord.getUserSize()).setUserCount(headRecord.getUserCount()); | |
| 227 | - // 虚拟信息 | |
| 228 | - newRecord.setCount(0); | |
| 229 | - newRecord.setUserId(0L); | |
| 230 | - newRecord.setNickname(""); | |
| 231 | - newRecord.setAvatar(""); | |
| 232 | - newRecord.setOrderId(0L); | |
| 233 | - createRecords.add(newRecord); | |
| 234 | - } | |
| 235 | - }); | |
| 215 | + // 计算需要创建的虚拟成团记录数量 | |
| 216 | + int count = virtualGroupHeadRecord.getUserSize() - virtualGroupHeadRecord.getUserCount(); | |
| 217 | + for (int i = 0; i < count; i++) { | |
| 218 | + // 基础信息和团长保持一致 | |
| 219 | + CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(virtualGroupHeadRecord.getActivityId()) | |
| 220 | + .setCombinationPrice(virtualGroupHeadRecord.getCombinationPrice()).setSpuId(virtualGroupHeadRecord.getSpuId()).setSpuName(virtualGroupHeadRecord.getSpuName()) | |
| 221 | + .setPicUrl(virtualGroupHeadRecord.getPicUrl()).setSkuId(virtualGroupHeadRecord.getSkuId()).setHeadId(virtualGroupHeadRecord.getId()) | |
| 222 | + .setStatus(virtualGroupHeadRecord.getStatus()) // 状态保持和创建时一致,创建完成后会接着处理 | |
| 223 | + .setVirtualGroup(virtualGroupHeadRecord.getVirtualGroup()).setExpireTime(virtualGroupHeadRecord.getExpireTime()) | |
| 224 | + .setStartTime(virtualGroupHeadRecord.getStartTime()).setUserSize(virtualGroupHeadRecord.getUserSize()).setUserCount(virtualGroupHeadRecord.getUserCount()); | |
| 225 | + // 虚拟信息 | |
| 226 | + newRecord.setCount(0); | |
| 227 | + newRecord.setUserId(0L); | |
| 228 | + newRecord.setNickname(""); | |
| 229 | + newRecord.setAvatar(""); | |
| 230 | + newRecord.setOrderId(0L); | |
| 231 | + createRecords.add(newRecord); | |
| 232 | + } | |
| 236 | 233 | return createRecords; |
| 237 | 234 | } |
| 238 | 235 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleCategoryMapper.java
| ... | ... | @@ -3,13 +3,10 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| 9 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 9 | |
| 11 | -import java.util.List; | |
| 12 | - | |
| 13 | 10 | /** |
| 14 | 11 | * 文章分类 Mapper |
| 15 | 12 | * |
| ... | ... | @@ -26,12 +23,4 @@ public interface ArticleCategoryMapper extends BaseMapperX<ArticleCategoryDO> { |
| 26 | 23 | .orderByDesc(ArticleCategoryDO::getSort)); |
| 27 | 24 | } |
| 28 | 25 | |
| 29 | - default List<ArticleCategoryDO> selectList(ArticleCategoryExportReqVO reqVO) { | |
| 30 | - return selectList(new LambdaQueryWrapperX<ArticleCategoryDO>() | |
| 31 | - .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName()) | |
| 32 | - .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus()) | |
| 33 | - .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime()) | |
| 34 | - .orderByDesc(ArticleCategoryDO::getSort)); | |
| 35 | - } | |
| 36 | - | |
| 37 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java
| ... | ... | @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.article; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 10 | |
| ... | ... | @@ -31,17 +31,16 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> { |
| 31 | 31 | .orderByDesc(ArticleDO::getId)); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - default List<ArticleDO> selectList(ArticleExportReqVO reqVO) { | |
| 34 | + default List<ArticleDO> selectList(Boolean recommendHot, Boolean recommendBanner) { | |
| 35 | 35 | return selectList(new LambdaQueryWrapperX<ArticleDO>() |
| 36 | - .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) | |
| 37 | - .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) | |
| 38 | - .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) | |
| 39 | - .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) | |
| 40 | - .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) | |
| 41 | - .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) | |
| 42 | - .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) | |
| 43 | - .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) | |
| 44 | - .orderByDesc(ArticleDO::getId)); | |
| 36 | + .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) | |
| 37 | + .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); | |
| 45 | 38 | } |
| 46 | 39 | |
| 40 | + default PageResult<ArticleDO> selectPage(AppArticlePageReqVO pageReqVO) { | |
| 41 | + return selectPage(pageReqVO, new LambdaQueryWrapperX<ArticleDO>() | |
| 42 | + .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); | |
| 43 | + } | |
| 44 | + | |
| 45 | + | |
| 47 | 46 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| ... | ... | @@ -99,10 +99,10 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 99 | 99 | LambdaQueryWrapperX<CombinationRecordDO> queryWrapper = new LambdaQueryWrapperX<CombinationRecordDO>() |
| 100 | 100 | .eqIfPresent(CombinationRecordDO::getStatus, pageVO.getStatus()) |
| 101 | 101 | .betweenIfPresent(CombinationRecordDO::getCreateTime, pageVO.getCreateTime()); |
| 102 | + // 如果 headId 非空,说明查询指定团的团长 + 团员的拼团记录 | |
| 102 | 103 | if (pageVO.getHeadId() != null) { |
| 103 | - queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) | |
| 104 | - .or() | |
| 105 | - .eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); | |
| 104 | + queryWrapper.eq(CombinationRecordDO::getId, pageVO.getHeadId()) // 团长 | |
| 105 | + .or().eq(CombinationRecordDO::getHeadId, pageVO.getHeadId()); // 团员 | |
| 106 | 106 | } |
| 107 | 107 | return selectPage(pageVO, queryWrapper); |
| 108 | 108 | } |
| ... | ... | @@ -127,10 +127,9 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 127 | 127 | * |
| 128 | 128 | * @return 参加过拼团的用户数 |
| 129 | 129 | */ |
| 130 | - default Long selectUserDistinctCount() { | |
| 130 | + default Long selectUserCount() { | |
| 131 | 131 | return selectCount(new QueryWrapper<CombinationRecordDO>() |
| 132 | - .select("DISTINCT (user_id)") | |
| 133 | - .groupBy("user_id")); | |
| 132 | + .select("DISTINCT (user_id)")); | |
| 134 | 133 | } |
| 135 | 134 | |
| 136 | 135 | default List<CombinationRecordDO> selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) { |
| ... | ... | @@ -140,8 +139,8 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 140 | 139 | .lt(CombinationRecordDO::getExpireTime, dateTime)); |
| 141 | 140 | } |
| 142 | 141 | |
| 143 | - default List<CombinationRecordDO> selectListByHeadIds(Collection<Long> headIds) { | |
| 144 | - return selectList(new LambdaQueryWrapperX<CombinationRecordDO>().in(CombinationRecordDO::getHeadId, headIds)); | |
| 142 | + default List<CombinationRecordDO> selectListByHeadId(Long headId) { | |
| 143 | + return selectList(new LambdaQueryWrapperX<CombinationRecordDO>().eq(CombinationRecordDO::getHeadId, headId)); | |
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryService.java
| ... | ... | @@ -2,13 +2,11 @@ package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| 9 | 8 | |
| 10 | 9 | import javax.validation.Valid; |
| 11 | -import java.util.Collection; | |
| 12 | 10 | import java.util.List; |
| 13 | 11 | |
| 14 | 12 | /** |
| ... | ... | @@ -49,14 +47,6 @@ public interface ArticleCategoryService { |
| 49 | 47 | ArticleCategoryDO getArticleCategory(Long id); |
| 50 | 48 | |
| 51 | 49 | /** |
| 52 | - * 获得文章分类列表 | |
| 53 | - * | |
| 54 | - * @param ids 编号 | |
| 55 | - * @return 文章分类列表 | |
| 56 | - */ | |
| 57 | - List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids); | |
| 58 | - | |
| 59 | - /** | |
| 60 | 50 | * 获得文章分类分页 |
| 61 | 51 | * |
| 62 | 52 | * @param pageReqVO 分页查询 |
| ... | ... | @@ -65,14 +55,6 @@ public interface ArticleCategoryService { |
| 65 | 55 | PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO); |
| 66 | 56 | |
| 67 | 57 | /** |
| 68 | - * 获得文章分类列表, 用于 Excel 导出 | |
| 69 | - * | |
| 70 | - * @param exportReqVO 查询条件 | |
| 71 | - * @return 文章分类列表 | |
| 72 | - */ | |
| 73 | - List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO); | |
| 74 | - | |
| 75 | - /** | |
| 76 | 58 | * 获得指定状态的文章分类列表 |
| 77 | 59 | * |
| 78 | 60 | * @param status 状态 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.hutool.core.collection.ListUtil; | |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | |
| 8 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 9 | 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 10 | 8 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; |
| 11 | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | |
| 12 | 11 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; |
| 13 | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | import org.springframework.validation.annotation.Validated; |
| 15 | 14 | |
| 16 | 15 | import javax.annotation.Resource; |
| 17 | -import java.util.Collection; | |
| 18 | 16 | import java.util.List; |
| 19 | 17 | |
| 20 | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES; | |
| 21 | 20 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; |
| 22 | 21 | |
| 23 | 22 | /** |
| ... | ... | @@ -31,14 +30,16 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { |
| 31 | 30 | |
| 32 | 31 | @Resource |
| 33 | 32 | private ArticleCategoryMapper articleCategoryMapper; |
| 33 | + @Resource | |
| 34 | + private ArticleService articleService; | |
| 34 | 35 | |
| 35 | 36 | @Override |
| 36 | 37 | public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { |
| 37 | 38 | // 插入 |
| 38 | - ArticleCategoryDO articleCategory = ArticleCategoryConvert.INSTANCE.convert(createReqVO); | |
| 39 | - articleCategoryMapper.insert(articleCategory); | |
| 39 | + ArticleCategoryDO category = ArticleCategoryConvert.INSTANCE.convert(createReqVO); | |
| 40 | + articleCategoryMapper.insert(category); | |
| 40 | 41 | // 返回 |
| 41 | - return articleCategory.getId(); | |
| 42 | + return category.getId(); | |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | @Override |
| ... | ... | @@ -54,6 +55,12 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { |
| 54 | 55 | public void deleteArticleCategory(Long id) { |
| 55 | 56 | // 校验存在 |
| 56 | 57 | validateArticleCategoryExists(id); |
| 58 | + // 校验是不是存在关联文章 | |
| 59 | + List<ArticleDO> articleList = articleService.getArticleByCategoryId(id); | |
| 60 | + if (CollUtil.isNotEmpty(articleList)) { | |
| 61 | + throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES); | |
| 62 | + } | |
| 63 | + | |
| 57 | 64 | // 删除 |
| 58 | 65 | articleCategoryMapper.deleteById(id); |
| 59 | 66 | } |
| ... | ... | @@ -70,24 +77,11 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { |
| 70 | 77 | } |
| 71 | 78 | |
| 72 | 79 | @Override |
| 73 | - public List<ArticleCategoryDO> getArticleCategoryList(Collection<Long> ids) { | |
| 74 | - if (CollUtil.isEmpty(ids)) { | |
| 75 | - return ListUtil.empty(); | |
| 76 | - } | |
| 77 | - return articleCategoryMapper.selectBatchIds(ids); | |
| 78 | - } | |
| 79 | - | |
| 80 | - @Override | |
| 81 | 80 | public PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { |
| 82 | 81 | return articleCategoryMapper.selectPage(pageReqVO); |
| 83 | 82 | } |
| 84 | 83 | |
| 85 | 84 | @Override |
| 86 | - public List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO) { | |
| 87 | - return articleCategoryMapper.selectList(exportReqVO); | |
| 88 | - } | |
| 89 | - | |
| 90 | - @Override | |
| 91 | 85 | public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { |
| 92 | 86 | return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); |
| 93 | 87 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 9 | 9 | |
| 10 | 10 | import javax.validation.Valid; |
| 11 | -import java.util.Collection; | |
| 12 | 11 | import java.util.List; |
| 13 | 12 | |
| 14 | 13 | /** |
| 15 | - * 文章管理 Service 接口 | |
| 14 | + * 文章详情 Service 接口 | |
| 16 | 15 | * |
| 17 | 16 | * @author HUIHUI |
| 18 | 17 | */ |
| 19 | 18 | public interface ArticleService { |
| 20 | 19 | |
| 21 | 20 | /** |
| 22 | - * 创建文章管理 | |
| 21 | + * 创建文章详情 | |
| 23 | 22 | * |
| 24 | 23 | * @param createReqVO 创建信息 |
| 25 | 24 | * @return 编号 |
| ... | ... | @@ -27,49 +26,58 @@ public interface ArticleService { |
| 27 | 26 | Long createArticle(@Valid ArticleCreateReqVO createReqVO); |
| 28 | 27 | |
| 29 | 28 | /** |
| 30 | - * 更新文章管理 | |
| 29 | + * 更新文章详情 | |
| 31 | 30 | * |
| 32 | 31 | * @param updateReqVO 更新信息 |
| 33 | 32 | */ |
| 34 | 33 | void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); |
| 35 | 34 | |
| 36 | 35 | /** |
| 37 | - * 删除文章管理 | |
| 36 | + * 删除文章详情 | |
| 38 | 37 | * |
| 39 | 38 | * @param id 编号 |
| 40 | 39 | */ |
| 41 | 40 | void deleteArticle(Long id); |
| 42 | 41 | |
| 43 | 42 | /** |
| 44 | - * 获得文章管理 | |
| 43 | + * 获得文章详情 | |
| 45 | 44 | * |
| 46 | 45 | * @param id 编号 |
| 47 | - * @return 文章管理 | |
| 46 | + * @return 文章详情 | |
| 48 | 47 | */ |
| 49 | 48 | ArticleDO getArticle(Long id); |
| 50 | 49 | |
| 51 | 50 | /** |
| 52 | - * 获得文章管理列表 | |
| 51 | + * 获得文章详情分页 | |
| 53 | 52 | * |
| 54 | - * @param ids 编号 | |
| 55 | - * @return 文章管理列表 | |
| 53 | + * @param pageReqVO 分页查询 | |
| 54 | + * @return 文章详情分页 | |
| 56 | 55 | */ |
| 57 | - List<ArticleDO> getArticleList(Collection<Long> ids); | |
| 56 | + PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); | |
| 58 | 57 | |
| 59 | 58 | /** |
| 60 | - * 获得文章管理分页 | |
| 59 | + * 获得文章详情列表 | |
| 60 | + * | |
| 61 | + * @param recommendHot 是否热门 | |
| 62 | + * @param recommendBanner 是否轮播图 | |
| 63 | + * @return 文章详情列表 | |
| 64 | + */ | |
| 65 | + List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 获得文章详情分页 | |
| 61 | 69 | * |
| 62 | 70 | * @param pageReqVO 分页查询 |
| 63 | - * @return 文章管理分页 | |
| 71 | + * @return 文章详情分页 | |
| 64 | 72 | */ |
| 65 | - PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); | |
| 73 | + PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO); | |
| 66 | 74 | |
| 67 | 75 | /** |
| 68 | - * 获得文章管理列表, 用于 Excel 导出 | |
| 76 | + * 获得指定分类的文章列表 | |
| 69 | 77 | * |
| 70 | - * @param exportReqVO 查询条件 | |
| 71 | - * @return 文章管理列表 | |
| 78 | + * @param categoryId 文章分类编号 | |
| 79 | + * @return 文章列表 | |
| 72 | 80 | */ |
| 73 | - List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO); | |
| 81 | + List<ArticleDO> getArticleByCategoryId(Long categoryId); | |
| 74 | 82 | |
| 75 | 83 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import cn.hutool.core.collection.ListUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | |
| 9 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | |
| 10 | 8 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; |
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; | |
| 11 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 12 | 11 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; |
| 13 | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | import org.springframework.validation.annotation.Validated; |
| 15 | 14 | |
| 16 | 15 | import javax.annotation.Resource; |
| 17 | -import java.util.Collection; | |
| 18 | 16 | import java.util.List; |
| 19 | 17 | |
| 20 | 18 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 19 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; | |
| 21 | 20 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; |
| 22 | 21 | |
| 23 | 22 | /** |
| ... | ... | @@ -31,9 +30,14 @@ public class ArticleServiceImpl implements ArticleService { |
| 31 | 30 | |
| 32 | 31 | @Resource |
| 33 | 32 | private ArticleMapper articleMapper; |
| 33 | + @Resource | |
| 34 | + private ArticleCategoryService articleCategoryService; | |
| 34 | 35 | |
| 35 | 36 | @Override |
| 36 | 37 | public Long createArticle(ArticleCreateReqVO createReqVO) { |
| 38 | + // 校验分类存在 | |
| 39 | + validateArticleCategoryExists(createReqVO.getCategoryId()); | |
| 40 | + | |
| 37 | 41 | // 插入 |
| 38 | 42 | ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); |
| 39 | 43 | articleMapper.insert(article); |
| ... | ... | @@ -45,6 +49,9 @@ public class ArticleServiceImpl implements ArticleService { |
| 45 | 49 | public void updateArticle(ArticleUpdateReqVO updateReqVO) { |
| 46 | 50 | // 校验存在 |
| 47 | 51 | validateArticleExists(updateReqVO.getId()); |
| 52 | + // 校验分类存在 | |
| 53 | + validateArticleCategoryExists(updateReqVO.getCategoryId()); | |
| 54 | + | |
| 48 | 55 | // 更新 |
| 49 | 56 | ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); |
| 50 | 57 | articleMapper.updateById(updateObj); |
| ... | ... | @@ -64,27 +71,36 @@ public class ArticleServiceImpl implements ArticleService { |
| 64 | 71 | } |
| 65 | 72 | } |
| 66 | 73 | |
| 74 | + private void validateArticleCategoryExists(Long categoryId) { | |
| 75 | + ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(categoryId); | |
| 76 | + if (articleCategory == null) { | |
| 77 | + throw exception(ARTICLE_CATEGORY_NOT_EXISTS); | |
| 78 | + } | |
| 79 | + } | |
| 80 | + | |
| 67 | 81 | @Override |
| 68 | 82 | public ArticleDO getArticle(Long id) { |
| 69 | 83 | return articleMapper.selectById(id); |
| 70 | 84 | } |
| 71 | 85 | |
| 72 | 86 | @Override |
| 73 | - public List<ArticleDO> getArticleList(Collection<Long> ids) { | |
| 74 | - if (CollUtil.isEmpty(ids)) { | |
| 75 | - return ListUtil.empty(); | |
| 76 | - } | |
| 77 | - return articleMapper.selectBatchIds(ids); | |
| 87 | + public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) { | |
| 88 | + return articleMapper.selectPage(pageReqVO); | |
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | @Override |
| 81 | - public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) { | |
| 92 | + public List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner) { | |
| 93 | + return articleMapper.selectList(recommendHot, recommendBanner); | |
| 94 | + } | |
| 95 | + | |
| 96 | + @Override | |
| 97 | + public PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO) { | |
| 82 | 98 | return articleMapper.selectPage(pageReqVO); |
| 83 | 99 | } |
| 84 | 100 | |
| 85 | 101 | @Override |
| 86 | - public List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO) { | |
| 87 | - return articleMapper.selectList(exportReqVO); | |
| 102 | + public List<ArticleDO> getArticleByCategoryId(Long categoryId) { | |
| 103 | + return articleMapper.selectList(ArticleDO::getCategoryId, categoryId); | |
| 88 | 104 | } |
| 89 | 105 | |
| 90 | 106 | } | ... | ... |
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 { |
| 247 | 247 | |
| 248 | 248 | @Override |
| 249 | 249 | public Long getCombinationUserCount() { |
| 250 | - return combinationRecordMapper.selectUserDistinctCount(); | |
| 250 | + return combinationRecordMapper.selectUserCount(); | |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | @Override |
| ... | ... | @@ -339,59 +339,58 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 339 | 339 | |
| 340 | 340 | @Override |
| 341 | 341 | public KeyValue<Integer, Integer> expireCombinationRecord() { |
| 342 | - // 1.获取所有正在进行中的过期的父拼团 | |
| 342 | + // 1. 获取所有正在进行中的过期的父拼团 | |
| 343 | 343 | List<CombinationRecordDO> headExpireRecords = combinationRecordMapper.selectListByHeadIdAndStatusAndExpireTimeLt( |
| 344 | 344 | CombinationRecordDO.HEAD_ID_GROUP, CombinationRecordStatusEnum.IN_PROGRESS.getStatus(), LocalDateTime.now()); |
| 345 | 345 | if (CollUtil.isEmpty(headExpireRecords)) { |
| 346 | 346 | return new KeyValue<>(0, 0); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - // 2.获取拼团活动 | |
| 349 | + // 2. 获取拼团活动 | |
| 350 | 350 | List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds( |
| 351 | 351 | convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); |
| 352 | 352 | Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); |
| 353 | 353 | |
| 354 | - // 3.校验是否虚拟成团 | |
| 355 | - List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 | |
| 356 | - for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { | |
| 357 | - CombinationRecordDO record = iterator.next(); | |
| 358 | - // 3.1.不匹配,则直接跳过 | |
| 359 | - CombinationActivityDO activity = activityMap.get(record.getActivityId()); | |
| 360 | - if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 | |
| 361 | - continue; | |
| 354 | + // 3. 改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务; | |
| 355 | + KeyValue<Integer, Integer> keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团 | |
| 356 | + for (CombinationRecordDO recordDO : headExpireRecords) { | |
| 357 | + try { | |
| 358 | + CombinationActivityDO activity = activityMap.get(recordDO.getActivityId()); | |
| 359 | + if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 | |
| 360 | + // 3.1. 处理过期的拼团 | |
| 361 | + getSelf().handleExpireRecord(recordDO); | |
| 362 | + keyValue.setKey(keyValue.getKey() + 1); | |
| 363 | + } else { | |
| 364 | + // 3.2. 处理虚拟成团 | |
| 365 | + getSelf().handleVirtualGroupRecord(recordDO); | |
| 366 | + keyValue.setValue(keyValue.getValue() + 1); | |
| 367 | + } | |
| 368 | + } catch (Exception ignored) { // 处理异常继续循环 | |
| 362 | 369 | } |
| 363 | - // 3.2.匹配,则移除,添加到虚拟成团中,并结束寻找 | |
| 364 | - virtualGroupHeadRecords.add(record); | |
| 365 | - iterator.remove(); | |
| 366 | - break; | |
| 367 | 370 | } |
| 368 | 371 | |
| 369 | - // 4.处理过期的拼团 | |
| 370 | - getSelf().handleExpireRecord(headExpireRecords); | |
| 371 | - // 5.虚拟成团 | |
| 372 | - getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords); | |
| 373 | - return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size()); | |
| 372 | + return keyValue; | |
| 374 | 373 | } |
| 375 | 374 | |
| 376 | 375 | /** |
| 377 | 376 | * 处理过期拼团 |
| 378 | 377 | * |
| 379 | - * @param headExpireRecords 过期拼团团长记录列表 | |
| 378 | + * @param headExpireRecord 过期拼团团长记录列表 | |
| 380 | 379 | */ |
| 381 | 380 | @Transactional(rollbackFor = Exception.class) |
| 382 | - public void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) { | |
| 383 | - if (CollUtil.isEmpty(headExpireRecords)) { | |
| 381 | + public void handleExpireRecord(CombinationRecordDO headExpireRecord) { | |
| 382 | + if (headExpireRecord == null) { | |
| 384 | 383 | return; |
| 385 | 384 | } |
| 386 | 385 | |
| 387 | 386 | // 1.更新拼团记录 |
| 388 | - List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecords, | |
| 387 | + List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecord, | |
| 389 | 388 | CombinationRecordStatusEnum.FAILED); |
| 390 | 389 | if (headsAndRecords == null) { |
| 391 | 390 | return; |
| 392 | 391 | } |
| 393 | 392 | |
| 394 | - // 2.订单取消 TODO 以现在的取消回滚逻辑好像只能循环了 | |
| 393 | + // 2.订单取消 | |
| 395 | 394 | headsAndRecords.forEach(item -> { |
| 396 | 395 | tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()); |
| 397 | 396 | }); |
| ... | ... | @@ -400,36 +399,32 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 400 | 399 | /** |
| 401 | 400 | * 处理虚拟拼团 |
| 402 | 401 | * |
| 403 | - * @param virtualGroupHeadRecords 虚拟成团团长记录列表 | |
| 402 | + * @param virtualGroupHeadRecord 虚拟成团团长记录列表 | |
| 404 | 403 | */ |
| 405 | 404 | @Transactional(rollbackFor = Exception.class) |
| 406 | - public void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) { | |
| 407 | - if (CollUtil.isEmpty(virtualGroupHeadRecords)) { | |
| 405 | + public void handleVirtualGroupRecord(CombinationRecordDO virtualGroupHeadRecord) { | |
| 406 | + if (virtualGroupHeadRecord == null) { | |
| 408 | 407 | return; |
| 409 | 408 | } |
| 410 | 409 | |
| 411 | 410 | // 1. 团员补齐 |
| 412 | - combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords)); | |
| 411 | + combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecord)); | |
| 413 | 412 | // 2. 更新拼团记录 |
| 414 | - updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS); | |
| 413 | + updateBatchCombinationRecords(virtualGroupHeadRecord, CombinationRecordStatusEnum.SUCCESS); | |
| 415 | 414 | } |
| 416 | 415 | |
| 417 | - private List<CombinationRecordDO> updateBatchCombinationRecords(List<CombinationRecordDO> headRecords, CombinationRecordStatusEnum status) { | |
| 418 | - // 1. 查询团成员 | |
| 419 | - List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadIds( | |
| 420 | - convertSet(headRecords, CombinationRecordDO::getId)); | |
| 416 | + private List<CombinationRecordDO> updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) { | |
| 417 | + // 1. 查询团成员(包含团长) | |
| 418 | + List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadId(headRecord.getId()); | |
| 421 | 419 | if (CollUtil.isEmpty(records)) { |
| 422 | 420 | return null; |
| 423 | 421 | } |
| 424 | - Map<Long, List<CombinationRecordDO>> recordsMap = convertMultiMap(records, CombinationRecordDO::getHeadId); | |
| 425 | - headRecords.forEach(item -> { | |
| 426 | - recordsMap.get(item.getId()).add(item); // 把团长加进团里 | |
| 427 | - }); | |
| 422 | + records.add(headRecord);// 把团长加进去 | |
| 423 | + | |
| 428 | 424 | // 2.批量更新拼团记录 status 和 失败/成团时间 |
| 429 | - List<CombinationRecordDO> headsAndRecords = mergeValuesFromMap(recordsMap); | |
| 430 | - List<CombinationRecordDO> updateRecords = new ArrayList<>(headsAndRecords.size()); | |
| 425 | + List<CombinationRecordDO> updateRecords = new ArrayList<>(records.size()); | |
| 431 | 426 | LocalDateTime now = LocalDateTime.now(); |
| 432 | - headsAndRecords.forEach(item -> { | |
| 427 | + records.forEach(item -> { | |
| 433 | 428 | CombinationRecordDO record = new CombinationRecordDO().setId(item.getId()) |
| 434 | 429 | .setStatus(status.getStatus()).setEndTime(now); |
| 435 | 430 | if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 |
| ... | ... | @@ -438,7 +433,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 438 | 433 | updateRecords.add(record); |
| 439 | 434 | }); |
| 440 | 435 | combinationRecordMapper.updateBatch(updateRecords); |
| 441 | - return headsAndRecords; | |
| 436 | + return records; | |
| 442 | 437 | } |
| 443 | 438 | |
| 444 | 439 | /** | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleCategoryServiceImplTest.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.article; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryExportReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 9 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO; |
| ... | ... | @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test; |
| 13 | 12 | import org.springframework.context.annotation.Import; |
| 14 | 13 | |
| 15 | 14 | import javax.annotation.Resource; |
| 16 | -import java.util.List; | |
| 17 | 15 | |
| 18 | 16 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; |
| 19 | 17 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| ... | ... | @@ -24,6 +22,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 24 | 22 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS; |
| 25 | 23 | import static org.junit.jupiter.api.Assertions.*; |
| 26 | 24 | |
| 25 | +// TODO 芋艿:review 单测 | |
| 27 | 26 | /** |
| 28 | 27 | * {@link ArticleCategoryServiceImpl} 的单元测试类 |
| 29 | 28 | * |
| ... | ... | @@ -137,39 +136,4 @@ public class ArticleCategoryServiceImplTest extends BaseDbUnitTest { |
| 137 | 136 | assertPojoEquals(dbArticleCategory, pageResult.getList().get(0)); |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | - @Test | |
| 141 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 142 | - public void testGetArticleCategoryList() { | |
| 143 | - // mock 数据 | |
| 144 | - ArticleCategoryDO dbArticleCategory = randomPojo(ArticleCategoryDO.class, o -> { // 等会查询到 | |
| 145 | - o.setName(null); | |
| 146 | - o.setPicUrl(null); | |
| 147 | - o.setStatus(null); | |
| 148 | - o.setSort(null); | |
| 149 | - o.setCreateTime(null); | |
| 150 | - }); | |
| 151 | - articleCategoryMapper.insert(dbArticleCategory); | |
| 152 | - // 测试 name 不匹配 | |
| 153 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setName(null))); | |
| 154 | - // 测试 picUrl 不匹配 | |
| 155 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setPicUrl(null))); | |
| 156 | - // 测试 status 不匹配 | |
| 157 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setStatus(null))); | |
| 158 | - // 测试 sort 不匹配 | |
| 159 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setSort(null))); | |
| 160 | - // 测试 createTime 不匹配 | |
| 161 | - articleCategoryMapper.insert(cloneIgnoreId(dbArticleCategory, o -> o.setCreateTime(null))); | |
| 162 | - // 准备参数 | |
| 163 | - ArticleCategoryExportReqVO reqVO = new ArticleCategoryExportReqVO(); | |
| 164 | - reqVO.setName(null); | |
| 165 | - reqVO.setStatus(null); | |
| 166 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 167 | - | |
| 168 | - // 调用 | |
| 169 | - List<ArticleCategoryDO> list = articleCategoryService.getArticleCategoryList(reqVO); | |
| 170 | - // 断言 | |
| 171 | - assertEquals(1, list.size()); | |
| 172 | - assertPojoEquals(dbArticleCategory, list.get(0)); | |
| 173 | - } | |
| 174 | - | |
| 175 | 139 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java
| ... | ... | @@ -2,10 +2,9 @@ package cn.iocoder.yudao.module.promotion.service.article; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticlePageReqVO; | |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleUpdateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; | |
| 9 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | 9 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; |
| 11 | 10 | import org.junit.jupiter.api.Disabled; |
| ... | ... | @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test; |
| 13 | 12 | import org.springframework.context.annotation.Import; |
| 14 | 13 | |
| 15 | 14 | import javax.annotation.Resource; |
| 16 | -import java.util.List; | |
| 17 | 15 | |
| 18 | 16 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; |
| 19 | 17 | import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; |
| ... | ... | @@ -166,68 +164,4 @@ public class ArticleServiceImplTest extends BaseDbUnitTest { |
| 166 | 164 | assertPojoEquals(dbArticle, pageResult.getList().get(0)); |
| 167 | 165 | } |
| 168 | 166 | |
| 169 | - @Test | |
| 170 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 171 | - public void testGetArticleList() { | |
| 172 | - // mock 数据 | |
| 173 | - ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到 | |
| 174 | - o.setCategoryId(null); | |
| 175 | - o.setTitle(null); | |
| 176 | - o.setAuthor(null); | |
| 177 | - o.setPicUrl(null); | |
| 178 | - o.setIntroduction(null); | |
| 179 | - o.setBrowseCount(null); | |
| 180 | - o.setSort(null); | |
| 181 | - o.setStatus(null); | |
| 182 | - o.setSpuId(null); | |
| 183 | - o.setRecommendHot(null); | |
| 184 | - o.setRecommendBanner(null); | |
| 185 | - o.setContent(null); | |
| 186 | - o.setCreateTime(null); | |
| 187 | - }); | |
| 188 | - articleMapper.insert(dbArticle); | |
| 189 | - // 测试 categoryId 不匹配 | |
| 190 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null))); | |
| 191 | - // 测试 title 不匹配 | |
| 192 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null))); | |
| 193 | - // 测试 author 不匹配 | |
| 194 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null))); | |
| 195 | - // 测试 picUrl 不匹配 | |
| 196 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null))); | |
| 197 | - // 测试 introduction 不匹配 | |
| 198 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null))); | |
| 199 | - // 测试 browseCount 不匹配 | |
| 200 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null))); | |
| 201 | - // 测试 sort 不匹配 | |
| 202 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null))); | |
| 203 | - // 测试 status 不匹配 | |
| 204 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null))); | |
| 205 | - // 测试 spuId 不匹配 | |
| 206 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null))); | |
| 207 | - // 测试 recommendHot 不匹配 | |
| 208 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null))); | |
| 209 | - // 测试 recommendBanner 不匹配 | |
| 210 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null))); | |
| 211 | - // 测试 content 不匹配 | |
| 212 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null))); | |
| 213 | - // 测试 createTime 不匹配 | |
| 214 | - articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null))); | |
| 215 | - // 准备参数 | |
| 216 | - ArticleExportReqVO reqVO = new ArticleExportReqVO(); | |
| 217 | - reqVO.setCategoryId(null); | |
| 218 | - reqVO.setTitle(null); | |
| 219 | - reqVO.setAuthor(null); | |
| 220 | - reqVO.setStatus(null); | |
| 221 | - reqVO.setSpuId(null); | |
| 222 | - reqVO.setRecommendHot(null); | |
| 223 | - reqVO.setRecommendBanner(null); | |
| 224 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 225 | - | |
| 226 | - // 调用 | |
| 227 | - List<ArticleDO> list = articleService.getArticleList(reqVO); | |
| 228 | - // 断言 | |
| 229 | - assertEquals(1, list.size()); | |
| 230 | - assertPojoEquals(dbArticle, list.get(0)); | |
| 231 | - } | |
| 232 | - | |
| 233 | 167 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-api/src/main/java/cn/iocoder/yudao/module/statistics/enums/TimeRangeTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.enums; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 时间范围类型的枚举 | |
| 11 | + * | |
| 12 | + * @author owen | |
| 13 | + */ | |
| 14 | +@AllArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum TimeRangeTypeEnum implements IntArrayValuable { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 天 | |
| 20 | + */ | |
| 21 | + DAY(1), | |
| 22 | + /** | |
| 23 | + * 周 | |
| 24 | + */ | |
| 25 | + WEEK(7), | |
| 26 | + /** | |
| 27 | + * 月 | |
| 28 | + */ | |
| 29 | + MONTH(30), | |
| 30 | + /** | |
| 31 | + * 年 | |
| 32 | + */ | |
| 33 | + YEAR(365), | |
| 34 | + ; | |
| 35 | + | |
| 36 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TimeRangeTypeEnum::getType).toArray(); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 类型 | |
| 40 | + */ | |
| 41 | + private final Integer type; | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public int[] array() { | |
| 45 | + return ARRAYS; | |
| 46 | + } | |
| 47 | + | |
| 48 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeStatisticsComparisonRespVO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/common/vo/DataComparisonRespVO.java
| 1 | -package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | |
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.common.vo; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.AllArgsConstructor; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | import lombok.NoArgsConstructor; |
| 7 | 7 | |
| 8 | -// TODO @疯狂:是不是搞成公用的哈;类似,controller/admin/common,下面直接放它 | |
| 9 | -@Schema(description = "管理后台 - 交易统计对照 Response VO") | |
| 8 | +@Schema(description = "管理后台 - 数据对照 Response VO") | |
| 10 | 9 | @Data |
| 11 | 10 | @NoArgsConstructor |
| 12 | 11 | @AllArgsConstructor |
| 13 | -public class TradeStatisticsComparisonRespVO<T> { | |
| 12 | +public class DataComparisonRespVO<T> { | |
| 14 | 13 | |
| 15 | 14 | @Schema(description = "当前数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | 15 | private T value; | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/MemberStatisticsController.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.controller.admin.member; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | |
| 4 | +import cn.hutool.core.util.NumberUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 6 | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; |
| 9 | +import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; | |
| 10 | +import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; | |
| 7 | 11 | import cn.iocoder.yudao.module.statistics.service.member.MemberStatisticsService; |
| 12 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; | |
| 8 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 10 | 15 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -15,10 +20,10 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 15 | 20 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 21 | |
| 17 | 22 | import javax.annotation.Resource; |
| 23 | +import java.time.LocalDateTime; | |
| 18 | 24 | import java.util.List; |
| 19 | 25 | |
| 20 | 26 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 21 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 22 | 27 | |
| 23 | 28 | @Tag(name = "管理后台 - 会员统计") |
| 24 | 29 | @RestController |
| ... | ... | @@ -29,6 +34,10 @@ public class MemberStatisticsController { |
| 29 | 34 | |
| 30 | 35 | @Resource |
| 31 | 36 | private MemberStatisticsService memberStatisticsService; |
| 37 | + @Resource | |
| 38 | + private TradeOrderStatisticsService tradeOrderStatisticsService; | |
| 39 | + @Resource | |
| 40 | + private ApiAccessLogStatisticsService apiAccessLogStatisticsService; | |
| 32 | 41 | |
| 33 | 42 | // TODO 芋艿:已经 review |
| 34 | 43 | @GetMapping("/summary") |
| ... | ... | @@ -43,11 +52,32 @@ public class MemberStatisticsController { |
| 43 | 52 | @Operation(summary = "获得会员分析数据") |
| 44 | 53 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| 45 | 54 | public CommonResult<MemberAnalyseRespVO> getMemberAnalyse(MemberAnalyseReqVO reqVO) { |
| 46 | - return success(memberStatisticsService.getMemberAnalyse( | |
| 47 | - ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); | |
| 55 | + // 1. 查询数据 | |
| 56 | + LocalDateTime beginTime = ArrayUtil.get(reqVO.getTimes(), 0); | |
| 57 | + LocalDateTime endTime = ArrayUtil.get(reqVO.getTimes(), 1); | |
| 58 | + // 1.1 查询分析对照数据 | |
| 59 | + DataComparisonRespVO<MemberAnalyseDataRespVO> comparisonData = memberStatisticsService.getMemberAnalyseComparisonData(beginTime, endTime); | |
| 60 | + // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; | |
| 61 | + // 1.2 查询成交用户数量 | |
| 62 | + Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); | |
| 63 | + // 1.3 计算客单价 | |
| 64 | + int atv = 0; | |
| 65 | + if (payUserCount != null && payUserCount > 0) { | |
| 66 | + // TODO @疯狂:类似上面的 payUserCount | |
| 67 | + Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); | |
| 68 | + atv = NumberUtil.div(payPrice, payUserCount).intValue(); | |
| 69 | + } | |
| 70 | + // 1.4 查询访客数量 | |
| 71 | + Integer visitUserCount = apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime); | |
| 72 | + // 1.5 下单用户数量 | |
| 73 | + Integer orderUserCount = tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime); | |
| 74 | + | |
| 75 | + // 2. 拼接返回 | |
| 76 | + return success(MemberStatisticsConvert.INSTANCE.convert(visitUserCount, orderUserCount, payUserCount, atv, comparisonData)); | |
| 48 | 77 | } |
| 49 | 78 | |
| 50 | 79 | // TODO 芋艿:已经 review |
| 80 | + // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 | |
| 51 | 81 | @GetMapping("/get-area-statistics-list") |
| 52 | 82 | @Operation(summary = "按照省份,获得会员统计列表") |
| 53 | 83 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| ... | ... | @@ -56,6 +86,7 @@ public class MemberStatisticsController { |
| 56 | 86 | } |
| 57 | 87 | |
| 58 | 88 | // TODO 芋艿:已经 review |
| 89 | + // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 | |
| 59 | 90 | @GetMapping("/get-sex-statistics-list") |
| 60 | 91 | @Operation(summary = "按照性别,获得会员统计列表") |
| 61 | 92 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| ... | ... | @@ -63,16 +94,29 @@ public class MemberStatisticsController { |
| 63 | 94 | return success(memberStatisticsService.getMemberSexStatisticsList()); |
| 64 | 95 | } |
| 65 | 96 | |
| 97 | + // TODO 芋艿:已经 review | |
| 98 | + // TODO @疯狂:要不 get 前缀去掉,和下面的 list 接口保持一致 | |
| 66 | 99 | @GetMapping("/get-terminal-statistics-list") |
| 67 | 100 | @Operation(summary = "按照终端,获得会员统计列表") |
| 68 | 101 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| 69 | 102 | public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() { |
| 70 | - // TODO 疯狂:这个可以晚点写,因为 user = = 上还没记录 terminal | |
| 71 | - // TODO @疯狂:在 member_user 上,增加 registerTerminal 字段,基于它来统计哈; | |
| 72 | - List<MemberTerminalStatisticsRespVO> list = convertList(TerminalEnum.values(), | |
| 73 | - t -> new MemberTerminalStatisticsRespVO() | |
| 74 | - .setTerminal(t.getTerminal()).setUserCount(t.getTerminal() * 100)); | |
| 75 | - return success(list); | |
| 103 | + return success(memberStatisticsService.getRegisterTerminalStatisticsList()); | |
| 104 | + } | |
| 105 | + | |
| 106 | + @GetMapping("/user-count-comparison") | |
| 107 | + @Operation(summary = "获得用户数量对照") | |
| 108 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 109 | + public CommonResult<DataComparisonRespVO<MemberCountRespVO>> getUserCountComparison() { | |
| 110 | + return success(memberStatisticsService.getUserCountComparison()); | |
| 111 | + } | |
| 112 | + | |
| 113 | + // TODO 芋艿:已经 review | |
| 114 | + @GetMapping("/register-count-list") | |
| 115 | + @Operation(summary = "获得会员注册数量列表") | |
| 116 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 117 | + public CommonResult<List<MemberRegisterCountRespVO>> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { | |
| 118 | + return success(memberStatisticsService.getMemberRegisterCountList( | |
| 119 | + ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); | |
| 76 | 120 | } |
| 77 | 121 | |
| 78 | 122 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseComparisonRespVO.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseDataRespVO.java
| ... | ... | @@ -3,17 +3,15 @@ package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -@Schema(description = "管理后台 - 会员分析对照数据 Response VO") | |
| 6 | +@Schema(description = "管理后台 - 会员分析数据 Response VO") | |
| 7 | 7 | @Data |
| 8 | -public class MemberAnalyseComparisonRespVO { | |
| 8 | +public class MemberAnalyseDataRespVO { | |
| 9 | 9 | |
| 10 | - // TODO @疯狂:这个字段,要不改成注册用户量;registerUserCount; | |
| 11 | 10 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 12 | - private Integer userCount; | |
| 11 | + private Integer registerUserCount; | |
| 13 | 12 | |
| 14 | - // TODO @疯狂:这个字段,名字改成 visitUserCount;有访问,就算活跃; | |
| 15 | 13 | @Schema(description = "活跃用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | - private Integer activeUserCount; | |
| 14 | + private Integer visitUserCount; | |
| 17 | 15 | |
| 18 | 16 | @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") |
| 19 | 17 | private Integer rechargeUserCount; | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAnalyseRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | |
| ... | ... | @@ -8,9 +8,8 @@ import lombok.Data; |
| 8 | 8 | @Data |
| 9 | 9 | public class MemberAnalyseRespVO { |
| 10 | 10 | |
| 11 | - // TODO @疯狂:这个字段改成 visitUserCount,保持和 userCount 字段统一 | |
| 12 | 11 | @Schema(description = "访客数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 13 | - private Integer visitorCount; | |
| 12 | + private Integer visitUserCount; | |
| 14 | 13 | |
| 15 | 14 | @Schema(description = "下单用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | 15 | private Integer orderUserCount; |
| ... | ... | @@ -22,6 +21,6 @@ public class MemberAnalyseRespVO { |
| 22 | 21 | private Integer atv; |
| 23 | 22 | |
| 24 | 23 | @Schema(description = "对照数据", requiredMode = Schema.RequiredMode.REQUIRED) |
| 25 | - private TradeStatisticsComparisonRespVO<MemberAnalyseComparisonRespVO> comparison; | |
| 24 | + private DataComparisonRespVO<MemberAnalyseDataRespVO> comparison; | |
| 26 | 25 | |
| 27 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberAreaStatisticsRespVO.java
| ... | ... | @@ -15,11 +15,10 @@ public class MemberAreaStatisticsRespVO { |
| 15 | 15 | @Schema(description = "会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 16 | 16 | private Integer userCount; |
| 17 | 17 | |
| 18 | - // TODO @疯狂:要不 orderCreateUserCount 和 orderPayUserCount 貌似更统一一些; | |
| 19 | - @Schema(description = "订单创建数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 20 | - private Integer orderCreateCount; | |
| 21 | - @Schema(description = "订单支付数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | |
| 22 | - private Integer orderPayCount; | |
| 18 | + @Schema(description = "下单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 19 | + private Integer orderCreateUserCount; | |
| 20 | + @Schema(description = "支付订单的会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "512") | |
| 21 | + private Integer orderPayUserCount; | |
| 23 | 22 | |
| 24 | 23 | @Schema(description = "订单支付金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "622") |
| 25 | 24 | private Integer orderPayPrice; | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberCountRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 会员数量统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class MemberCountRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Integer visitUserCount; | |
| 12 | + | |
| 13 | + // TODO @疯狂:要不改成 registerUserCount,注册 | |
| 14 | + @Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 15 | + private Integer createUserCount; | |
| 16 | + | |
| 17 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/vo/MemberRegisterCountRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.member.vo; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.time.LocalDate; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - 会员注册数量 Response VO") | |
| 13 | +@Data | |
| 14 | +public class MemberRegisterCountRespVO { | |
| 15 | + | |
| 16 | + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT) | |
| 17 | + @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 18 | + private LocalDate date; | |
| 19 | + | |
| 20 | + @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 21 | + private Integer count; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/pay/PayStatisticsController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.pay; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | |
| 5 | +import io.swagger.v3.oas.annotations.Operation; | |
| 6 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 7 | +import lombok.extern.slf4j.Slf4j; | |
| 8 | +import org.springframework.validation.annotation.Validated; | |
| 9 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 16 | + | |
| 17 | +@Tag(name = "管理后台 - 支付统计") | |
| 18 | +@RestController | |
| 19 | +@RequestMapping("/statistics/pay") | |
| 20 | +@Validated | |
| 21 | +@Slf4j | |
| 22 | +public class PayStatisticsController { | |
| 23 | + | |
| 24 | + @Resource | |
| 25 | + private PayWalletStatisticsService payWalletStatisticsService; | |
| 26 | + | |
| 27 | + // TODO @疯狂:要不搞成 PaySummary?只是目前只有 rechargePrice 充值金额? | |
| 28 | + @GetMapping("/wallet-recharge-price") | |
| 29 | + @Operation(summary = "获取充值金额") | |
| 30 | + public CommonResult<Integer> getWalletRechargePrice() { | |
| 31 | + return success(payWalletStatisticsService.getRechargePriceSummary()); | |
| 32 | + } | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java
| ... | ... | @@ -3,9 +3,17 @@ package cn.iocoder.yudao.module.statistics.controller.admin.trade; |
| 3 | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 6 | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; |
| 7 | 8 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; |
| 9 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 10 | +import cn.iocoder.yudao.module.statistics.service.trade.AfterSaleStatisticsService; | |
| 11 | +import cn.iocoder.yudao.module.statistics.service.trade.BrokerageStatisticsService; | |
| 12 | +import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; | |
| 8 | 13 | import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; |
| 14 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | |
| 15 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; | |
| 16 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 9 | 17 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | 18 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | 19 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -17,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController; |
| 17 | 25 | |
| 18 | 26 | import javax.annotation.Resource; |
| 19 | 27 | import javax.servlet.http.HttpServletResponse; |
| 28 | +import javax.validation.Valid; | |
| 20 | 29 | import java.io.IOException; |
| 21 | 30 | import java.util.List; |
| 22 | 31 | |
| ... | ... | @@ -31,46 +40,91 @@ public class TradeStatisticsController { |
| 31 | 40 | |
| 32 | 41 | @Resource |
| 33 | 42 | private TradeStatisticsService tradeStatisticsService; |
| 43 | + @Resource | |
| 44 | + private TradeOrderStatisticsService tradeOrderStatisticsService; | |
| 45 | + @Resource | |
| 46 | + private AfterSaleStatisticsService afterSaleStatisticsService; | |
| 47 | + @Resource | |
| 48 | + private BrokerageStatisticsService brokerageStatisticsService; | |
| 34 | 49 | |
| 50 | + // TODO 芋艿:已经 review | |
| 35 | 51 | @GetMapping("/summary") |
| 36 | 52 | @Operation(summary = "获得交易统计") |
| 37 | 53 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 38 | - public CommonResult<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() { | |
| 39 | - // TODO @疯狂:这个要不要 tradeStatisticsService 调用里面的多个方法,组合出最终的 TradeSummaryRespVO; | |
| 40 | - return success(tradeStatisticsService.getTradeSummaryComparison()); | |
| 54 | + public CommonResult<DataComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() { | |
| 55 | + // 1.1 昨天的数据 | |
| 56 | + TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1); | |
| 57 | + // 1.2 前天的数据(用于对照昨天的数据) | |
| 58 | + TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2); | |
| 59 | + | |
| 60 | + // 2.1 本月数据 | |
| 61 | + TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0); | |
| 62 | + // 2.2 上月数据(用于对照本月的数据) | |
| 63 | + TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1); | |
| 64 | + // 拼接数据 | |
| 65 | + return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData)); | |
| 41 | 66 | } |
| 42 | 67 | |
| 43 | 68 | // TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse |
| 44 | 69 | @GetMapping("/trend/summary") |
| 45 | 70 | @Operation(summary = "获得交易状况统计") |
| 46 | 71 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 47 | - public CommonResult<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison( | |
| 72 | + public CommonResult<DataComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison( | |
| 48 | 73 | TradeTrendReqVO reqVO) { |
| 49 | 74 | return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0), |
| 50 | 75 | ArrayUtil.get(reqVO.getTimes(), 1))); |
| 51 | 76 | } |
| 52 | 77 | |
| 53 | 78 | // TODO 芋艿:已经 review |
| 54 | - // TODO @疯狂:这个要不直接叫 list;它即使就是把每条统计拿出来 | |
| 55 | - @GetMapping("/trend/list") | |
| 79 | + @GetMapping("/list") | |
| 56 | 80 | @Operation(summary = "获得交易状况明细") |
| 57 | 81 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 58 | - public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList( | |
| 59 | - TradeTrendReqVO reqVO) { | |
| 60 | - return success(tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 61 | - ArrayUtil.get(reqVO.getTimes(), 1))); | |
| 82 | + public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList(TradeTrendReqVO reqVO) { | |
| 83 | + List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 84 | + ArrayUtil.get(reqVO.getTimes(), 1)); | |
| 85 | + return success(TradeStatisticsConvert.INSTANCE.convertList(list)); | |
| 62 | 86 | } |
| 63 | 87 | |
| 64 | - // TODO @疯狂:这个要不直接叫 export;它即使就是把每条统计导出 | |
| 65 | - @GetMapping("/trend/export-excel") | |
| 88 | + // TODO 芋艿:已经 review | |
| 89 | + @GetMapping("/export-excel") | |
| 66 | 90 | @Operation(summary = "导出获得交易状况明细 Excel") |
| 67 | 91 | @PreAuthorize("@ss.hasPermission('statistics:trade:export')") |
| 68 | 92 | public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { |
| 69 | - List<TradeTrendSummaryRespVO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 93 | + List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 70 | 94 | ArrayUtil.get(reqVO.getTimes(), 1)); |
| 71 | 95 | // 导出 Excel |
| 72 | - List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(list); | |
| 96 | + List<TradeTrendSummaryRespVO> voList = TradeStatisticsConvert.INSTANCE.convertList(list); | |
| 97 | + List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(voList); | |
| 73 | 98 | ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); |
| 74 | 99 | } |
| 75 | 100 | |
| 101 | + // TODO 芋艿:已经 review | |
| 102 | + @GetMapping("/order-count") | |
| 103 | + @Operation(summary = "获得交易订单数量") | |
| 104 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | |
| 105 | + public CommonResult<TradeOrderCountRespVO> getOrderCount() { | |
| 106 | + // 订单统计 | |
| 107 | + TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount(); | |
| 108 | + // 售后统计 | |
| 109 | + vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY)) | |
| 110 | + .setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING)); | |
| 111 | + return success(vo); | |
| 112 | + } | |
| 113 | + | |
| 114 | + // TODO 芋艿:已经 review | |
| 115 | + @GetMapping("/order-comparison") | |
| 116 | + @Operation(summary = "获得交易订单数量") | |
| 117 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | |
| 118 | + public CommonResult<DataComparisonRespVO<TradeOrderSummaryRespVO>> getOrderComparison() { | |
| 119 | + return success(tradeOrderStatisticsService.getOrderComparison()); | |
| 120 | + } | |
| 121 | + | |
| 122 | + // TODO 芋艿:已经 review | |
| 123 | + @GetMapping("/order-count-trend") | |
| 124 | + @Operation(summary = "获得订单量趋势统计") | |
| 125 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | |
| 126 | + public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { | |
| 127 | + return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); | |
| 128 | + } | |
| 129 | + | |
| 76 | 130 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderCountRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 交易订单数量 Response VO") | |
| 7 | +@Data | |
| 8 | +public class TradeOrderCountRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "待发货", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Long undelivered; | |
| 12 | + | |
| 13 | + @Schema(description = "待核销", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Long pickUp; | |
| 15 | + | |
| 16 | + @Schema(description = "退款中", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + private Long afterSaleApply; | |
| 18 | + | |
| 19 | + @Schema(description = "提现待审核", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 20 | + private Long auditingWithdraw; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderSummaryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 交易订单统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class TradeOrderSummaryRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "支付订单商品数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Integer orderPayCount; | |
| 12 | + | |
| 13 | + @Schema(description = "总支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Integer orderPayPrice; | |
| 15 | + | |
| 16 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | +import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 交易订单量趋势统计 Request VO") | |
| 15 | +@Data | |
| 16 | +public class TradeOrderTrendReqVO { | |
| 17 | + | |
| 18 | + @Schema(description = "日期范围类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 19 | + @NotNull(message = "日期范围类型不能为空") | |
| 20 | + @InEnum(value = TimeRangeTypeEnum.class, message = "日期范围类型,必须是 {value}") | |
| 21 | + private Integer type; | |
| 22 | + | |
| 23 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 24 | + @Schema(description = "起始时间") | |
| 25 | + private LocalDateTime beginTime; | |
| 26 | + | |
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 28 | + @Schema(description = "截止时间") | |
| 29 | + private LocalDateTime endTime; | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeOrderTrendRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.controller.admin.trade.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 订单量趋势统计 Response VO") | |
| 7 | +@Data | |
| 8 | +public class TradeOrderTrendRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private String date; | |
| 12 | + | |
| 13 | + @Schema(description = "订单数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Integer orderPayCount; | |
| 15 | + | |
| 16 | + @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + private Integer orderPayPrice; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryExcelVO.java
| ... | ... | @@ -22,7 +22,7 @@ public class TradeTrendSummaryExcelVO { |
| 22 | 22 | private LocalDate date; |
| 23 | 23 | |
| 24 | 24 | @ExcelProperty(value = "营业额", converter = MoneyConvert.class) |
| 25 | - private Integer turnover; | |
| 25 | + private Integer turnoverPrice; | |
| 26 | 26 | |
| 27 | 27 | @ExcelProperty(value = "商品支付金额", converter = MoneyConvert.class) |
| 28 | 28 | private Integer orderPayPrice; |
| ... | ... | @@ -34,7 +34,7 @@ public class TradeTrendSummaryExcelVO { |
| 34 | 34 | private Integer expensePrice; |
| 35 | 35 | |
| 36 | 36 | @ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class) |
| 37 | - private Integer balancePrice; | |
| 37 | + private Integer orderWalletPayPrice; | |
| 38 | 38 | |
| 39 | 39 | @ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class) |
| 40 | 40 | private Integer brokerageSettlementPrice; | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java
| ... | ... | @@ -16,13 +16,15 @@ public class TradeTrendSummaryRespVO { |
| 16 | 16 | @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY) |
| 17 | 17 | private LocalDate date; |
| 18 | 18 | |
| 19 | - // TODO @疯狂,要不加个 turnoverPrice? | |
| 20 | 19 | @Schema(description = "营业额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 21 | - private Integer turnover; // 营业额 = 商品支付金额 + 充值金额 | |
| 20 | + private Integer turnoverPrice; // 营业额 = 商品支付金额 + 充值金额 | |
| 22 | 21 | |
| 23 | 22 | @Schema(description = "订单支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 24 | 23 | private Integer orderPayPrice; |
| 25 | 24 | |
| 25 | + @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 26 | + private Integer orderWalletPayPrice; | |
| 27 | + | |
| 26 | 28 | @Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 27 | 29 | private Integer orderRefundPrice; |
| 28 | 30 | |
| ... | ... | @@ -35,7 +37,4 @@ public class TradeTrendSummaryRespVO { |
| 35 | 37 | @Schema(description = "支出金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 36 | 38 | private Integer expensePrice; // 余额支付金额 + 支付佣金金额 + 商品退款金额 |
| 37 | 39 | |
| 38 | - @Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 39 | - private Integer balancePrice; // TODO @疯狂:这个字段要不改成:walletPayPrice | |
| 40 | - | |
| 41 | 40 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/member/MemberStatisticsConvert.java
| ... | ... | @@ -4,6 +4,9 @@ import cn.hutool.core.map.MapUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | 6 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 8 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseDataRespVO; | |
| 9 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; | |
| 7 | 10 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 8 | 11 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; |
| 9 | 12 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| ... | ... | @@ -28,16 +31,20 @@ public interface MemberStatisticsConvert { |
| 28 | 31 | Map<Integer, Integer> userCountMap, |
| 29 | 32 | Map<Integer, MemberAreaStatisticsRespVO> orderMap) { |
| 30 | 33 | return CollectionUtils.convertList(areaList, area -> { |
| 31 | - MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())).orElseGet(MemberAreaStatisticsRespVO::new); | |
| 34 | + MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId())) | |
| 35 | + .orElseGet(MemberAreaStatisticsRespVO::new); | |
| 32 | 36 | return new MemberAreaStatisticsRespVO() |
| 33 | 37 | .setAreaId(area.getId()).setAreaName(area.getName()) |
| 34 | 38 | .setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0)) |
| 35 | - .setOrderCreateCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateCount(), 0)) | |
| 36 | - .setOrderPayCount(ObjUtil.defaultIfNull(orderVo.getOrderPayCount(), 0)) | |
| 39 | + .setOrderCreateUserCount(ObjUtil.defaultIfNull(orderVo.getOrderCreateUserCount(), 0)) | |
| 40 | + .setOrderPayUserCount(ObjUtil.defaultIfNull(orderVo.getOrderPayUserCount(), 0)) | |
| 37 | 41 | .setOrderPayPrice(ObjUtil.defaultIfNull(orderVo.getOrderPayPrice(), 0)); |
| 38 | 42 | }); |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | 45 | MemberSummaryRespVO convert(RechargeSummaryRespBO rechargeSummary, Integer expensePrice, Integer userCount); |
| 42 | 46 | |
| 47 | + MemberAnalyseRespVO convert(Integer visitUserCount, Integer orderUserCount, Integer payUserCount, int atv, | |
| 48 | + DataComparisonRespVO<MemberAnalyseDataRespVO> comparison); | |
| 49 | + | |
| 43 | 50 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/convert/trade/TradeStatisticsConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.convert.trade; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; |
| 6 | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO; |
| 7 | 6 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 8 | 7 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 8 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | |
| 9 | 9 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 10 | 10 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| 11 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; | |
| 11 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 12 | 12 | import org.mapstruct.Mapper; |
| 13 | 13 | import org.mapstruct.factory.Mappers; |
| 14 | 14 | |
| ... | ... | @@ -25,10 +25,10 @@ public interface TradeStatisticsConvert { |
| 25 | 25 | |
| 26 | 26 | TradeStatisticsConvert INSTANCE = Mappers.getMapper(TradeStatisticsConvert.class); |
| 27 | 27 | |
| 28 | - default TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData, | |
| 29 | - TradeSummaryRespBO beforeYesterdayData, | |
| 30 | - TradeSummaryRespBO monthData, | |
| 31 | - TradeSummaryRespBO lastMonthData) { | |
| 28 | + default DataComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespBO yesterdayData, | |
| 29 | + TradeSummaryRespBO beforeYesterdayData, | |
| 30 | + TradeSummaryRespBO monthData, | |
| 31 | + TradeSummaryRespBO lastMonthData) { | |
| 32 | 32 | return convert(convert(yesterdayData, monthData), convert(beforeYesterdayData, lastMonthData)); |
| 33 | 33 | } |
| 34 | 34 | |
| ... | ... | @@ -39,10 +39,10 @@ public interface TradeStatisticsConvert { |
| 39 | 39 | .setMonthOrderCount(monthData.getCount()).setMonthPayPrice(monthData.getSummary()); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - TradeStatisticsComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); | |
| 42 | + DataComparisonRespVO<TradeSummaryRespVO> convert(TradeSummaryRespVO value, TradeSummaryRespVO reference); | |
| 43 | 43 | |
| 44 | - TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, | |
| 45 | - TradeTrendSummaryRespVO reference); | |
| 44 | + DataComparisonRespVO<TradeTrendSummaryRespVO> convert(TradeTrendSummaryRespVO value, | |
| 45 | + TradeTrendSummaryRespVO reference); | |
| 46 | 46 | |
| 47 | 47 | List<TradeTrendSummaryExcelVO> convertList02(List<TradeTrendSummaryRespVO> list); |
| 48 | 48 | |
| ... | ... | @@ -50,4 +50,21 @@ public interface TradeStatisticsConvert { |
| 50 | 50 | AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, |
| 51 | 51 | WalletSummaryRespBO walletSummary); |
| 52 | 52 | |
| 53 | + List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list); | |
| 54 | + | |
| 55 | + // TODO @疯狂:要不要搞个默认的 convertA 方法,然后这个 convert 去调用 convertA,特殊字段再去 set? | |
| 56 | + default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { | |
| 57 | + return new TradeTrendSummaryRespVO() | |
| 58 | + .setDate(tradeStatistics.getTime().toLocalDate()) | |
| 59 | + // 营业额 = 商品支付金额 + 充值金额 | |
| 60 | + .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) | |
| 61 | + .setOrderPayPrice(tradeStatistics.getOrderPayPrice()) | |
| 62 | + .setRechargePrice(tradeStatistics.getRechargePayPrice()) | |
| 63 | + // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | |
| 64 | + .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()) | |
| 65 | + .setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice()) | |
| 66 | + .setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice()) | |
| 67 | + .setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice()); | |
| 68 | + } | |
| 69 | + | |
| 53 | 70 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/dataobject/trade/TradeStatisticsDO.java
| ... | ... | @@ -48,11 +48,6 @@ public class TradeStatisticsDO extends TenantBaseDO { |
| 48 | 48 | * 总支付金额,单位:分 |
| 49 | 49 | */ |
| 50 | 50 | private Integer orderPayPrice; |
| 51 | - // TODO @疯狂:这个字段改成 walletPayPrice,然后挪到 rechargePayCount 前面; | |
| 52 | - /** | |
| 53 | - * 总支付金额(余额),单位:分 | |
| 54 | - */ | |
| 55 | - private Integer orderWalletPayPrice; | |
| 56 | 51 | |
| 57 | 52 | /** |
| 58 | 53 | * 退款订单数 |
| ... | ... | @@ -68,6 +63,11 @@ public class TradeStatisticsDO extends TenantBaseDO { |
| 68 | 63 | */ |
| 69 | 64 | private Integer brokerageSettlementPrice; |
| 70 | 65 | |
| 66 | + // TODO @疯狂:walletPayPrice,钱包支付金额 | |
| 67 | + /** | |
| 68 | + * 总支付金额(余额),单位:分 | |
| 69 | + */ | |
| 70 | + private Integer orderWalletPayPrice; | |
| 71 | 71 | /** |
| 72 | 72 | * 充值订单数 |
| 73 | 73 | * <p> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java
| ... | ... | @@ -13,14 +13,17 @@ import java.time.LocalDateTime; |
| 13 | 13 | * @author owen |
| 14 | 14 | */ |
| 15 | 15 | @Mapper |
| 16 | -public interface ApiAccessLogStatisticsMapper extends BaseMapperX<Object> { | |
| 16 | +@SuppressWarnings("rawtypes") | |
| 17 | +public interface ApiAccessLogStatisticsMapper extends BaseMapperX { | |
| 17 | 18 | |
| 18 | - // TODO @疯狂:是不是 selectIpCount | |
| 19 | - Integer selectCountByIp(@Param("beginTime") LocalDateTime beginTime, | |
| 20 | - @Param("endTime") LocalDateTime endTime); | |
| 19 | + // TODO 芋艿:已经 review | |
| 20 | + Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, | |
| 21 | + @Param("beginTime") LocalDateTime beginTime, | |
| 22 | + @Param("endTime") LocalDateTime endTime); | |
| 21 | 23 | |
| 22 | - // TODO @疯狂:是不是 selectUserCount | |
| 23 | - Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, | |
| 24 | - @Param("endTime") LocalDateTime endTime); | |
| 24 | + // TODO 芋艿:已经 review | |
| 25 | + Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, | |
| 26 | + @Param("beginTime") LocalDateTime beginTime, | |
| 27 | + @Param("endTime") LocalDateTime endTime); | |
| 25 | 28 | |
| 26 | 29 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/member/MemberStatisticsMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.member; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | |
| 4 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO; | |
| 5 | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO; | |
| 7 | +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; | |
| 6 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 9 | import org.apache.ibatis.annotations.Param; |
| 8 | 10 | |
| ... | ... | @@ -15,16 +17,31 @@ import java.util.List; |
| 15 | 17 | * @author owen |
| 16 | 18 | */ |
| 17 | 19 | @Mapper |
| 18 | -public interface MemberStatisticsMapper extends BaseMapperX<Object> { | |
| 20 | +@SuppressWarnings("rawtypes") | |
| 21 | +public interface MemberStatisticsMapper extends BaseMapperX { | |
| 19 | 22 | |
| 20 | 23 | // TODO @芋艿:已经 review |
| 21 | - // TODO @疯狂:要不还是搞下 bo?虽然可能冗余了点~~ | |
| 22 | - List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId(); | |
| 24 | + List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId(); | |
| 23 | 25 | |
| 26 | + // TODO @芋艿:已经 review | |
| 24 | 27 | List<MemberSexStatisticsRespVO> selectSummaryListBySex(); |
| 25 | 28 | |
| 26 | 29 | // TODO @芋艿:已经 review |
| 30 | + List<MemberTerminalStatisticsRespVO> selectSummaryListByRegisterTerminal(); | |
| 31 | + | |
| 32 | + // TODO @芋艿:已经 review | |
| 27 | 33 | Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, |
| 28 | 34 | @Param("endTime") LocalDateTime endTime); |
| 29 | 35 | |
| 36 | + // TODO @芋艿:已经 review | |
| 37 | + /** | |
| 38 | + * 获得用户的每天注册数量列表 | |
| 39 | + * | |
| 40 | + * @param beginTime 开始时间 | |
| 41 | + * @param endTime 结束时间 | |
| 42 | + * @return 每天注册数量列表 | |
| 43 | + */ | |
| 44 | + List<MemberRegisterCountRespVO> selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 45 | + @Param("endTime") LocalDateTime endTime); | |
| 46 | + | |
| 30 | 47 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/pay/PayWalletStatisticsMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.pay; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | -import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 5 | 4 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| 6 | 5 | import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; |
| 7 | 6 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -15,7 +14,8 @@ import java.time.LocalDateTime; |
| 15 | 14 | * @author owen |
| 16 | 15 | */ |
| 17 | 16 | @Mapper |
| 18 | -public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { | |
| 17 | +@SuppressWarnings("rawtypes") | |
| 18 | +public interface PayWalletStatisticsMapper extends BaseMapperX { | |
| 19 | 19 | |
| 20 | 20 | // TODO 芋艿:已经 review; |
| 21 | 21 | WalletSummaryRespBO selectRechargeSummaryByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| ... | ... | @@ -37,4 +37,7 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO |
| 37 | 37 | @Param("endTime") LocalDateTime endTime, |
| 38 | 38 | @Param("payStatus") Boolean payStatus); |
| 39 | 39 | |
| 40 | + // TODO 芋艿:已经 review; | |
| 41 | + Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus); | |
| 42 | + | |
| 40 | 43 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java
| ... | ... | @@ -20,4 +20,7 @@ public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO |
| 20 | 20 | AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 21 | 21 | @Param("endTime") LocalDateTime endTime); |
| 22 | 22 | |
| 23 | + // TODO 芋艿:已经 review | |
| 24 | + Long selectCountByStatus(@Param("status") Integer status); | |
| 25 | + | |
| 23 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java
| ... | ... | @@ -15,9 +15,13 @@ import java.time.LocalDateTime; |
| 15 | 15 | @Mapper |
| 16 | 16 | public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { |
| 17 | 17 | |
| 18 | + // TODO 芋艿:已经 review | |
| 18 | 19 | Integer selectSummaryPriceByStatusAndUnfreezeTimeBetween(@Param("bizType") Integer bizType, |
| 19 | 20 | @Param("status") Integer status, |
| 20 | 21 | @Param("beginTime") LocalDateTime beginTime, |
| 21 | 22 | @Param("endTime") LocalDateTime endTime); |
| 22 | 23 | |
| 24 | + // TODO 芋艿:已经 review | |
| 25 | + Long selectWithdrawCountByStatus(@Param("status") Integer status); | |
| 26 | + | |
| 23 | 27 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeOrderStatisticsMapper.java
| ... | ... | @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.statistics.dal.mysql.trade; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 5 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO; | |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO; | |
| 5 | 7 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 6 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 9 | import org.apache.ibatis.annotations.Param; |
| ... | ... | @@ -40,4 +42,37 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD |
| 40 | 42 | Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 41 | 43 | @Param("endTime") LocalDateTime endTime); |
| 42 | 44 | |
| 45 | + // TODO 芋艿:已经 review | |
| 46 | + /** | |
| 47 | + * 按照支付时间统计订单(按天分组) | |
| 48 | + * | |
| 49 | + * @param beginTime 支付起始时间 | |
| 50 | + * @param endTime 支付截止时间 | |
| 51 | + * @return 订单统计列表 | |
| 52 | + */ | |
| 53 | + List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, | |
| 54 | + @Param("endTime") LocalDateTime endTime); | |
| 55 | + | |
| 56 | + // TODO 芋艿:已经 review | |
| 57 | + /** | |
| 58 | + * 按照支付时间统计订单(按月分组) | |
| 59 | + * | |
| 60 | + * @param beginTime 支付起始时间 | |
| 61 | + * @param endTime 支付截止时间 | |
| 62 | + * @return 订单统计列表 | |
| 63 | + */ | |
| 64 | + List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime, | |
| 65 | + @Param("endTime") LocalDateTime endTime); | |
| 66 | + | |
| 67 | + // TODO @芋艿:已经 review | |
| 68 | + Long selectCountByStatus(@Param("status") Integer status); | |
| 69 | + | |
| 70 | + // TODO 芋艿:已经 review | |
| 71 | + Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status); | |
| 72 | + | |
| 73 | + // TODO 芋艿:已经 review | |
| 74 | + TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status, | |
| 75 | + @Param("beginTime") LocalDateTime beginTime, | |
| 76 | + @Param("endTime") LocalDateTime endTime); | |
| 77 | + | |
| 43 | 78 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/TradeStatisticsMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.dal.mysql.trade; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 4 | 5 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 5 | 6 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 6 | 7 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; |
| ... | ... | @@ -21,14 +22,23 @@ public interface TradeStatisticsMapper extends BaseMapperX<TradeStatisticsDO> { |
| 21 | 22 | TradeSummaryRespBO selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 22 | 23 | @Param("endTime") LocalDateTime endTime); |
| 23 | 24 | |
| 24 | - TradeTrendSummaryRespVO selectByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 25 | - @Param("endTime") LocalDateTime endTime); | |
| 25 | + TradeTrendSummaryRespVO selectVoByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 26 | + @Param("endTime") LocalDateTime endTime); | |
| 26 | 27 | |
| 27 | 28 | // TODO @芋艿:已经 review |
| 28 | - List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 29 | - @Param("endTime") LocalDateTime endTime); | |
| 29 | + default List<TradeStatisticsDO> selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 30 | + return selectList(new LambdaQueryWrapperX<TradeStatisticsDO>() | |
| 31 | + .between(TradeStatisticsDO::getTime, beginTime, endTime)); | |
| 32 | + } | |
| 30 | 33 | |
| 34 | + // TODO @芋艿:已经 review | |
| 31 | 35 | Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 32 | 36 | @Param("endTime") LocalDateTime endTime); |
| 33 | 37 | |
| 38 | + // TODO @芋艿:已经 review | |
| 39 | + default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 40 | + return selectOne(new LambdaQueryWrapperX<TradeStatisticsDO>() | |
| 41 | + .between(TradeStatisticsDO::getTime, beginTime, endTime)); | |
| 42 | + } | |
| 43 | + | |
| 34 | 44 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/job/trade/TradeStatisticsJob.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.job.trade; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.convert.Convert; | |
| 4 | +import cn.hutool.core.util.NumberUtil; | |
| 3 | 5 | import cn.hutool.core.util.StrUtil; |
| 4 | 6 | import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; |
| 5 | 7 | import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; |
| ... | ... | @@ -19,11 +21,25 @@ public class TradeStatisticsJob implements JobHandler { |
| 19 | 21 | @Resource |
| 20 | 22 | private TradeStatisticsService tradeStatisticsService; |
| 21 | 23 | |
| 24 | + /** | |
| 25 | + * 执行交易统计任务 | |
| 26 | + * | |
| 27 | + * @param param 要统计的天数,只能是正整数,1 代表昨日数据 | |
| 28 | + * @return 统计结果 | |
| 29 | + */ | |
| 22 | 30 | @Override |
| 23 | 31 | @TenantJob |
| 24 | 32 | public String execute(String param) { |
| 25 | - String times = tradeStatisticsService.statisticsYesterdayTrade(); | |
| 26 | - return StrUtil.format("交易统计耗时: {}", times); | |
| 33 | + // TODO @疯狂:要搞个默认的 1 哈; | |
| 34 | + if (NumberUtil.isInteger(param)) { | |
| 35 | + throw new RuntimeException("交易统计任务的参数只能为是正整数"); | |
| 36 | + } | |
| 37 | + Integer days = Convert.toInt(param, 0); | |
| 38 | + if (days < 1) { | |
| 39 | + throw new RuntimeException("交易统计任务的参数只能为是正整数"); | |
| 40 | + } | |
| 41 | + String result = tradeStatisticsService.statisticsTrade(days); | |
| 42 | + return StrUtil.format("交易统计:\n{}", result); | |
| 27 | 43 | } |
| 28 | 44 | |
| 29 | 45 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java
| ... | ... | @@ -9,26 +9,26 @@ import java.time.LocalDateTime; |
| 9 | 9 | */ |
| 10 | 10 | public interface ApiAccessLogStatisticsService { |
| 11 | 11 | |
| 12 | - // TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型; | |
| 13 | - // TODO @疯狂:方法名,要不改成 getUserCount;原因:让它更业务无关 | |
| 12 | + // TODO 芋艿:已经 review | |
| 14 | 13 | /** |
| 15 | 14 | * 获取活跃用户数量 |
| 16 | 15 | * |
| 16 | + * @param userType 用户类型 | |
| 17 | 17 | * @param beginTime 起始时间 |
| 18 | 18 | * @param endTime 截止时间 |
| 19 | 19 | * @return 活跃用户数量 |
| 20 | 20 | */ |
| 21 | - Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime); | |
| 21 | + Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | 22 | |
| 23 | - // TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型; | |
| 24 | - // TODO @疯狂:方法名,要不改成 getIpCount;原因:让它更业务无关 | |
| 23 | + // TODO 芋艿:已经 review | |
| 25 | 24 | /** |
| 26 | 25 | * 获取访问用户数量 |
| 27 | 26 | * |
| 27 | + * @param userType 用户类型 | |
| 28 | 28 | * @param beginTime 起始时间 |
| 29 | 29 | * @param endTime 截止时间 |
| 30 | 30 | * @return 访问用户数量 |
| 31 | 31 | */ |
| 32 | - Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime); | |
| 32 | + Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); | |
| 33 | 33 | |
| 34 | 34 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsServiceImpl.java
| ... | ... | @@ -20,13 +20,13 @@ public class ApiAccessLogStatisticsServiceImpl implements ApiAccessLogStatistics |
| 20 | 20 | private ApiAccessLogStatisticsMapper apiAccessLogStatisticsMapper; |
| 21 | 21 | |
| 22 | 22 | @Override |
| 23 | - public Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 24 | - return apiAccessLogStatisticsMapper.selectCountByUserId(beginTime, endTime); | |
| 23 | + public Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 24 | + return apiAccessLogStatisticsMapper.selectUserCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); | |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | @Override |
| 28 | - public Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | - return apiAccessLogStatisticsMapper.selectCountByIp(beginTime, endTime); | |
| 28 | + public Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | + return apiAccessLogStatisticsMapper.selectIpCountByUserTypeAndCreateTimeBetween(userType, beginTime, endTime); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsService.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.member; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO; | |
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; | |
| 5 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSexStatisticsRespVO; | |
| 6 | -import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO; | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 4 | +import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; | |
| 7 | 5 | |
| 8 | 6 | import java.time.LocalDateTime; |
| 9 | 7 | import java.util.List; |
| ... | ... | @@ -25,14 +23,16 @@ public interface MemberStatisticsService { |
| 25 | 23 | |
| 26 | 24 | // TODO 芋艿:已经 review |
| 27 | 25 | /** |
| 28 | - * 获取用户分析数据 | |
| 26 | + * 获取会员分析对照数据 | |
| 29 | 27 | * |
| 30 | 28 | * @param beginTime 起始时间 |
| 31 | 29 | * @param endTime 截止时间 |
| 32 | - * @return 用户分析数据 | |
| 30 | + * @return 会员分析对照数据 | |
| 33 | 31 | */ |
| 34 | - MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); | |
| 32 | + DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime, | |
| 33 | + LocalDateTime endTime); | |
| 35 | 34 | |
| 35 | + // TODO 芋艿:已经 review | |
| 36 | 36 | /** |
| 37 | 37 | * 按照省份,获得会员统计列表 |
| 38 | 38 | * |
| ... | ... | @@ -40,6 +40,7 @@ public interface MemberStatisticsService { |
| 40 | 40 | */ |
| 41 | 41 | List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList(); |
| 42 | 42 | |
| 43 | + // TODO 芋艿:已经 review | |
| 43 | 44 | /** |
| 44 | 45 | * 按照性别,获得会员统计列表 |
| 45 | 46 | * |
| ... | ... | @@ -47,4 +48,30 @@ public interface MemberStatisticsService { |
| 47 | 48 | */ |
| 48 | 49 | List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); |
| 49 | 50 | |
| 51 | + // TODO @疯狂:这个要不要使用 getMemberTerminalStatisticsList;保持统一? | |
| 52 | + /** | |
| 53 | + * 按照终端,获得会员统计列表 | |
| 54 | + * | |
| 55 | + * @return 会员统计列表 | |
| 56 | + */ | |
| 57 | + List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList(); | |
| 58 | + | |
| 59 | + // TODO 芋艿:已经 review | |
| 60 | + /** | |
| 61 | + * 获取用户注册数量列表 | |
| 62 | + * | |
| 63 | + * @param beginTime 起始时间 | |
| 64 | + * @param endTime 截止时间 | |
| 65 | + * @return 注册数量列表 | |
| 66 | + */ | |
| 67 | + List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); | |
| 68 | + | |
| 69 | + // TODO 芋艿:已经 review | |
| 70 | + /** | |
| 71 | + * 获得用户数量量统计对照 | |
| 72 | + * | |
| 73 | + * @return 用户数量量统计对照 | |
| 74 | + */ | |
| 75 | + DataComparisonRespVO<MemberCountRespVO> getUserCountComparison(); | |
| 76 | + | |
| 50 | 77 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/MemberStatisticsServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.member; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.util.NumberUtil; | |
| 3 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 5 | +import cn.iocoder.yudao.framework.ip.core.Area; | |
| 4 | 6 | import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; |
| 5 | 7 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 8 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 6 | 9 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.*; |
| 7 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | |
| 10 | +import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; | |
| 8 | 11 | import cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper; |
| 9 | 12 | import cn.iocoder.yudao.module.statistics.service.infra.ApiAccessLogStatisticsService; |
| 13 | +import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO; | |
| 10 | 14 | import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; |
| 11 | 15 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| 12 | 16 | import cn.iocoder.yudao.module.statistics.service.trade.TradeOrderStatisticsService; |
| 13 | 17 | import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService; |
| 14 | 18 | import org.springframework.stereotype.Service; |
| 15 | 19 | import org.springframework.validation.annotation.Validated; |
| 16 | -import cn.iocoder.yudao.module.statistics.convert.member.MemberStatisticsConvert; | |
| 17 | 20 | |
| 18 | 21 | import javax.annotation.Resource; |
| 19 | 22 | import java.time.Duration; |
| ... | ... | @@ -57,63 +60,77 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService { |
| 57 | 60 | @Override |
| 58 | 61 | public List<MemberAreaStatisticsRespVO> getMemberAreaStatisticsList() { |
| 59 | 62 | // 统计用户 |
| 60 | - // TODO @疯狂:要处理下,未知省份;就是没填写省份的情况; | |
| 61 | 63 | // TODO @疯狂:可能得把每个省的用户,都查询出来,然后去 order 那边 in;因为要按照这些人为基础来计算;;用户规模量大可能不太好,但是暂时就先这样搞吧 = = |
| 62 | 64 | Map<Integer, Integer> userCountMap = convertMap(memberStatisticsMapper.selectSummaryListByAreaId(), |
| 63 | 65 | vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), |
| 64 | - MemberAreaStatisticsRespVO::getUserCount, Integer::sum); | |
| 66 | + MemberAreaStatisticsRespBO::getUserCount, Integer::sum); | |
| 65 | 67 | // 统计订单 |
| 66 | 68 | Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(), |
| 67 | 69 | vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE), |
| 68 | 70 | vo -> vo, |
| 69 | 71 | (a, b) -> new MemberAreaStatisticsRespVO() |
| 70 | - .setOrderCreateCount(a.getOrderCreateCount() + b.getOrderCreateCount()) | |
| 71 | - .setOrderPayCount(a.getOrderPayCount() + b.getOrderPayCount()) | |
| 72 | + .setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount()) | |
| 73 | + .setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount()) | |
| 72 | 74 | .setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice())); |
| 73 | 75 | // 拼接数据 |
| 74 | - return MemberStatisticsConvert.INSTANCE.convertList(AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area), userCountMap, orderMap); | |
| 76 | + List<Area> areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); | |
| 77 | + areaList.add(new Area().setId(null).setName("未知")); | |
| 78 | + return MemberStatisticsConvert.INSTANCE.convertList(areaList, userCountMap, orderMap); | |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | - // TODO @疯狂:这个方法,要不拆成:1)controller 调用 getMemberAnalyseComparisonData;2)tradeOrderStatisticsService.getPayUserCount;3)tradeOrderStatisticsService.getOrderPayPrice;4)。。。 | |
| 78 | - // TODO 就是说:分析交给 controller 去组合; | |
| 79 | 81 | @Override |
| 80 | - public MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 82 | + public DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 83 | + // 当前数据 | |
| 84 | + MemberAnalyseDataRespVO vo = getMemberAnalyseData(beginTime, endTime); | |
| 81 | 85 | // 对照数据 |
| 82 | - MemberAnalyseComparisonRespVO vo = getMemberAnalyseComparisonData(beginTime, endTime); | |
| 83 | - // TODO @疯狂:如果时间段这么处理,会不会 beginTime 重叠了。因为是 <= 一个时间;如果数据库插入的是 ,xxxx-yy-zz 00:00:00 的话,它既满足 >= ? 也满足 <= ;(如果不好理解,微信聊) | |
| 84 | - LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); | |
| 85 | - MemberAnalyseComparisonRespVO reference = getMemberAnalyseComparisonData(referenceBeginTime, beginTime); | |
| 86 | - | |
| 87 | - // 计算客单价 | |
| 88 | - // TODO @疯狂:这个可能有点特殊,要按照 create_time 来查询;不然它的漏斗就不统一;因为是访问数量 > 今日下单人 > 今日支付人;是一个统一的维度; | |
| 89 | - Integer payUserCount = tradeOrderStatisticsService.getPayUserCount(beginTime, endTime); | |
| 90 | - int atv = 0; | |
| 91 | - if (payUserCount != null && payUserCount > 0) { | |
| 92 | - // TODO @疯狂:类似上面的 payUserCount | |
| 93 | - Integer payPrice = tradeOrderStatisticsService.getOrderPayPrice(beginTime, endTime); | |
| 94 | - atv = NumberUtil.div(payPrice, payUserCount).intValue(); | |
| 95 | - } | |
| 96 | - return new MemberAnalyseRespVO() | |
| 97 | - .setVisitorCount(apiAccessLogStatisticsService.getVisitorUserCount(beginTime, endTime)) | |
| 98 | - .setOrderUserCount(tradeOrderStatisticsService.getOrderUserCount(beginTime, endTime)) | |
| 99 | - .setPayUserCount(payUserCount) | |
| 100 | - .setAtv(atv) | |
| 101 | - .setComparison(new TradeStatisticsComparisonRespVO<>(vo, reference)); | |
| 86 | + LocalDateTime referenceEndDate = beginTime.minusDays(1); // 减少1天,防止出现时间重叠 | |
| 87 | + LocalDateTime referenceBeginDate = referenceEndDate.minus(Duration.between(beginTime, endTime)); | |
| 88 | + MemberAnalyseDataRespVO reference = getMemberAnalyseData( | |
| 89 | + LocalDateTimeUtil.beginOfDay(referenceBeginDate), LocalDateTimeUtil.endOfDay(referenceEndDate)); | |
| 90 | + return new DataComparisonRespVO<>(vo, reference); | |
| 102 | 91 | } |
| 103 | 92 | |
| 104 | - private MemberAnalyseComparisonRespVO getMemberAnalyseComparisonData(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 93 | + private MemberAnalyseDataRespVO getMemberAnalyseData(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 105 | 94 | Integer rechargeUserCount = Optional.ofNullable(payWalletStatisticsService.getUserRechargeSummary(beginTime, endTime)) |
| 106 | 95 | .map(RechargeSummaryRespBO::getRechargeUserCount).orElse(0); |
| 107 | - return new MemberAnalyseComparisonRespVO() | |
| 108 | - .setUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | |
| 109 | - .setActiveUserCount(apiAccessLogStatisticsService.getActiveUserCount(beginTime, endTime)) | |
| 96 | + return new MemberAnalyseDataRespVO() | |
| 97 | + .setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | |
| 98 | + .setVisitUserCount(apiAccessLogStatisticsService.getUserCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)) | |
| 110 | 99 | .setRechargeUserCount(rechargeUserCount); |
| 111 | 100 | } |
| 112 | 101 | |
| 113 | 102 | @Override |
| 114 | 103 | public List<MemberSexStatisticsRespVO> getMemberSexStatisticsList() { |
| 115 | - // TODO @疯狂:需要考虑,用户性别为空,则是“未知” | |
| 116 | 104 | return memberStatisticsMapper.selectSummaryListBySex(); |
| 117 | 105 | } |
| 118 | 106 | |
| 107 | + @Override | |
| 108 | + public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() { | |
| 109 | + return memberStatisticsMapper.selectSummaryListByRegisterTerminal(); | |
| 110 | + } | |
| 111 | + | |
| 112 | + @Override | |
| 113 | + public List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 114 | + return memberStatisticsMapper.selectListByCreateTimeBetween(beginTime, endTime); | |
| 115 | + } | |
| 116 | + | |
| 117 | + @Override | |
| 118 | + public DataComparisonRespVO<MemberCountRespVO> getUserCountComparison() { | |
| 119 | + // 今日时间范围 | |
| 120 | + LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); | |
| 121 | + LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(beginOfToday); | |
| 122 | + // 昨日时间范围 | |
| 123 | + LocalDateTime beginOfYesterday = LocalDateTimeUtil.beginOfDay(beginOfToday.minusDays(1)); | |
| 124 | + LocalDateTime endOfYesterday = LocalDateTimeUtil.endOfDay(beginOfYesterday); | |
| 125 | + return new DataComparisonRespVO<MemberCountRespVO>() | |
| 126 | + .setValue(getUserCount(beginOfToday, endOfToday)) | |
| 127 | + .setReference(getUserCount(beginOfYesterday, endOfYesterday)); | |
| 128 | + } | |
| 129 | + | |
| 130 | + private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 131 | + return new MemberCountRespVO() | |
| 132 | + .setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime)) | |
| 133 | + .setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime)); | |
| 134 | + } | |
| 135 | + | |
| 119 | 136 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/member/bo/MemberAreaStatisticsRespBO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.statistics.service.member.bo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - 会员地区统计 Response BO") | |
| 7 | +@Data | |
| 8 | +public class MemberAreaStatisticsRespBO { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * 省份编号 | |
| 12 | + */ | |
| 13 | + private Integer areaId; | |
| 14 | + /** | |
| 15 | + * 省份名称 | |
| 16 | + */ | |
| 17 | + private String areaName; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 会员数量 | |
| 21 | + */ | |
| 22 | + private Integer userCount; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 下单的会员数量 | |
| 26 | + */ | |
| 27 | + private Integer orderCreateUserCount; | |
| 28 | + /** | |
| 29 | + * 支付订单的会员数量 | |
| 30 | + */ | |
| 31 | + private Integer orderPayUserCount; | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 订单支付金额,单位:分 | |
| 35 | + */ | |
| 36 | + private Integer orderPayPrice; | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsService.java
| ... | ... | @@ -32,4 +32,12 @@ public interface PayWalletStatisticsService { |
| 32 | 32 | */ |
| 33 | 33 | RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 34 | 34 | |
| 35 | + // TODO 芋艿:已经 review | |
| 36 | + /** | |
| 37 | + * 获取充值金额合计 | |
| 38 | + * | |
| 39 | + * @return 充值金额合计 | |
| 40 | + */ | |
| 41 | + Integer getRechargePriceSummary(); | |
| 42 | + | |
| 35 | 43 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/PayWalletStatisticsServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.pay; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 4 | +import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum; |
| 5 | 6 | import cn.iocoder.yudao.module.statistics.dal.mysql.pay.PayWalletStatisticsMapper; |
| 6 | 7 | import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO; |
| ... | ... | @@ -43,4 +44,9 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic |
| 43 | 44 | return payWalletStatisticsMapper.selectRechargeSummaryGroupByWalletId(beginTime, endTime, true); |
| 44 | 45 | } |
| 45 | 46 | |
| 47 | + @Override | |
| 48 | + public Integer getRechargePriceSummary() { | |
| 49 | + return payWalletStatisticsMapper.selectRechargePriceSummary(PayOrderStatusEnum.SUCCESS.getStatus()); | |
| 50 | + } | |
| 51 | + | |
| 46 | 52 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/pay/bo/RechargeSummaryRespBO.java
| ... | ... | @@ -3,15 +3,20 @@ package cn.iocoder.yudao.module.statistics.service.pay.bo; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -// TODO @疯狂:BO 不用写 swagger 注解哈,写注释就好啦; | |
| 7 | -@Schema(description = "管理后台 - 充值统计 Response VO") | |
| 6 | +/** | |
| 7 | + * 充值统计 Response BO | |
| 8 | + */ | |
| 8 | 9 | @Data |
| 9 | 10 | public class RechargeSummaryRespBO { |
| 10 | 11 | |
| 11 | - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") | |
| 12 | + /** | |
| 13 | + * 充值会员数量 | |
| 14 | + */ | |
| 12 | 15 | private Integer rechargeUserCount; |
| 13 | 16 | |
| 14 | - @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + /** | |
| 18 | + * 充值金额 | |
| 19 | + */ | |
| 15 | 20 | private Integer rechargePrice; |
| 16 | 21 | |
| 17 | 22 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsService.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; |
| 4 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; | |
| 4 | 5 | |
| 5 | 6 | import java.time.LocalDateTime; |
| 6 | 7 | |
| ... | ... | @@ -21,4 +22,13 @@ public interface AfterSaleStatisticsService { |
| 21 | 22 | */ |
| 22 | 23 | AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 23 | 24 | |
| 25 | + // TODO 芋艿:已经 review | |
| 26 | + /** | |
| 27 | + * 获取指定状态的售后订单数量 | |
| 28 | + * | |
| 29 | + * @param status 售后状态 | |
| 30 | + * @return 售后订单数量 | |
| 31 | + */ | |
| 32 | + Long getCountByStatus(AfterSaleStatusEnum status); | |
| 33 | + | |
| 24 | 34 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/AfterSaleStatisticsServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.AfterSaleStatisticsMapper; |
| 4 | 4 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; |
| 5 | +import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum; | |
| 5 | 6 | import org.springframework.stereotype.Service; |
| 6 | 7 | import org.springframework.validation.annotation.Validated; |
| 7 | 8 | |
| ... | ... | @@ -25,4 +26,9 @@ public class AfterSaleStatisticsServiceImpl implements AfterSaleStatisticsServic |
| 25 | 26 | return afterSaleStatisticsMapper.selectSummaryByRefundTimeBetween(beginTime, endTime); |
| 26 | 27 | } |
| 27 | 28 | |
| 29 | + @Override | |
| 30 | + public Long getCountByStatus(AfterSaleStatusEnum status) { | |
| 31 | + return afterSaleStatisticsMapper.selectCountByStatus(status.getStatus()); | |
| 32 | + } | |
| 33 | + | |
| 28 | 34 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsService.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 4 | + | |
| 3 | 5 | import java.time.LocalDateTime; |
| 4 | 6 | |
| 5 | 7 | /** |
| ... | ... | @@ -19,4 +21,13 @@ public interface BrokerageStatisticsService { |
| 19 | 21 | */ |
| 20 | 22 | Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 21 | 23 | |
| 24 | + // TODO 芋艿:已经 review | |
| 25 | + /** | |
| 26 | + * 获取指定状态的提现记录数量 | |
| 27 | + * | |
| 28 | + * @param status 提现记录状态 | |
| 29 | + * @return 提现记录数量 | |
| 30 | + */ | |
| 31 | + Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status); | |
| 32 | + | |
| 22 | 33 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/BrokerageStatisticsServiceImpl.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.statistics.service.trade; |
| 3 | 3 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.BrokerageStatisticsMapper; |
| 4 | 4 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; |
| 6 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 6 | 7 | import org.springframework.stereotype.Service; |
| 7 | 8 | import org.springframework.validation.annotation.Validated; |
| 8 | 9 | |
| ... | ... | @@ -28,4 +29,9 @@ public class BrokerageStatisticsServiceImpl implements BrokerageStatisticsServic |
| 28 | 29 | beginTime, endTime); |
| 29 | 30 | } |
| 30 | 31 | |
| 32 | + @Override | |
| 33 | + public Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status) { | |
| 34 | + return brokerageStatisticsMapper.selectWithdrawCountByStatus(status.getStatus()); | |
| 35 | + } | |
| 36 | + | |
| 31 | 37 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsService.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 3 | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 5 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; | |
| 4 | 6 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 5 | 7 | |
| 6 | 8 | import java.time.LocalDateTime; |
| ... | ... | @@ -60,4 +62,29 @@ public interface TradeOrderStatisticsService { |
| 60 | 62 | */ |
| 61 | 63 | Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); |
| 62 | 64 | |
| 65 | + // TODO 芋艿:已经 review | |
| 66 | + /** | |
| 67 | + * 获得交易订单数量 | |
| 68 | + * | |
| 69 | + * @return 订单数量 | |
| 70 | + */ | |
| 71 | + TradeOrderCountRespVO getOrderCount(); | |
| 72 | + | |
| 73 | + // TODO 芋艿:已经 review | |
| 74 | + /** | |
| 75 | + * 交易订单销售额对照 | |
| 76 | + * | |
| 77 | + * @return 销售额对照 | |
| 78 | + */ | |
| 79 | + DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison(); | |
| 80 | + | |
| 81 | + // TODO 芋艿:已经 review | |
| 82 | + /** | |
| 83 | + * 获得订单量趋势统计 | |
| 84 | + * | |
| 85 | + * @param reqVO 统计参数 | |
| 86 | + * @return 订单量趋势统计 | |
| 87 | + */ | |
| 88 | + List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); | |
| 89 | + | |
| 63 | 90 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeOrderStatisticsServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 5 | +import cn.hutool.core.util.ObjUtil; | |
| 6 | +import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; | |
| 7 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 3 | 8 | import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO; |
| 9 | +import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*; | |
| 4 | 10 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper; |
| 11 | +import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum; | |
| 5 | 12 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 13 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; | |
| 6 | 14 | import org.springframework.stereotype.Service; |
| 7 | 15 | import org.springframework.validation.annotation.Validated; |
| 8 | 16 | |
| 9 | 17 | import javax.annotation.Resource; |
| 18 | +import java.time.Duration; | |
| 10 | 19 | import java.time.LocalDateTime; |
| 11 | 20 | import java.util.List; |
| 21 | +import java.util.stream.Collectors; | |
| 22 | +import java.util.stream.IntStream; | |
| 12 | 23 | |
| 13 | 24 | /** |
| 14 | 25 | * 交易订单统计 Service 实现类 |
| ... | ... | @@ -50,4 +61,53 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ |
| 50 | 61 | return tradeOrderStatisticsMapper.selectSummaryPriceByPayTimeBetween(beginTime, endTime); |
| 51 | 62 | } |
| 52 | 63 | |
| 64 | + @Override | |
| 65 | + public TradeOrderCountRespVO getOrderCount() { | |
| 66 | + // TODO 疯狂:这个可以根据 status + delivertyType 来过滤呀;ps:是不是搞个 service 方法,交给上层去聚合,这样 TradeOrderCountRespVO 可以更明确返回,不用搞 bo; | |
| 67 | + Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); | |
| 68 | + Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus()); | |
| 69 | + return new TradeOrderCountRespVO() | |
| 70 | + .setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L)) | |
| 71 | + .setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L)); | |
| 72 | + } | |
| 73 | + | |
| 74 | + @Override | |
| 75 | + public DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison() { | |
| 76 | + return new DataComparisonRespVO<TradeOrderSummaryRespVO>() | |
| 77 | + .setValue(getPayPriceSummary(LocalDateTime.now())) | |
| 78 | + .setReference(getPayPriceSummary(LocalDateTime.now().minusDays(1))); | |
| 79 | + } | |
| 80 | + | |
| 81 | + private TradeOrderSummaryRespVO getPayPriceSummary(LocalDateTime date) { | |
| 82 | + LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); | |
| 83 | + LocalDateTime endTime = LocalDateTimeUtil.beginOfDay(date); | |
| 84 | + return tradeOrderStatisticsMapper.selectPaySummaryByStatusAndPayTimeBetween( | |
| 85 | + PayOrderStatusEnum.SUCCESS.getStatus(), beginTime, endTime); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @Override | |
| 89 | + public List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO) { | |
| 90 | + // 查询当前数据 | |
| 91 | + List<TradeOrderTrendRespVO> value = getOrderCountTrend(reqVO.getType(), reqVO.getBeginTime(), reqVO.getEndTime()); | |
| 92 | + // 查询对照数据 | |
| 93 | + LocalDateTime referenceEndTime = reqVO.getBeginTime().minusDays(1); | |
| 94 | + LocalDateTime referenceBeginTime = referenceEndTime.minus(Duration.between(reqVO.getBeginTime(), reqVO.getEndTime())); | |
| 95 | + List<TradeOrderTrendRespVO> reference = getOrderCountTrend(reqVO.getType(), referenceBeginTime, referenceEndTime); | |
| 96 | + // 顺序对比返回 | |
| 97 | + return IntStream.range(0, value.size()) | |
| 98 | + .mapToObj(index -> new DataComparisonRespVO<TradeOrderTrendRespVO>() | |
| 99 | + .setValue(CollUtil.get(value, index)) | |
| 100 | + .setReference(CollUtil.get(reference, index))) | |
| 101 | + .collect(Collectors.toList()); | |
| 102 | + } | |
| 103 | + | |
| 104 | + private List<TradeOrderTrendRespVO> getOrderCountTrend(Integer timeRangeType, LocalDateTime beginTime, LocalDateTime endTime) { | |
| 105 | + // 情况一:按年统计时,以月份分组 | |
| 106 | + if (TimeRangeTypeEnum.YEAR.getType().equals(timeRangeType)) { | |
| 107 | + return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByMonth(beginTime, endTime); | |
| 108 | + } | |
| 109 | + // 情况二:其它以天分组(天、周、月) | |
| 110 | + return tradeOrderStatisticsMapper.selectListByPayTimeBetweenAndGroupByDay(beginTime, endTime); | |
| 111 | + } | |
| 112 | + | |
| 53 | 113 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | |
| 4 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; | |
| 3 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 5 | +import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; | |
| 6 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | |
| 6 | 7 | |
| 7 | 8 | import java.time.LocalDateTime; |
| 8 | 9 | import java.util.List; |
| ... | ... | @@ -15,25 +16,18 @@ import java.util.List; |
| 15 | 16 | public interface TradeStatisticsService { |
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | - * 获得交易统计 | |
| 19 | - * | |
| 20 | - * @return 统计数据对照 | |
| 21 | - */ | |
| 22 | - TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison(); | |
| 23 | - | |
| 24 | - /** | |
| 25 | 19 | * 获得交易状况统计对照 |
| 26 | 20 | * |
| 27 | 21 | * @return 统计数据对照 |
| 28 | 22 | */ |
| 29 | - TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison( | |
| 23 | + DataComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison( | |
| 30 | 24 | LocalDateTime beginTime, LocalDateTime endTime); |
| 31 | 25 | |
| 32 | 26 | /** |
| 33 | 27 | * 获得交易状况统计 |
| 34 | 28 | * |
| 35 | 29 | * @param beginTime 开始时间 |
| 36 | - * @param endTime 结束时间 | |
| 30 | + * @param endTime 结束时间 | |
| 37 | 31 | * @return 统计数据对照 |
| 38 | 32 | */ |
| 39 | 33 | Integer getExpensePrice(LocalDateTime beginTime, LocalDateTime endTime); |
| ... | ... | @@ -41,16 +35,36 @@ public interface TradeStatisticsService { |
| 41 | 35 | /** |
| 42 | 36 | * 获得交易状况明细 |
| 43 | 37 | * |
| 38 | + * @param beginTime 开始时间 | |
| 39 | + * @param endTime 结束时间 | |
| 44 | 40 | * @return 统计数据列表 |
| 45 | 41 | */ |
| 46 | - List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); | |
| 42 | + List<TradeStatisticsDO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); | |
| 47 | 43 | |
| 48 | 44 | // TODO 芋艿:已经 review; |
| 49 | 45 | /** |
| 50 | - * 统计昨日交易 | |
| 46 | + * 统计指定天数的交易数据 | |
| 47 | + * | |
| 48 | + * @return 统计结果 | |
| 49 | + */ | |
| 50 | + String statisticsTrade(Integer days); | |
| 51 | + | |
| 52 | + // TODO 芋艿:已经 review | |
| 53 | + /** | |
| 54 | + * 统计指定日期的交易数据 | |
| 55 | + * | |
| 56 | + * @param days 增加的天数 | |
| 57 | + * @return 交易数据 | |
| 58 | + */ | |
| 59 | + TradeSummaryRespBO getTradeSummaryByDays(int days); | |
| 60 | + | |
| 61 | + // TODO 芋艿:已经 review | |
| 62 | + /** | |
| 63 | + * 统计指定月份的交易数据 | |
| 51 | 64 | * |
| 52 | - * @return 耗时 | |
| 65 | + * @param months 增加的月数 | |
| 66 | + * @return 交易数据 | |
| 53 | 67 | */ |
| 54 | - String statisticsYesterdayTrade(); | |
| 68 | + TradeSummaryRespBO getTradeSummaryByMonths(int months); | |
| 55 | 69 | |
| 56 | 70 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.statistics.service.trade; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.date.DatePattern; | |
| 3 | 4 | import cn.hutool.core.date.LocalDateTimeUtil; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 5 | -import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | |
| 6 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 7 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeStatisticsComparisonRespVO; | |
| 8 | -import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO; | |
| 6 | +import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO; | |
| 9 | 7 | import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO; |
| 10 | 8 | import cn.iocoder.yudao.module.statistics.convert.trade.TradeStatisticsConvert; |
| 11 | 9 | import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO; |
| 12 | 10 | import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper; |
| 13 | -import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | |
| 11 | +import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService; | |
| 14 | 12 | import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespBO; |
| 15 | 13 | import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO; |
| 14 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO; | |
| 15 | +import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO; | |
| 16 | 16 | import org.springframework.stereotype.Service; |
| 17 | 17 | import org.springframework.util.StopWatch; |
| 18 | 18 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -21,6 +21,8 @@ import javax.annotation.Resource; |
| 21 | 21 | import java.time.Duration; |
| 22 | 22 | import java.time.LocalDateTime; |
| 23 | 23 | import java.util.List; |
| 24 | +import java.util.stream.Collectors; | |
| 25 | +import java.util.stream.IntStream; | |
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * 交易统计 Service 实现类 |
| ... | ... | @@ -44,51 +46,27 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 44 | 46 | private PayWalletStatisticsService payWalletStatisticsService; |
| 45 | 47 | |
| 46 | 48 | @Override |
| 47 | - public TradeStatisticsComparisonRespVO<TradeSummaryRespVO> getTradeSummaryComparison() { | |
| 48 | - // 1.1 昨天的数据 | |
| 49 | - TradeSummaryRespBO yesterdayData = getTradeSummaryByDays(-1); | |
| 50 | - // 1.2 前天的数据(用于对照昨天的数据) | |
| 51 | - TradeSummaryRespBO beforeYesterdayData = getTradeSummaryByDays(-2); | |
| 52 | - // 2.1 本月数据 | |
| 53 | - TradeSummaryRespBO monthData = getTradeSummaryByMonths(0); | |
| 54 | - // 2.2 上月数据(用于对照本月的数据) | |
| 55 | - TradeSummaryRespBO lastMonthData = getTradeSummaryByMonths(-1); | |
| 56 | - // 转换返回 | |
| 57 | - return TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData); | |
| 58 | - } | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * 统计指定日期的交易数据 | |
| 62 | - * | |
| 63 | - * @param days 增加的天数 | |
| 64 | - * @return 交易数据 | |
| 65 | - */ | |
| 66 | - private TradeSummaryRespBO getTradeSummaryByDays(int days) { | |
| 49 | + public TradeSummaryRespBO getTradeSummaryByDays(int days) { | |
| 67 | 50 | LocalDateTime date = LocalDateTime.now().plusDays(days); |
| 68 | 51 | return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( |
| 69 | 52 | LocalDateTimeUtil.beginOfDay(date), LocalDateTimeUtil.endOfDay(date)); |
| 70 | 53 | } |
| 71 | 54 | |
| 72 | - /** | |
| 73 | - * 统计指定月份的交易数据 | |
| 74 | - * | |
| 75 | - * @param months 增加的月数 | |
| 76 | - * @return 交易数据 | |
| 77 | - */ | |
| 78 | - private TradeSummaryRespBO getTradeSummaryByMonths(int months) { | |
| 55 | + @Override | |
| 56 | + public TradeSummaryRespBO getTradeSummaryByMonths(int months) { | |
| 79 | 57 | LocalDateTime monthDate = LocalDateTime.now().plusMonths(months); |
| 80 | 58 | return tradeStatisticsMapper.selectOrderCreateCountSumAndOrderPayPriceSumByTimeBetween( |
| 81 | 59 | LocalDateTimeUtils.beginOfMonth(monthDate), LocalDateTimeUtils.endOfMonth(monthDate)); |
| 82 | 60 | } |
| 83 | 61 | |
| 84 | 62 | @Override |
| 85 | - public TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime, | |
| 86 | - LocalDateTime endTime) { | |
| 63 | + public DataComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime, | |
| 64 | + LocalDateTime endTime) { | |
| 87 | 65 | // 统计数据 |
| 88 | - TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); | |
| 66 | + TradeTrendSummaryRespVO value = tradeStatisticsMapper.selectVoByTimeBetween(beginTime, endTime); | |
| 89 | 67 | // 对照数据 |
| 90 | 68 | LocalDateTime referenceBeginTime = beginTime.minus(Duration.between(beginTime, endTime)); |
| 91 | - TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectByTimeBetween(referenceBeginTime, beginTime); | |
| 69 | + TradeTrendSummaryRespVO reference = tradeStatisticsMapper.selectVoByTimeBetween(referenceBeginTime, beginTime); | |
| 92 | 70 | return TradeStatisticsConvert.INSTANCE.convert(value, reference); |
| 93 | 71 | } |
| 94 | 72 | |
| ... | ... | @@ -97,42 +75,63 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 97 | 75 | return tradeStatisticsMapper.selectExpensePriceByTimeBetween(beginTime, endTime); |
| 98 | 76 | } |
| 99 | 77 | |
| 100 | - // TODO @疯狂:是不是直接返回 TradeStatisticsDO;上层在去聚合? | |
| 101 | 78 | @Override |
| 102 | - public List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 79 | + public List<TradeStatisticsDO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 103 | 80 | return tradeStatisticsMapper.selectListByTimeBetween(beginTime, endTime); |
| 104 | 81 | } |
| 105 | 82 | |
| 106 | 83 | @Override |
| 107 | - public String statisticsYesterdayTrade() { | |
| 108 | - // TODO @疯狂:如果已经统计,则跳过; | |
| 109 | - // TODO @疯狂:改成 statisticsTrade,然后传入 days,统计多少天;days 通过 job 传参;方便把历史给统计出来;或者大家有的时候要修复数据(会 fix 业务数据,然后清理统计表),重新统计的时候; | |
| 110 | - // 1. 从各个数据表,统计对应数据 | |
| 111 | - LocalDateTime yesterday = LocalDateTime.now().minusDays(1); | |
| 112 | - LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(yesterday); | |
| 113 | - LocalDateTime endTime = LocalDateTimeUtil.endOfDay(yesterday); | |
| 114 | - // 1.1 统计订单 | |
| 115 | - StopWatch stopWatch = new StopWatch("交易统计"); | |
| 84 | + public String statisticsTrade(Integer days) { | |
| 85 | + LocalDateTime today = LocalDateTime.now(); | |
| 86 | + // TODO @疯狂:不用并发哈,因为租户可能会丢;然后,一般串行就好,对性能没绝对的要求哈,天数也不会多; | |
| 87 | + return IntStream.rangeClosed(1, days) | |
| 88 | + .parallel() | |
| 89 | + .mapToObj(day -> statisticsTrade(today.minusDays(day))) | |
| 90 | + .sorted() | |
| 91 | + .collect(Collectors.joining("\n")); | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * 统计交易数据 | |
| 96 | + * | |
| 97 | + * @param date 需要统计的日期 | |
| 98 | + * @return 统计结果 | |
| 99 | + */ | |
| 100 | + private String statisticsTrade(LocalDateTime date) { | |
| 101 | + // 1. 处理统计时间范围 | |
| 102 | + LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); | |
| 103 | + LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); | |
| 104 | + String dateStr = DatePattern.NORM_DATE_FORMAT.format(date); | |
| 105 | + // 2. 检查该日是否已经统计过 | |
| 106 | + TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); | |
| 107 | + if (entity != null) { | |
| 108 | + return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; | |
| 109 | + } | |
| 110 | + | |
| 111 | + // 3. 从各个数据表,统计对应数据 | |
| 112 | + StopWatch stopWatch = new StopWatch(dateStr); | |
| 113 | + // 3.1 统计订单 | |
| 116 | 114 | stopWatch.start("统计订单"); |
| 117 | 115 | TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); |
| 118 | 116 | stopWatch.stop(); |
| 119 | - // 1.2 统计售后 | |
| 117 | + // 3.2 统计售后 | |
| 120 | 118 | stopWatch.start("统计售后"); |
| 121 | 119 | AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); |
| 122 | 120 | stopWatch.stop(); |
| 123 | - // 1.3 统计佣金 | |
| 121 | + // 3.3 统计佣金 | |
| 124 | 122 | stopWatch.start("统计佣金"); |
| 125 | 123 | Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); |
| 126 | 124 | stopWatch.stop(); |
| 127 | - // 1.4 统计充值 | |
| 125 | + // 3.4 统计充值 | |
| 128 | 126 | stopWatch.start("统计充值"); |
| 129 | 127 | WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); |
| 130 | 128 | stopWatch.stop(); |
| 131 | 129 | |
| 132 | - // 2. 插入数据 | |
| 133 | - TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, | |
| 134 | - brokerageSettlementPrice, walletSummary); | |
| 130 | + // 4. 插入数据 | |
| 131 | + entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, | |
| 132 | + walletSummary); | |
| 135 | 133 | tradeStatisticsMapper.insert(entity); |
| 134 | + // TODO @疯狂:这里是不是也要把日期带上?类似 108 那边 | |
| 136 | 135 | return stopWatch.prettyPrint(); |
| 137 | 136 | } |
| 138 | 137 | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/infra/ApiAccessLogStatisticsMapper.xml
| ... | ... | @@ -2,23 +2,21 @@ |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.infra.ApiAccessLogStatisticsMapper"> |
| 4 | 4 | |
| 5 | - <select id="selectCountByIp" resultType="java.lang.Integer"> | |
| 6 | - <!-- TODO @疯狂:distinct 会不会更合适哈 --> | |
| 7 | - SELECT COUNT(1) | |
| 5 | + <select id="selectIpCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer"> | |
| 6 | + SELECT COUNT(DISTINCT user_ip) | |
| 8 | 7 | FROM infra_api_access_log |
| 9 | - WHERE create_time BETWEEN #{beginTime} AND #{endTime} | |
| 10 | - AND deleted = FALSE | |
| 11 | - GROUP BY user_ip | |
| 8 | + WHERE user_type = #{userType} | |
| 9 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 10 | + AND deleted = FALSE | |
| 12 | 11 | </select> |
| 13 | 12 | |
| 14 | - <select id="selectCountByUserId" resultType="java.lang.Integer"> | |
| 15 | - <!-- TODO @疯狂:distinct 会不会更合适哈 --> | |
| 16 | - SELECT COUNT(1) | |
| 13 | + <select id="selectUserCountByUserTypeAndCreateTimeBetween" resultType="java.lang.Integer"> | |
| 14 | + SELECT COUNT(DISTINCT user_id) | |
| 17 | 15 | FROM infra_api_access_log |
| 18 | 16 | WHERE user_id > 0 |
| 17 | + AND user_type = #{userType} | |
| 19 | 18 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 20 | 19 | AND deleted = FALSE |
| 21 | - GROUP BY user_id | |
| 22 | 20 | </select> |
| 23 | 21 | |
| 24 | 22 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/member/MemberStatisticsMapper.xml
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.member.MemberStatisticsMapper"> |
| 4 | 4 | |
| 5 | 5 | <select id="selectSummaryListByAreaId" |
| 6 | - resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> | |
| 6 | + resultType="cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO"> | |
| 7 | 7 | SELECT area_id, COUNT(1) AS userCount |
| 8 | 8 | FROM member_user |
| 9 | 9 | WHERE deleted = FALSE |
| ... | ... | @@ -18,6 +18,14 @@ |
| 18 | 18 | GROUP BY sex |
| 19 | 19 | </select> |
| 20 | 20 | |
| 21 | + <select id="selectSummaryListByRegisterTerminal" | |
| 22 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberTerminalStatisticsRespVO"> | |
| 23 | + SELECT register_terminal as terminal, COUNT(1) AS userCount | |
| 24 | + FROM member_user | |
| 25 | + WHERE deleted = FALSE | |
| 26 | + GROUP BY register_terminal | |
| 27 | + </select> | |
| 28 | + | |
| 21 | 29 | <select id="selectUserCount" resultType="java.lang.Integer"> |
| 22 | 30 | SELECT COUNT(1) |
| 23 | 31 | FROM member_user |
| ... | ... | @@ -30,4 +38,14 @@ |
| 30 | 38 | </if> |
| 31 | 39 | </select> |
| 32 | 40 | |
| 41 | + <select id="selectListByCreateTimeBetween" | |
| 42 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberRegisterCountRespVO"> | |
| 43 | + SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date, | |
| 44 | + count(1) AS count | |
| 45 | + FROM member_user | |
| 46 | + WHERE create_time BETWEEN #{beginTime} AND #{endTime} | |
| 47 | + AND deleted = FALSE | |
| 48 | + GROUP BY date | |
| 49 | + </select> | |
| 50 | + | |
| 33 | 51 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/pay/PayWalletStatisticsMapper.xml
| ... | ... | @@ -32,9 +32,8 @@ |
| 32 | 32 | |
| 33 | 33 | <select id="selectRechargeSummaryGroupByWalletId" |
| 34 | 34 | resultType="cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO"> |
| 35 | - <!-- TODO @疯狂:是不是不用 group by,而是通过 DISTINCT wallet_id 更合适哈? --> | |
| 36 | - SELECT COUNT(1) AS rechargeUserCount, | |
| 37 | - SUM(pay_price) AS rechargePrice | |
| 35 | + SELECT COUNT(DISTINCT wallet_id) AS rechargeUserCount, | |
| 36 | + SUM(pay_price) AS rechargePrice | |
| 38 | 37 | FROM pay_wallet_recharge |
| 39 | 38 | WHERE pay_status = #{payStatus} |
| 40 | 39 | <if test="beginTime != null"> |
| ... | ... | @@ -44,7 +43,13 @@ |
| 44 | 43 | AND pay_time <= #{endTime} |
| 45 | 44 | </if> |
| 46 | 45 | AND deleted = FALSE |
| 47 | - GROUP BY wallet_id | |
| 46 | + </select> | |
| 47 | + | |
| 48 | + <select id="selectRechargePriceSummary" resultType="java.lang.Integer"> | |
| 49 | + SELECT IFNULL(SUM(pay_price), 0) | |
| 50 | + FROM pay_wallet_recharge | |
| 51 | + WHERE pay_status = #{payStatus} | |
| 52 | + AND deleted = FALSE | |
| 48 | 53 | </select> |
| 49 | 54 | |
| 50 | 55 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/AfterSaleStatisticsMapper.xml
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/BrokerageStatisticsMapper.xml
| ... | ... | @@ -11,4 +11,11 @@ |
| 11 | 11 | AND deleted = FALSE |
| 12 | 12 | </select> |
| 13 | 13 | |
| 14 | + <select id="selectWithdrawCountByStatus" resultType="java.lang.Long"> | |
| 15 | + SELECT COUNT(1) | |
| 16 | + FROM trade_brokerage_withdraw | |
| 17 | + WHERE status = #{status} | |
| 18 | + AND deleted = FALSE | |
| 19 | + </select> | |
| 20 | + | |
| 14 | 21 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeOrderStatisticsMapper.xml
| ... | ... | @@ -2,17 +2,18 @@ |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper"> |
| 4 | 4 | |
| 5 | + <!-- TODO @疯狂:是返回不是的 MemberAreaStatisticsRespBO 哈 --> | |
| 5 | 6 | <select id="selectSummaryListByAreaId" |
| 6 | 7 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> |
| 7 | 8 | SELECT receiver_area_id AS areaId, |
| 8 | - (SELECT COUNT(1) | |
| 9 | + (SELECT COUNT(DISTINCT s.user_id) | |
| 9 | 10 | FROM trade_order AS s |
| 10 | - WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateCount, | |
| 11 | - (SELECT COUNT(1) | |
| 11 | + WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateUserCount, | |
| 12 | + (SELECT COUNT(DISTINCT s.user_id) | |
| 12 | 13 | FROM trade_order AS s |
| 13 | 14 | WHERE s.receiver_area_id = m.receiver_area_id |
| 14 | 15 | AND s.pay_status = TRUE |
| 15 | - AND s.deleted = FALSE) AS orderPayCount, | |
| 16 | + AND s.deleted = FALSE) AS orderPayUserCount, | |
| 16 | 17 | (SELECT SUM(s.pay_price) |
| 17 | 18 | FROM trade_order AS s |
| 18 | 19 | WHERE s.receiver_area_id = m.receiver_area_id |
| ... | ... | @@ -24,14 +25,14 @@ |
| 24 | 25 | </select> |
| 25 | 26 | |
| 26 | 27 | <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> |
| 27 | - SELECT COUNT(DISTINCT(user_id)) | |
| 28 | + SELECT COUNT(DISTINCT (user_id)) | |
| 28 | 29 | FROM trade_order |
| 29 | 30 | WHERE deleted = FALSE |
| 30 | 31 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 31 | 32 | </select> |
| 32 | 33 | |
| 33 | 34 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> |
| 34 | - SELECT COUNT(DISTINCT(user_id)) | |
| 35 | + SELECT COUNT(DISTINCT (user_id)) | |
| 35 | 36 | FROM trade_order |
| 36 | 37 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} |
| 37 | 38 | AND pay_status = TRUE |
| ... | ... | @@ -61,4 +62,53 @@ |
| 61 | 62 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 62 | 63 | </select> |
| 63 | 64 | |
| 65 | + <select id="selectListByPayTimeBetweenAndGroupByDay" | |
| 66 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO"> | |
| 67 | + SELECT DATE_FORMAT(pay_time, '%Y-%m-%d') AS date, | |
| 68 | + COUNT(1) AS orderPayCount, | |
| 69 | + SUM(pay_price) AS orderPayPrice | |
| 70 | + FROM trade_order | |
| 71 | + WHERE pay_status = TRUE | |
| 72 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 73 | + AND deleted = FALSE | |
| 74 | + GROUP BY date | |
| 75 | + </select> | |
| 76 | + | |
| 77 | + <select id="selectListByPayTimeBetweenAndGroupByMonth" | |
| 78 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO"> | |
| 79 | + SELECT DATE_FORMAT(pay_time, '%Y-%m') AS date, | |
| 80 | + COUNT(1) AS orderPayCount, | |
| 81 | + SUM(pay_price) AS orderPayPrice | |
| 82 | + FROM trade_order | |
| 83 | + WHERE pay_status = TRUE | |
| 84 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 85 | + AND deleted = FALSE | |
| 86 | + GROUP BY date | |
| 87 | + </select> | |
| 88 | + | |
| 89 | + <select id="selectCountByStatus" resultType="java.lang.Long"> | |
| 90 | + SELECT COUNT(1) | |
| 91 | + FROM trade_order | |
| 92 | + WHERE status = #{status} | |
| 93 | + AND deleted = FALSE | |
| 94 | + </select> | |
| 95 | + | |
| 96 | + <select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long"> | |
| 97 | + SELECT COUNT(1) | |
| 98 | + FROM trade_order | |
| 99 | + WHERE status = #{status} | |
| 100 | + AND pick_up_store_id IS NOT NULL | |
| 101 | + AND deleted = FALSE | |
| 102 | + </select> | |
| 103 | + | |
| 104 | + <select id="selectPaySummaryByStatusAndPayTimeBetween" | |
| 105 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO"> | |
| 106 | + SELECT IFNULL(SUM(pay_price), 0) AS orderPayPrice, | |
| 107 | + COUNT(1) AS orderPayCount | |
| 108 | + FROM trade_order | |
| 109 | + WHERE status = #{status} | |
| 110 | + AND pay_time BETWEEN #{beginTime} AND #{endTime} | |
| 111 | + AND deleted = FALSE | |
| 112 | + </select> | |
| 113 | + | |
| 64 | 114 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml
| ... | ... | @@ -11,16 +11,16 @@ |
| 11 | 11 | AND deleted = FALSE |
| 12 | 12 | </select> |
| 13 | 13 | |
| 14 | - <select id="selectByTimeBetween" | |
| 14 | + <select id="selectVoByTimeBetween" | |
| 15 | 15 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> |
| 16 | 16 | SELECT |
| 17 | 17 | -- 营业额 = 商品支付金额 + 充值金额 |
| 18 | - SUM(order_pay_price + recharge_pay_price) AS turnover, | |
| 18 | + SUM(order_pay_price + recharge_pay_price) AS turnoverPrice, | |
| 19 | 19 | SUM(order_pay_price) AS orderPayPrice, |
| 20 | 20 | SUM(recharge_pay_price) AS rechargePrice, |
| 21 | 21 | -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 |
| 22 | 22 | SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, |
| 23 | - SUM(order_wallet_pay_price) AS balancePrice, | |
| 23 | + SUM(order_wallet_pay_price) AS orderWalletPayPrice, | |
| 24 | 24 | SUM(brokerage_settlement_price) AS brokerageSettlementPrice, |
| 25 | 25 | SUM(after_sale_refund_price) AS orderRefundPrice |
| 26 | 26 | FROM trade_statistics |
| ... | ... | @@ -28,25 +28,6 @@ |
| 28 | 28 | AND deleted = FALSE |
| 29 | 29 | </select> |
| 30 | 30 | |
| 31 | - <select id="selectListByTimeBetween" | |
| 32 | - resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> | |
| 33 | - SELECT DATE_FORMAT(time, '%Y-%m-%d') AS date, | |
| 34 | - -- 营业额 = 商品支付金额 + 充值金额 | |
| 35 | - SUM(order_pay_price + recharge_pay_price) AS turnover, | |
| 36 | - SUM(order_pay_price) AS orderPayPrice, | |
| 37 | - SUM(recharge_pay_price) AS rechargePrice, | |
| 38 | - -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | |
| 39 | - SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice, | |
| 40 | - SUM(order_wallet_pay_price) AS balancePrice, | |
| 41 | - SUM(brokerage_settlement_price) AS brokerageSettlementPrice, | |
| 42 | - SUM(after_sale_refund_price) AS orderRefundPrice | |
| 43 | - FROM trade_statistics | |
| 44 | - WHERE time BETWEEN #{beginTime} AND #{endTime} | |
| 45 | - AND deleted = FALSE | |
| 46 | - <!-- TODO @疯狂:已经不用 group by,它就是每天统计一条; --> | |
| 47 | - GROUP BY date | |
| 48 | - </select> | |
| 49 | - | |
| 50 | 31 | <select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer"> |
| 51 | 32 | SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 |
| 52 | 33 | SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/order/TradeOrderMapper.java
| ... | ... | @@ -101,7 +101,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 101 | 101 | * @param status 订单状态 |
| 102 | 102 | * @return 交易订单 |
| 103 | 103 | */ |
| 104 | - default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { | |
| 104 | + default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status) { | |
| 105 | 105 | return selectOne(new LambdaQueryWrapperX<TradeOrderDO>() |
| 106 | 106 | .eq(TradeOrderDO::getUserId, userId) |
| 107 | 107 | .eq(TradeOrderDO::getStatus, status) | ... | ... |
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 { |
| 46 | 46 | * @param status 订单状态 |
| 47 | 47 | * @return 交易订单 |
| 48 | 48 | */ |
| 49 | - TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status); | |
| 49 | + TradeOrderDO getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status); | |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * 获得订单列表 | ... | ... |
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 { |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | @Override |
| 74 | - public TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { | |
| 75 | - return tradeOrderMapper.selectByUserIdAndActivityIdAndStatus(userId, activityId, status); | |
| 74 | + public TradeOrderDO getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus(Long userId, Long activityId, Integer status) { | |
| 75 | + return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, activityId, status); | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | @Override | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -8,10 +8,10 @@ import cn.hutool.core.util.ObjectUtil; |
| 8 | 8 | import cn.hutool.core.util.RandomUtil; |
| 9 | 9 | import cn.hutool.extra.spring.SpringUtil; |
| 10 | 10 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 11 | -import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | |
| 12 | 11 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 13 | 12 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 14 | 13 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 14 | +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | |
| 15 | 15 | import cn.iocoder.yudao.module.member.api.address.AddressApi; |
| 16 | 16 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| 17 | 17 | import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; |
| ... | ... | @@ -187,7 +187,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 187 | 187 | order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); |
| 188 | 188 | order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); |
| 189 | 189 | order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); |
| 190 | - order.setTerminal(TerminalEnum.H5.getTerminal()); // todo 数据来源? | |
| 190 | + // TODO @疯狂:无状态,terminal 不从 servletuTILS 拿,而是通过 controller 传递给 service; | |
| 191 | + order.setTerminal(ServletUtils.getTerminal()); | |
| 191 | 192 | // 支付 + 退款信息 |
| 192 | 193 | order.setAdjustPrice(0).setPayStatus(false); |
| 193 | 194 | order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); | ... | ... |
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 { |
| 49 | 49 | order.getCombinationHeadId(), item.getSkuId(), item.getCount()); |
| 50 | 50 | |
| 51 | 51 | // 2. 校验该用户是否存在未支付的拼团活动订单,避免一个拼团可以下多个单子了 |
| 52 | - TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus( | |
| 52 | + TradeOrderDO activityOrder = orderQueryService.getCombinationActivityOrderByUserIdAndCombinationActivityIdAndStatus( | |
| 53 | 53 | order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus()); |
| 54 | 54 | if (activityOrder != null) { |
| 55 | 55 | throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID); |
| ... | ... | @@ -70,8 +70,8 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler { |
| 70 | 70 | TradeOrderConvert.INSTANCE.convert(order, item)); |
| 71 | 71 | |
| 72 | 72 | // 3. 更新拼团相关信息到订单 |
| 73 | - // TODO 芋艿,只需要更新 record。 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的, | |
| 74 | - // 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的,所以支付完创建拼团记录后需要设置一下记录编号和团长编号 | |
| 73 | + // 为什么几个字段都要更新?原因是: | |
| 74 | + // 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 的,设置团长编号这个操作时在订单是否后创建拼团记录时才设置的。 | |
| 75 | 75 | orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(), |
| 76 | 76 | combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId()); |
| 77 | 77 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java
| 1 | 1 | package cn.iocoder.yudao.module.member.dal.dataobject.user; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | +import cn.iocoder.yudao.framework.common.enums.TerminalEnum; | |
| 4 | 5 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 6 | 7 | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; |
| ... | ... | @@ -61,6 +62,11 @@ public class MemberUserDO extends TenantBaseDO { |
| 61 | 62 | */ |
| 62 | 63 | private String registerIp; |
| 63 | 64 | /** |
| 65 | + * 注册终端 | |
| 66 | + * 枚举 {@link TerminalEnum} | |
| 67 | + */ | |
| 68 | + private Integer registerTerminal; | |
| 69 | + /** | |
| 64 | 70 | * 最后登录IP |
| 65 | 71 | */ |
| 66 | 72 | private String loginIp; |
| ... | ... | @@ -111,7 +117,7 @@ public class MemberUserDO extends TenantBaseDO { |
| 111 | 117 | * 积分 |
| 112 | 118 | */ |
| 113 | 119 | private Integer point; |
| 114 | - // TODO 芋艿:增加一个 totalPoint;个人信息接口要返回 | |
| 120 | + // TODO 疯狂:增加一个 totalPoint;个人信息接口要返回 | |
| 115 | 121 | |
| 116 | 122 | /** |
| 117 | 123 | * 会员标签列表,以逗号分隔 | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java
| ... | ... | @@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; |
| 7 | 7 | import cn.hutool.core.util.StrUtil; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | +import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | |
| 10 | 11 | import cn.iocoder.yudao.module.infra.api.file.FileApi; |
| 11 | 12 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO; |
| 12 | 13 | import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO; |
| ... | ... | @@ -99,6 +100,8 @@ public class MemberUserServiceImpl implements MemberUserService { |
| 99 | 100 | user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 |
| 100 | 101 | user.setPassword(encodePassword(password)); // 加密密码 |
| 101 | 102 | user.setRegisterIp(registerIp); |
| 103 | + // TODO @疯狂:无状态,terminal 不从 servletuTILS 拿,而是通过 controller 传递给 service; | |
| 104 | + user.setRegisterTerminal(ServletUtils.getTerminal()); | |
| 102 | 105 | memberUserMapper.insert(user); |
| 103 | 106 | |
| 104 | 107 | // 发送 MQ 消息:用户创建 | ... | ... |