Commit 01ef5f79110b8dd92c603e748ff48b65d6f4fab5
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
# Conflicts: # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/ArticleController.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExcelVO.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/article/ArticleExportReqVO.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/article/ArticleMapper.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImpl.java # yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/article/ArticleServiceImplTest.java
Showing
98 changed files
with
1215 additions
and
708 deletions
sql/mysql/mall.sql
0 → 100644
sql/mysql/member.sql
0 → 100644
sql/mysql/pay_wallet.sql
| ... | ... | @@ -125,3 +125,58 @@ CREATE TABLE `pay_wallet_recharge` ( |
| 125 | 125 | `tenant_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '租户编号', |
| 126 | 126 | PRIMARY KEY (`id`) USING BTREE |
| 127 | 127 | ) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic; |
| 128 | + | |
| 129 | +-- 钱包充值套餐菜单脚本 | |
| 130 | + | |
| 131 | +INSERT INTO system_menu( | |
| 132 | + name, permission, type, sort, parent_id, | |
| 133 | + path, icon, component, status, component_name | |
| 134 | +) | |
| 135 | +VALUES ( | |
| 136 | + '钱包管理', '', 1, 5, 1117, | |
| 137 | + 'wallet', 'ep:caret-right', '', 0, '' | |
| 138 | + ); | |
| 139 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 140 | +INSERT INTO system_menu( | |
| 141 | + name, permission, type, sort, parent_id, | |
| 142 | + path, icon, component, status, component_name | |
| 143 | +) | |
| 144 | +VALUES ( | |
| 145 | + '充值套餐', '', 2, 2, @parentId, | |
| 146 | + 'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage' | |
| 147 | + ); | |
| 148 | +SELECT @parentId := LAST_INSERT_ID(); | |
| 149 | + | |
| 150 | +-- 按钮 SQL | |
| 151 | +INSERT INTO system_menu( | |
| 152 | + name, permission, type, sort, parent_id, | |
| 153 | + path, icon, component, status | |
| 154 | +) | |
| 155 | +VALUES ( | |
| 156 | + '钱包充值套餐查询', 'pay:wallet-recharge-package:query', 3, 1, @parentId, | |
| 157 | + '', '', '', 0 | |
| 158 | + ); | |
| 159 | +INSERT INTO system_menu( | |
| 160 | + name, permission, type, sort, parent_id, | |
| 161 | + path, icon, component, status | |
| 162 | +) | |
| 163 | +VALUES ( | |
| 164 | + '钱包充值套餐创建', 'pay:wallet-recharge-package:create', 3, 2, @parentId, | |
| 165 | + '', '', '', 0 | |
| 166 | + ); | |
| 167 | +INSERT INTO system_menu( | |
| 168 | + name, permission, type, sort, parent_id, | |
| 169 | + path, icon, component, status | |
| 170 | +) | |
| 171 | +VALUES ( | |
| 172 | + '钱包充值套餐更新', 'pay:wallet-recharge-package:update', 3, 3, @parentId, | |
| 173 | + '', '', '', 0 | |
| 174 | + ); | |
| 175 | +INSERT INTO system_menu( | |
| 176 | + name, permission, type, sort, parent_id, | |
| 177 | + path, icon, component, status | |
| 178 | +) | |
| 179 | +VALUES ( | |
| 180 | + '钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId, | |
| 181 | + '', '', '', 0 | |
| 182 | + ); | ... | ... |
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-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.article.*; | |
| 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/article/ArticleBaseVO.java
| ... | ... | @@ -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/article/ArticleExcelVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; | |
| 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/article/ArticleExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article; | |
| 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/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/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/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
| ... | ... | @@ -29,8 +29,6 @@ public interface ArticleCategoryConvert { |
| 29 | 29 | |
| 30 | 30 | PageResult<ArticleCategoryRespVO> convertPage(PageResult<ArticleCategoryDO> page); |
| 31 | 31 | |
| 32 | - List<ArticleCategoryExcelVO> convertList02(List<ArticleCategoryDO> list); | |
| 33 | - | |
| 34 | 32 | List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list); |
| 35 | 33 | |
| 36 | 34 | List<AppArticleCategoryRespVO> convertList04(List<ArticleCategoryDO> categoryList); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/article/ArticleConvert.java
| ... | ... | @@ -2,10 +2,8 @@ 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.article.ArticleCreateReqVO; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExcelVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO; | |
| 9 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | 8 | import org.mapstruct.Mapper; |
| 11 | 9 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -32,12 +30,4 @@ public interface ArticleConvert { |
| 32 | 30 | |
| 33 | 31 | PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page); |
| 34 | 32 | |
| 35 | - List<ArticleExcelVO> convertList02(List<ArticleDO> list); | |
| 36 | - | |
| 37 | - List<AppArticleRespVO> convertList03(List<ArticleDO> list); | |
| 38 | - | |
| 39 | - AppArticleRespVO convert01(ArticleDO article); | |
| 40 | - | |
| 41 | - PageResult<AppArticleRespVO> convertPage02(PageResult<ArticleDO> articlePage); | |
| 42 | - | |
| 43 | 33 | } | ... | ... |
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)); | ... | ... |
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,14 +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.article.ArticleExportReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | |
| 9 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | 8 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 9 | |
| 12 | -import java.util.List; | |
| 13 | - | |
| 14 | 10 | /** |
| 15 | 11 | * 文章管理 Mapper |
| 16 | 12 | * |
| ... | ... | @@ -32,28 +28,4 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> { |
| 32 | 28 | .orderByDesc(ArticleDO::getId)); |
| 33 | 29 | } |
| 34 | 30 | |
| 35 | - default List<ArticleDO> selectList(ArticleExportReqVO reqVO) { | |
| 36 | - return selectList(new LambdaQueryWrapperX<ArticleDO>() | |
| 37 | - .eqIfPresent(ArticleDO::getCategoryId, reqVO.getCategoryId()) | |
| 38 | - .eqIfPresent(ArticleDO::getTitle, reqVO.getTitle()) | |
| 39 | - .eqIfPresent(ArticleDO::getAuthor, reqVO.getAuthor()) | |
| 40 | - .eqIfPresent(ArticleDO::getStatus, reqVO.getStatus()) | |
| 41 | - .eqIfPresent(ArticleDO::getSpuId, reqVO.getSpuId()) | |
| 42 | - .eqIfPresent(ArticleDO::getRecommendHot, reqVO.getRecommendHot()) | |
| 43 | - .eqIfPresent(ArticleDO::getRecommendBanner, reqVO.getRecommendBanner()) | |
| 44 | - .betweenIfPresent(ArticleDO::getCreateTime, reqVO.getCreateTime()) | |
| 45 | - .orderByDesc(ArticleDO::getId)); | |
| 46 | - } | |
| 47 | - | |
| 48 | - default List<ArticleDO> selectList(Boolean recommendHot, Boolean recommendBanner) { | |
| 49 | - return selectList(new LambdaQueryWrapperX<ArticleDO>() | |
| 50 | - .eqIfPresent(ArticleDO::getRecommendHot, recommendHot) | |
| 51 | - .eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner)); | |
| 52 | - } | |
| 53 | - | |
| 54 | - default PageResult<ArticleDO> selectPage(AppArticlePageReqVO pageReqVO) { | |
| 55 | - return selectPage(pageReqVO, new LambdaQueryWrapperX<ArticleDO>() | |
| 56 | - .eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId())); | |
| 57 | - } | |
| 58 | - | |
| 59 | 31 | } | ... | ... |
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,6 +127,7 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 127 | 127 | * |
| 128 | 128 | * @return 参加过拼团的用户数 |
| 129 | 129 | */ |
| 130 | + // TODO @puhui999:1)方法名,直接 selectUserCount;2)COUNT(DISTINCT(user_id)) 就可以啦,不用 group by 哈 | |
| 130 | 131 | default Long selectUserDistinctCount() { |
| 131 | 132 | return selectCount(new QueryWrapper<CombinationRecordDO>() |
| 132 | 133 | .select("DISTINCT (user_id)") | ... | ... |
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 | -import cn.hutool.core.collection.CollUtil; | |
| 4 | -import cn.hutool.core.collection.ListUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 4 | 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 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; |
| 9 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO; |
| 10 | 7 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; |
| ... | ... | @@ -14,7 +11,6 @@ import org.springframework.stereotype.Service; |
| 14 | 11 | import org.springframework.validation.annotation.Validated; |
| 15 | 12 | |
| 16 | 13 | import javax.annotation.Resource; |
| 17 | -import java.util.Collection; | |
| 18 | 14 | import java.util.List; |
| 19 | 15 | |
| 20 | 16 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -35,10 +31,10 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { |
| 35 | 31 | @Override |
| 36 | 32 | public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { |
| 37 | 33 | // 插入 |
| 38 | - ArticleCategoryDO articleCategory = ArticleCategoryConvert.INSTANCE.convert(createReqVO); | |
| 39 | - articleCategoryMapper.insert(articleCategory); | |
| 34 | + ArticleCategoryDO category = ArticleCategoryConvert.INSTANCE.convert(createReqVO); | |
| 35 | + articleCategoryMapper.insert(category); | |
| 40 | 36 | // 返回 |
| 41 | - return articleCategory.getId(); | |
| 37 | + return category.getId(); | |
| 42 | 38 | } |
| 43 | 39 | |
| 44 | 40 | @Override |
| ... | ... | @@ -54,6 +50,8 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { |
| 54 | 50 | public void deleteArticleCategory(Long id) { |
| 55 | 51 | // 校验存在 |
| 56 | 52 | validateArticleCategoryExists(id); |
| 53 | + // TODO @puhui999:需要校验下,是不是存在文章 | |
| 54 | + | |
| 57 | 55 | // 删除 |
| 58 | 56 | articleCategoryMapper.deleteById(id); |
| 59 | 57 | } |
| ... | ... | @@ -70,24 +68,11 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService { |
| 70 | 68 | } |
| 71 | 69 | |
| 72 | 70 | @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 | 71 | public PageResult<ArticleCategoryDO> getArticleCategoryPage(ArticleCategoryPageReqVO pageReqVO) { |
| 82 | 72 | return articleCategoryMapper.selectPage(pageReqVO); |
| 83 | 73 | } |
| 84 | 74 | |
| 85 | 75 | @Override |
| 86 | - public List<ArticleCategoryDO> getArticleCategoryList(ArticleCategoryExportReqVO exportReqVO) { | |
| 87 | - return articleCategoryMapper.selectList(exportReqVO); | |
| 88 | - } | |
| 89 | - | |
| 90 | - @Override | |
| 91 | 76 | public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { |
| 92 | 77 | return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); |
| 93 | 78 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/article/ArticleService.java
| ... | ... | @@ -2,25 +2,21 @@ 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.article.ArticleCreateReqVO; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | |
| 9 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 10 | 8 | |
| 11 | 9 | import javax.validation.Valid; |
| 12 | -import java.util.Collection; | |
| 13 | -import java.util.List; | |
| 14 | 10 | |
| 15 | 11 | /** |
| 16 | - * 文章详情 Service 接口 | |
| 12 | + * 文章管理 Service 接口 | |
| 17 | 13 | * |
| 18 | 14 | * @author HUIHUI |
| 19 | 15 | */ |
| 20 | 16 | public interface ArticleService { |
| 21 | 17 | |
| 22 | 18 | /** |
| 23 | - * 创建文章详情 | |
| 19 | + * 创建文章管理 | |
| 24 | 20 | * |
| 25 | 21 | * @param createReqVO 创建信息 |
| 26 | 22 | * @return 编号 |
| ... | ... | @@ -28,66 +24,33 @@ public interface ArticleService { |
| 28 | 24 | Long createArticle(@Valid ArticleCreateReqVO createReqVO); |
| 29 | 25 | |
| 30 | 26 | /** |
| 31 | - * 更新文章详情 | |
| 27 | + * 更新文章管理 | |
| 32 | 28 | * |
| 33 | 29 | * @param updateReqVO 更新信息 |
| 34 | 30 | */ |
| 35 | 31 | void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); |
| 36 | 32 | |
| 37 | 33 | /** |
| 38 | - * 删除文章详情 | |
| 34 | + * 删除文章管理 | |
| 39 | 35 | * |
| 40 | 36 | * @param id 编号 |
| 41 | 37 | */ |
| 42 | 38 | void deleteArticle(Long id); |
| 43 | 39 | |
| 44 | 40 | /** |
| 45 | - * 获得文章详情 | |
| 41 | + * 获得文章管理 | |
| 46 | 42 | * |
| 47 | 43 | * @param id 编号 |
| 48 | - * @return 文章详情 | |
| 44 | + * @return 文章管理 | |
| 49 | 45 | */ |
| 50 | 46 | ArticleDO getArticle(Long id); |
| 51 | 47 | |
| 52 | 48 | /** |
| 53 | - * 获得文章详情列表 | |
| 54 | - * | |
| 55 | - * @param ids 编号 | |
| 56 | - * @return 文章详情列表 | |
| 57 | - */ | |
| 58 | - List<ArticleDO> getArticleList(Collection<Long> ids); | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * 获得文章详情分页 | |
| 49 | + * 获得文章管理分页 | |
| 62 | 50 | * |
| 63 | 51 | * @param pageReqVO 分页查询 |
| 64 | - * @return 文章详情分页 | |
| 52 | + * @return 文章管理分页 | |
| 65 | 53 | */ |
| 66 | 54 | PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); |
| 67 | 55 | |
| 68 | - /** | |
| 69 | - * 获得文章详情列表, 用于 Excel 导出 | |
| 70 | - * | |
| 71 | - * @param exportReqVO 查询条件 | |
| 72 | - * @return 文章详情列表 | |
| 73 | - */ | |
| 74 | - List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO); | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * 获得文章详情列表 | |
| 78 | - * | |
| 79 | - * @param recommendHot 是否热门 | |
| 80 | - * @param recommendBanner 是否轮播图 | |
| 81 | - * @return 文章详情列表 | |
| 82 | - */ | |
| 83 | - List<ArticleDO> getArticleCategoryListByRecommendHotAndRecommendBanner(Boolean recommendHot, Boolean recommendBanner); | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * 获得文章详情分页 | |
| 87 | - * | |
| 88 | - * @param pageReqVO 分页查询 | |
| 89 | - * @return 文章详情分页 | |
| 90 | - */ | |
| 91 | - PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO); | |
| 92 | - | |
| 93 | 56 | } | ... | ... |
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 | 4 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO; |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; | |
| 8 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; |
| 9 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; |
| 10 | -import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO; | |
| 11 | 7 | import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert; |
| 12 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; |
| 13 | 9 | import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; |
| ... | ... | @@ -15,8 +11,6 @@ import org.springframework.stereotype.Service; |
| 15 | 11 | import org.springframework.validation.annotation.Validated; |
| 16 | 12 | |
| 17 | 13 | import javax.annotation.Resource; |
| 18 | -import java.util.Collection; | |
| 19 | -import java.util.List; | |
| 20 | 14 | |
| 21 | 15 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 22 | 16 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS; |
| ... | ... | @@ -35,6 +29,7 @@ public class ArticleServiceImpl implements ArticleService { |
| 35 | 29 | |
| 36 | 30 | @Override |
| 37 | 31 | public Long createArticle(ArticleCreateReqVO createReqVO) { |
| 32 | + // TODO @puhui999:需要校验分类存在 | |
| 38 | 33 | // 插入 |
| 39 | 34 | ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); |
| 40 | 35 | articleMapper.insert(article); |
| ... | ... | @@ -46,6 +41,8 @@ public class ArticleServiceImpl implements ArticleService { |
| 46 | 41 | public void updateArticle(ArticleUpdateReqVO updateReqVO) { |
| 47 | 42 | // 校验存在 |
| 48 | 43 | validateArticleExists(updateReqVO.getId()); |
| 44 | + // TODO @puhui999:需要校验分类存在 | |
| 45 | + | |
| 49 | 46 | // 更新 |
| 50 | 47 | ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); |
| 51 | 48 | articleMapper.updateById(updateObj); |
| ... | ... | @@ -71,31 +68,8 @@ public class ArticleServiceImpl implements ArticleService { |
| 71 | 68 | } |
| 72 | 69 | |
| 73 | 70 | @Override |
| 74 | - public List<ArticleDO> getArticleList(Collection<Long> ids) { | |
| 75 | - if (CollUtil.isEmpty(ids)) { | |
| 76 | - return ListUtil.empty(); | |
| 77 | - } | |
| 78 | - return articleMapper.selectBatchIds(ids); | |
| 79 | - } | |
| 80 | - | |
| 81 | - @Override | |
| 82 | 71 | public PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO) { |
| 83 | 72 | return articleMapper.selectPage(pageReqVO); |
| 84 | 73 | } |
| 85 | 74 | |
| 86 | - @Override | |
| 87 | - public List<ArticleDO> getArticleList(ArticleExportReqVO exportReqVO) { | |
| 88 | - return articleMapper.selectList(exportReqVO); | |
| 89 | - } | |
| 90 | - | |
| 91 | - @Override | |
| 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) { | |
| 98 | - return articleMapper.selectPage(pageReqVO); | |
| 99 | - } | |
| 100 | - | |
| 101 | 75 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -339,19 +339,20 @@ 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.校验是否虚拟成团 | |
| 354 | + // TODO @puhui999:这里可以改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务; | |
| 355 | + // 3. 校验是否虚拟成团 | |
| 355 | 356 | List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 |
| 356 | 357 | for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { |
| 357 | 358 | CombinationRecordDO record = iterator.next(); | ... | ... |
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
| ... | ... | @@ -3,7 +3,7 @@ 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.article.ArticleCreateReqVO; |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleExportReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; | ... | ... |
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 | + */ | |
| 42 | + private final Integer type; | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public int[] array() { | |
| 46 | + return ARRAYS; | |
| 47 | + } | |
| 48 | + | |
| 49 | +} | ... | ... |
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,8 +52,28 @@ 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 |
| ... | ... | @@ -67,12 +96,22 @@ public class MemberStatisticsController { |
| 67 | 96 | @Operation(summary = "按照终端,获得会员统计列表") |
| 68 | 97 | @PreAuthorize("@ss.hasPermission('statistics:member:query')") |
| 69 | 98 | 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); | |
| 99 | + return success(memberStatisticsService.getRegisterTerminalStatisticsList()); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @GetMapping("/user-count-comparison") | |
| 103 | + @Operation(summary = "获得用户数量对照") | |
| 104 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 105 | + public CommonResult<DataComparisonRespVO<MemberCountRespVO>> getUserCountComparison() { | |
| 106 | + return success(memberStatisticsService.getUserCountComparison()); | |
| 107 | + } | |
| 108 | + | |
| 109 | + @GetMapping("/register-count-list") | |
| 110 | + @Operation(summary = "获得会员注册数量列表") | |
| 111 | + @PreAuthorize("@ss.hasPermission('statistics:member:query')") | |
| 112 | + public CommonResult<List<MemberRegisterCountRespVO>> getMemberRegisterCountList(MemberAnalyseReqVO reqVO) { | |
| 113 | + return success(memberStatisticsService.getMemberRegisterCountList( | |
| 114 | + ArrayUtil.get(reqVO.getTimes(), 0), ArrayUtil.get(reqVO.getTimes(), 1))); | |
| 76 | 115 | } |
| 77 | 116 | |
| 78 | 117 | } | ... | ... |
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 | + @Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Integer createUserCount; | |
| 15 | + | |
| 16 | +} | ... | ... |
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 | + @GetMapping("/wallet-recharge-price") | |
| 28 | + @Operation(summary = "获取充值金额") | |
| 29 | + public CommonResult<Integer> getWalletRechargePrice() { | |
| 30 | + return success(payWalletStatisticsService.getRechargePriceSummary()); | |
| 31 | + } | |
| 32 | + | |
| 33 | +} | ... | ... |
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,82 @@ 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 | |
| 35 | 50 | @GetMapping("/summary") |
| 36 | 51 | @Operation(summary = "获得交易统计") |
| 37 | 52 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 38 | - public CommonResult<TradeStatisticsComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() { | |
| 39 | - // TODO @疯狂:这个要不要 tradeStatisticsService 调用里面的多个方法,组合出最终的 TradeSummaryRespVO; | |
| 40 | - return success(tradeStatisticsService.getTradeSummaryComparison()); | |
| 53 | + public CommonResult<DataComparisonRespVO<TradeSummaryRespVO>> getTradeSummaryComparison() { | |
| 54 | + // 1.1 昨天的数据 | |
| 55 | + TradeSummaryRespBO yesterdayData = tradeStatisticsService.getTradeSummaryByDays(-1); | |
| 56 | + // 1.2 前天的数据(用于对照昨天的数据) | |
| 57 | + TradeSummaryRespBO beforeYesterdayData = tradeStatisticsService.getTradeSummaryByDays(-2); | |
| 58 | + // 2.1 本月数据 | |
| 59 | + TradeSummaryRespBO monthData = tradeStatisticsService.getTradeSummaryByMonths(0); | |
| 60 | + // 2.2 上月数据(用于对照本月的数据) | |
| 61 | + TradeSummaryRespBO lastMonthData = tradeStatisticsService.getTradeSummaryByMonths(-1); | |
| 62 | + // 拼接数据 | |
| 63 | + return success(TradeStatisticsConvert.INSTANCE.convert(yesterdayData, beforeYesterdayData, monthData, lastMonthData)); | |
| 41 | 64 | } |
| 42 | 65 | |
| 43 | 66 | // TODO @疯狂:【晚点再改和讨论;等首页的接口出来】这个要不还是叫 analyse,对比选中的时间段,和上一个时间段;类似 MemberStatisticsController 的 getMemberAnalyse |
| 44 | 67 | @GetMapping("/trend/summary") |
| 45 | 68 | @Operation(summary = "获得交易状况统计") |
| 46 | 69 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| 47 | - public CommonResult<TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison( | |
| 70 | + public CommonResult<DataComparisonRespVO<TradeTrendSummaryRespVO>> getTradeTrendSummaryComparison( | |
| 48 | 71 | TradeTrendReqVO reqVO) { |
| 49 | 72 | return success(tradeStatisticsService.getTradeTrendSummaryComparison(ArrayUtil.get(reqVO.getTimes(), 0), |
| 50 | 73 | ArrayUtil.get(reqVO.getTimes(), 1))); |
| 51 | 74 | } |
| 52 | 75 | |
| 53 | - // TODO 芋艿:已经 review | |
| 54 | - // TODO @疯狂:这个要不直接叫 list;它即使就是把每条统计拿出来 | |
| 55 | - @GetMapping("/trend/list") | |
| 76 | + @GetMapping("/list") | |
| 56 | 77 | @Operation(summary = "获得交易状况明细") |
| 57 | 78 | @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))); | |
| 79 | + public CommonResult<List<TradeTrendSummaryRespVO>> getTradeStatisticsList(TradeTrendReqVO reqVO) { | |
| 80 | + List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 81 | + ArrayUtil.get(reqVO.getTimes(), 1)); | |
| 82 | + return success(TradeStatisticsConvert.INSTANCE.convertList(list)); | |
| 62 | 83 | } |
| 63 | 84 | |
| 64 | - // TODO @疯狂:这个要不直接叫 export;它即使就是把每条统计导出 | |
| 65 | - @GetMapping("/trend/export-excel") | |
| 85 | + @GetMapping("/export-excel") | |
| 66 | 86 | @Operation(summary = "导出获得交易状况明细 Excel") |
| 67 | 87 | @PreAuthorize("@ss.hasPermission('statistics:trade:export')") |
| 68 | 88 | public void exportTradeStatisticsExcel(TradeTrendReqVO reqVO, HttpServletResponse response) throws IOException { |
| 69 | - List<TradeTrendSummaryRespVO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 89 | + List<TradeStatisticsDO> list = tradeStatisticsService.getTradeStatisticsList(ArrayUtil.get(reqVO.getTimes(), 0), | |
| 70 | 90 | ArrayUtil.get(reqVO.getTimes(), 1)); |
| 71 | 91 | // 导出 Excel |
| 72 | - List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(list); | |
| 92 | + List<TradeTrendSummaryRespVO> voList = TradeStatisticsConvert.INSTANCE.convertList(list); | |
| 93 | + List<TradeTrendSummaryExcelVO> data = TradeStatisticsConvert.INSTANCE.convertList02(voList); | |
| 73 | 94 | ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data); |
| 74 | 95 | } |
| 75 | 96 | |
| 97 | + @GetMapping("/order-count") | |
| 98 | + @Operation(summary = "获得交易订单数量") | |
| 99 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | |
| 100 | + public CommonResult<TradeOrderCountRespVO> getOrderCount() { | |
| 101 | + TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount(); | |
| 102 | + vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY)) | |
| 103 | + .setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING)); | |
| 104 | + return success(vo); | |
| 105 | + } | |
| 106 | + | |
| 107 | + @GetMapping("/order-comparison") | |
| 108 | + @Operation(summary = "获得交易订单数量") | |
| 109 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | |
| 110 | + public CommonResult<DataComparisonRespVO<TradeOrderSummaryRespVO>> getOrderComparison() { | |
| 111 | + return success(tradeOrderStatisticsService.getOrderComparison()); | |
| 112 | + } | |
| 113 | + | |
| 114 | + @GetMapping("/order-count-trend") | |
| 115 | + @Operation(summary = "获得订单量趋势统计") | |
| 116 | + @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | |
| 117 | + public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { | |
| 118 | + return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); | |
| 119 | + } | |
| 120 | + | |
| 76 | 121 | } | ... | ... |
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,20 @@ public interface TradeStatisticsConvert { |
| 50 | 50 | AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice, |
| 51 | 51 | WalletSummaryRespBO walletSummary); |
| 52 | 52 | |
| 53 | + List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list); | |
| 54 | + | |
| 55 | + default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) { | |
| 56 | + return new TradeTrendSummaryRespVO() | |
| 57 | + .setDate(tradeStatistics.getTime().toLocalDate()) | |
| 58 | + // 营业额 = 商品支付金额 + 充值金额 | |
| 59 | + .setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice()) | |
| 60 | + .setOrderPayPrice(tradeStatistics.getOrderPayPrice()) | |
| 61 | + .setRechargePrice(tradeStatistics.getRechargePayPrice()) | |
| 62 | + // 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额 | |
| 63 | + .setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice()) | |
| 64 | + .setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice()) | |
| 65 | + .setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice()) | |
| 66 | + .setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice()); | |
| 67 | + } | |
| 68 | + | |
| 53 | 69 | } | ... | ... |
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 | * 退款订单数 |
| ... | ... | @@ -69,6 +64,10 @@ public class TradeStatisticsDO extends TenantBaseDO { |
| 69 | 64 | private Integer brokerageSettlementPrice; |
| 70 | 65 | |
| 71 | 66 | /** |
| 67 | + * 总支付金额(余额),单位:分 | |
| 68 | + */ | |
| 69 | + private Integer orderWalletPayPrice; | |
| 70 | + /** | |
| 72 | 71 | * 充值订单数 |
| 73 | 72 | * <p> |
| 74 | 73 | * 从 PayWalletRechargeDO 计算 | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/infra/ApiAccessLogStatisticsMapper.java
| ... | ... | @@ -13,14 +13,15 @@ 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 | + Integer selectIpCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, | |
| 20 | + @Param("beginTime") LocalDateTime beginTime, | |
| 21 | + @Param("endTime") LocalDateTime endTime); | |
| 21 | 22 | |
| 22 | - // TODO @疯狂:是不是 selectUserCount | |
| 23 | - Integer selectCountByUserId(@Param("beginTime") LocalDateTime beginTime, | |
| 24 | - @Param("endTime") LocalDateTime endTime); | |
| 23 | + Integer selectUserCountByUserTypeAndCreateTimeBetween(@Param("userType") Integer userType, | |
| 24 | + @Param("beginTime") LocalDateTime beginTime, | |
| 25 | + @Param("endTime") LocalDateTime endTime); | |
| 25 | 26 | |
| 26 | 27 | } | ... | ... |
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,20 @@ 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 | - // TODO @芋艿:已经 review | |
| 21 | - // TODO @疯狂:要不还是搞下 bo?虽然可能冗余了点~~ | |
| 22 | - List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId(); | |
| 23 | + List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId(); | |
| 23 | 24 | |
| 24 | 25 | List<MemberSexStatisticsRespVO> selectSummaryListBySex(); |
| 25 | 26 | |
| 27 | + List<MemberTerminalStatisticsRespVO> selectSummaryListByRegisterTerminal(); | |
| 28 | + | |
| 26 | 29 | // TODO @芋艿:已经 review |
| 27 | 30 | Integer selectUserCount(@Param("beginTime") LocalDateTime beginTime, |
| 28 | 31 | @Param("endTime") LocalDateTime endTime); |
| 29 | 32 | |
| 33 | + List<MemberRegisterCountRespVO> selectListByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 34 | + @Param("endTime") LocalDateTime endTime); | |
| 35 | + | |
| 30 | 36 | } | ... | ... |
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,6 @@ public interface PayWalletStatisticsMapper extends BaseMapperX<TradeStatisticsDO |
| 37 | 37 | @Param("endTime") LocalDateTime endTime, |
| 38 | 38 | @Param("payStatus") Boolean payStatus); |
| 39 | 39 | |
| 40 | + Integer selectRechargePriceSummary(@Param("payStatus") Integer payStatus); | |
| 41 | + | |
| 40 | 42 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/AfterSaleStatisticsMapper.java
| ... | ... | @@ -20,4 +20,6 @@ public interface AfterSaleStatisticsMapper extends BaseMapperX<TradeStatisticsDO |
| 20 | 20 | AfterSaleSummaryRespBO selectSummaryByRefundTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 21 | 21 | @Param("endTime") LocalDateTime endTime); |
| 22 | 22 | |
| 23 | + Long selectCountByStatus(@Param("status") Integer status); | |
| 24 | + | |
| 23 | 25 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/dal/mysql/trade/BrokerageStatisticsMapper.java
| ... | ... | @@ -20,4 +20,6 @@ public interface BrokerageStatisticsMapper extends BaseMapperX<TradeStatisticsDO |
| 20 | 20 | @Param("beginTime") LocalDateTime beginTime, |
| 21 | 21 | @Param("endTime") LocalDateTime endTime); |
| 22 | 22 | |
| 23 | + Long selectWithdrawCountByStatus(@Param("status") Integer status); | |
| 24 | + | |
| 23 | 25 | } | ... | ... |
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,32 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD |
| 40 | 42 | Integer selectUserCountByPayTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 41 | 43 | @Param("endTime") LocalDateTime endTime); |
| 42 | 44 | |
| 45 | + /** | |
| 46 | + * 按照支付时间统计订单(按天分组) | |
| 47 | + * | |
| 48 | + * @param beginTime 支付起始时间 | |
| 49 | + * @param endTime 支付截止时间 | |
| 50 | + * @return 订单统计列表 | |
| 51 | + */ | |
| 52 | + List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByDay(@Param("beginTime") LocalDateTime beginTime, | |
| 53 | + @Param("endTime") LocalDateTime endTime); | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 按照支付时间统计订单(按月分组) | |
| 57 | + * | |
| 58 | + * @param beginTime 支付起始时间 | |
| 59 | + * @param endTime 支付截止时间 | |
| 60 | + * @return 订单统计列表 | |
| 61 | + */ | |
| 62 | + List<TradeOrderTrendRespVO> selectListByPayTimeBetweenAndGroupByMonth(@Param("beginTime") LocalDateTime beginTime, | |
| 63 | + @Param("endTime") LocalDateTime endTime); | |
| 64 | + | |
| 65 | + Long selectCountByStatus(@Param("status") Integer status); | |
| 66 | + | |
| 67 | + Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status); | |
| 68 | + | |
| 69 | + TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status, | |
| 70 | + @Param("beginTime") LocalDateTime beginTime, | |
| 71 | + @Param("endTime") LocalDateTime endTime); | |
| 72 | + | |
| 43 | 73 | } | ... | ... |
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,20 @@ 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 | - // TODO @芋艿:已经 review | |
| 28 | - List<TradeTrendSummaryRespVO> selectListByTimeBetween(@Param("beginTime") LocalDateTime beginTime, | |
| 29 | - @Param("endTime") LocalDateTime endTime); | |
| 28 | + default List<TradeStatisticsDO> selectListByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 29 | + return selectList(new LambdaQueryWrapperX<TradeStatisticsDO>() | |
| 30 | + .between(TradeStatisticsDO::getTime, beginTime, endTime)); | |
| 31 | + } | |
| 30 | 32 | |
| 31 | 33 | Integer selectExpensePriceByTimeBetween(@Param("beginTime") LocalDateTime beginTime, |
| 32 | 34 | @Param("endTime") LocalDateTime endTime); |
| 33 | 35 | |
| 36 | + default TradeStatisticsDO selectByTimeBetween(LocalDateTime beginTime, LocalDateTime endTime) { | |
| 37 | + return selectOne(new LambdaQueryWrapperX<TradeStatisticsDO>() | |
| 38 | + .between(TradeStatisticsDO::getTime, beginTime, endTime)); | |
| 39 | + } | |
| 40 | + | |
| 34 | 41 | } | ... | ... |
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,24 @@ 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 | + if (NumberUtil.isInteger(param)) { | |
| 34 | + throw new RuntimeException("交易统计任务的参数只能为是正整数"); | |
| 35 | + } | |
| 36 | + Integer days = Convert.toInt(param, 0); | |
| 37 | + if (days < 1) { | |
| 38 | + throw new RuntimeException("交易统计任务的参数只能为是正整数"); | |
| 39 | + } | |
| 40 | + String result = tradeStatisticsService.statisticsTrade(days); | |
| 41 | + return StrUtil.format("交易统计:\n{}", result); | |
| 27 | 42 | } |
| 28 | 43 | |
| 29 | 44 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/infra/ApiAccessLogStatisticsService.java
| ... | ... | @@ -9,26 +9,24 @@ import java.time.LocalDateTime; |
| 9 | 9 | */ |
| 10 | 10 | public interface ApiAccessLogStatisticsService { |
| 11 | 11 | |
| 12 | - // TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型; | |
| 13 | - // TODO @疯狂:方法名,要不改成 getUserCount;原因:让它更业务无关 | |
| 14 | 12 | /** |
| 15 | 13 | * 获取活跃用户数量 |
| 16 | 14 | * |
| 15 | + * @param userType 用户类型 | |
| 17 | 16 | * @param beginTime 起始时间 |
| 18 | 17 | * @param endTime 截止时间 |
| 19 | 18 | * @return 活跃用户数量 |
| 20 | 19 | */ |
| 21 | - Integer getActiveUserCount(LocalDateTime beginTime, LocalDateTime endTime); | |
| 20 | + Integer getUserCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); | |
| 22 | 21 | |
| 23 | - // TODO @疯狂:需要传递 userType;因为访问日志,可能涉及多种用户类型; | |
| 24 | - // TODO @疯狂:方法名,要不改成 getIpCount;原因:让它更业务无关 | |
| 25 | 22 | /** |
| 26 | 23 | * 获取访问用户数量 |
| 27 | 24 | * |
| 25 | + * @param userType 用户类型 | |
| 28 | 26 | * @param beginTime 起始时间 |
| 29 | 27 | * @param endTime 截止时间 |
| 30 | 28 | * @return 访问用户数量 |
| 31 | 29 | */ |
| 32 | - Integer getVisitorUserCount(LocalDateTime beginTime, LocalDateTime endTime); | |
| 30 | + Integer getIpCount(Integer userType, LocalDateTime beginTime, LocalDateTime endTime); | |
| 33 | 31 | |
| 34 | 32 | } | ... | ... |
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; |
| ... | ... | @@ -23,15 +21,15 @@ public interface MemberStatisticsService { |
| 23 | 21 | */ |
| 24 | 22 | MemberSummaryRespVO getMemberSummary(); |
| 25 | 23 | |
| 26 | - // TODO 芋艿:已经 review | |
| 27 | 24 | /** |
| 28 | - * 获取用户分析数据 | |
| 25 | + * 获取会员分析对照数据 | |
| 29 | 26 | * |
| 30 | 27 | * @param beginTime 起始时间 |
| 31 | 28 | * @param endTime 截止时间 |
| 32 | - * @return 用户分析数据 | |
| 29 | + * @return 会员分析对照数据 | |
| 33 | 30 | */ |
| 34 | - MemberAnalyseRespVO getMemberAnalyse(LocalDateTime beginTime, LocalDateTime endTime); | |
| 31 | + DataComparisonRespVO<MemberAnalyseDataRespVO> getMemberAnalyseComparisonData(LocalDateTime beginTime, | |
| 32 | + LocalDateTime endTime); | |
| 35 | 33 | |
| 36 | 34 | /** |
| 37 | 35 | * 按照省份,获得会员统计列表 |
| ... | ... | @@ -47,4 +45,27 @@ public interface MemberStatisticsService { |
| 47 | 45 | */ |
| 48 | 46 | List<MemberSexStatisticsRespVO> getMemberSexStatisticsList(); |
| 49 | 47 | |
| 48 | + /** | |
| 49 | + * 按照终端,获得会员统计列表 | |
| 50 | + * | |
| 51 | + * @return 会员统计列表 | |
| 52 | + */ | |
| 53 | + List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList(); | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 获取用户注册数量列表 | |
| 57 | + * | |
| 58 | + * @param beginTime 起始时间 | |
| 59 | + * @param endTime 截止时间 | |
| 60 | + * @return 注册数量列表 | |
| 61 | + */ | |
| 62 | + List<MemberRegisterCountRespVO> getMemberRegisterCountList(LocalDateTime beginTime, LocalDateTime endTime); | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * 获得用户数量量统计对照 | |
| 66 | + * | |
| 67 | + * @return 用户数量量统计对照 | |
| 68 | + */ | |
| 69 | + DataComparisonRespVO<MemberCountRespVO> getUserCountComparison(); | |
| 70 | + | |
| 50 | 71 | } | ... | ... |
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,11 @@ public interface PayWalletStatisticsService { |
| 32 | 32 | */ |
| 33 | 33 | RechargeSummaryRespBO getUserRechargeSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 34 | 34 | |
| 35 | + /** | |
| 36 | + * 获取充值金额合计 | |
| 37 | + * | |
| 38 | + * @return 充值金额合计 | |
| 39 | + */ | |
| 40 | + Integer getRechargePriceSummary(); | |
| 41 | + | |
| 35 | 42 | } | ... | ... |
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,21 @@ 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 | + */ | |
| 9 | +@Schema(description = "管理后台 - ") | |
| 8 | 10 | @Data |
| 9 | 11 | public class RechargeSummaryRespBO { |
| 10 | 12 | |
| 11 | - @Schema(description = "充值会员数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "221") | |
| 13 | + /** | |
| 14 | + * 充值会员数量 | |
| 15 | + */ | |
| 12 | 16 | private Integer rechargeUserCount; |
| 13 | 17 | |
| 14 | - @Schema(description = "充值金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 18 | + /** | |
| 19 | + * 充值金额 | |
| 20 | + */ | |
| 15 | 21 | private Integer rechargePrice; |
| 16 | 22 | |
| 17 | 23 | } | ... | ... |
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,12 @@ public interface AfterSaleStatisticsService { |
| 21 | 22 | */ |
| 22 | 23 | AfterSaleSummaryRespBO getAfterSaleSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 23 | 24 | |
| 25 | + /** | |
| 26 | + * 获取指定状态的售后订单数量 | |
| 27 | + * | |
| 28 | + * @param status 售后状态 | |
| 29 | + * @return 售后订单数量 | |
| 30 | + */ | |
| 31 | + Long getCountByStatus(AfterSaleStatusEnum status); | |
| 32 | + | |
| 24 | 33 | } | ... | ... |
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,12 @@ public interface BrokerageStatisticsService { |
| 19 | 21 | */ |
| 20 | 22 | Integer getBrokerageSettlementPriceSummary(LocalDateTime beginTime, LocalDateTime endTime); |
| 21 | 23 | |
| 24 | + /** | |
| 25 | + * 获取指定状态的提现记录数量 | |
| 26 | + * | |
| 27 | + * @param status 提现记录状态 | |
| 28 | + * @return 提现记录数量 | |
| 29 | + */ | |
| 30 | + Long getWithdrawCountByStatus(BrokerageWithdrawStatusEnum status); | |
| 31 | + | |
| 22 | 32 | } | ... | ... |
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,26 @@ public interface TradeOrderStatisticsService { |
| 60 | 62 | */ |
| 61 | 63 | Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime); |
| 62 | 64 | |
| 65 | + /** | |
| 66 | + * 获得交易订单数量 | |
| 67 | + * | |
| 68 | + * @return 订单数量 | |
| 69 | + */ | |
| 70 | + TradeOrderCountRespVO getOrderCount(); | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 交易订单销售额对照 | |
| 74 | + * | |
| 75 | + * @return 销售额对照 | |
| 76 | + */ | |
| 77 | + DataComparisonRespVO<TradeOrderSummaryRespVO> getOrderComparison(); | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 获得订单量趋势统计 | |
| 81 | + * | |
| 82 | + * @param reqVO 统计参数 | |
| 83 | + * @return 订单量趋势统计 | |
| 84 | + */ | |
| 85 | + List<DataComparisonRespVO<TradeOrderTrendRespVO>> getOrderCountTrendComparison(TradeOrderTrendReqVO reqVO); | |
| 86 | + | |
| 63 | 87 | } | ... | ... |
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 | + Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()); | |
| 67 | + Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus()); | |
| 68 | + | |
| 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 | + | |
| 85 | + return tradeOrderStatisticsMapper.selectPaySummaryByStatusAndPayTimeBetween(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,34 @@ 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 | + /** | |
| 53 | + * 统计指定日期的交易数据 | |
| 54 | + * | |
| 55 | + * @param days 增加的天数 | |
| 56 | + * @return 交易数据 | |
| 57 | + */ | |
| 58 | + TradeSummaryRespBO getTradeSummaryByDays(int days); | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 统计指定月份的交易数据 | |
| 51 | 62 | * |
| 52 | - * @return 耗时 | |
| 63 | + * @param months 增加的月数 | |
| 64 | + * @return 交易数据 | |
| 53 | 65 | */ |
| 54 | - String statisticsYesterdayTrade(); | |
| 66 | + TradeSummaryRespBO getTradeSummaryByMonths(int months); | |
| 55 | 67 | |
| 56 | 68 | } | ... | ... |
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,41 +75,60 @@ 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 | + return IntStream.rangeClosed(1, days) | |
| 87 | + .parallel() | |
| 88 | + .mapToObj(day -> statisticsTrade(today.minusDays(day))) | |
| 89 | + .sorted() | |
| 90 | + .collect(Collectors.joining("\n")); | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * 统计交易数据 | |
| 95 | + * | |
| 96 | + * @param date 需要统计的日期 | |
| 97 | + * @return 统计结果 | |
| 98 | + */ | |
| 99 | + private String statisticsTrade(LocalDateTime date) { | |
| 100 | + // 1. 处理统计时间范围 | |
| 101 | + LocalDateTime beginTime = LocalDateTimeUtil.beginOfDay(date); | |
| 102 | + LocalDateTime endTime = LocalDateTimeUtil.endOfDay(date); | |
| 103 | + String dateStr = DatePattern.NORM_DATE_FORMAT.format(date); | |
| 104 | + // 2. 检查该日是否已经统计过 | |
| 105 | + TradeStatisticsDO entity = tradeStatisticsMapper.selectByTimeBetween(beginTime, endTime); | |
| 106 | + if (entity != null) { | |
| 107 | + return dateStr + " 数据已存在,如果需要重新统计,请先删除对应的数据"; | |
| 108 | + } | |
| 109 | + | |
| 110 | + // 3. 从各个数据表,统计对应数据 | |
| 111 | + StopWatch stopWatch = new StopWatch(dateStr); | |
| 112 | + // 3.1 统计订单 | |
| 116 | 113 | stopWatch.start("统计订单"); |
| 117 | 114 | TradeOrderSummaryRespBO orderSummary = tradeOrderStatisticsService.getOrderSummary(beginTime, endTime); |
| 118 | 115 | stopWatch.stop(); |
| 119 | - // 1.2 统计售后 | |
| 116 | + // 3.2 统计售后 | |
| 120 | 117 | stopWatch.start("统计售后"); |
| 121 | 118 | AfterSaleSummaryRespBO afterSaleSummary = afterSaleStatisticsService.getAfterSaleSummary(beginTime, endTime); |
| 122 | 119 | stopWatch.stop(); |
| 123 | - // 1.3 统计佣金 | |
| 120 | + // 3.3 统计佣金 | |
| 124 | 121 | stopWatch.start("统计佣金"); |
| 125 | 122 | Integer brokerageSettlementPrice = brokerageStatisticsService.getBrokerageSettlementPriceSummary(beginTime, endTime); |
| 126 | 123 | stopWatch.stop(); |
| 127 | - // 1.4 统计充值 | |
| 124 | + // 3.4 统计充值 | |
| 128 | 125 | stopWatch.start("统计充值"); |
| 129 | 126 | WalletSummaryRespBO walletSummary = payWalletStatisticsService.getWalletSummary(beginTime, endTime); |
| 130 | 127 | stopWatch.stop(); |
| 131 | 128 | |
| 132 | - // 2. 插入数据 | |
| 133 | - TradeStatisticsDO entity = TradeStatisticsConvert.INSTANCE.convert(yesterday, orderSummary, afterSaleSummary, | |
| 134 | - brokerageSettlementPrice, walletSummary); | |
| 129 | + // 4. 插入数据 | |
| 130 | + entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice, | |
| 131 | + walletSummary); | |
| 135 | 132 | tradeStatisticsMapper.insert(entity); |
| 136 | 133 | return stopWatch.prettyPrint(); |
| 137 | 134 | } | ... | ... |
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
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 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 | - | |
| 5 | 4 | <select id="selectSummaryListByAreaId" |
| 6 | 5 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO"> |
| 7 | 6 | SELECT receiver_area_id AS areaId, |
| 8 | - (SELECT COUNT(1) | |
| 7 | + (SELECT COUNT(DISTINCT s.user_id) | |
| 9 | 8 | FROM trade_order AS s |
| 10 | - WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateCount, | |
| 11 | - (SELECT COUNT(1) | |
| 9 | + WHERE s.receiver_area_id = m.receiver_area_id) AS orderCreateUserCount, | |
| 10 | + (SELECT COUNT(DISTINCT s.user_id) | |
| 12 | 11 | FROM trade_order AS s |
| 13 | 12 | WHERE s.receiver_area_id = m.receiver_area_id |
| 14 | 13 | AND s.pay_status = TRUE |
| 15 | - AND s.deleted = FALSE) AS orderPayCount, | |
| 14 | + AND s.deleted = FALSE) AS orderPayUserCount, | |
| 16 | 15 | (SELECT SUM(s.pay_price) |
| 17 | 16 | FROM trade_order AS s |
| 18 | 17 | WHERE s.receiver_area_id = m.receiver_area_id |
| ... | ... | @@ -24,14 +23,14 @@ |
| 24 | 23 | </select> |
| 25 | 24 | |
| 26 | 25 | <select id="selectUserCountByCreateTimeBetween" resultType="java.lang.Integer"> |
| 27 | - SELECT COUNT(DISTINCT(user_id)) | |
| 26 | + SELECT COUNT(DISTINCT (user_id)) | |
| 28 | 27 | FROM trade_order |
| 29 | 28 | WHERE deleted = FALSE |
| 30 | 29 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 31 | 30 | </select> |
| 32 | 31 | |
| 33 | 32 | <select id="selectUserCountByPayTimeBetween" resultType="java.lang.Integer"> |
| 34 | - SELECT COUNT(DISTINCT(user_id)) | |
| 33 | + SELECT COUNT(DISTINCT (user_id)) | |
| 35 | 34 | FROM trade_order |
| 36 | 35 | WHERE pay_time BETWEEN #{beginTime} AND #{endTime} |
| 37 | 36 | AND pay_status = TRUE |
| ... | ... | @@ -61,4 +60,52 @@ |
| 61 | 60 | AND create_time BETWEEN #{beginTime} AND #{endTime} |
| 62 | 61 | </select> |
| 63 | 62 | |
| 63 | + <select id="selectListByPayTimeBetweenAndGroupByDay" | |
| 64 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO"> | |
| 65 | + SELECT DATE_FORMAT(pay_time, '%Y-%m-%d') AS date, | |
| 66 | + COUNT(1) AS orderPayCount, | |
| 67 | + SUM(pay_price) AS orderPayPrice | |
| 68 | + FROM trade_order | |
| 69 | + WHERE pay_status = TRUE | |
| 70 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 71 | + AND deleted = FALSE | |
| 72 | + GROUP BY date | |
| 73 | + </select> | |
| 74 | + | |
| 75 | + <select id="selectListByPayTimeBetweenAndGroupByMonth" | |
| 76 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO"> | |
| 77 | + SELECT DATE_FORMAT(pay_time, '%Y-%m') AS date, | |
| 78 | + COUNT(1) AS orderPayCount, | |
| 79 | + SUM(pay_price) AS orderPayPrice | |
| 80 | + FROM trade_order | |
| 81 | + WHERE pay_status = TRUE | |
| 82 | + AND create_time BETWEEN #{beginTime} AND #{endTime} | |
| 83 | + AND deleted = FALSE | |
| 84 | + GROUP BY date | |
| 85 | + </select> | |
| 86 | + | |
| 87 | + <select id="selectCountByStatus" resultType="java.lang.Long"> | |
| 88 | + SELECT COUNT(1) | |
| 89 | + FROM trade_order | |
| 90 | + WHERE status = #{status} AND deleted = FALSE | |
| 91 | + </select> | |
| 92 | + | |
| 93 | + <select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long"> | |
| 94 | + SELECT COUNT(1) | |
| 95 | + FROM trade_order | |
| 96 | + WHERE status = #{status} | |
| 97 | + AND pick_up_store_id IS NOT NULL | |
| 98 | + AND deleted = FALSE | |
| 99 | + </select> | |
| 100 | + | |
| 101 | + <select id="selectPaySummaryByStatusAndPayTimeBetween" | |
| 102 | + resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO"> | |
| 103 | + SELECT IFNULL(SUM(pay_price), 0) AS orderPayPrice, | |
| 104 | + COUNT(1) AS orderPayCount | |
| 105 | + FROM trade_order | |
| 106 | + WHERE status = #{status} | |
| 107 | + AND pay_time BETWEEN #{beginTime} AND #{endTime} | |
| 108 | + AND deleted = FALSE | |
| 109 | + </select> | |
| 110 | + | |
| 64 | 111 | </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
| ... | ... | @@ -93,6 +93,7 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> { |
| 93 | 93 | return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | + // TODO @puhui999:selectByUserIdAndCombinationActivityIdAndStatus,这样更容易理解哈。 | |
| 96 | 97 | /** |
| 97 | 98 | * 只针对 combinationActivityId 的查询 |
| 98 | 99 | * | ... | ... |
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,7 @@ 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 | + order.setTerminal(ServletUtils.getTerminal()); | |
| 191 | 191 | // 支付 + 退款信息 |
| 192 | 192 | order.setAdjustPrice(0).setPayStatus(false); |
| 193 | 193 | 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
| ... | ... | @@ -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; | ... | ... |
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,7 @@ public class MemberUserServiceImpl implements MemberUserService { |
| 99 | 100 | user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 |
| 100 | 101 | user.setPassword(encodePassword(password)); // 加密密码 |
| 101 | 102 | user.setRegisterIp(registerIp); |
| 103 | + user.setRegisterTerminal(ServletUtils.getTerminal()); | |
| 102 | 104 | memberUserMapper.insert(user); |
| 103 | 105 | |
| 104 | 106 | // 发送 MQ 消息:用户创建 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletController.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.admin.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletRespVO; | |
| 5 | -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletUserReqVO; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; | |
| 7 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO; | |
| 6 | 8 | import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert; |
| 7 | 9 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 8 | 10 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService; |
| ... | ... | @@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 16 | 18 | import org.springframework.web.bind.annotation.RestController; |
| 17 | 19 | |
| 18 | 20 | import javax.annotation.Resource; |
| 21 | +import javax.validation.Valid; | |
| 19 | 22 | |
| 20 | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 21 | 24 | |
| ... | ... | @@ -37,4 +40,12 @@ public class PayWalletController { |
| 37 | 40 | return success(PayWalletConvert.INSTANCE.convert02(wallet)); |
| 38 | 41 | } |
| 39 | 42 | |
| 43 | + @GetMapping("/page") | |
| 44 | + @Operation(summary = "获得会员钱包分页") | |
| 45 | + @PreAuthorize("@ss.hasPermission('pay:wallet:query')") | |
| 46 | + public CommonResult<PageResult<PayWalletRespVO>> getWalletPage(@Valid PayWalletPageReqVO pageVO) { | |
| 47 | + PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(pageVO); | |
| 48 | + return success(PayWalletConvert.INSTANCE.convertPage(pageResult)); | |
| 49 | + } | |
| 50 | + | |
| 40 | 51 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletTransactionController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; | |
| 7 | +import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; | |
| 8 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; | |
| 9 | +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; | |
| 10 | +import io.swagger.v3.oas.annotations.Operation; | |
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 12 | +import lombok.extern.slf4j.Slf4j; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 15 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RestController; | |
| 17 | + | |
| 18 | +import javax.annotation.Resource; | |
| 19 | +import javax.validation.Valid; | |
| 20 | + | |
| 21 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 22 | + | |
| 23 | +@Tag(name = "管理后台 - 钱包余额明细") | |
| 24 | +@RestController | |
| 25 | +@RequestMapping("/pay/wallet-transaction") | |
| 26 | +@Validated | |
| 27 | +@Slf4j | |
| 28 | +public class PayWalletTransactionController { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private PayWalletTransactionService payWalletTransactionService; | |
| 32 | + | |
| 33 | + @GetMapping("/page") | |
| 34 | + @Operation(summary = "获得钱包流水分页") | |
| 35 | + public CommonResult<PageResult<PayWalletTransactionRespVO>> getWalletTransactionPage( | |
| 36 | + @Valid PayWalletTransactionPageReqVO pageReqVO) { | |
| 37 | + PageResult<PayWalletTransactionDO> result = payWalletTransactionService.getWalletTransactionPage(pageReqVO); | |
| 38 | + return success(PayWalletTransactionConvert.INSTANCE.convertPage2(result)); | |
| 39 | + } | |
| 40 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - 钱包流水分页 Request VO") | |
| 8 | +@Data | |
| 9 | +public class PayWalletTransactionPageReqVO extends PageParam { | |
| 10 | + | |
| 11 | + @Schema(description = "钱包编号", example = "1") | |
| 12 | + private Long walletId; | |
| 13 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/transaction/PayWalletTransactionRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +@Schema(description = "用户 APP - 钱包流水分页 Response VO") | |
| 9 | +@Data | |
| 10 | +public class PayWalletTransactionRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 13 | + private Long id; | |
| 14 | + | |
| 15 | + @Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") | |
| 16 | + private Long walletId; | |
| 17 | + | |
| 18 | + @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 19 | + private Integer bizType; | |
| 20 | + | |
| 21 | + @Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 22 | + private Long price; | |
| 23 | + | |
| 24 | + @Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆") | |
| 25 | + private String title; | |
| 26 | + | |
| 27 | + @Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + private LocalDateTime createTime; | |
| 29 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/PayWalletBaseVO.java renamed to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletBaseVO.java
| 1 | -package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo; | |
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| ... | ... | @@ -18,7 +18,7 @@ public class PayWalletBaseVO { |
| 18 | 18 | |
| 19 | 19 | @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 20 | 20 | @NotNull(message = "用户类型不能为空") |
| 21 | - private Byte userType; | |
| 21 | + private Integer userType; | |
| 22 | 22 | |
| 23 | 23 | @Schema(description = "余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED) |
| 24 | 24 | @NotNull(message = "余额,单位分不能为空") | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/article/vo/category/ArticleCategoryExportReqVO.java renamed to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletPageReqVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category; | |
| 1 | +package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet; | |
| 2 | 2 | |
| 3 | +import lombok.*; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.Data; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 5 | 6 | import org.springframework.format.annotation.DateTimeFormat; |
| 6 | - | |
| 7 | 7 | import java.time.LocalDateTime; |
| 8 | 8 | |
| 9 | 9 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 10 | 10 | |
| 11 | -@Schema(description = "管理后台 - 文章分类 Excel 导出 Request VO,参数和 ArticleCategoryPageReqVO 是一致的") | |
| 11 | +@Schema(description = "管理后台 - 会员钱包分页 Request VO") | |
| 12 | 12 | @Data |
| 13 | -public class ArticleCategoryExportReqVO { | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class PayWalletPageReqVO extends PageParam { | |
| 14 | 16 | |
| 15 | - @Schema(description = "文章分类名称", example = "秒杀") | |
| 16 | - private String name; | |
| 17 | + @Schema(description = "用户编号", example = "14138") | |
| 18 | + private Long userId; | |
| 17 | 19 | |
| 18 | - @Schema(description = "状态", example = "1") | |
| 19 | - private Integer status; | |
| 20 | + @Schema(description = "用户类型", example = "1") | |
| 21 | + private Integer userType; | |
| 20 | 22 | |
| 21 | 23 | @Schema(description = "创建时间") |
| 22 | 24 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/PayWalletRespVO.java renamed to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletRespVO.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/PayWalletUserReqVO.java renamed to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserReqVO.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/transaction/AppPayWalletTransactionRespVO.java
| ... | ... | @@ -9,9 +9,6 @@ import java.time.LocalDateTime; |
| 9 | 9 | @Data |
| 10 | 10 | public class AppPayWalletTransactionRespVO { |
| 11 | 11 | |
| 12 | - @Schema(description = "交易金额, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 13 | - private Integer amount; | |
| 14 | - | |
| 15 | 12 | @Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 16 | 13 | private Integer bizType; |
| 17 | 14 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.convert.wallet; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletRespVO; | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 6 | 7 | import org.mapstruct.Mapper; |
| ... | ... | @@ -14,4 +15,6 @@ public interface PayWalletConvert { |
| 14 | 15 | AppPayWalletRespVO convert(PayWalletDO bean); |
| 15 | 16 | |
| 16 | 17 | PayWalletRespVO convert02(PayWalletDO wallet); |
| 18 | + | |
| 19 | + PageResult<PayWalletRespVO> convertPage(PageResult<PayWalletDO> page); | |
| 17 | 20 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.convert.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; |
| ... | ... | @@ -14,6 +15,8 @@ public interface PayWalletTransactionConvert { |
| 14 | 15 | |
| 15 | 16 | PageResult<AppPayWalletTransactionRespVO> convertPage(PageResult<PayWalletTransactionDO> page); |
| 16 | 17 | |
| 18 | + PageResult<PayWalletTransactionRespVO> convertPage2(PageResult<PayWalletTransactionDO> page); | |
| 19 | + | |
| 17 | 20 | PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean); |
| 18 | 21 | |
| 19 | 22 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.dal.mysql.wallet; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; | |
| 5 | 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 6 | 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 7 | 10 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -14,6 +17,14 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { |
| 14 | 17 | PayWalletDO::getUserType, userType); |
| 15 | 18 | } |
| 16 | 19 | |
| 20 | + default PageResult<PayWalletDO> selectPage(PayWalletPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<PayWalletDO>() | |
| 22 | + .eqIfPresent(PayWalletDO::getUserId, reqVO.getUserId()) | |
| 23 | + .eqIfPresent(PayWalletDO::getUserType, reqVO.getUserType()) | |
| 24 | + .betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime()) | |
| 25 | + .orderByDesc(PayWalletDO::getId)); | |
| 26 | + } | |
| 27 | + | |
| 17 | 28 | /** |
| 18 | 29 | * 当消费退款时候, 更新钱包 |
| 19 | 30 | * | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletTransactionMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.dal.mysql.wallet; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 7 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| ... | ... | @@ -13,17 +14,17 @@ import java.util.Objects; |
| 13 | 14 | @Mapper |
| 14 | 15 | public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> { |
| 15 | 16 | |
| 16 | - default PageResult<PayWalletTransactionDO> selectPage(Long walletId, | |
| 17 | - AppPayWalletTransactionPageReqVO pageReqVO) { | |
| 17 | + default PageResult<PayWalletTransactionDO> selectPage(Long walletId, Integer type, | |
| 18 | + PageParam pageParam) { | |
| 18 | 19 | LambdaQueryWrapperX<PayWalletTransactionDO> query = new LambdaQueryWrapperX<PayWalletTransactionDO>() |
| 19 | - .eq(PayWalletTransactionDO::getWalletId, walletId); | |
| 20 | - if (Objects.equals(pageReqVO.getType(), AppPayWalletTransactionPageReqVO.TYPE_INCOME)) { | |
| 20 | + .eqIfPresent(PayWalletTransactionDO::getWalletId, walletId); | |
| 21 | + if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_INCOME)) { | |
| 21 | 22 | query.gt(PayWalletTransactionDO::getPrice, 0); |
| 22 | - } else if (Objects.equals(pageReqVO.getType(), AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) { | |
| 23 | + } else if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) { | |
| 23 | 24 | query.lt(PayWalletTransactionDO::getPrice, 0); |
| 24 | 25 | } |
| 25 | 26 | query.orderByDesc(PayWalletTransactionDO::getId); |
| 26 | - return selectPage(pageReqVO, query); | |
| 27 | + return selectPage(pageParam, query); | |
| 27 | 28 | } |
| 28 | 29 | |
| 29 | 30 | default PayWalletTransactionDO selectByNo(String no) { | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; | |
| 3 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| 4 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 5 | 7 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| ... | ... | @@ -28,6 +30,15 @@ public interface PayWalletService { |
| 28 | 30 | */ |
| 29 | 31 | PayWalletDO getWallet(Long walletId); |
| 30 | 32 | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 获得会员钱包分页 | |
| 36 | + * | |
| 37 | + * @param pageReqVO 分页查询 | |
| 38 | + * @return 会员钱包分页 | |
| 39 | + */ | |
| 40 | + PageResult<PayWalletDO> getWalletPage(PayWalletPageReqVO pageReqVO); | |
| 41 | + | |
| 31 | 42 | /** |
| 32 | 43 | * 钱包订单支付 |
| 33 | 44 | * | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO; | |
| 4 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; |
| 5 | 7 | import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; |
| 6 | 8 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| ... | ... | @@ -61,6 +63,11 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 61 | 63 | } |
| 62 | 64 | |
| 63 | 65 | @Override |
| 66 | + public PageResult<PayWalletDO> getWalletPage(PayWalletPageReqVO pageReqVO) { | |
| 67 | + return walletMapper.selectPage(pageReqVO); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @Override | |
| 64 | 71 | @Transactional(rollbackFor = Exception.class) |
| 65 | 72 | public PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price) { |
| 66 | 73 | // 1. 判断支付交易拓展单是否存 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| ... | ... | @@ -26,6 +27,13 @@ public interface PayWalletTransactionService { |
| 26 | 27 | AppPayWalletTransactionPageReqVO pageVO); |
| 27 | 28 | |
| 28 | 29 | /** |
| 30 | + * 查询钱包余额流水分页 | |
| 31 | + * | |
| 32 | + * @param pageVO 分页查询参数 | |
| 33 | + */ | |
| 34 | + PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO); | |
| 35 | + | |
| 36 | + /** | |
| 29 | 37 | * 新增钱包余额流水 |
| 30 | 38 | * |
| 31 | 39 | * @param bo 创建钱包流水 bo | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.service.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; |
| ... | ... | @@ -39,7 +40,12 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ |
| 39 | 40 | public PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType, |
| 40 | 41 | AppPayWalletTransactionPageReqVO pageVO) { |
| 41 | 42 | PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); |
| 42 | - return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO); | |
| 43 | + return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) { | |
| 48 | + return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO); | |
| 43 | 49 | } |
| 44 | 50 | |
| 45 | 51 | @Override | ... | ... |