mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
promotion:新增砍价记录列表
This commit is contained in:
parent
cd45be1fe2
commit
269da3d56d
@ -132,20 +132,20 @@
|
|||||||
align="center"
|
align="center"
|
||||||
prop="${javaField}"
|
prop="${javaField}"
|
||||||
:formatter="dateFormatter"
|
:formatter="dateFormatter"
|
||||||
width="150px"
|
width="180px"
|
||||||
/>
|
/>
|
||||||
#elseif("" != $column.dictType)## 数据字典
|
#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">
|
<template #default="scope">
|
||||||
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
|
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
#else
|
#else
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="150px" />
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<el-table-column label="操作" align="center" width="150px">
|
<el-table-column label="操作" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
link
|
link
|
||||||
|
@ -5,7 +5,7 @@ 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.product.api.spu.ProductSpuApi;
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
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.convert.bargain.BargainActivityConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum;
|
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> recordUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, null);
|
||||||
Map<Long, Integer> recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds,
|
Map<Long, Integer> recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds,
|
||||||
BargainRecordStatusEnum.SUCCESS.getStatus());
|
BargainRecordStatusEnum.SUCCESS.getStatus());
|
||||||
Map<Long, Integer> helpUserCountMap = bargainHelpService.getBargainHelpUserCountMap(activityIds);
|
Map<Long, Integer> helpUserCountMap = bargainHelpService.getBargainHelpUserCountMapByActivity(activityIds);
|
||||||
return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList,
|
return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList,
|
||||||
recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap));
|
recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap));
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -56,9 +56,9 @@ public class BargainActivityBaseVO {
|
|||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
@Schema(description = "砍价人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
|
@Schema(description = "最大助力次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
|
||||||
@NotNull(message = "砍价人数不能为空")
|
@NotNull(message = "最大助力次数不能为空")
|
||||||
private Integer userSize;
|
private Integer helpMaxCount;
|
||||||
|
|
||||||
@Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
|
@Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222")
|
||||||
@NotNull(message = "最大帮砍次数不能为空")
|
@NotNull(message = "最大帮砍次数不能为空")
|
@ -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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -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 cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
@ -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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -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.framework.dict.core.util.DictFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||||
import cn.iocoder.yudao.module.product.enums.DictTypeConstants;
|
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.activity.BargainActivityBaseVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageItemRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
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.AppBargainActivityDetailRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
|
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
}
|
@ -82,7 +82,7 @@ public class BargainActivityDO extends BaseDO {
|
|||||||
*
|
*
|
||||||
* 需要多少人,砍价才能成功,即 {@link BargainRecordDO#getStatus()} 更新为 {@link BargainRecordDO#getStatus()} 成功状态
|
* 需要多少人,砍价才能成功,即 {@link BargainRecordDO#getStatus()} 更新为 {@link BargainRecordDO#getStatus()} 成功状态
|
||||||
*/
|
*/
|
||||||
private Integer userSize;
|
private Integer helpMaxCount;
|
||||||
/**
|
/**
|
||||||
* 帮砍次数
|
* 帮砍次数
|
||||||
*
|
*
|
||||||
|
@ -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.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.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 cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
@ -49,4 +49,19 @@ public interface BargainHelpMapper extends BaseMapperX<BargainHelpDO> {
|
|||||||
record -> MapUtil.getInt(record, "userCount" ));
|
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" ));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
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.common.util.collection.CollectionUtils;
|
||||||
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.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
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.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
@ -65,4 +68,11 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> {
|
|||||||
record -> MapUtil.getInt(record, "userCount" ));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.activity.BargainActivityCreateReqVO;
|
||||||
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.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 砍价活动 Service 接口
|
* 砍价活动 Service 接口
|
||||||
@ -55,6 +56,14 @@ public interface BargainActivityService {
|
|||||||
*/
|
*/
|
||||||
BargainActivityDO getBargainActivity(Long id);
|
BargainActivityDO getBargainActivity(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得砍价活动列表
|
||||||
|
*
|
||||||
|
* @param ids 编号数组
|
||||||
|
* @return 砍价活动列表
|
||||||
|
*/
|
||||||
|
List<BargainActivityDO> getBargainActivityList(Set<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验砍价活动,是否可以参与(发起砍价、下单、帮好友砍价)
|
* 校验砍价活动,是否可以参与(发起砍价、下单、帮好友砍价)
|
||||||
*
|
*
|
||||||
|
@ -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.framework.common.util.date.LocalDateTimeUtils;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO;
|
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.activity.BargainActivityCreateReqVO;
|
||||||
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.controller.admin.bargain.vo.BargainActivityUpdateReqVO;
|
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.convert.bargain.BargainActivityConvert;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper;
|
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 javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
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.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
|
||||||
@ -144,6 +145,11 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
|||||||
return bargainActivityMapper.selectById(id);
|
return bargainActivityMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BargainActivityDO> getBargainActivityList(Set<Long> ids) {
|
||||||
|
return bargainActivityMapper.selectBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BargainActivityDO validateBargainActivityCanJoin(Long id) {
|
public BargainActivityDO validateBargainActivityCanJoin(Long id) {
|
||||||
BargainActivityDO activity = bargainActivityMapper.selectById(id);
|
BargainActivityDO activity = bargainActivityMapper.selectById(id);
|
||||||
|
@ -23,11 +23,19 @@ public interface BargainHelpService {
|
|||||||
BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO);
|
BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得助力人数 Map
|
* 【砍价活动】获得助力人数 Map
|
||||||
*
|
*
|
||||||
* @param activityIds 活动编号
|
* @param activityIds 活动编号
|
||||||
* @return 助力人数 Map
|
* @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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class BargainHelpServiceImpl implements BargainHelpService {
|
|||||||
|
|
||||||
// 5. 判断砍价记录是否完成
|
// 5. 判断砍价记录是否完成
|
||||||
Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价
|
Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价
|
||||||
|| bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getTotalLimitCount(); // 情况二:砍价助力已经达到上限
|
|| bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限
|
||||||
if (!bargainRecordService.updateBargainRecordBargainPrice(
|
if (!bargainRecordService.updateBargainRecordBargainPrice(
|
||||||
record.getId(), record.getBargainPrice(), reducePrice, success)) {
|
record.getId(), record.getBargainPrice(), reducePrice, success)) {
|
||||||
// 多人一起砍价,需要重试
|
// 多人一起砍价,需要重试
|
||||||
@ -103,8 +103,13 @@ public class BargainHelpServiceImpl implements BargainHelpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, Integer> getBargainHelpUserCountMap(Collection<Long> activityIds) {
|
public Map<Long, Integer> getBargainHelpUserCountMapByActivity(Collection<Long> activityIds) {
|
||||||
return bargainHelpMapper.selectCountByActivityId(activityIds);
|
return bargainHelpMapper.selectCountByActivityId(activityIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, Integer> getBargainHelpUserCountMapByRecord(Collection<Long> recordIds) {
|
||||||
|
return bargainHelpMapper.selectCountByRecordId(recordIds);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.service.bargain;
|
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.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.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
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);
|
Map<Long, Integer> getBargainRecordUserCountMap(Collection<Long> activityIds, @Nullable Integer status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得砍价记录分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 砍价记录分页
|
||||||
|
*/
|
||||||
|
PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.promotion.service.bargain;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
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.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.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.BargainActivityDO;
|
||||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO;
|
||||||
@ -100,4 +102,9 @@ public class BargainRecordServiceImpl implements BargainRecordService {
|
|||||||
return bargainRecordMapper.selectCountByActivityIdsAndStatus(activityIds, status);
|
return bargainRecordMapper.selectCountByActivityIdsAndStatus(activityIds, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO) {
|
||||||
|
return bargainRecordMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user