Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product
# Conflicts: # sql/mysql/statistics.sql
This commit is contained in:
commit
b1e0129046
|
@ -1 +0,0 @@
|
|||
ALTER TABLE member_user ADD COLUMN register_terminal tinyint NULL COMMENT '注册终端' AFTER register_ip;
|
|
@ -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
|
||||
);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
@ -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, "文章不存在");
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 即可;ps:uniapp 那边也要接下噢
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -207,31 +207,30 @@ public interface CombinationActivityConvert {
|
|||
/**
|
||||
* 转换生成虚拟成团虚拟记录
|
||||
*
|
||||
* @param virtualGroupHeadRecords 虚拟成团团长记录列表
|
||||
* @param virtualGroupHeadRecord 虚拟成团团长记录
|
||||
* @return 虚拟记录列表
|
||||
*/
|
||||
default List<CombinationRecordDO> convertVirtualGroupList(List<CombinationRecordDO> virtualGroupHeadRecords) {
|
||||
// TODO @puhui999:1)方法名,建议改成 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -127,11 +127,9 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||
*
|
||||
* @return 参加过拼团的用户数
|
||||
*/
|
||||
// TODO @puhui999:1)方法名,直接 selectUserCount;2)COUNT(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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 @puhui999:selectListByStatus
|
||||
return articleCategoryMapper.selectList(ArticleCategoryDO::getStatus, status);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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:这里可以改成“每个团”,处理一次哈;这样 handleExpireRecord、handleVirtualGroupRecord 都改成按团处理,每个是一个小事务;
|
||||
// 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 @puhui999:recordDO 非必要的情况下,不用带 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 @puhui999:headExpireRecord 可以简化成 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 @puhui999:headExpireRecord 可以简化成 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 @puhui999:record 改成 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,6 +100,8 @@ public class MemberStatisticsController {
|
|||
return success(memberStatisticsService.getMemberTerminalStatisticsList());
|
||||
}
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
// TODO @疯狂:要注意 date 的排序;
|
||||
@GetMapping("/user-count-comparison")
|
||||
@Operation(summary = "获得用户数量对照")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:member:query')")
|
||||
|
|
|
@ -130,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));
|
||||
}
|
||||
|
||||
|
|
|
@ -92,21 +92,12 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
|
|||
default TradeOrderDO selectOneByPickUpVerifyCode(String pickUpVerifyCode) {
|
||||
return selectOne(TradeOrderDO::getPickUpVerifyCode, pickUpVerifyCode);
|
||||
}
|
||||
|
||||
// TODO @puhui999:selectByUserIdAndCombinationActivityIdAndStatus,这样更容易理解哈。
|
||||
/**
|
||||
* 只针对 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)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
* 获得订单列表
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue