promotion:新增砍价记录列表

This commit is contained in:
YunaiV 2023-10-05 12:07:05 +08:00
parent cd45be1fe2
commit 269da3d56d
24 changed files with 331 additions and 31 deletions

View File

@ -132,20 +132,20 @@
align="center"
prop="${javaField}"
:formatter="dateFormatter"
width="150px"
width="180px"
/>
#elseif("" != $column.dictType)## 数据字典
<el-table-column label="${comment}" align="center" prop="${javaField}" width="150px">
<el-table-column label="${comment}" align="center" prop="${javaField}">
<template #default="scope">
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
</template>
</el-table-column>
#else
<el-table-column label="${comment}" align="center" prop="${javaField}" width="150px" />
<el-table-column label="${comment}" align="center" prop="${javaField}" />
#end
#end
#end
<el-table-column label="操作" align="center" width="150px">
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link

View File

@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.*;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.*;
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum;
@ -94,7 +94,7 @@ public class BargainActivityController {
Map<Long, Integer> recordUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, null);
Map<Long, Integer> recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds,
BargainRecordStatusEnum.SUCCESS.getStatus());
Map<Long, Integer> helpUserCountMap = bargainHelpService.getBargainHelpUserCountMap(activityIds);
Map<Long, Integer> helpUserCountMap = bargainHelpService.getBargainHelpUserCountMapByActivity(activityIds);
return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList,
recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap));
}

