Merge branch 'feature/mall_product' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into feature/mall_product

This commit is contained in:
zhijiantianya@gmail.com 2023-10-17 20:29:54 +08:00
commit 0dcab0363d
58 changed files with 484 additions and 457 deletions

View File

@ -1 +0,0 @@
ALTER TABLE member_user ADD COLUMN register_terminal tinyint NULL COMMENT '注册终端' AFTER register_ip;

View File

@ -126,7 +126,7 @@ CREATE TABLE `pay_wallet_recharge` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic;
-- 钱包充值套餐菜单脚本
-- 钱包充值套餐,钱包余额菜单脚本
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
@ -136,13 +136,14 @@ VALUES (
'钱包管理', '', 1, 5, 1117,
'wallet', 'ep:caret-right', '', 0, ''
);
SELECT @parentId := LAST_INSERT_ID();
SELECT @parentId1 := LAST_INSERT_ID();
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'充值套餐', '', 2, 2, @parentId,
'充值套餐', '', 2, 2, @parentId1,
'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage'
);
SELECT @parentId := LAST_INSERT_ID();
@ -180,3 +181,25 @@ VALUES (
'钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'钱包余额', '', 2, 1, @parentId1,
'wallet-balance', 'fa:leaf', 'pay/wallet/balance/index', 0, 'WalletBalance'
);
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包余额查询', 'pay:wallet:query', 3, 1, @parentId,
'', '', '', 0
);

View File

@ -1,49 +0,0 @@
-- 交易统计表
CREATE TABLE trade_statistics
(
id bigint AUTO_INCREMENT COMMENT '编号主键自增'
PRIMARY KEY,
time datetime NOT NULL COMMENT '统计日期',
order_create_count int DEFAULT 0 NOT NULL COMMENT '创建订单数',
order_pay_count int DEFAULT 0 NOT NULL COMMENT '支付订单商品数',
order_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额单位',
order_wallet_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额余额单位',
after_sale_count int DEFAULT 0 NOT NULL COMMENT '退款订单数',
after_sale_refund_price int DEFAULT 0 NOT NULL COMMENT '总退款金额单位',
brokerage_settlement_price int DEFAULT 0 NOT NULL COMMENT '佣金金额已结算单位',
recharge_pay_count int DEFAULT 0 NOT NULL COMMENT '充值订单数',
recharge_pay_price int DEFAULT 0 NOT NULL COMMENT '充值金额单位',
recharge_refund_count int DEFAULT 0 NOT NULL COMMENT '充值退款订单数',
recharge_refund_price int DEFAULT 0 NOT NULL COMMENT '充值退款金额单位',
creator varchar(64) DEFAULT '' NULL COMMENT '创建者',
create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
updater varchar(64) DEFAULT '' NULL COMMENT '更新者',
update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
deleted bit DEFAULT b'0' NOT NULL COMMENT '是否删除',
tenant_id bigint DEFAULT 0 NOT NULL COMMENT '租户编号'
)
COMMENT '交易统计表';
CREATE INDEX trade_statistics_time_index
ON trade_statistics (time);
-- 菜单
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
VALUES ('统计管理', '', 1, 4, 0, '/statistics', 'ep:data-line', '', '');
SELECT @parentId := LAST_INSERT_ID();
-- 交易统计
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
VALUES ('交易统计', '', 2, 1, @parentId, 'trade', 'fa-solid:credit-card', 'statistics/trade/index', 'TradeStatistics');
SELECT @parentId := LAST_INSERT_ID();
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('交易统计查询', 'statistics:trade:query', 3, 1, @parentId, '', '', '', 0);
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('交易统计导出', 'statistics:trade:export', 3, 2, @parentId, '', '', '', 0);
-- 会员统计
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
VALUES ('会员统计', '', 2, 2, @parentId, 'member', 'ep:avatar', 'statistics/member/index', 'MemberStatistics');
SELECT @parentId := LAST_INSERT_ID();
INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
VALUES ('会员统计查询', 'statistics:member:query', 3, 1, @parentId, '', '', '', 0);

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.framework.common.util.servlet;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
@ -89,18 +88,6 @@ public class ServletUtils {
return ServletUtil.getClientIP(request);
}
public static Integer getTerminal() {
return getHeaderInt("terminal");
}
public static String getHeader(String header) {
return getHeader(getRequest(), header);
}
public static Integer getHeaderInt(String header) {
return Convert.toInt(getHeader(header));
}
public static boolean isJsonRequest(ServletRequest request) {
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
}
@ -121,11 +108,4 @@ public class ServletUtils {
return ServletUtil.getParamMap(request);
}
public static String getHeader(HttpServletRequest request, String header) {
if (request == null) {
return null;
}
return request.getHeader(header);
}
}

View File

@ -111,9 +111,10 @@ public interface ErrorCodeConstants {
ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了");
// ========== 文章分类 1-013-015-000 ==========
ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "分类不存在");
ErrorCode ARTICLE_CATEGORY_NOT_EXISTS = new ErrorCode(1_013_015_000, "文章分类不存在");
ErrorCode ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES = new ErrorCode(1_013_015_001, "文章分类删除失败,存在关联文章");
// ========== 文章管理 1-013-016-000 ==========
ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章管理不存在");
ErrorCode ARTICLE_NOT_EXISTS = new ErrorCode(1_013_016_000, "文章不存在");
}

View File

@ -1,16 +1,19 @@
package cn.iocoder.yudao.module.promotion.controller.app.article;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO;
import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
import cn.iocoder.yudao.module.promotion.service.article.ArticleCategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import javax.annotation.Resource;
import java.util.List;
import java.util.Random;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -20,20 +23,16 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppArticleCategoryController {
@Resource
private ArticleCategoryService articleCategoryService;
@RequestMapping("/list")
@Operation(summary = "获得文章分类列表")
// TODO @芋艿swagger 注解
public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() {
List<AppArticleCategoryRespVO> appArticleRespVOList = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO();
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setName("分类 - " + i);
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVOList.add(appArticleRespVO);
}
return success(appArticleRespVOList);
List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus(
CommonStatusEnum.ENABLE.getStatus());
// TODO @puhui999排序下
return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList));
}
}

View File

