Commit 269da3d56d181a2bb7c44bf9e075b02b69103b5b
1 parent
cd45be1f
promotion:新增砍价记录列表
Showing
24 changed files
with
331 additions
and
31 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
| ... | ... | @@ -132,20 +132,20 @@ |
| 132 | 132 | align="center" |
| 133 | 133 | prop="${javaField}" |
| 134 | 134 | :formatter="dateFormatter" |
| 135 | - width="150px" | |
| 135 | + width="180px" | |
| 136 | 136 | /> |
| 137 | 137 | #elseif("" != $column.dictType)## 数据字典 |
| 138 | - <el-table-column label="${comment}" align="center" prop="${javaField}" width="150px"> | |
| 138 | + <el-table-column label="${comment}" align="center" prop="${javaField}"> | |
| 139 | 139 | <template #default="scope"> |
| 140 | 140 | <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" /> |
| 141 | 141 | </template> |
| 142 | 142 | </el-table-column> |
| 143 | 143 | #else |
| 144 | - <el-table-column label="${comment}" align="center" prop="${javaField}" width="150px" /> | |
| 144 | + <el-table-column label="${comment}" align="center" prop="${javaField}" /> | |
| 145 | 145 | #end |
| 146 | 146 | #end |
| 147 | 147 | #end |
| 148 | - <el-table-column label="操作" align="center" width="150px"> | |
| 148 | + <el-table-column label="操作" align="center"> | |
| 149 | 149 | <template #default="scope"> |
| 150 | 150 | <el-button |
| 151 | 151 | link | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java
| ... | ... | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 7 | 7 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.*; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.*; | |
| 9 | 9 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 10 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 11 | 11 | import cn.iocoder.yudao.module.promotion.enums.bargain.BargainRecordStatusEnum; |
| ... | ... | @@ -94,7 +94,7 @@ public class BargainActivityController { |
| 94 | 94 | Map<Long, Integer> recordUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, null); |
| 95 | 95 | Map<Long, Integer> recordSuccessUserCountMap = bargainRecordService.getBargainRecordUserCountMap(activityIds, |
| 96 | 96 | BargainRecordStatusEnum.SUCCESS.getStatus()); |
| 97 | - Map<Long, Integer> helpUserCountMap = bargainHelpService.getBargainHelpUserCountMap(activityIds); | |
| 97 | + Map<Long, Integer> helpUserCountMap = bargainHelpService.getBargainHelpUserCountMapByActivity(activityIds); | |
| 98 | 98 | return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList, |
| 99 | 99 | recordUserCountMap, recordSuccessUserCountMap, helpUserCountMap)); |
| 100 | 100 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain; | |
| 2 | + | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | |
| 7 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.promotion.convert.bargain.BargainRecordConvert; | |
| 11 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | |
| 12 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; | |
| 13 | +import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService; | |
| 14 | +import cn.iocoder.yudao.module.promotion.service.bargain.BargainHelpService; | |
| 15 | +import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService; | |
| 16 | +import io.swagger.v3.oas.annotations.Operation; | |
| 17 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 18 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 19 | +import org.springframework.validation.annotation.Validated; | |
| 20 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 21 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 22 | +import org.springframework.web.bind.annotation.RestController; | |
| 23 | + | |
| 24 | +import javax.annotation.Resource; | |
| 25 | +import javax.validation.Valid; | |
| 26 | +import java.util.List; | |
| 27 | +import java.util.Map; | |
| 28 | + | |
| 29 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 31 | + | |
| 32 | +@Tag(name = "管理后台 - 砍价记录") | |
| 33 | +@RestController | |
| 34 | +@RequestMapping("/promotion/bargain-record") | |
| 35 | +@Validated | |
| 36 | +public class BargainRecordController { | |
| 37 | + | |
| 38 | + @Resource | |
| 39 | + private BargainRecordService bargainRecordService; | |
| 40 | + @Resource | |
| 41 | + private BargainActivityService bargainActivityService; | |
| 42 | + @Resource | |
| 43 | + private BargainHelpService bargainHelpService; | |
| 44 | + | |
| 45 | + @Resource | |
| 46 | + private MemberUserApi memberUserApi; | |
| 47 | + | |
| 48 | + @GetMapping("/page") | |
| 49 | + @Operation(summary = "获得砍价记录分页") | |
| 50 | + @PreAuthorize("@ss.hasPermission('promotion:bargain-record:query')") | |
| 51 | + public CommonResult<PageResult<BargainRecordPageItemRespVO>> getBargainRecordPage(@Valid BargainRecordPageReqVO pageVO) { | |
| 52 | + PageResult<BargainRecordDO> pageResult = bargainRecordService.getBargainRecordPage(pageVO); | |
| 53 | + if (CollUtil.isEmpty(pageResult.getList())) { | |
| 54 | + return success(PageResult.empty(pageResult.getTotal())); | |
| 55 | + } | |
| 56 | + | |
| 57 | + // 拼接数据 | |
| 58 | + Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap( | |
| 59 | + convertSet(pageResult.getList(), BargainRecordDO::getUserId)); | |
| 60 | + List<BargainActivityDO> activityList = bargainActivityService.getBargainActivityList( | |
| 61 | + convertSet(pageResult.getList(), BargainRecordDO::getActivityId)); | |
| 62 | + Map<Long, Integer> helpCountMap = bargainHelpService.getBargainHelpUserCountMapByRecord( | |
| 63 | + convertSet(pageResult.getList(), BargainRecordDO::getId)); | |
| 64 | + return success(BargainRecordConvert.INSTANCE.convertPage(pageResult, helpCountMap, activityList, userMap)); | |
| 65 | + } | |
| 66 | + | |
| 67 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityBaseVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityBaseVO.java
| 1 | -package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo; | |
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity; | |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| ... | ... | @@ -56,9 +56,9 @@ public class BargainActivityBaseVO { |
| 56 | 56 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 57 | 57 | private LocalDateTime endTime; |
| 58 | 58 | |
| 59 | - @Schema(description = "砍价人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") | |
| 60 | - @NotNull(message = "砍价人数不能为空") | |
| 61 | - private Integer userSize; | |
| 59 | + @Schema(description = "最大助力次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") | |
| 60 | + @NotNull(message = "最大助力次数不能为空") | |
| 61 | + private Integer helpMaxCount; | |
| 62 | 62 | |
| 63 | 63 | @Schema(description = "最大帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "25222") |
| 64 | 64 | @NotNull(message = "最大帮砍次数不能为空") | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityCreateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityCreateReqVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityPageItemRespVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageItemRespVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityPageReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityPageReqVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityRespVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityRespVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/BargainActivityUpdateReqVO.java renamed to yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/activity/BargainActivityUpdateReqVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 砍价记录 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 14 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +public class BargainRecordBaseVO { | |
| 18 | + | |
| 19 | + @Schema(description = "砍价活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "22690") | |
| 20 | + @NotNull(message = "砍价活动名称不能为空") | |
| 21 | + private Long activityId; | |
| 22 | + | |
| 23 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9430") | |
| 24 | + @NotNull(message = "用户编号不能为空") | |
| 25 | + private Long userId; | |
| 26 | + | |
| 27 | + @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23622") | |
| 28 | + @NotNull(message = "商品 SPU 编号不能为空") | |
| 29 | + private Long spuId; | |
| 30 | + | |
| 31 | + @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29950") | |
| 32 | + @NotNull(message = "商品 SKU 编号不能为空") | |
| 33 | + private Long skuId; | |
| 34 | + | |
| 35 | + @Schema(description = "砍价起始价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "31160") | |
| 36 | + @NotNull(message = "砍价起始价格,单位:分不能为空") | |
| 37 | + private Integer bargainFirstPrice; | |
| 38 | + | |
| 39 | + @Schema(description = "当前砍价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "22743") | |
| 40 | + @NotNull(message = "当前砍价,单位:分不能为空") | |
| 41 | + private Integer bargainPrice; | |
| 42 | + | |
| 43 | + @Schema(description = "砍价状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 44 | + @NotNull(message = "砍价状态不能为空") | |
| 45 | + private Integer status; | |
| 46 | + | |
| 47 | + @Schema(description = "订单编号", example = "27845") | |
| 48 | + private Long orderId; | |
| 49 | + | |
| 50 | + @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 51 | + @NotNull(message = "结束时间不能为空") | |
| 52 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 53 | + private LocalDateTime endTime; | |
| 54 | + | |
| 55 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageItemRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 砍价记录的分页项 Response VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class BargainRecordPageItemRespVO extends BargainRecordBaseVO { | |
| 16 | + | |
| 17 | + @Schema(description = "记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2022-07-01 23:59:59") | |
| 21 | + private LocalDateTime createTime; | |
| 22 | + | |
| 23 | + @Schema(description = "帮砍次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") | |
| 24 | + private Integer helpCount; | |
| 25 | + | |
| 26 | + // ========== 用户相关 ========== | |
| 27 | + | |
| 28 | + @Schema(description = "用户昵称", example = "老芋艿") | |
| 29 | + private String nickname; | |
| 30 | + | |
| 31 | + @Schema(description = "用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xxx.jpg") | |
| 32 | + private String avatar; | |
| 33 | + | |
| 34 | + // ========== 活动相关 ========== | |
| 35 | + | |
| 36 | + private BargainActivityRespVO activity; | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/vo/recrod/BargainRecordPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 砍价记录分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class BargainRecordPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "砍价状态", example = "1") | |
| 21 | + private Integer status; | |
| 22 | + | |
| 23 | + @Schema(description = "创建时间") | |
| 24 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 25 | + private LocalDateTime[] createTime; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java
| ... | ... | @@ -5,10 +5,10 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | 5 | import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; |
| 6 | 6 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 7 | 7 | import cn.iocoder.yudao.module.product.enums.DictTypeConstants; |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityBaseVO; | |
| 9 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageItemRespVO; | |
| 10 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityRespVO; | |
| 11 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityBaseVO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageItemRespVO; | |
| 10 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityRespVO; | |
| 11 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | |
| 12 | 12 | import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; |
| 13 | 13 | import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityRespVO; |
| 14 | 14 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.convert.bargain; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 6 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; | |
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; | |
| 10 | +import org.mapstruct.Mapper; | |
| 11 | +import org.mapstruct.factory.Mappers; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | +import java.util.Map; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * 砍价记录 Convert | |
| 18 | + * | |
| 19 | + * @author 芋道源码 | |
| 20 | + */ | |
| 21 | +@Mapper | |
| 22 | +public interface BargainRecordConvert { | |
| 23 | + | |
| 24 | + BargainRecordConvert INSTANCE = Mappers.getMapper(BargainRecordConvert.class); | |
| 25 | + | |
| 26 | + default PageResult<BargainRecordPageItemRespVO> convertPage(PageResult<BargainRecordDO> page, | |
| 27 | + Map<Long, Integer> helpCountMap, | |
| 28 | + List<BargainActivityDO> activityList, | |
| 29 | + Map<Long, MemberUserRespDTO> userMap) { | |
| 30 | + PageResult<BargainRecordPageItemRespVO> pageResult = convertPage(page); | |
| 31 | + // 拼接数据 | |
| 32 | + Map<Long, BargainActivityDO> activityMap = CollectionUtils.convertMap(activityList, BargainActivityDO::getId); | |
| 33 | + pageResult.getList().forEach(record -> { | |
| 34 | + MapUtils.findAndThen(userMap, record.getUserId(), | |
| 35 | + user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar())); | |
| 36 | + record.setActivity(BargainActivityConvert.INSTANCE.convert(activityMap.get(record.getActivityId()))) | |
| 37 | + .setHelpCount(helpCountMap.getOrDefault(record.getId(), 0)); | |
| 38 | + }); | |
| 39 | + return pageResult; | |
| 40 | + } | |
| 41 | + PageResult<BargainRecordPageItemRespVO> convertPage(PageResult<BargainRecordDO> page); | |
| 42 | + | |
| 43 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/bargain/BargainActivityDO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 9 | 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 10 | 10 | import org.apache.ibatis.annotations.Mapper; | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java
| ... | ... | @@ -49,4 +49,19 @@ public interface BargainHelpMapper extends BaseMapperX<BargainHelpDO> { |
| 49 | 49 | record -> MapUtil.getInt(record, "userCount" )); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | + default Map<Long, Integer> selectCountByRecordId(Collection<Long> recordIds) { | |
| 53 | + // SQL count 查询 | |
| 54 | + List<Map<String, Object>> result = selectMaps(new QueryWrapper<BargainHelpDO>() | |
| 55 | + .select("COUNT(1) AS userCount, record_id AS recordId") | |
| 56 | + .in("record_id", recordIds) | |
| 57 | + .groupBy("record_id")); | |
| 58 | + if (CollUtil.isEmpty(result)) { | |
| 59 | + return Collections.emptyMap(); | |
| 60 | + } | |
| 61 | + // 转换数据 | |
| 62 | + return CollectionUtils.convertMap(result, | |
| 63 | + record -> MapUtil.getLong(record, "recordId"), | |
| 64 | + record -> MapUtil.getInt(record, "userCount" )); | |
| 65 | + } | |
| 66 | + | |
| 52 | 67 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java
| ... | ... | @@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; | |
| 7 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; |
| 8 | 11 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 9 | 12 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| ... | ... | @@ -65,4 +68,11 @@ public interface BargainRecordMapper extends BaseMapperX<BargainRecordDO> { |
| 65 | 68 | record -> MapUtil.getInt(record, "userCount" )); |
| 66 | 69 | } |
| 67 | 70 | |
| 71 | + default PageResult<BargainRecordDO> selectPage(BargainRecordPageReqVO reqVO) { | |
| 72 | + return selectPage(reqVO, new LambdaQueryWrapperX<BargainRecordDO>() | |
| 73 | + .eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus()) | |
| 74 | + .betweenIfPresent(BargainRecordDO::getCreateTime, reqVO.getCreateTime()) | |
| 75 | + .orderByDesc(BargainRecordDO::getId)); | |
| 76 | + } | |
| 77 | + | |
| 68 | 78 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
| ... | ... | @@ -2,13 +2,14 @@ package cn.iocoder.yudao.module.promotion.service.bargain; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 9 | 9 | |
| 10 | 10 | import javax.validation.Valid; |
| 11 | 11 | import java.util.List; |
| 12 | +import java.util.Set; | |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | 15 | * 砍价活动 Service 接口 |
| ... | ... | @@ -56,6 +57,14 @@ public interface BargainActivityService { |
| 56 | 57 | BargainActivityDO getBargainActivity(Long id); |
| 57 | 58 | |
| 58 | 59 | /** |
| 60 | + * 获得砍价活动列表 | |
| 61 | + * | |
| 62 | + * @param ids 编号数组 | |
| 63 | + * @return 砍价活动列表 | |
| 64 | + */ | |
| 65 | + List<BargainActivityDO> getBargainActivityList(Set<Long> ids); | |
| 66 | + | |
| 67 | + /** | |
| 59 | 68 | * 校验砍价活动,是否可以参与(发起砍价、下单、帮好友砍价) |
| 60 | 69 | * |
| 61 | 70 | * @param id 编号 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
| ... | ... | @@ -8,9 +8,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 9 | 9 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 10 | 10 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 11 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO; | |
| 12 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityPageReqVO; | |
| 13 | -import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityUpdateReqVO; | |
| 11 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityCreateReqVO; | |
| 12 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO; | |
| 13 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityUpdateReqVO; | |
| 14 | 14 | import cn.iocoder.yudao.module.promotion.convert.bargain.BargainActivityConvert; |
| 15 | 15 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 16 | 16 | import cn.iocoder.yudao.module.promotion.dal.mysql.bargain.BargainActivityMapper; |
| ... | ... | @@ -21,6 +21,7 @@ import org.springframework.validation.annotation.Validated; |
| 21 | 21 | import javax.annotation.Resource; |
| 22 | 22 | import java.time.LocalDateTime; |
| 23 | 23 | import java.util.List; |
| 24 | +import java.util.Set; | |
| 24 | 25 | |
| 25 | 26 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 26 | 27 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; |
| ... | ... | @@ -145,6 +146,11 @@ public class BargainActivityServiceImpl implements BargainActivityService { |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | 148 | @Override |
| 149 | + public List<BargainActivityDO> getBargainActivityList(Set<Long> ids) { | |
| 150 | + return bargainActivityMapper.selectBatchIds(ids); | |
| 151 | + } | |
| 152 | + | |
| 153 | + @Override | |
| 148 | 154 | public BargainActivityDO validateBargainActivityCanJoin(Long id) { |
| 149 | 155 | BargainActivityDO activity = bargainActivityMapper.selectById(id); |
| 150 | 156 | if (activity == null) { | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpService.java
| ... | ... | @@ -23,11 +23,19 @@ public interface BargainHelpService { |
| 23 | 23 | BargainHelpDO createBargainHelp(Long userId, AppBargainHelpCreateReqVO reqVO); |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * 获得助力人数 Map | |
| 26 | + * 【砍价活动】获得助力人数 Map | |
| 27 | 27 | * |
| 28 | 28 | * @param activityIds 活动编号 |
| 29 | 29 | * @return 助力人数 Map |
| 30 | 30 | */ |
| 31 | - Map<Long, Integer> getBargainHelpUserCountMap(Collection<Long> activityIds); | |
| 31 | + Map<Long, Integer> getBargainHelpUserCountMapByActivity(Collection<Long> activityIds); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 【砍价记录】获得助力人数 Map | |
| 35 | + * | |
| 36 | + * @param recordIds 记录编号 | |
| 37 | + * @return 助力人数 Map | |
| 38 | + */ | |
| 39 | + Map<Long, Integer> getBargainHelpUserCountMapByRecord(Collection<Long> recordIds); | |
| 32 | 40 | |
| 33 | 41 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java
| ... | ... | @@ -81,7 +81,7 @@ public class BargainHelpServiceImpl implements BargainHelpService { |
| 81 | 81 | |
| 82 | 82 | // 5. 判断砍价记录是否完成 |
| 83 | 83 | Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价 |
| 84 | - || bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getTotalLimitCount(); // 情况二:砍价助力已经达到上限 | |
| 84 | + || bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限 | |
| 85 | 85 | if (!bargainRecordService.updateBargainRecordBargainPrice( |
| 86 | 86 | record.getId(), record.getBargainPrice(), reducePrice, success)) { |
| 87 | 87 | // 多人一起砍价,需要重试 |
| ... | ... | @@ -103,8 +103,13 @@ public class BargainHelpServiceImpl implements BargainHelpService { |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | @Override |
| 106 | - public Map<Long, Integer> getBargainHelpUserCountMap(Collection<Long> activityIds) { | |
| 106 | + public Map<Long, Integer> getBargainHelpUserCountMapByActivity(Collection<Long> activityIds) { | |
| 107 | 107 | return bargainHelpMapper.selectCountByActivityId(activityIds); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | + @Override | |
| 111 | + public Map<Long, Integer> getBargainHelpUserCountMapByRecord(Collection<Long> recordIds) { | |
| 112 | + return bargainHelpMapper.selectCountByRecordId(recordIds); | |
| 113 | + } | |
| 114 | + | |
| 110 | 115 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.bargain; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | 5 | import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; |
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; | |
| 5 | 7 | import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; |
| 6 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; |
| 7 | 9 | |
| ... | ... | @@ -68,4 +70,12 @@ public interface BargainRecordService { |
| 68 | 70 | */ |
| 69 | 71 | Map<Long, Integer> getBargainRecordUserCountMap(Collection<Long> activityIds, @Nullable Integer status); |
| 70 | 72 | |
| 73 | + /** | |
| 74 | + * 获得砍价记录分页 | |
| 75 | + * | |
| 76 | + * @param pageReqVO 分页查询 | |
| 77 | + * @return 砍价记录分页 | |
| 78 | + */ | |
| 79 | + PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO); | |
| 80 | + | |
| 71 | 81 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java
| ... | ... | @@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.promotion.service.bargain; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.util.ObjUtil; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | 7 | import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; | |
| 7 | 9 | import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordCreateReqVO; |
| 8 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; |
| 9 | 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; |
| ... | ... | @@ -100,4 +102,9 @@ public class BargainRecordServiceImpl implements BargainRecordService { |
| 100 | 102 | return bargainRecordMapper.selectCountByActivityIdsAndStatus(activityIds, status); |
| 101 | 103 | } |
| 102 | 104 | |
| 105 | + @Override | |
| 106 | + public PageResult<BargainRecordDO> getBargainRecordPage(BargainRecordPageReqVO pageReqVO) { | |
| 107 | + return bargainRecordMapper.selectPage(pageReqVO); | |
| 108 | + } | |
| 109 | + | |
| 103 | 110 | } | ... | ... |