Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
# Conflicts: # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
This commit is contained in:
commit
c95317577d
@ -1,8 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.app.combination;
|
package cn.iocoder.yudao.module.promotion.controller.app.combination;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordSummaryRespVO;
|
||||||
@ -23,6 +21,7 @@ import javax.annotation.Resource;
|
|||||||
import javax.validation.constraints.Max;
|
import javax.validation.constraints.Max;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
@ -61,7 +60,7 @@ public class AppCombinationRecordController {
|
|||||||
@Operation(summary = "获得最近 n 条拼团记录(团长发起的)")
|
@Operation(summary = "获得最近 n 条拼团记录(团长发起的)")
|
||||||
@Parameters({
|
@Parameters({
|
||||||
@Parameter(name = "activityId", description = "拼团活动编号"),
|
@Parameter(name = "activityId", description = "拼团活动编号"),
|
||||||
@Parameter(name = "status", description = "状态"),
|
@Parameter(name = "status", description = "拼团状态"), // 对应 CombinationRecordStatusEnum 枚举
|
||||||
@Parameter(name = "count", description = "数量")
|
@Parameter(name = "count", description = "数量")
|
||||||
})
|
})
|
||||||
public CommonResult<List<AppCombinationRecordRespVO>> getHeadCombinationRecordList(
|
public CommonResult<List<AppCombinationRecordRespVO>> getHeadCombinationRecordList(
|
||||||
@ -69,44 +68,37 @@ public class AppCombinationRecordController {
|
|||||||
@RequestParam("status") Integer status,
|
@RequestParam("status") Integer status,
|
||||||
@RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
|
@RequestParam(value = "count", defaultValue = "20") @Max(20) Integer count) {
|
||||||
return success(CombinationActivityConvert.INSTANCE.convertList3(
|
return success(CombinationActivityConvert.INSTANCE.convertList3(
|
||||||
combinationRecordService.getCombinationRecordListWithHead(activityId, status, count)));
|
combinationRecordService.getHeadCombinationRecordList(activityId, status, count)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-detail")
|
@GetMapping("/get-detail")
|
||||||
@Operation(summary = "获得拼团记录明细")
|
@Operation(summary = "获得拼团记录明细")
|
||||||
@Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
|
||||||
public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
|
public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
|
||||||
// 1、查询这条记录
|
// 1. 查找这条拼团记录
|
||||||
CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
|
CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
return success(null);
|
return success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppCombinationRecordDetailRespVO detail = new AppCombinationRecordDetailRespVO();
|
// 2. 查找该拼团的参团记录
|
||||||
List<CombinationRecordDO> records;
|
CombinationRecordDO headRecord;
|
||||||
// 2、判断是否为团长
|
List<CombinationRecordDO> memberRecords;
|
||||||
if (record.getHeadId() == null) {
|
if (Objects.equals(record.getHeadId(), CombinationRecordDO.HEAD_ID_GROUP)) { // 情况一:团长
|
||||||
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(record));
|
headRecord = record;
|
||||||
// 2.1、查找团员拼团记录
|
memberRecords = combinationRecordService.getCombinationRecordListByHeadId(record.getId());
|
||||||
records = combinationRecordService.getCombinationRecordListByHeadId(record.getId());
|
} else { // 情况二:团员
|
||||||
} else {
|
headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId());
|
||||||
// 2.2、查找团长拼团记录
|
memberRecords = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId());
|
||||||
CombinationRecordDO headRecord = combinationRecordService.getCombinationRecordById(record.getHeadId());
|
|
||||||
if (headRecord == null) {
|
|
||||||
return success(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
detail.setHeadRecord(CombinationActivityConvert.INSTANCE.convert(headRecord));
|
|
||||||
// 2.3、查找团员拼团记录
|
|
||||||
records = combinationRecordService.getCombinationRecordListByHeadId(headRecord.getId());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
detail.setMemberRecords(CombinationActivityConvert.INSTANCE.convertList3(records));
|
|
||||||
|
|
||||||
// 3、获取当前用户参团记录订单编号
|
// 3. 拼接数据
|
||||||
CombinationRecordDO userRecord = CollectionUtils.findFirst(records, r -> ObjectUtil.equal(r.getUserId(), getLoginUserId()));
|
return success(CombinationActivityConvert.INSTANCE.convert(getLoginUserId(), headRecord, memberRecords));
|
||||||
detail.setOrderId(userRecord == null ? null : userRecord.getOrderId()); // 如果没参团,返回 null
|
|
||||||
return success(detail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @puhui:新增一个取消拼团的接口,cancel
|
||||||
|
// 1. 需要先校验拼团记录未完成;
|
||||||
|
// 2. 在 Order 那增加一个 cancelPaidOrder 接口,用于取消已支付的订单
|
||||||
|
// 3. order 完成后,取消拼团记录。另外,如果它是团长,则顺序(下单时间)继承
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.convert.combination;
|
package cn.iocoder.yudao.module.promotion.convert.combination;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product
|
|||||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.recrod.CombinationRecordRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO;
|
||||||
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO;
|
||||||
@ -168,4 +170,16 @@ public interface CombinationActivityConvert {
|
|||||||
|
|
||||||
PageResult<CombinationRecordRespVO> convert(PageResult<CombinationRecordDO> result);
|
PageResult<CombinationRecordRespVO> convert(PageResult<CombinationRecordDO> result);
|
||||||
|
|
||||||
|
default AppCombinationRecordDetailRespVO convert(Long userId, CombinationRecordDO headRecord, List<CombinationRecordDO> memberRecords) {
|
||||||
|
AppCombinationRecordDetailRespVO respVO = new AppCombinationRecordDetailRespVO()
|
||||||
|
.setHeadRecord(convert(headRecord)).setMemberRecords(convertList3(memberRecords));
|
||||||
|
// 处理自己参与拼团的 orderId
|
||||||
|
CombinationRecordDO userRecord = CollectionUtils.findFirst(memberRecords, r -> ObjectUtil.equal(r.getUserId(), userId));
|
||||||
|
if (userRecord == null && ObjectUtil.equal(headRecord.getUserId(), userId)) {
|
||||||
|
userRecord = headRecord;
|
||||||
|
}
|
||||||
|
respVO.setOrderId(userRecord == null ? null : userRecord.getOrderId());
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class CombinationRecordDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 团长编号 - 团长
|
* 团长编号 - 团长
|
||||||
*/
|
*/
|
||||||
public static final Integer HEAD_ID_GROUP = 0;
|
public static final Long HEAD_ID_GROUP = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编号,主键自增
|
* 编号,主键自增
|
||||||
|
@ -81,25 +81,18 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO
|
|||||||
.last("LIMIT " + count));
|
.last("LIMIT " + count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
default List<CombinationRecordDO> selectListByActivityIdAndStatusAndHeadId(Long activityId, Integer status,
|
||||||
* 获得最近 count 条拼团记录(团长发起的)
|
Long headId, Integer count) {
|
||||||
*
|
|
||||||
* @param activityId 拼团活动编号
|
|
||||||
* @param status 记录状态
|
|
||||||
* @param count 数量
|
|
||||||
* @return 拼团记录列表
|
|
||||||
*/
|
|
||||||
default List<CombinationRecordDO> selectList(Long activityId, Integer status, Integer count) {
|
|
||||||
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
return selectList(new LambdaQueryWrapperX<CombinationRecordDO>()
|
||||||
.eqIfPresent(CombinationRecordDO::getActivityId, activityId)
|
.eq(CombinationRecordDO::getActivityId, activityId)
|
||||||
.eqIfPresent(CombinationRecordDO::getStatus, status)
|
.eq(CombinationRecordDO::getStatus, status)
|
||||||
.eq(CombinationRecordDO::getHeadId, null) // TODO 团长的 headId 是不是 null 还是自己的记录编号来着?
|
.eq(CombinationRecordDO::getHeadId, headId)
|
||||||
.orderByDesc(CombinationRecordDO::getCreateTime)
|
.orderByDesc(CombinationRecordDO::getId)
|
||||||
.last("LIMIT " + count));
|
.last("LIMIT " + count));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Map<Long, Integer> selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection<Long> activityIds,
|
default Map<Long, Integer> selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection<Long> activityIds,
|
||||||
Integer status, Integer headId) {
|
Integer status, Long headId) {
|
||||||
// SQL count 查询
|
// SQL count 查询
|
||||||
List<Map<String, Object>> result = selectMaps(new QueryWrapper<CombinationRecordDO>()
|
List<Map<String, Object>> result = selectMaps(new QueryWrapper<CombinationRecordDO>()
|
||||||
.select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId")
|
.select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId")
|
||||||
|
@ -139,7 +139,7 @@ public interface CombinationRecordService {
|
|||||||
* @param count 数量
|
* @param count 数量
|
||||||
* @return 拼团记录列表
|
* @return 拼团记录列表
|
||||||
*/
|
*/
|
||||||
List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count);
|
List<CombinationRecordDO> getHeadCombinationRecordList(Long activityId, Integer status, Integer count);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定编号的拼团记录
|
* 获取指定编号的拼团记录
|
||||||
@ -175,6 +175,6 @@ public interface CombinationRecordService {
|
|||||||
*/
|
*/
|
||||||
Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
||||||
@Nullable Integer status,
|
@Nullable Integer status,
|
||||||
@Nullable Integer headId);
|
@Nullable Long headId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -216,6 +216,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId());
|
ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId());
|
||||||
ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId());
|
ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId());
|
||||||
recordMapper.insert(CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku));
|
recordMapper.insert(CombinationActivityConvert.INSTANCE.convert(reqDTO, keyValue.getKey(), user, spu, sku));
|
||||||
|
// TODO @puhui999:status 未设置;headId 未设置
|
||||||
|
recordMapper.insert(CombinationActivityConvert.INSTANCE.convert(reqDTO, activity, user, spu, sku));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -263,8 +265,9 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CombinationRecordDO> getCombinationRecordListWithHead(Long activityId, Integer status, Integer count) {
|
public List<CombinationRecordDO> getHeadCombinationRecordList(Long activityId, Integer status, Integer count) {
|
||||||
return recordMapper.selectList(activityId, status, count);
|
return recordMapper.selectListByActivityIdAndStatusAndHeadId(activityId, status,
|
||||||
|
CombinationRecordDO.HEAD_ID_GROUP, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -284,7 +287,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds,
|
||||||
@Nullable Integer status, @Nullable Integer headId) {
|
@Nullable Integer status, @Nullable Long headId) {
|
||||||
return recordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId);
|
return recordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user