@ -4,16 +4,19 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO;
import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert;
import cn.iocoder.yudao.module.promotion.service.article.ArticleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.ArrayList;
import javax.annotation.Resource;
import java.util.List;
import java.util.Random;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -23,68 +26,34 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class AppArticleController {
@Resource
private ArticleService articleService;
@RequestMapping("/list")
// TODO @芋艿swagger 注解
public CommonResult<List<AppArticleRespVO>> getArticleList(@RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
@RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setTitle("芋道源码 - " + i + "模块");
appArticleRespVO.setAuthor("芋道源码");
appArticleRespVO.setCategoryId((long) random.nextInt(10000));
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVO.setIntroduction("我是简介");
appArticleRespVO.setDescription("我是详细");
appArticleRespVO.setCreateTime(LocalDateTime.now());
appArticleRespVO.setBrowseCount(random.nextInt(10000));
appArticleRespVO.setSpuId((long) random.nextInt(10000));
appArticleRespVOList.add(appArticleRespVO);
}
return success(appArticleRespVOList);
@Operation(summary = "获得文章详情列表")
@Parameters({
@Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一查看指定的文章
@Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二查看指定的文章
})
public CommonResult<List<AppArticleRespVO>> getArticleList(
@RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
@RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
return success(ArticleConvert.INSTANCE.convertList03(
articleService.getArticleCategoryListByRecommend(recommendHot, recommendBanner)));
}
@RequestMapping("/page")
// TODO @芋艿swagger 注解
@Operation(summary = "获得文章详情分页")
public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) {
List<AppArticleRespVO> appArticleRespVOList = new ArrayList<>();
Random random = new Random();
for (int i = 0; i < 10; i++) {
AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setTitle("芋道源码 - " + i + "模块");
appArticleRespVO.setAuthor("芋道源码");
appArticleRespVO.setCategoryId((long) random.nextInt(10000));
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVO.setIntroduction("我是简介");
appArticleRespVO.setDescription("我是详细");
appArticleRespVO.setCreateTime(LocalDateTime.now());
appArticleRespVO.setBrowseCount(random.nextInt(10000));
appArticleRespVO.setSpuId((long) random.nextInt(10000));
appArticleRespVOList.add(appArticleRespVO);
}
return success(new PageResult<>(appArticleRespVOList, 10L));
return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO)));
}
@RequestMapping("/get")
// TODO @芋艿swagger 注解
@Operation(summary = "获得文章详情")
@Parameter(name = "id", description = "文章编号", example = "1024")
public CommonResult<AppArticleRespVO> getArticlePage(@RequestParam("id") Long id) {
Random random = new Random();
AppArticleRespVO appArticleRespVO = new AppArticleRespVO();
appArticleRespVO.setId((long) (1));
appArticleRespVO.setTitle("芋道源码 - " + 0 + "模块");
appArticleRespVO.setAuthor("芋道源码");
appArticleRespVO.setCategoryId((long) random.nextInt(10000));
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (0 + 1) + ".png");
appArticleRespVO.setIntroduction("我是简介");
appArticleRespVO.setDescription("我是详细");
appArticleRespVO.setCreateTime(LocalDateTime.now());
appArticleRespVO.setBrowseCount(random.nextInt(10000));
appArticleRespVO.setSpuId((long) random.nextInt(10000));
appArticleRespVO.setSpuId(633L);
return success(appArticleRespVO);
return success(ArticleConvert.INSTANCE.convert01(articleService.getArticle(id)));
}
// TODO @puhui999增加浏览量实现一个接口先简单做用户规模不大 +1 即可psuniapp 那边也要接下噢
}

View File

@ -39,11 +39,4 @@ public class AppArticleRespVO {
@Schema(description = "关联的商品 SPU 编号", example = "1024")
private Long spuId;
// TODO 芋艿下面 2 个字段后端要存储前端不用返回
// @Schema(description = "是否热卖推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
// private Boolean recommendHot;
//
// @Schema(description = "是否 Banner 推荐", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
// private Boolean recommendBanner;
}

View File

@ -16,11 +16,4 @@ public class AppArticleCategoryRespVO {
@Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png")
private String picUrl;
// TODO 芋艿下面 2 个字段后端要存储前端不用返回
// @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
// private Integer status;
//
// @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
// private Integer sort;
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.convert.article;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -30,4 +31,6 @@ public interface ArticleCategoryConvert {
List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list);
List<AppArticleCategoryRespVO> convertList04(List<ArticleCategoryDO> categoryList);
}

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticleRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -30,4 +31,10 @@ public interface ArticleConvert {
PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page);
AppArticleRespVO convert01(ArticleDO article);
PageResult<AppArticleRespVO> convertPage02(PageResult<ArticleDO> articlePage);
List<AppArticleRespVO> convertList03(List<ArticleDO> articleCategoryListByRecommendHotAndRecommendBanner);
}

View File

@ -207,31 +207,30 @@ public interface CombinationActivityConvert {
/**
* 转换生成虚拟成团虚拟记录
*
* @param virtualGroupHeadRecords 虚拟成团团长记录列表
* @param virtualGroupHeadRecord 虚拟成团团长记录
* @return 虚拟记录列表
*/
default List<CombinationRecordDO> convertVirtualGroupList(List<CombinationRecordDO> virtualGroupHeadRecords) {
// TODO @puhui9991方法名建议改成 convertVirtualRecordList(CombinationRecordDO headRecord)2 220 225 可以搞成 mapstruct 一个方法默认都 copy 进去然后 set 226 232 的字段
default List<CombinationRecordDO> convertVirtualGroupList(CombinationRecordDO virtualGroupHeadRecord) {
List<CombinationRecordDO> createRecords = new ArrayList<>();
virtualGroupHeadRecords.forEach(headRecord -> {
// 计算需要创建的虚拟成团记录数量
int count = headRecord.getUserSize() - headRecord.getUserCount();
for (int i = 0; i < count; i++) {
// 基础信息和团长保持一致
CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(headRecord.getActivityId())
.setCombinationPrice(headRecord.getCombinationPrice()).setSpuId(headRecord.getSpuId()).setSpuName(headRecord.getSpuName())
.setPicUrl(headRecord.getPicUrl()).setSkuId(headRecord.getSkuId()).setHeadId(headRecord.getId())
.setStatus(headRecord.getStatus()) // 状态保持和创建时一致创建完成后会接着处理
.setVirtualGroup(headRecord.getVirtualGroup()).setExpireTime(headRecord.getExpireTime())
.setStartTime(headRecord.getStartTime()).setUserSize(headRecord.getUserSize()).setUserCount(headRecord.getUserCount());
// 虚拟信息
newRecord.setCount(0);
newRecord.setUserId(0L);
newRecord.setNickname("");
newRecord.setAvatar("");
newRecord.setOrderId(0L);
createRecords.add(newRecord);
}
});
// 计算需要创建的虚拟成团记录数量
int count = virtualGroupHeadRecord.getUserSize() - virtualGroupHeadRecord.getUserCount();
for (int i = 0; i < count; i++) {
// 基础信息和团长保持一致
CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(virtualGroupHeadRecord.getActivityId())
.setCombinationPrice(virtualGroupHeadRecord.getCombinationPrice()).setSpuId(virtualGroupHeadRecord.getSpuId()).setSpuName(virtualGroupHeadRecord.getSpuName())
.setPicUrl(virtualGroupHeadRecord.getPicUrl()).setSkuId(virtualGroupHeadRecord.getSkuId()).setHeadId(virtualGroupHeadRecord.getId())
.setStatus(virtualGroupHeadRecord.getStatus()) // 状态保持和创建时一致创建完成后会接着处理
.setVirtualGroup(virtualGroupHeadRecord.getVirtualGroup()).setExpireTime(virtualGroupHeadRecord.getExpireTime())
.setStartTime(virtualGroupHeadRecord.getStartTime()).setUserSize(virtualGroupHeadRecord.getUserSize()).setUserCount(virtualGroupHeadRecord.getUserCount());
// 虚拟信息
newRecord.setCount(0);
newRecord.setUserId(0L);
newRecord.setNickname("");
newRecord.setAvatar("");
newRecord.setOrderId(0L);
createRecords.add(newRecord);
}
return createRecords;
}

View File

@ -4,9 +4,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 文章管理 Mapper
*
@ -28,4 +31,16 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> {
.orderByDesc(ArticleDO::getId));
}
default List<ArticleDO> selectList(Boolean recommendHot, Boolean recommendBanner) {
return selectList(new LambdaQueryWrapperX<ArticleDO>()
.eqIfPresent(ArticleDO::getRecommendHot, recommendHot)
.eqIfPresent(ArticleDO::getRecommendBanner, recommendBanner));
}
default PageResult<ArticleDO> selectPage(AppArticlePageReqVO pageReqVO) {
return selectPage(pageReqVO, new LambdaQueryWrapperX<ArticleDO>()
.eqIfPresent(ArticleDO::getCategoryId, pageReqVO.getCategoryId()));
}
}

View File

@ -127,11 +127,9 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
*
* @return 参加过拼团的用户数
*/
// TODO @puhui9991方法名直接 selectUserCount2COUNT(DISTINCT(user_id)) 就可以啦不用 group by
default Long selectUserDistinctCount() {
default Long selectUserCount() {
return selectCount(new QueryWrapper<CombinationRecordDO>()
.select("DISTINCT (user_id)")
.groupBy("user_id"));
.select("DISTINCT (user_id)"));
}
default List<CombinationRecordDO> selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) {
@ -141,8 +139,8 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
.lt(CombinationRecordDO::getExpireTime, dateTime));
}
default List<CombinationRecordDO> selectListByHeadIds(Collection<Long> headIds) {
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>().in(CombinationRecordDO::getHeadId, headIds));
default List<CombinationRecordDO> selectListByHeadId(Long headId) {
return selectList(CombinationRecordDO::getHeadId, headId);
}
}

View File

@ -1,12 +1,15 @@
package cn.iocoder.yudao.module.promotion.service.article;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO;
import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -14,6 +17,7 @@ import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS;
/**
@ -28,6 +32,10 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService {
@Resource
private ArticleCategoryMapper articleCategoryMapper;
@Resource
@Lazy // 延迟加载解决循环依赖问题
private ArticleService articleService;
@Override
public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) {
// 插入
@ -50,7 +58,12 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService {
public void deleteArticleCategory(Long id) {
// 校验存在
validateArticleCategoryExists(id);
// TODO @puhui999需要校验下是不是存在文章
// 校验是不是存在关联文章
// TODO @puhui999最好获得数量哈
List<ArticleDO> articleList = articleService.getArticleByCategoryId(id);
if (CollUtil.isNotEmpty(articleList)) {
throw exception(ARTICLE_CATEGORY_DELETE_FAIL_HAVE_ARTICLES);
}
// 删除
articleCategoryMapper.deleteById(id);
@ -74,6 +87,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService {
@Override
public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) {
// TODO @puhui999selectListByStatus
return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status);
}

View File

@ -4,19 +4,21 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import javax.validation.Valid;
import java.util.List;
/**
* 文章管理 Service 接口
* 文章详情 Service 接口
*
* @author HUIHUI
*/
public interface ArticleService {
/**
* 创建文章管理
* 创建文章详情
*
* @param createReqVO 创建信息
* @return 编号
@ -24,33 +26,58 @@ public interface ArticleService {
Long createArticle(@Valid ArticleCreateReqVO createReqVO);
/**
* 更新文章管理
* 更新文章详情
*
* @param updateReqVO 更新信息
*/
void updateArticle(@Valid ArticleUpdateReqVO updateReqVO);
/**
* 删除文章管理
* 删除文章详情
*
* @param id 编号
*/
void deleteArticle(Long id);
/**
* 获得文章管理
* 获得文章详情
*
* @param id 编号
* @return 文章管理
* @return 文章详情
*/
ArticleDO getArticle(Long id);
/**
* 获得文章管理分页
* 获得文章详情分页
*
* @param pageReqVO 分页查询
* @return 文章管理分页
* @return 文章详情分页
*/
PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO);
/**
* 获得文章详情列表
*
* @param recommendHot 是否热门
* @param recommendBanner 是否轮播图
* @return 文章详情列表
*/
List<ArticleDO> getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner);
/**
* 获得文章详情分页
*
* @param pageReqVO 分页查询
* @return 文章详情分页
*/
PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO);
/**
* 获得指定分类的文章列表
*
* @param categoryId 文章分类编号
* @return 文章列表
*/
List<ArticleDO> getArticleByCategoryId(Long categoryId);
}

View File

