Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product

# Conflicts:
#	sql/mysql/statistics.sql
This commit is contained in:
owen 2023-10-17 16:13:46 +08:00
commit b1e0129046
25 changed files with 263 additions and 309 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 PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic;
-- 钱包充值套餐菜单脚本 -- 钱包充值套餐,钱包余额菜单脚本
INSERT INTO system_menu( INSERT INTO system_menu(
name, permission, type, sort, parent_id, name, permission, type, sort, parent_id,
@ -136,13 +136,14 @@ VALUES (
'钱包管理', '', 1, 5, 1117, '钱包管理', '', 1, 5, 1117,
'wallet', 'ep:caret-right', '', 0, '' 'wallet', 'ep:caret-right', '', 0, ''
); );
SELECT @parentId := LAST_INSERT_ID(); SELECT @parentId1 := LAST_INSERT_ID();
INSERT INTO system_menu( INSERT INTO system_menu(
name, permission, type, sort, parent_id, name, permission, type, sort, parent_id,
path, icon, component, status, component_name path, icon, component, status, component_name
) )
VALUES ( VALUES (
'充值套餐', '', 2, 2, @parentId, '充值套餐', '', 2, 2, @parentId1,
'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage' 'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage'
); );
SELECT @parentId := LAST_INSERT_ID(); SELECT @parentId := LAST_INSERT_ID();
@ -180,3 +181,25 @@ VALUES (
'钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId, '钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId,
'', '', '', 0 '', '', '', 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 '总支付金额单位',
after_sale_count int DEFAULT 0 NOT NULL COMMENT '退款订单数',
after_sale_refund_price int DEFAULT 0 NOT NULL COMMENT '总退款金额单位',
brokerage_settlement_price int DEFAULT 0 NOT NULL COMMENT '佣金金额已结算单位',
wallet_pay_price int DEFAULT 0 NOT NULL COMMENT '总支付金额余额单位',
recharge_pay_count int DEFAULT 0 NOT NULL COMMENT '充值订单数',
recharge_pay_price int DEFAULT 0 NOT NULL COMMENT '充值金额单位',
recharge_refund_count int DEFAULT 0 NOT NULL COMMENT '充值退款订单数',
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

@ -111,9 +111,10 @@ public interface ErrorCodeConstants {
ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了"); ErrorCode BARGAIN_HELP_CREATE_FAIL_HELP_EXISTS = new ErrorCode(1_013_014_004, "助力失败,您已经助力过了");
// ========== 文章分类 1-013-015-000 ========== // ========== 文章分类 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 ========== // ========== 文章管理 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; 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.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.app.article.vo.category.AppArticleCategoryRespVO; 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.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Random;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 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 @Validated
public class AppArticleCategoryController { public class AppArticleCategoryController {
@Resource
private ArticleCategoryService articleCategoryService;
@RequestMapping("/list") @RequestMapping("/list")
@Operation(summary = "获得文章分类列表") @Operation(summary = "获得文章分类列表")
// TODO @芋艿swagger 注解
public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() { public CommonResult<List<AppArticleCategoryRespVO>> getArticleCategoryList() {
List<AppArticleCategoryRespVO> appArticleRespVOList = new ArrayList<>(); List<ArticleCategoryDO> categoryList = articleCategoryService.getArticleCategoryListByStatus(
Random random = new Random(); CommonStatusEnum.ENABLE.getStatus());
for (int i = 0; i < 10; i++) { // TODO @puhui999排序下
AppArticleCategoryRespVO appArticleRespVO = new AppArticleCategoryRespVO(); return success(ArticleCategoryConvert.INSTANCE.convertList04(categoryList));
appArticleRespVO.setId((long) (i + 1));
appArticleRespVO.setName("分类 - " + i);
appArticleRespVO.setPicUrl("https://www.iocoder.cn/" + (i + 1) + ".png");
appArticleRespVOList.add(appArticleRespVO);
}
return success(appArticleRespVOList);
} }
} }

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

View File

@ -39,11 +39,4 @@ public class AppArticleRespVO {
@Schema(description = "关联的商品 SPU 编号", example = "1024") @Schema(description = "关联的商品 SPU 编号", example = "1024")
private Long spuId; 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") @Schema(description = "分类图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png")
private String picUrl; 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.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.*; 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 cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleCategoryDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -30,4 +31,6 @@ public interface ArticleCategoryConvert {
List<ArticleCategorySimpleRespVO> convertList03(List<ArticleCategoryDO> list); 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.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleRespVO; 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.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 cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@ -30,4 +31,10 @@ public interface ArticleConvert {
PageResult<ArticleRespVO> convertPage(PageResult<ArticleDO> page); 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 虚拟记录列表 * @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<>(); List<CombinationRecordDO> createRecords = new ArrayList<>();
virtualGroupHeadRecords.forEach(headRecord -> { // 计算需要创建的虚拟成团记录数量
// 计算需要创建的虚拟成团记录数量 int count = virtualGroupHeadRecord.getUserSize() - virtualGroupHeadRecord.getUserCount();
int count = headRecord.getUserSize() - headRecord.getUserCount(); for (int i = 0; i < count; i++) {
for (int i = 0; i < count; i++) { // 基础信息和团长保持一致
// 基础信息和团长保持一致 CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(virtualGroupHeadRecord.getActivityId())
CombinationRecordDO newRecord = new CombinationRecordDO().setActivityId(headRecord.getActivityId()) .setCombinationPrice(virtualGroupHeadRecord.getCombinationPrice()).setSpuId(virtualGroupHeadRecord.getSpuId()).setSpuName(virtualGroupHeadRecord.getSpuName())
.setCombinationPrice(headRecord.getCombinationPrice()).setSpuId(headRecord.getSpuId()).setSpuName(headRecord.getSpuName()) .setPicUrl(virtualGroupHeadRecord.getPicUrl()).setSkuId(virtualGroupHeadRecord.getSkuId()).setHeadId(virtualGroupHeadRecord.getId())
.setPicUrl(headRecord.getPicUrl()).setSkuId(headRecord.getSkuId()).setHeadId(headRecord.getId()) .setStatus(virtualGroupHeadRecord.getStatus()) // 状态保持和创建时一致创建完成后会接着处理
.setStatus(headRecord.getStatus()) // 状态保持和创建时一致创建完成后会接着处理 .setVirtualGroup(virtualGroupHeadRecord.getVirtualGroup()).setExpireTime(virtualGroupHeadRecord.getExpireTime())
.setVirtualGroup(headRecord.getVirtualGroup()).setExpireTime(headRecord.getExpireTime()) .setStartTime(virtualGroupHeadRecord.getStartTime()).setUserSize(virtualGroupHeadRecord.getUserSize()).setUserCount(virtualGroupHeadRecord.getUserCount());
.setStartTime(headRecord.getStartTime()).setUserSize(headRecord.getUserSize()).setUserCount(headRecord.getUserCount()); // 虚拟信息
// 虚拟信息 newRecord.setCount(0);
newRecord.setCount(0); newRecord.setUserId(0L);
newRecord.setUserId(0L); newRecord.setNickname("");
newRecord.setNickname(""); newRecord.setAvatar("");
newRecord.setAvatar(""); newRecord.setOrderId(0L);
newRecord.setOrderId(0L); createRecords.add(newRecord);
createRecords.add(newRecord); }
}
});
return createRecords; 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.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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.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 cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/** /**
* 文章管理 Mapper * 文章管理 Mapper
* *
@ -28,4 +31,16 @@ public interface ArticleMapper extends BaseMapperX<ArticleDO> {
.orderByDesc(ArticleDO::getId)); .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 参加过拼团的用户数 * @return 参加过拼团的用户数
*/ */
// TODO @puhui9991方法名直接 selectUserCount2COUNT(DISTINCT(user_id)) 就可以啦不用 group by default Long selectUserCount() {
default Long selectUserDistinctCount() {
return selectCount(new QueryWrapper<CombinationRecordDO>() return selectCount(new QueryWrapper<CombinationRecordDO>()
.select("DISTINCT (user_id)") .select("DISTINCT (user_id)"));
.groupBy("user_id"));
} }
default List<CombinationRecordDO> selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) { default List<CombinationRecordDO> selectListByHeadIdAndStatusAndExpireTimeLt(Long headId, Integer status, LocalDateTime dateTime) {
@ -141,8 +139,8 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
.lt(CombinationRecordDO::getExpireTime, dateTime)); .lt(CombinationRecordDO::getExpireTime, dateTime));
} }
default List<CombinationRecordDO> selectListByHeadIds(Collection<Long> headIds) { default List<CombinationRecordDO> selectListByHeadId(Long headId) {
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>().in(CombinationRecordDO::getHeadId, headIds)); return selectList(CombinationRecordDO::getHeadId, headId);
} }
} }

View File

@ -1,12 +1,15 @@
package cn.iocoder.yudao.module.promotion.service.article; 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.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.ArticleCategoryCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.category.ArticleCategoryPageReqVO; 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.controller.admin.article.vo.category.ArticleCategoryUpdateReqVO;
import cn.iocoder.yudao.module.promotion.convert.article.ArticleCategoryConvert; 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.ArticleCategoryDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper; import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleCategoryMapper;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -14,6 +17,7 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 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; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_CATEGORY_NOT_EXISTS;
/** /**
@ -28,6 +32,10 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService {
@Resource @Resource
private ArticleCategoryMapper articleCategoryMapper; private ArticleCategoryMapper articleCategoryMapper;
@Resource
@Lazy // 延迟加载解决循环依赖问题
private ArticleService articleService;
@Override @Override
public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) { public Long createArticleCategory(ArticleCategoryCreateReqVO createReqVO) {
// 插入 // 插入
@ -50,7 +58,12 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService {
public void deleteArticleCategory(Long id) { public void deleteArticleCategory(Long id) {
// 校验存在 // 校验存在
validateArticleCategoryExists(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); articleCategoryMapper.deleteById(id);
@ -74,6 +87,7 @@ public class ArticleCategoryServiceImpl implements ArticleCategoryService {
@Override @Override
public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) { public List<ArticleCategoryDO> getArticleCategoryListByStatus(Integer status) {
// TODO @puhui999selectListByStatus
return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status); 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.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; 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.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 cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
/** /**
* 文章管理 Service 接口 * 文章详情 Service 接口
* *
* @author HUIHUI * @author HUIHUI
*/ */
public interface ArticleService { public interface ArticleService {
/** /**
* 创建文章管理 * 创建文章详情
* *
* @param createReqVO 创建信息 * @param createReqVO 创建信息
* @return 编号 * @return 编号
@ -24,33 +26,58 @@ public interface ArticleService {
Long createArticle(@Valid ArticleCreateReqVO createReqVO); Long createArticle(@Valid ArticleCreateReqVO createReqVO);
/** /**
* 更新文章管理 * 更新文章详情
* *
* @param updateReqVO 更新信息 * @param updateReqVO 更新信息
*/ */
void updateArticle(@Valid ArticleUpdateReqVO updateReqVO); void updateArticle(@Valid ArticleUpdateReqVO updateReqVO);
/** /**
* 删除文章管理 * 删除文章详情
* *
* @param id 编号 * @param id 编号
*/ */
void deleteArticle(Long id); void deleteArticle(Long id);
/** /**
* 获得文章管理 * 获得文章详情
* *
* @param id 编号 * @param id 编号
* @return 文章管理 * @return 文章详情
*/ */
ArticleDO getArticle(Long id); ArticleDO getArticle(Long id);
/** /**
* 获得文章管理分页 * 获得文章详情分页
* *
* @param pageReqVO 分页查询 * @param pageReqVO 分页查询
* @return 文章管理分页 * @return 文章详情分页
*/ */
PageResult<ArticleDO> getArticlePage(ArticlePageReqVO pageReqVO); 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.ArticleCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticlePageReqVO; 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.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.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.dataobject.article.ArticleDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper; import cn.iocoder.yudao.module.promotion.dal.mysql.article.ArticleMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 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; import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.ARTICLE_NOT_EXISTS;
/** /**
@ -27,9 +31,14 @@ public class ArticleServiceImpl implements ArticleService {
@Resource @Resource
private ArticleMapper articleMapper; private ArticleMapper articleMapper;
@Resource
private ArticleCategoryService articleCategoryService;
@Override @Override
public Long createArticle(ArticleCreateReqVO createReqVO) { public Long createArticle(ArticleCreateReqVO createReqVO) {
// TODO @puhui999需要校验分类存在 // 校验分类存在
validateArticleCategoryExists(createReqVO.getCategoryId());
// 插入 // 插入
ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO); ArticleDO article = ArticleConvert.INSTANCE.convert(createReqVO);
articleMapper.insert(article); articleMapper.insert(article);
@ -41,7 +50,8 @@ public class ArticleServiceImpl implements ArticleService {
public void updateArticle(ArticleUpdateReqVO updateReqVO) { public void updateArticle(ArticleUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
validateArticleExists(updateReqVO.getId()); validateArticleExists(updateReqVO.getId());
// TODO @puhui999需要校验分类存在 // 校验分类存在
validateArticleCategoryExists(updateReqVO.getCategoryId());
// 更新 // 更新
ArticleDO updateObj = ArticleConvert.INSTANCE.convert(updateReqVO); 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 @Override
public ArticleDO getArticle(Long id) { public ArticleDO getArticle(Long id) {
return articleMapper.selectById(id); return articleMapper.selectById(id);
@ -72,4 +89,19 @@ public class ArticleServiceImpl implements ArticleService {
return articleMapper.selectPage(pageReqVO); 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 @Override
public Long getCombinationUserCount() { public Long getCombinationUserCount() {
return combinationRecordMapper.selectUserDistinctCount(); return combinationRecordMapper.selectUserCount();
} }
@Override @Override
@ -351,86 +351,87 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
convertSet(headExpireRecords, CombinationRecordDO::getActivityId)); convertSet(headExpireRecords, CombinationRecordDO::getActivityId));
Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId); Map<Long, CombinationActivityDO> activityMap = convertMap(activities, CombinationActivityDO::getId);
// TODO @puhui999这里可以改成每个团处理一次哈这样 handleExpireRecordhandleVirtualGroupRecord 都改成按团处理每个是一个小事务 // 3. 逐个处理拼团过期 or 虚拟成团
// 3. 校验是否虚拟成团 KeyValue<Integer, Integer> keyValue = new KeyValue<>(0, 0); // 统计过期拼团和虚拟成团
List<CombinationRecordDO> virtualGroupHeadRecords = new ArrayList<>(); // 虚拟成团 for (CombinationRecordDO recordDO : headExpireRecords) {
for (Iterator<CombinationRecordDO> iterator = headExpireRecords.iterator(); iterator.hasNext(); ) { // TODO @puhui999recordDO 非必要的情况下不用带 DO直接 record;
CombinationRecordDO record = iterator.next(); try {
// 3.1.不匹配则直接跳过 CombinationActivityDO activity = activityMap.get(recordDO.getActivityId());
CombinationActivityDO activity = activityMap.get(record.getActivityId()); if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的
if (activity == null || !activity.getVirtualGroup()) { // 取不到活动的或者不是虚拟拼团的 // 3.1. 处理过期的拼团
continue; 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;
} }
return keyValue;
// 4.处理过期的拼团
getSelf().handleExpireRecord(headExpireRecords);
// 5.虚拟成团
getSelf().handleVirtualGroupRecord(virtualGroupHeadRecords);
return new KeyValue<>(headExpireRecords.size(), virtualGroupHeadRecords.size());
} }
/** /**
* 处理过期拼团 * 处理过期拼团
* *
* @param headExpireRecords 过期拼团团长记录列表 * @param headExpireRecord 过期拼团团长记录列表
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void handleExpireRecord(List<CombinationRecordDO> headExpireRecords) { public void handleExpireRecord(CombinationRecordDO headExpireRecord) {
if (CollUtil.isEmpty(headExpireRecords)) { // TODO @puhui999这里的 null 其实不用判断真出现应该要处个 npe因为就是要错哈
// TODO @puhui999headExpireRecord 可以简化成 headRecord
if (headExpireRecord == null) {
return; return;
} }
// 1.更新拼团记录 // 1.更新拼团记录
List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecords, List<CombinationRecordDO> headsAndRecords = updateBatchCombinationRecords(headExpireRecord,
CombinationRecordStatusEnum.FAILED); CombinationRecordStatusEnum.FAILED);
// TODO @puhui999这里的 null 其实不用判断真出现应该要处个 npe因为就是要错哈
if (headsAndRecords == null) { if (headsAndRecords == null) {
return; return;
} }
// 2.订单取消 TODO 以现在的取消回滚逻辑好像只能循环了 // 2.订单取消
headsAndRecords.forEach(item -> { headsAndRecords.forEach(item -> tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId()));
tradeOrderApi.cancelPaidOrder(item.getUserId(), item.getOrderId());
});
} }
/** /**
* 处理虚拟拼团 * 处理虚拟拼团
* *
* @param virtualGroupHeadRecords 虚拟成团团长记录列表 * @param virtualGroupHeadRecord 虚拟成团团长记录列表
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void handleVirtualGroupRecord(List<CombinationRecordDO> virtualGroupHeadRecords) { public void handleVirtualGroupRecord(CombinationRecordDO virtualGroupHeadRecord) {
if (CollUtil.isEmpty(virtualGroupHeadRecords)) { // TODO @puhui999这里的 null 其实不用判断真出现应该要处个 npe因为就是要错哈
// TODO @puhui999headExpireRecord 可以简化成 headRecord
if (virtualGroupHeadRecord == null) {
return; return;
} }
// 1. 团员补齐 // 1. 团员补齐
combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecords)); combinationRecordMapper.insertBatch(CombinationActivityConvert.INSTANCE.convertVirtualGroupList(virtualGroupHeadRecord));
// 2. 更新拼团记录 // 2. 更新拼团记录
updateBatchCombinationRecords(virtualGroupHeadRecords, CombinationRecordStatusEnum.SUCCESS); updateBatchCombinationRecords(virtualGroupHeadRecord, CombinationRecordStatusEnum.SUCCESS);
} }
private List<CombinationRecordDO> updateBatchCombinationRecords(List<CombinationRecordDO> headRecords, CombinationRecordStatusEnum status) { // TODO @puhui999写下方法注释
// 1. 查询团成员 private List<CombinationRecordDO> updateBatchCombinationRecords(CombinationRecordDO headRecord, CombinationRecordStatusEnum status) {
List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadIds( // 1. 查询团成员包含团长
convertSet(headRecords, CombinationRecordDO::getId)); List<CombinationRecordDO> records = combinationRecordMapper.selectListByHeadId(headRecord.getId());
// TODO @puhui999是不是不用判断空哈例如说就一个团长然后过期
if (CollUtil.isEmpty(records)) { if (CollUtil.isEmpty(records)) {
return null; return null;
} }
Map<Long, List<CombinationRecordDO>> recordsMap = convertMultiMap(records, CombinationRecordDO::getHeadId); records.add(headRecord);// 把团长加进去
headRecords.forEach(item -> {
recordsMap.get(item.getId()).add(item); // 把团长加进团里 // 2. 批量更新拼团记录 status endTime
}); List<CombinationRecordDO> updateRecords = new ArrayList<>(records.size());
// 2.批量更新拼团记录 status 失败/成团时间
List<CombinationRecordDO> headsAndRecords = mergeValuesFromMap(recordsMap);
List<CombinationRecordDO> updateRecords = new ArrayList<>(headsAndRecords.size());
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
headsAndRecords.forEach(item -> { records.forEach(item -> {
// TODO @puhui999record 改成 updateRecord
CombinationRecordDO record = new CombinationRecordDO().setId(item.getId()) CombinationRecordDO record = new CombinationRecordDO().setId(item.getId())
.setStatus(status.getStatus()).setEndTime(now); .setStatus(status.getStatus()).setEndTime(now);
if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数 if (CombinationRecordStatusEnum.isSuccess(status.getStatus())) { // 虚拟成团完事更改状态成功后还需要把参与人数修改为成团需要人数
@ -439,7 +440,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
updateRecords.add(record); updateRecords.add(record);
}); });
combinationRecordMapper.updateBatch(updateRecords); 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.common.pojo.PageResult;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 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.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.ArticlePageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.article.vo.article.ArticleUpdateReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO; import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import javax.annotation.Resource; 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.date.LocalDateTimeUtils.buildBetweenTime;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; 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)); 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

@ -100,6 +100,8 @@ public class MemberStatisticsController {
return success(memberStatisticsService.getMemberTerminalStatisticsList()); return success(memberStatisticsService.getMemberTerminalStatisticsList());
} }
// TODO 芋艿已经 review
// TODO @疯狂要注意 date 的排序
@GetMapping("/user-count-comparison") @GetMapping("/user-count-comparison")
@Operation(summary = "获得用户数量对照") @Operation(summary = "获得用户数量对照")
@PreAuthorize("@ss.hasPermission('statistics:member:query')") @PreAuthorize("@ss.hasPermission('statistics:member:query')")

View File

@ -130,6 +130,7 @@ public class TradeStatisticsController {
@Operation(summary = "获得订单量趋势统计") @Operation(summary = "获得订单量趋势统计")
@PreAuthorize("@ss.hasPermission('statistics:trade:query')") @PreAuthorize("@ss.hasPermission('statistics:trade:query')")
public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) { public CommonResult<List<DataComparisonRespVO<TradeOrderTrendRespVO>>> getOrderCountTrendComparison(@Valid TradeOrderTrendReqVO reqVO) {
// TODO @疯狂要注意 date 的排序
return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO)); return success(tradeOrderStatisticsService.getOrderCountTrendComparison(reqVO));
} }

View File

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

View File

@ -42,11 +42,11 @@ public interface TradeOrderQueryService {
* 获得指定用户指定活动指定状态的交易订单 * 获得指定用户指定活动指定状态的交易订单
* *
* @param userId 用户编号 * @param userId 用户编号
* @param activityId 活动编号 * @param combinationActivityId 活动编号
* @param status 订单状态 * @param status 订单状态
* @return 交易订单 * @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 @Override
public TradeOrderDO getActivityOrderByUserIdAndActivityIdAndStatus(Long userId, Long activityId, Integer status) { public TradeOrderDO getOrderByUserIdAndStatusAndCombination(Long userId, Long combinationActivityId, Integer status) {
return tradeOrderMapper.selectByUserIdAndActivityIdAndStatus(userId, activityId, status); return tradeOrderMapper.selectByUserIdAndCombinationActivityIdAndStatus(userId, combinationActivityId, status);
} }
@Override @Override

View File

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

View File

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