View File

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO;
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService;
import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@Tag(name = "管理后台 - 砍价记录")
@RestController
@RequestMapping("/promotion/bargain-record")
@Validated
public class BargainRecordController {
@Resource
private BargainRecordService bargainRecordService;
@Resource
private BargainActivityService bargainActivityService;
@Resource
private BargainHelpService bargainHelpService;
@Resource
private MemberUserApi memberUserApi;
@GetMapping("/page")
@Operation(summary = "获得砍价记录分页")
@PreAuthorize("@ss.hasPermission('promotion:bargain-record:query')")
public CommonResult<PageResult<BargainRecordPageItemRespVO>> getBargainRecordPage(@Valid BargainRecordPageReqVO pageVO) {
PageResult<BargainRecordDO> pageResult = bargainRecordService.getBargainRecordPage(pageVO);
if (CollUtil.isEmpty(pageResult.getList())) {
return success(PageResult.empty(pageResult.getTotal()));
}
// 拼接数据
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(
convertSet(pageResult.getList(), BargainRecordDO::getUserId));
List<BargainActivityDO> activityList = bargainActivityService.getBargainActivityList(
convertSet(pageResult.getList(), BargainRecordDO::getActivityId));
Map<Long, Integer> helpCountMap = bargainHelpService.getBargainHelpUserCountMapByRecord(
convertSet(pageResult.getList(), BargainRecordDO::getId));
return success(BargainRecordConvert.INSTANCE.convertPage(pageResult, helpCountMap, activityList, userMap));
}
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -56,9 +56,9 @@ public class BargainActivityBaseVO {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime endTime;
@Schema(description = "砍价人", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
@NotNull(message = "砍价人数不能为空")
private Integer userSize;
@Schema(description = "最大助力次", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
@NotNull(message = "最大助力次数不能为空")
private Integer helpMaxCount;
@Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
@NotNull(message = "最大帮砍次数不能为空")

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo;
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 砍价记录 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class BargainRecordBaseVO {
@Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "22690")
@NotNull(message = "砍价活动名称不能为空")
private Long activityId;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430")
@NotNull(message = "用户编号不能为空")
private Long userId;
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622")
@NotNull(message = "商品 SPU 编号不能为空")
private Long spuId;
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950")
@NotNull(message = "商品 SKU 编号不能为空")
private Long skuId;
@Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "31160")
@NotNull(message = "砍价起始价格,单位:分不能为空")
private Integer bargainFirstPrice;
@Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22743")
@NotNull(message = "当前砍价,单位:分不能为空")
private Integer bargainPrice;
@Schema(description = "砍价状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "砍价状态不能为空")
private Integer status;
@Schema(description = "订单编号", example = "27845")
private Long orderId;
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "结束时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime endTime;
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 砍价记录的分页项 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BargainRecordPageItemRespVO extends BargainRecordBaseVO {
@Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901")
private Long id;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59")
private LocalDateTime createTime;
@Schema(description = "帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
private Integer helpCount;
// ========== 用户相关 ==========
@Schema(description = "用户昵称", example = "老芋艿")
private String nickname;
@Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg")
private String avatar;
// ========== 活动相关 ==========
private BargainActivityRespVO activity;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 砍价记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BargainRecordPageReqVO extends PageParam {
@Schema(description = "砍价状态", example = "1")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -5,10 +5,10 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageItemRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.promotion.convert.bargain;
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.MapUtils;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
/**
* 砍价记录 Convert
*
* @author 芋道源码
*/
@Mapper
public interface BargainRecordConvert {
BargainRecordConvert INSTANCE = Mappers.getMapper(BargainRecordConvert.class);
default PageResult<BargainRecordPageItemRespVO> convertPage(PageResult<BargainRecordDO> page,
Map<Long, Integer> helpCountMap,
List<BargainActivityDO> activityList,
Map<Long, MemberUserRespDTO> userMap) {
PageResult<BargainRecordPageItemRespVO> pageResult = convertPage(page);
// 拼接数据
Map<Long, BargainActivityDO> activityMap = CollectionUtils.convertMap(activityList, BargainActivityDO::getId);
pageResult.getList().forEach(record -> {
MapUtils.findAndThen(userMap, record.getUserId(),
user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar()));
record.setActivity(BargainActivityConvert.INSTANCE.convert(activityMap.get(record.getActivityId())))
.setHelpCount(helpCountMap.getOrDefault(record.getId(), 0));
});
return pageResult;
}
PageResult<BargainRecordPageItemRespVO> convertPage(PageResult<BargainRecordDO> page);
}

View File

@ -82,7 +82,7 @@ public class BargainActivityDO extends BaseDO {
*
* 需要多少人砍价才能成功 {@link BargainRecordDO#getStatus()} 更新为 {@link BargainRecordDO#getStatus()} 成功状态
*/
private Integer userSize;
private Integer helpMaxCount;
/**
* 帮砍次数
*

View File

@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
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.bargain.vo.BargainActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;

View File

@ -49,4 +49,19 @@ public interface BargainHelpMapper extends BaseMapperX<BargainHelpDO> {
record -> MapUtil.getInt(record, "userCount" ));
}
default Map<Long, Integer> selectCountByRecordId(Collection<Long> recordIds) {
// SQL count 查询
List<Map<String, Object>> result = selectMaps(new QueryWrapper<BargainHelpDO>()
.select("COUNT(1) AS userCount, record_id AS recordId")
.in("record_id", recordIds)
.groupBy("record_id"));
if (CollUtil.isEmpty(result)) {
return Collections.emptyMap();
}
// 转换数据
return CollectionUtils.convertMap(result,
record -> MapUtil.getLong(record, "recordId"),
record -> MapUtil.getInt(record, "userCount" ));
}
}

View File

@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
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.bargain.vo.recrod.BargainRecordPageReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -65,4 +68,11 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> {
record -> MapUtil.getInt(record, "userCount" ));
}
default PageResult<BargainRecordDO> selectPage(BargainRecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BargainRecordDO>()
.eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus())
.betweenIfPresent(BargainRecordDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BargainRecordDO::getId));
}
}

View File

@ -2,13 +2,14 @@ package cn.iocoder.yudao.module.promotion.service.bargain;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import javax.validation.Valid;
import java.util.List;
import java.util.Set;
/**
* 砍价活动 Service 接口
@ -55,6 +56,14 @@ public interface BargainActivityService {
*/
BargainActivityDO getBargainActivity(Long id);
/**
* 获得砍价活动列表
*
* @param ids 编号数组
* @return 砍价活动列表
*/
List<BargainActivityDO> getBargainActivityList(Set<Long> ids);
/**
* 校验砍价活动是否可以参与发起砍价下单帮好友砍价
*

View File

@ -8,9 +8,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper;
@ -21,6 +21,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
@ -144,6 +145,11 @@ public class BargainActivityServiceImpl implements BargainActivityService {
return bargainActivityMapper.selectById(id);
}
@Override
public List<BargainActivityDO> getBargainActivityList(Set<Long> ids) {
return bargainActivityMapper.selectBatchIds(ids);
}
@Override
public BargainActivityDO validateBargainActivityCanJoin(Long id) {
BargainActivityDO activity = bargainActivityMapper.selectById(id);

View File

@ -23,11 +23,19 @@ public interface BargainHelpService {
BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO);
/**
* 获得助力人数 Map
* 砍价活动获得助力人数 Map
*
* @param activityIds 活动编号
* @return 助力人数 Map
*/
Map<Long, Integer> getBargainHelpUserCountMap(Collection<Long> activityIds);
Map<Long, Integer> getBargainHelpUserCountMapByActivity(Collection<Long> activityIds);
/**
* 砍价记录获得助力人数 Map
*
* @param recordIds 记录编号
* @return 助力人数 Map
*/
Map<Long, Integer> getBargainHelpUserCountMapByRecord(Collection<Long> recordIds);
}

View File

@ -81,7 +81,7 @@ public class BargainHelpServiceImpl implements BargainHelpService {
// 5. 判断砍价记录是否完成
Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一砍价已经砍到最低价
|| bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getTotalLimitCount(); // 情况二砍价助力已经达到上限
|| bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二砍价助力已经达到上限
if (!bargainRecordService.updateBargainRecordBargainPrice(
record.getId(), record.getBargainPrice(), reducePrice, success)) {
// 多人一起砍价需要重试
@ -103,8 +103,13 @@ public class BargainHelpServiceImpl implements BargainHelpService {
}
@Override
public Map<Long, Integer> getBargainHelpUserCountMap(Collection<Long> activityIds) {
public Map<Long, Integer> getBargainHelpUserCountMapByActivity(Collection<Long> activityIds) {
return bargainHelpMapper.selectCountByActivityId(activityIds);
}
@Override
public Map<Long, Integer> getBargainHelpUserCountMapByRecord(Collection<Long> recordIds) {
return bargainHelpMapper.selectCountByRecordId(recordIds);
}
}

View File

@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.promotion.service.bargain;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
@ -68,4 +70,12 @@ public interface BargainRecordService {
*/
Map<Long, Integer> getBargainRecordUserCountMap(Collection<Long> activityIds, @Nullable Integer status);
/**
* 获得砍价记录分页
*
* @param pageReqVO 分页查询
* @return 砍价记录分页
*/
PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO);
}

View File

@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.promotion.service.bargain;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
@ -100,4 +102,9 @@ public class BargainRecordServiceImpl implements BargainRecordService {
return bargainRecordMapper.selectCountByActivityIdsAndStatus(activityIds, status);
}
@Override
public PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO) {
return bargainRecordMapper.selectPage(pageReqVO);
}
}