@ -4,15 +4,19 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.article.AppArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.convert.article.ArticleConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS;
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS;
/**
@ -27,9 +31,14 @@ public class ArticleServiceImpl implements ArticleService {
@Resource
private ArticleMapper articleMapper;
@Resource
private ArticleCategoryService articleCategoryService;
@Override
public Long createArticle(ArticleCreateReqVO createReqVO) {
// TODO @puhui999需要校验分类存在
// 校验分类存在
validateArticleCategoryExists(createReqVO.getCategoryId());
// 插入
ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO);
articleMapper.insert(article);
@ -41,7 +50,8 @@ public class ArticleServiceImpl implements ArticleService {
public void updateArticle(ArticleUpdateReqVO updateReqVO) {
// 校验存在
validateArticleExists(updateReqVO.getId());
// TODO @puhui999需要校验分类存在
// 校验分类存在
validateArticleCategoryExists(updateReqVO.getCategoryId());
// 更新
ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO);
@ -62,6 +72,13 @@ public class ArticleServiceImpl implements ArticleService {
}
}
private void validateArticleCategoryExists(Long categoryId) {
ArticleCategoryDO articleCategory = articleCategoryService.getArticleCategory(categoryId);
if (articleCategory == null) {
throw exception(ARTICLE_CATEGORY_NOT_EXISTS);
}
}
@Override
public ArticleDO getArticle(Long id) {
return articleMapper.selectById(id);
@ -72,4 +89,19 @@ public class ArticleServiceImpl implements ArticleService {
return articleMapper.selectPage(pageReqVO);
}
@Override
public List<ArticleDO> getArticleCategoryListByRecommend(Boolean recommendHot, Boolean recommendBanner) {
return articleMapper.selectList(recommendHot, recommendBanner);
}
@Override
public PageResult<ArticleDO> getArticlePage(AppArticlePageReqVO pageReqVO) {
return articleMapper.selectPage(pageReqVO);
}
@Override
public List<ArticleDO> getArticleByCategoryId(Long categoryId) {
return articleMapper.selectList(ArticleDO::getCategoryId, categoryId);
}
}

View File

@ -247,7 +247,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
@Override
public Long getCombinationUserCount() {
return combinationRecordMapper.selectUserDistinctCount();
return combinationRecordMapper.selectUserCount();
}
@Override
@ -351,86 +351,87 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
convertSet(headExpireRecords, CombinationRecordDO::getActivityId));
Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId);
// TODO @puhui999这里可以改成每个团处理一次哈这样 handleExpireRecordhandleVirtualGroupRecord 都改成按团处理每个是一个小事务
// 3. 校验是否虚拟成团
List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团
for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) {
CombinationRecordDO record = iterator.next();
// 3.1.不匹配则直接跳过
CombinationActivityDO activity = activityMap.get(record.getActivityId());
if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的
continue;
// 3. 逐个处理拼团过期 or 虚拟成团
KeyValue<Integer, Integer> keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团
for (CombinationRecordDO recordDO : headExpireRecords) {
// TODO @puhui999recordDO 非必要的情况下不用带 DO直接 record;
try {
CombinationActivityDO activity = activityMap.get(recordDO.getActivityId());
if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的
// 3.1. 处理过期的拼团
getSelf().handleExpireRecord(recordDO);
keyValue.setKey(keyValue.getKey() + 1);
} else {
// 3.2. 处理虚拟成团
getSelf().handleVirtualGroupRecord(recordDO);
keyValue.setValue(keyValue.getValue() + 1);
}
} catch (Exception ignored) { // 处理异常继续循环
// TODO @puhui999需要打印异常日志
}
// 3.2.匹配则移除添加到虚拟成团中并结束寻找
virtualGroupHeadRecords.add(record);
iterator.remove();
break;
}
// 4.处理过期的拼团
getSelf().handleExpireRecord(headExpireRecords);
// 5.虚拟成团
getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords);
return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size());
return keyValue;
}
/**
* 处理过期拼团
*
* @param headExpireRecords 过期拼团团长记录列表
* @param headExpireRecord 过期拼团团长记录列表
*/
@Transactional(rollbackFor = Exception.class)
public void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) {
if (CollUtil.isEmpty(headExpireRecords)) {
public void handleExpireRecord(CombinationRecordDO headExpireRecord) {
// TODO @puhui999这里的 null 其实不用判断真出现应该要处个 npe因为就是要错哈
// TODO @puhui999headExpireRecord 可以简化成 headRecord
if (headExpireRecord == null) {
return;
}
// 1.更新拼团记录
List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecords,
List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecord,
CombinationRecordStatusEnum.FAILED);
// TODO @puhui999这里的 null 其实不用判断真出现应该要处个 npe因为就是要错哈
if (headsAndRecords == null) {
return;
}
// 2.订单取消 TODO 以现在的取消回滚逻辑好像只能循环了
headsAndRecords.forEach(item -> {
tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId());
});
// 2.订单取消
headsAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()));
}
/**
* 处理虚拟拼团
*
* @param virtualGroupHeadRecords 虚拟成团团长记录列表
* @param virtualGroupHeadRecord 虚拟成团团长记录列表
*/
@Transactional(rollbackFor = Exception.class)
public void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) {
if (CollUtil.isEmpty(virtualGroupHeadRecords)) {
public void handleVirtualGroupRecord(CombinationRecordDO virtualGroupHeadRecord) {
// TODO @puhui999这里的 null 其实不用判断真出现应该要处个 npe因为就是要错哈
// TODO @puhui999headExpireRecord 可以简化成 headRecord
if (virtualGroupHeadRecord == null) {
return;
}
// 1. 团员补齐
combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords));
combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecord));
// 2. 更新拼团记录
updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS);
updateBatchCombinationRecords(virtualGroupHeadRecord, CombinationRecordStatusEnum.SUCCESS);
}
private List<CombinationRecordDO> updateBatchCombinationRecords(List<CombinationRecordDO> headRecords, CombinationRecordStatusEnum status) {
// 1. 查询团成员
List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadIds(
convertSet(headRecords, CombinationRecordDO::getId));
// TODO @puhui999写下方法注释
private List<CombinationRecordDO> updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) {
// 1. 查询团成员包含团长
List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadId(headRecord.getId());
// TODO @puhui999是不是不用判断空哈例如说就一个团长然后过期
if (CollUtil.isEmpty(records)) {
return null;
}
Map<Long, List<CombinationRecordDO>> recordsMap = convertMultiMap(records, CombinationRecordDO::getHeadId);
headRecords.forEach(item -> {
recordsMap.get(item.getId()).add(item); // 把团长加进团里
});
// 2.批量更新拼团记录 status 失败/成团时间
List<CombinationRecordDO> headsAndRecords = mergeValuesFromMap(recordsMap);
List<CombinationRecordDO> updateRecords = new ArrayList<>(headsAndRecords.size());
records.add(headRecord);// 把团长加进去
// 2. 批量更新拼团记录 status endTime
List<CombinationRecordDO> updateRecords = new ArrayList<>(records.size());
LocalDateTime now = LocalDateTime.now();
headsAndRecords.forEach(item -> {
records.forEach(item -> {
// TODO @puhui999record 改成 updateRecord
CombinationRecordDO record = new CombinationRecordDO().setId(item.getId())
.setStatus(status.getStatus()).setEndTime(now);
if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数
@ -439,7 +440,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
updateRecords.add(record);
});
combinationRecordMapper.updateBatch(updateRecords);
return headsAndRecords;
return records;
}
/**

View File

@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.article;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.ArticleExportReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
@ -166,68 +164,4 @@ public class ArticleServiceImplTest extends BaseDbUnitTest {
assertPojoEquals(dbArticle, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetArticleList() {
// mock 数据
ArticleDO dbArticle = randomPojo(ArticleDO.class, o -> { // 等会查询到
o.setCategoryId(null);
o.setTitle(null);
o.setAuthor(null);
o.setPicUrl(null);
o.setIntroduction(null);
o.setBrowseCount(null);
o.setSort(null);
o.setStatus(null);
o.setSpuId(null);
o.setRecommendHot(null);
o.setRecommendBanner(null);
o.setContent(null);
o.setCreateTime(null);
});
articleMapper.insert(dbArticle);
// 测试 categoryId 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCategoryId(null)));
// 测试 title 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setTitle(null)));
// 测试 author 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setAuthor(null)));
// 测试 picUrl 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setPicUrl(null)));
// 测试 introduction 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setIntroduction(null)));
// 测试 browseCount 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setBrowseCount(null)));
// 测试 sort 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSort(null)));
// 测试 status 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setStatus(null)));
// 测试 spuId 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setSpuId(null)));
// 测试 recommendHot 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendHot(null)));
// 测试 recommendBanner 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setRecommendBanner(null)));
// 测试 content 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setContent(null)));
// 测试 createTime 不匹配
articleMapper.insert(cloneIgnoreId(dbArticle, o -> o.setCreateTime(null)));
// 准备参数
ArticleExportReqVO reqVO = new ArticleExportReqVO();
reqVO.setCategoryId(null);
reqVO.setTitle(null);
reqVO.setAuthor(null);
reqVO.setStatus(null);
reqVO.setSpuId(null);
reqVO.setRecommendHot(null);
reqVO.setRecommendBanner(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
List<ArticleDO> list = articleService.getArticleList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbArticle, list.get(0));
}
}

View File

@ -77,8 +77,7 @@ public class MemberStatisticsController {
}
// TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致
@GetMapping("/get-area-statistics-list")
@GetMapping("/area-statistics-list")
@Operation(summary = "按照省份,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberAreaStatisticsRespVO>> getMemberAreaStatisticsList() {
@ -86,8 +85,7 @@ public class MemberStatisticsController {
}
// TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致
@GetMapping("/get-sex-statistics-list")
@GetMapping("/sex-statistics-list")
@Operation(summary = "按照性别,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberSexStatisticsRespVO>> getMemberSexStatisticsList() {
@ -95,14 +93,15 @@ public class MemberStatisticsController {
}
// TODO 芋艿已经 review
// TODO @疯狂要不 get 前缀去掉和下面的 list 接口保持一致
@GetMapping("/get-terminal-statistics-list")
@GetMapping("/terminal-statistics-list")
@Operation(summary = "按照终端,获得会员统计列表")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
public CommonResult<List<MemberTerminalStatisticsRespVO>> getMemberTerminalStatisticsList() {
return success(memberStatisticsService.getRegisterTerminalStatisticsList());
return success(memberStatisticsService.getMemberTerminalStatisticsList());
}
// TODO 芋艿已经 review
// TODO @疯狂要注意 date 的排序
@GetMapping("/user-count-comparison")
@Operation(summary = "获得用户数量对照")
@PreAuthorize("@ss.hasPermission('statistics:member:query')")

View File

@ -10,8 +10,7 @@ public class MemberCountRespVO {
@Schema(description = "用户访问量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer visitUserCount;
// TODO @疯狂要不改成 registerUserCount注册
@Schema(description = "新增用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer createUserCount;
@Schema(description = "注册用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer registerUserCount;
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.statistics.controller.admin.pay;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO;
import cn.iocoder.yudao.module.statistics.convert.pay.PayStatisticsConvert;
import cn.iocoder.yudao.module.statistics.service.pay.PayWalletStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -24,11 +26,11 @@ public class PayStatisticsController {
@Resource
private PayWalletStatisticsService payWalletStatisticsService;
// TODO @疯狂要不搞成 PaySummary只是目前只有 rechargePrice 充值金额
@GetMapping("/wallet-recharge-price")
@GetMapping("/summary")
@Operation(summary = "获取充值金额")
public CommonResult<Integer> getWalletRechargePrice() {
return success(payWalletStatisticsService.getRechargePriceSummary());
public CommonResult<PaySummaryRespVO> getWalletRechargePrice() {
Integer rechargePrice = payWalletStatisticsService.getRechargePriceSummary();
return success(PayStatisticsConvert.INSTANCE.convert(rechargePrice));
}
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.statistics.controller.admin.pay.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 支付统计 Response VO")
@Data
public class PaySummaryRespVO {
@Schema(description = "充值金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer rechargePrice;
}

View File

@ -14,6 +14,8 @@ import cn.iocoder.yudao.module.statistics.service.trade.TradeStatisticsService;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.aftersale.AfterSaleStatusEnum;
import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum;
import cn.iocoder.yudao.module.trade.enums.delivery.DeliveryTypeEnum;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
@ -104,11 +106,15 @@ public class TradeStatisticsController {
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<TradeOrderCountRespVO> getOrderCount() {
// 订单统计
TradeOrderCountRespVO vo = tradeOrderStatisticsService.getOrderCount();
Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType(
TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType());
Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType(
TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType());
// 售后统计
vo.setAfterSaleApply(afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY))
.setAuditingWithdraw(brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING));
return success(vo);
Long afterSaleApplyCount = afterSaleStatisticsService.getCountByStatus(AfterSaleStatusEnum.APPLY);
Long auditingWithdrawCount = brokerageStatisticsService.getWithdrawCountByStatus(BrokerageWithdrawStatusEnum.AUDITING);
// 拼接返回
return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount));
}
// TODO 芋艿已经 review
@ -124,6 +130,7 @@ public class TradeStatisticsController {
@Operation(summary = "获得订单量趋势统计")
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) {
// TODO @疯狂要注意 date 的排序
return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO));
}

View File

@ -34,11 +34,11 @@ public class TradeTrendSummaryExcelVO {
private Integer expensePrice;
@ExcelProperty(value = "余额支付金额", converter = MoneyConvert.class)
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
@ExcelProperty(value = "支付佣金金额", converter = MoneyConvert.class)
private Integer brokerageSettlementPrice;
@ExcelProperty(value = "商品退款金额", converter = MoneyConvert.class)
private Integer orderRefundPrice;
private Integer afterSaleRefundPrice;
}

View File

@ -23,10 +23,10 @@ public class TradeTrendSummaryRespVO {
private Integer orderPayPrice;
@Schema(description = "余额支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
@Schema(description = "订单退款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer orderRefundPrice;
private Integer afterSaleRefundPrice;
@Schema(description = "支付佣金金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Integer brokerageSettlementPrice;

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnaly
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAnalyseRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberSummaryRespVO;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import cn.iocoder.yudao.module.statistics.service.pay.bo.RechargeSummaryRespBO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@ -29,10 +30,10 @@ public interface MemberStatisticsConvert {
default List<MemberAreaStatisticsRespVO> convertList(List<Area> areaList,
Map<Integer, Integer> userCountMap,
Map<Integer, MemberAreaStatisticsRespVO> orderMap) {
Map<Integer, MemberAreaStatisticsRespBO> orderMap) {
return CollectionUtils.convertList(areaList, area -> {
MemberAreaStatisticsRespVO orderVo = Optional.ofNullable(orderMap.get(area.getId()))
.orElseGet(MemberAreaStatisticsRespVO::new);
MemberAreaStatisticsRespBO orderVo = Optional.ofNullable(orderMap.get(area.getId()))
.orElseGet(MemberAreaStatisticsRespBO::new);
return new MemberAreaStatisticsRespVO()
.setAreaId(area.getId()).setAreaName(area.getName())
.setUserCount(MapUtil.getInt(userCountMap, area.getId(), 0))

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.statistics.convert.pay;
import cn.iocoder.yudao.module.statistics.controller.admin.pay.vo.PaySummaryRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 支付统计 Convert
*
* @author owen
*/
@Mapper
public interface PayStatisticsConvert {
PayStatisticsConvert INSTANCE = Mappers.getMapper(PayStatisticsConvert.class);
PaySummaryRespVO convert(Integer rechargePrice);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.statistics.convert.trade;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderCountRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryExcelVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO;
@ -9,7 +10,9 @@ import cn.iocoder.yudao.module.statistics.service.trade.bo.AfterSaleSummaryRespB
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeSummaryRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.WalletSummaryRespBO;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import java.time.LocalDateTime;
@ -50,21 +53,22 @@ public interface TradeStatisticsConvert {
AfterSaleSummaryRespBO afterSaleSummary, Integer brokerageSettlementPrice,
WalletSummaryRespBO walletSummary);
@IterableMapping(qualifiedByName = "convert")
List<TradeTrendSummaryRespVO> convertList(List<TradeStatisticsDO> list);
// TODO @疯狂要不要搞个默认的 convertA 方法然后这个 convert 去调用 convertA特殊字段再去 set
TradeTrendSummaryRespVO convertA(TradeStatisticsDO tradeStatistics);
@Named("convert")
default TradeTrendSummaryRespVO convert(TradeStatisticsDO tradeStatistics) {
return new TradeTrendSummaryRespVO()
TradeTrendSummaryRespVO vo = convertA(tradeStatistics);
return vo
.setDate(tradeStatistics.getTime().toLocalDate())
// 营业额 = 商品支付金额 + 充值金额
.setTurnoverPrice(tradeStatistics.getOrderPayPrice() + tradeStatistics.getRechargePayPrice())
.setOrderPayPrice(tradeStatistics.getOrderPayPrice())
.setRechargePrice(tradeStatistics.getRechargePayPrice())
// 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
.setExpensePrice(tradeStatistics.getOrderWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice())
.setOrderWalletPayPrice(tradeStatistics.getOrderWalletPayPrice())
.setBrokerageSettlementPrice(tradeStatistics.getBrokerageSettlementPrice())
.setOrderRefundPrice(tradeStatistics.getAfterSaleRefundPrice());
.setExpensePrice(tradeStatistics.getWalletPayPrice() + tradeStatistics.getBrokerageSettlementPrice() + tradeStatistics.getAfterSaleRefundPrice());
}
TradeOrderCountRespVO convert(Long undelivered, Long pickUp, Long afterSaleApply, Long auditingWithdraw);
}

View File

@ -63,11 +63,10 @@ public class TradeStatisticsDO extends TenantBaseDO {
*/
private Integer brokerageSettlementPrice;
// TODO @疯狂walletPayPrice钱包支付金额
/**
* 总支付金额余额单位
*/
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
/**
* 充值订单数
* <p>

View File

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.statistics.dal.mysql.trade;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO;
import cn.iocoder.yudao.module.statistics.dal.dataobject.trade.TradeStatisticsDO;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -20,7 +20,7 @@ import java.util.List;
public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsDO> {
// TODO 芋艿已经 review
List<MemberAreaStatisticsRespVO> selectSummaryListByAreaId();
List<MemberAreaStatisticsRespBO> selectSummaryListByAreaId();
// TODO 芋艿已经 review
Integer selectCountByCreateTimeBetween(@Param("beginTime") LocalDateTime beginTime,
@ -65,10 +65,7 @@ public interface TradeOrderStatisticsMapper extends BaseMapperX<TradeStatisticsD
@Param("endTime") LocalDateTime endTime);
// TODO @芋艿已经 review
Long selectCountByStatus(@Param("status") Integer status);
// TODO 芋艿已经 review
Long selectCountByStatusAndPickUpStoreIdIsNotNull(@Param("status") Integer status);
Long selectCountByStatusAndDeliveryType(@Param("status") Integer status, @Param("deliveryType") Integer deliveryType);
// TODO 芋艿已经 review
TradeOrderSummaryRespVO selectPaySummaryByStatusAndPayTimeBetween(@Param("status") Integer status,

View File

@ -30,8 +30,10 @@ public class TradeStatisticsJob implements JobHandler {
@Override
@TenantJob
public String execute(String param) {
// TODO @疯狂要搞个默认的 1
if (NumberUtil.isInteger(param)) {
// 默认 昨日
if (StrUtil.isBlank(param)) {
param = "1";
} else if (!NumberUtil.isInteger(param)) {
throw new RuntimeException("交易统计任务的参数只能为是正整数");
}
Integer days = Convert.toInt(param, 0);

View File

@ -48,13 +48,12 @@ public interface MemberStatisticsService {
*/
List<MemberSexStatisticsRespVO> getMemberSexStatisticsList();
// TODO @疯狂这个要不要使用 getMemberTerminalStatisticsList保持统一
/**
* 按照终端获得会员统计列表
*
* @return 会员统计列表
*/
List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList();
List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList();
// TODO 芋艿已经 review
/**

View File

@ -65,10 +65,10 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
MemberAreaStatisticsRespBO::getUserCount, Integer::sum);
// 统计订单
Map<Integer, MemberAreaStatisticsRespVO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
vo -> AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE),
vo -> vo,
(a, b) -> new MemberAreaStatisticsRespVO()
Map<Integer, MemberAreaStatisticsRespBO> orderMap = convertMap(tradeOrderStatisticsService.getSummaryListByAreaId(),
bo -> AreaUtils.getParentIdByType(bo.getAreaId(), AreaTypeEnum.PROVINCE),
bo -> bo,
(a, b) -> new MemberAreaStatisticsRespBO()
.setOrderCreateUserCount(a.getOrderCreateUserCount() + b.getOrderCreateUserCount())
.setOrderPayUserCount(a.getOrderPayUserCount() + b.getOrderPayUserCount())
.setOrderPayPrice(a.getOrderPayPrice() + b.getOrderPayPrice()));
@ -105,7 +105,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
}
@Override
public List<MemberTerminalStatisticsRespVO> getRegisterTerminalStatisticsList() {
public List<MemberTerminalStatisticsRespVO> getMemberTerminalStatisticsList() {
return memberStatisticsMapper.selectSummaryListByRegisterTerminal();
}
@ -129,7 +129,7 @@ public class MemberStatisticsServiceImpl implements MemberStatisticsService {
private MemberCountRespVO getUserCount(LocalDateTime beginTime, LocalDateTime endTime) {
return new MemberCountRespVO()
.setCreateUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setRegisterUserCount(memberStatisticsMapper.selectUserCount(beginTime, endTime))
.setVisitUserCount(apiAccessLogStatisticsService.getIpCount(UserTypeEnum.MEMBER.getValue(), beginTime, endTime));
}

View File

@ -33,7 +33,7 @@ public class PayWalletStatisticsServiceImpl implements PayWalletStatisticsServic
Integer walletPayPrice = payWalletStatisticsMapper.selectPriceSummaryByBizTypeAndCreateTimeBetween(
beginTime, endTime, PayWalletBizTypeEnum.PAYMENT.getType());
// 拼接
paySummary.setOrderWalletPayPrice(walletPayPrice)
paySummary.setWalletPayPrice(walletPayPrice)
.setRechargeRefundCount(refundSummary.getRechargeRefundCount())
.setRechargeRefundPrice(refundSummary.getRechargeRefundPrice());
return paySummary;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.statistics.service.trade;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import java.time.LocalDateTime;
@ -30,7 +30,7 @@ public interface TradeOrderStatisticsService {
*
* @return 订单统计结果
*/
List<MemberAreaStatisticsRespVO> getSummaryListByAreaId();
List<MemberAreaStatisticsRespBO> getSummaryListByAreaId();
// TODO 芋艿已经 review
/**
@ -62,13 +62,12 @@ public interface TradeOrderStatisticsService {
*/
Integer getOrderPayPrice(LocalDateTime beginTime, LocalDateTime endTime);
// TODO 芋艿已经 review
/**
* 获得交易订单数量
* 根据订单状态物流类型获得交易订单数量
*
* @return 订单数量
*/
TradeOrderCountRespVO getOrderCount();
Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType);
// TODO 芋艿已经 review
/**

View File

@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.statistics.service.trade;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
import cn.iocoder.yudao.module.statistics.controller.admin.common.vo.DataComparisonRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.*;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderSummaryRespVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendReqVO;
import cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeOrderTrendRespVO;
import cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper;
import cn.iocoder.yudao.module.statistics.enums.TimeRangeTypeEnum;
import cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO;
import cn.iocoder.yudao.module.statistics.service.trade.bo.TradeOrderSummaryRespBO;
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -42,7 +42,7 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
}
@Override
public List<MemberAreaStatisticsRespVO> getSummaryListByAreaId() {
public List<MemberAreaStatisticsRespBO> getSummaryListByAreaId() {
return tradeOrderStatisticsMapper.selectSummaryListByAreaId();
}
@ -62,13 +62,8 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
}
@Override
public TradeOrderCountRespVO getOrderCount() {
// TODO 疯狂这个可以根据 status + delivertyType 来过滤呀ps是不是搞个 service 方法交给上层去聚合这样 TradeOrderCountRespVO 可以更明确返回不用搞 bo
Long undeliveredCount = tradeOrderStatisticsMapper.selectCountByStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus());
Long pickUpCount = tradeOrderStatisticsMapper.selectCountByStatusAndPickUpStoreIdIsNotNull(TradeOrderStatusEnum.DELIVERED.getStatus());
return new TradeOrderCountRespVO()
.setPickUp(ObjUtil.defaultIfNull(pickUpCount, 0L))
.setUndelivered(ObjUtil.defaultIfNull(undeliveredCount, 0L));
public Long getCountByStatusAndDeliveryType(Integer status, Integer deliveryType) {
return tradeOrderStatisticsMapper.selectCountByStatusAndDeliveryType(status, deliveryType);
}
@Override

View File

@ -83,9 +83,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
@Override
public String statisticsTrade(Integer days) {
LocalDateTime today = LocalDateTime.now();
// TODO @疯狂不用并发哈因为租户可能会丢然后一般串行就好对性能没绝对的要求哈天数也不会多
return IntStream.rangeClosed(1, days)
.parallel()
.mapToObj(day -> statisticsTrade(today.minusDays(day)))
.sorted()
.collect(Collectors.joining("\n"));
@ -131,7 +129,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice,
walletSummary);
tradeStatisticsMapper.insert(entity);
// TODO @疯狂这里是不是也要把日期带上类似 108 那边
// TODO @疯狂这里是不是也要把日期带上类似 108 那边; 110 已经带上了
return stopWatch.prettyPrint();
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.statistics.service.trade.bo;
import lombok.Data;
/**
* 会员地区统计 Response BO
*
* @author owen
*/
@Data
public class MemberAreaStatisticsRespBO {
/**
* 省份编号
*/
private Integer areaId;
/**
* 省份名称
*/
private String areaName;
/**
* 会员数量
*/
private Integer userCount;
/**
* 下单的会员数量
*/
private Integer orderCreateUserCount;
/**
* 支付订单的会员数量
*/
private Integer orderPayUserCount;
/**
* 订单支付金额单位
*/
private Integer orderPayPrice;
}

View File

@ -13,7 +13,7 @@ public class WalletSummaryRespBO {
/**
* 总支付金额余额单位
*/
private Integer orderWalletPayPrice;
private Integer walletPayPrice;
/**
* 充值订单数

View File

@ -2,9 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeOrderStatisticsMapper">
<!-- TODO @疯狂:是返回不是的 MemberAreaStatisticsRespBO 哈 -->
<select id="selectSummaryListByAreaId"
resultType="cn.iocoder.yudao.module.statistics.controller.admin.member.vo.MemberAreaStatisticsRespVO">
resultType="cn.iocoder.yudao.module.statistics.service.member.bo.MemberAreaStatisticsRespBO">
SELECT receiver_area_id AS areaId,
(SELECT COUNT(DISTINCT s.user_id)
FROM trade_order AS s
@ -86,18 +85,11 @@
GROUP BY date
</select>
<select id="selectCountByStatus" resultType="java.lang.Long">
<select id="selectCountByStatusAndDeliveryType" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status}
AND deleted = FALSE
</select>
<select id="selectCountByStatusAndPickUpStoreIdIsNotNull" resultType="java.lang.Long">
SELECT COUNT(1)
FROM trade_order
WHERE status = #{status}
AND pick_up_store_id IS NOT NULL
ANd delivery_type = #{deliveryType}
AND deleted = FALSE
</select>

View File

@ -15,14 +15,14 @@
resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO">
SELECT
-- 营业额 = 商品支付金额 + 充值金额
SUM(order_pay_price + recharge_pay_price) AS turnoverPrice,
SUM(order_pay_price) AS orderPayPrice,
SUM(recharge_pay_price) AS rechargePrice,
SUM(order_pay_price + recharge_pay_price) AS turnoverPrice,
SUM(order_pay_price) AS orderPayPrice,
SUM(recharge_pay_price) AS rechargePrice,
-- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
SUM(order_wallet_pay_price) AS orderWalletPayPrice,
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
SUM(after_sale_refund_price) AS orderRefundPrice
SUM(wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice,
SUM(wallet_pay_price) AS walletPayPrice,
SUM(brokerage_settlement_price) AS brokerageSettlementPrice,
SUM(after_sale_refund_price) AS afterSaleRefundPrice
FROM trade_statistics
WHERE time BETWEEN #{beginTime} AND #{endTime}
AND deleted = FALSE
@ -30,7 +30,7 @@
<select id="selectExpensePriceByTimeBetween" resultType="java.lang.Integer">
SELECT -- 支出金额 = 余额支付金额 + 支付佣金金额 + 商品退款金额
SUM(order_wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
SUM(wallet_pay_price + brokerage_settlement_price + after_sale_refund_price) AS expensePrice
FROM trade_statistics
WHERE deleted = FALSE
<if test="beginTime != null">

View File

@ -56,7 +56,7 @@ public class TradeOrderController {
}
// 查询用户信息
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), TradeOrderDO::getUserId));;
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(pageResult.getList(), TradeOrderDO::getUserId));
// 查询订单项
List<TradeOrderItemDO> orderItems = tradeOrderQueryService.getOrderItemListByOrderId(
convertSet(pageResult.getList(), TradeOrderDO::getId));
@ -126,18 +126,31 @@ public class TradeOrderController {
return success(true);
}
// TODO @疯狂1订单列表界面增加一个核销按钮点击后弹窗出一个核销码输入的窗口
//
//2输入核销码后点击确认基于 code 查询对应的订单之后弹窗展示
//
//3新的弹窗下面有个确认核销按钮确认后进行订单核销逻辑注意只有门店自提的订单才可以核销
// TODO 这里的 id 应该是 pickUpVerifyCode 参数哈
@PutMapping("/pick-up")
@PutMapping("/pick-up-by-id")
@Operation(summary = "订单核销")
@Parameter(name = "id", description = "交易订单编号")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrder(@RequestParam("id") Long id) {
public CommonResult<Boolean> pickUpOrderById(@RequestParam("id") Long id) {
tradeOrderUpdateService.pickUpOrderByMember(id);
return success(true);
}
@PutMapping("/pick-up-by-verify-code")
@Operation(summary = "订单核销")
@Parameter(name = "pickUpVerifyCode", description = "自提核销码")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrderByVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) {
tradeOrderUpdateService.pickUpOrderByAdmin(pickUpVerifyCode);
return success(true);
}
@GetMapping("/get-by-pick-up-verify-code")
@Operation(summary = "查询核销码对应的订单")
@Parameter(name = "pickUpVerifyCode", description = "自提核销码")
@PreAuthorize("@ss.hasPermission('trade:order:query')")
public CommonResult<TradeOrderDetailRespVO> getByPickUpVerifyCode(@RequestParam("pickUpVerifyCode") String pickUpVerifyCode) {
TradeOrderDO tradeOrder = tradeOrderUpdateService.getByPickUpVerifyCode(pickUpVerifyCode);
return success(TradeOrderConvert.INSTANCE.convert2(tradeOrder, null));
}
}

View File

@ -93,6 +93,9 @@ public class TradeOrderBaseVO {
@Schema(description = "自提门店", example = "10")
private Long pickUpStoreId;
@Schema(description = "自提核销码", example = "10")
private Long pickUpVerifyCode;
@Schema(description = "配送模板编号", example = "1024")
private Long deliveryTemplateId;
@ -102,9 +105,6 @@ public class TradeOrderBaseVO {
@Schema(description = "发货物流单号", example = "1024")
private String logisticsNo;
@Schema(description = "发货状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer deliveryStatus;
@Schema(description = "发货时间")
private LocalDateTime deliveryTime;

View File

@ -61,8 +61,9 @@ public class AppTradeOrderController {
@PostMapping("/create")
@Operation(summary = "创建订单")
@PreAuthenticated
public CommonResult<AppTradeOrderCreateRespVO> createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO) {
TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO);
public CommonResult<AppTradeOrderCreateRespVO> createOrder(@Valid @RequestBody AppTradeOrderCreateReqVO createReqVO,
@RequestHeader Integer terminal) {
TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO, terminal);
return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId()));
}

View File

@ -92,21 +92,12 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) {
return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode);
}
// TODO @puhui999selectByUserIdAndCombinationActivityIdAndStatus这样更容易理解哈
/**
* 只针对 combinationActivityId 的查询
*
* @param userId 用户编号
* @param activityId 拼团活动编号
* @param status 订单状态
* @return 交易订单
*/
default TradeOrderDO selectByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) {
default TradeOrderDO selectByUserIdAndCombinationActivityIdAndStatus(Long userId, Long combinationActivityId, Integer status) {
return selectOne(new LambdaQueryWrapperX<TradeOrderDO>()
.eq(TradeOrderDO::getUserId, userId)
.eq(TradeOrderDO::getStatus, status)
.eq(TradeOrderDO::getCombinationActivityId, activityId)
.eq(TradeOrderDO::getCombinationActivityId, combinationActivityId)
);
}

View File

@ -42,11 +42,11 @@ public interface TradeOrderQueryService {
* 获得指定用户指定活动指定状态的交易订单
*
* @param userId 用户编号
* @param activityId 活动编号
* @param combinationActivityId 活动编号
* @param status 订单状态
* @return 交易订单
*/
TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status);
TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status);
/**
* 获得订单列表

View File

@ -71,8 +71,8 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
}
@Override
public TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) {
return tradeOrderMapper.selectByUserIdAndActivityIdAndStatus(userId, activityId, status);
public TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status) {
return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, combinationActivityId, status);
}
@Override

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.trade.service.order;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
import cn.iocoder.yudao.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
@ -37,9 +38,10 @@ public interface TradeOrderUpdateService {
* @param userId 登录用户
* @param userIp 用户 IP 地址
* @param createReqVO 创建交易订单请求模型
* @param terminal 终端 {@link TerminalEnum}
* @return 交易订单的
*/
TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO);
TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal);
/**
* 更新交易订单已支付
@ -129,6 +131,13 @@ public interface TradeOrderUpdateService {
*/
void pickUpOrderByAdmin(String pickUpVerifyCode);
/**
* 管理员根据自提核销码查询订单
*
* @param pickUpVerifyCode 自提核销码
*/
TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode);
// =================== Order Item ===================
/**

View File

@ -11,7 +11,6 @@ import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.module.member.api.address.AddressApi;
import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO;
import cn.iocoder.yudao.module.pay.api.order.PayOrderApi;
@ -159,11 +158,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override
@Transactional(rollbackFor = Exception.class)
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_CREATE)
public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) {
public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO, Integer terminal) {
// 1.1 价格计算
TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO);
// 1.2 构建订单
TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO);
TradeOrderDO order = buildTradeOrder(userId, userIp, createReqVO, calculateRespBO, terminal);
List<TradeOrderItemDO> orderItems = buildTradeOrderItems(order, calculateRespBO);
// 2. 订单创建前的逻辑
@ -180,15 +179,14 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
}
private TradeOrderDO buildTradeOrder(Long userId, String clientIp, AppTradeOrderCreateReqVO createReqVO,
TradePriceCalculateRespBO calculateRespBO) {
TradePriceCalculateRespBO calculateRespBO, Integer terminal) {
TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO);
order.setType(calculateRespBO.getType());
order.setNo(tradeNoRedisDAO.generate(TradeNoRedisDAO.TRADE_ORDER_NO_PREFIX));
order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus());
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());
order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum));
// TODO @疯狂无状态terminal 不从 servletuTILS 而是通过 controller 传递给 service
order.setTerminal(ServletUtils.getTerminal());
order.setTerminal(terminal);
// 支付 + 退款信息
order.setAdjustPrice(0).setPayStatus(false);
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
@ -682,6 +680,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
getSelf().pickUpOrder(tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode));
}
@Override
public TradeOrderDO getByPickUpVerifyCode(String pickUpVerifyCode) {
return tradeOrderMapper.selectOneByPickUpVerifyCode(pickUpVerifyCode);
}
@Transactional(rollbackFor = Exception.class)
public void pickUpOrder(TradeOrderDO order) {
if (order == null) {

View File

@ -49,7 +49,7 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
order.getCombinationHeadId(), item.getSkuId(), item.getCount());
// 2. 校验该用户是否存在未支付的拼团活动订单避免一个拼团可以下多个单子了
TradeOrderDO activityOrder = orderQueryService.getActivityOrderByUserIdAndActivityIdAndStatus(
TradeOrderDO activityOrder = orderQueryService.getOrderByUserIdAndStatusAndCombination(
order.getUserId(), order.getCombinationActivityId(), TradeOrderStatusEnum.UNPAID.getStatus());
if (activityOrder != null) {
throw exception(ORDER_CREATE_FAIL_EXIST_UNPAID);
@ -69,9 +69,8 @@ public class TradeCombinationOrderHandler implements TradeOrderHandler {
CombinationRecordCreateRespDTO combinationRecord = combinationRecordApi.createCombinationRecord(
TradeOrderConvert.INSTANCE.convert(order, item));
// 3. 更新拼团相关信息到订单
// 为什么几个字段都要更新原因是
// 如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的
// 3. 更新拼团相关信息到订单为什么几个字段都要更新
// 原因是如果创建订单时自己是团长的情况下 combinationHeadId 是为 null 设置团长编号这个操作时在订单是否后创建拼团记录时才设置的
orderUpdateService.updateOrderCombinationInfo(order.getId(), order.getCombinationActivityId(),
combinationRecord.getCombinationRecordId(), combinationRecord.getCombinationHeadId());
}

View File

@ -152,7 +152,7 @@ public class TradeOrderUpdateServiceTest extends BaseDbUnitTest {
}))).thenReturn(1000L);
// 调用方法
TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO);
TradeOrderDO order = tradeOrderUpdateService.createOrder(userId, userIp, reqVO, null);
// 断言 TradeOrderDO 订单
List<TradeOrderDO> tradeOrderDOs = tradeOrderMapper.selectList();
assertEquals(tradeOrderDOs.size(), 1);

View File

@ -65,8 +65,9 @@ public class AppAuthController {
@PostMapping("/sms-login")
@Operation(summary = "使用手机 + 验证码登录")
public CommonResult<AppAuthLoginRespVO> smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO) {
return success(authService.smsLogin(reqVO));
public CommonResult<AppAuthLoginRespVO> smsLogin(@RequestBody @Valid AppAuthSmsLoginReqVO reqVO,
@RequestHeader Integer terminal) {
return success(authService.smsLogin(reqVO, terminal));
}
@PostMapping("/send-sms-code")

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.service.auth;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.module.member.controller.app.auth.vo.*;
import javax.validation.Valid;
@ -31,10 +32,11 @@ public interface MemberAuthService {
/**
* 手机 + 验证码登陆
*
* @param reqVO 登陆信息
* @param reqVO 登陆信息
* @param terminal 终端 {@link TerminalEnum}
* @return 登录结果
*/
AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO);
AppAuthLoginRespVO smsLogin(@Valid AppAuthSmsLoginReqVO reqVO, Integer terminal);
/**
* 社交登录使用 code 授权码

View File

@ -5,6 +5,7 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
@ -78,13 +79,13 @@ public class MemberAuthServiceImpl implements MemberAuthService {
@Override
@Transactional
public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO) {
public AppAuthLoginRespVO smsLogin(AppAuthSmsLoginReqVO reqVO, Integer terminal) {
// 校验验证码
String userIp = getClientIP();
smsCodeApi.useSmsCode(AuthConvert.INSTANCE.convert(reqVO, SmsSceneEnum.MEMBER_LOGIN.getScene(), userIp));
// 获得获得注册用户
MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp);
MemberUserDO user = userService.createUserIfAbsent(reqVO.getMobile(), userIp, terminal);
Assert.notNull(user, "获取用户失败,结果为空");
// 如果 socialType 非空说明需要绑定社交用户
@ -128,7 +129,7 @@ public class MemberAuthServiceImpl implements MemberAuthService {
throw exception(AUTH_WEIXIN_MINI_APP_PHONE_CODE_ERROR);
}
// 获得获得注册用户
MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), getClientIP());
MemberUserDO user = userService.createUserIfAbsent(phoneNumberInfo.getPurePhoneNumber(), getClientIP(), TerminalEnum.WECHAT_MINI_PROGRAM.getTerminal());
Assert.notNull(user, "获取用户失败,结果为空");
// 绑定社交用户

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.service.user;
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
@ -43,9 +44,10 @@ public interface MemberUserService {
*
* @param mobile 手机号
* @param registerIp 注册 IP
* @param terminal 终端 {@link TerminalEnum}
* @return 用户对象
*/
MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp);
MemberUserDO createUserIfAbsent(@Mobile String mobile, String registerIp, Integer terminal);
/**
* 更新用户的最后登陆信息

View File

@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserPageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
@ -81,17 +80,17 @@ public class MemberUserServiceImpl implements MemberUserService {
@Override
@Transactional(rollbackFor = Exception.class)
public MemberUserDO createUserIfAbsent(String mobile, String registerIp) {
public MemberUserDO createUserIfAbsent(String mobile, String registerIp, Integer terminal) {
// 用户已经存在
MemberUserDO user = memberUserMapper.selectByMobile(mobile);
if (user != null) {
return user;
}
// 用户不存在则进行创建
return createUser(mobile, registerIp);
return createUser(mobile, registerIp, terminal);
}
private MemberUserDO createUser(String mobile, String registerIp) {
private MemberUserDO createUser(String mobile, String registerIp, Integer terminal) {
// 生成密码
String password = IdUtil.fastSimpleUUID();
// 插入用户
@ -100,8 +99,7 @@ public class MemberUserServiceImpl implements MemberUserService {
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
user.setPassword(encodePassword(password)); // 加密密码
user.setRegisterIp(registerIp);
// TODO @疯狂无状态terminal 不从 servletuTILS 而是通过 controller 传递给 service
user.setRegisterTerminal(ServletUtils.getTerminal());
user.setRegisterTerminal(terminal);
memberUserMapper.insert(user);
// 发送 MQ 消息用户创建

View File

@ -24,6 +24,9 @@ public class PayWalletTransactionRespVO {
@Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆")
private String title;
@Schema(description = "交易后的余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Long balance;
@Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}