diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
index 4811147b8..3383ec879 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.toolkit.Db;
diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java
index d9dd76f7c..f8db9be21 100644
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java
+++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/BargainRecordApi.java
@@ -1,12 +1,7 @@
package cn.iocoder.yudao.module.promotion.api.bargain;
-import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainRecordCreateReqDTO;
import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO;
-import javax.validation.Valid;
-
-// TODO @芋艿:后面也再撸撸这几个接口
-
/**
* 砍价记录 API 接口
*
@@ -14,13 +9,6 @@ import javax.validation.Valid;
*/
public interface BargainRecordApi {
- /**
- * 创建砍价记录
- *
- * @param reqDTO 请求 DTO
- */
- void createBargainRecord(@Valid BargainRecordCreateReqDTO reqDTO);
-
/**
* 【下单前】校验是否参与砍价活动
*
diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java
deleted file mode 100644
index 9f605417c..000000000
--- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package cn.iocoder.yudao.module.promotion.api.bargain.dto;
-
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-// TODO @芋艿:这块要在看看
-
-/**
- * 砍价记录的创建 Request DTO
- *
- * @author HUIHUI
- */
-@Data
-public class BargainRecordCreateReqDTO {
-
- /**
- * 砍价活动编号
- */
- @NotNull(message = "砍价活动编号不能为空")
- private Long activityId;
- /**
- * spu 编号
- */
- @NotNull(message = "spu 编号不能为空")
- private Long spuId;
- /**
- * sku 编号
- */
- @NotNull(message = "sku 编号不能为空")
- private Long skuId;
- /**
- * 用户编号
- */
- @NotNull(message = "用户编号不能为空")
- private Long userId;
- /**
- * 订单编号
- */
- @NotNull(message = "订单编号不能为空")
- private Long orderId;
-
- /**
- * 砍价商品单价
- */
- @NotNull(message = "砍价底价不能为空")
- private Integer bargainPrice;
- /**
- * 商品原价,单位分
- */
- @NotNull(message = "商品原价不能为空")
- private Integer price;
-
- // TODO @puhui999:创建时,这个参数不应该传递哈;
- /**
- * 开团状态:进行中 砍价成功 砍价失败
- */
- @NotNull(message = "开团状态不能为空")
- private Integer status;
-
-}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
index 6576262b5..4ced7d565 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
@@ -11,6 +11,8 @@ import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppB
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.service.bargain.BargainActivityService;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -21,10 +23,12 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
+import java.time.Duration;
+import java.util.Collections;
import java.util.List;
-import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@Tag(name = "用户 App - 砍价活动")
@@ -33,11 +37,42 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
@Validated
public class AppBargainActivityController {
+ /**
+ * {@link AppBargainActivityRespVO} 缓存,通过它异步刷新 {@link #getBargainActivityList0(Integer)} 所要的首页数据
+ */
+ private final LoadingCache> bargainActivityListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
+ new CacheLoader>() {
+
+ @Override
+ public List load(Integer count) {
+ return getBargainActivityList0(count);
+ }
+
+ });
+
@Resource
private BargainActivityService bargainActivityService;
@Resource
private ProductSpuApi spuApi;
+ @GetMapping("/list")
+ @Operation(summary = "获得砍价活动列表", description = "用于小程序首页")
+ @Parameter(name = "count", description = "需要展示的数量", example = "6")
+ public CommonResult> getBargainActivityList(
+ @RequestParam(name = "count", defaultValue = "6") Integer count) {
+ return success(bargainActivityListCache.getUnchecked(count));
+ }
+
+ private ListgetBargainActivityList0(Integer count) {
+ List list = bargainActivityService.getBargainActivityListByCount(count);
+ if (CollUtil.isEmpty(list)) {
+ return Collections.emptyList();
+ }
+ // 拼接数据
+ List spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId));
+ return BargainActivityConvert.INSTANCE.convertAppList(list, spuList);
+ }
+
@GetMapping("/page")
@Operation(summary = "获得砍价活动分页")
public CommonResult> getBargainActivityPage(PageParam pageReqVO) {
@@ -50,21 +85,6 @@ public class AppBargainActivityController {
return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList));
}
- // TODO 芋艿:增加 Spring Cache
- @GetMapping("/list")
- @Operation(summary = "获得砍价活动列表", description = "用于小程序首页")
- @Parameter(name = "count", description = "需要展示的数量", example = "6")
- public CommonResult> getBargainActivityList(
- @RequestParam(name = "count", defaultValue = "6") Integer count) {
- List list = bargainActivityService.getBargainActivityListByCount(defaultIfNull(count, 6));
- if (CollUtil.isEmpty(list)) {
- return success(BargainActivityConvert.INSTANCE.convertAppList(list));
- }
- // 拼接数据
- List spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId));
- return success(BargainActivityConvert.INSTANCE.convertAppList(list, spuList));
- }
-
@GetMapping("/get-detail")
@Operation(summary = "获得砍价活动详情")
@Parameter(name = "id", description = "活动编号", example = "1")
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java
index a172226ea..a7bce9265 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainRecordController.java
@@ -1,15 +1,27 @@
package cn.iocoder.yudao.module.promotion.controller.app.bargain;
+import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
+import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
+import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
+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.app.bargain.vo.record.AppBargainRecordCreateReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordDetailRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO;
+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.enums.bargain.BargainRecordStatusEnum;
+import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
import cn.iocoder.yudao.module.promotion.service.bargain.BargainRecordService;
+import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
+import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
@@ -17,9 +29,12 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.Duration;
-import java.util.ArrayList;
+import java.util.Collections;
+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;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "用户 App - 砍价记录")
@@ -30,25 +45,35 @@ public class AppBargainRecordController {
@Resource
private BargainRecordService bargainRecordService;
+ @Resource
+ private BargainActivityService bargainActivityService;
+
+ @Resource
+ private MemberUserApi memberUserApi;
+ @Resource
+ private ProductSpuApi productSpuApi;
+ @Resource
+ private TradeOrderApi tradeOrderApi;
@GetMapping("/get-summary")
@Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页")
- // TODO 芋艿:增加 @Cache 缓存,1 分钟过期
public CommonResult getBargainRecordSummary() {
- AppBargainRecordSummaryRespVO summary = new AppBargainRecordSummaryRespVO();
- summary.setUserCount(1024);
- summary.setSuccessRecords(new ArrayList<>());
- AppBargainRecordSummaryRespVO.Record record1 = new AppBargainRecordSummaryRespVO.Record();
- record1.setNickname("王**");
- record1.setAvatar("https://www.iocoder.cn/xxx.jpg");
- record1.setActivityName("天蚕土豆");
- AppBargainRecordSummaryRespVO.Record record2 = new AppBargainRecordSummaryRespVO.Record();
- record2.setNickname("张**");
- record2.setAvatar("https://www.iocoder.cn/yyy.jpg");
- record2.setActivityName("斗罗大陆");
- summary.getSuccessRecords().add(record1);
- summary.getSuccessRecords().add(record2);
- return success(summary);
+ // 砍价成功的用户数量
+ Integer successUserCount = bargainRecordService.getBargainRecordUserCount(
+ BargainRecordStatusEnum.SUCCESS.getStatus());
+ if (successUserCount == 0) {
+ return success(new AppBargainRecordSummaryRespVO().setSuccessUserCount(0)
+ .setSuccessList(Collections.emptyList()));
+ }
+ // 砍价成功的用户列表
+ List successList = bargainRecordService.getBargainRecordList(
+ BargainRecordStatusEnum.SUCCESS.getStatus(), 7);
+ List activityList = bargainActivityService.getBargainActivityList(
+ convertSet(successList, BargainRecordDO::getActivityId));
+ Map userMap = memberUserApi.getUserMap(
+ convertSet(successList, BargainRecordDO::getUserId));
+ // 拼接返回
+ return success(BargainRecordConvert.INSTANCE.convert(successUserCount, successList, activityList, userMap));
}
@GetMapping("/get-detail")
@@ -75,72 +100,19 @@ public class AppBargainRecordController {
@GetMapping("/page")
@Operation(summary = "获得砍价记录的分页")
public CommonResult> getBargainRecordPage(PageParam pageParam) {
- PageResult page = new PageResult<>();
- page.setList(new ArrayList<>());
- AppBargainRecordRespVO record1 = new AppBargainRecordRespVO();
- record1.setId(1L);
- record1.setUserId(1L);
- record1.setSpuId(1L);
- record1.setSkuId(1L);
- record1.setPrice(500);
- record1.setActivityId(1L);
- record1.setBargainPrice(150);
- record1.setPrice(200);
- record1.setPayPrice(180);
- record1.setStatus(1);
- record1.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
- record1.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2)));
- page.getList().add(record1);
+ PageResult pageResult = bargainRecordService.getBargainRecordPage(getLoginUserId(), pageParam);
+ if (CollUtil.isEmpty(pageResult.getList())) {
+ return success(PageResult.empty(pageResult.getTotal()));
+ }
- AppBargainRecordRespVO record2 = new AppBargainRecordRespVO();
- record2.setId(1L);
- record2.setUserId(1L);
- record2.setSpuId(1L);
- record2.setSkuId(1L);
- record2.setPrice(500);
- record2.setActivityId(1L);
- record2.setBargainPrice(150);
- record2.setPrice(200);
- record2.setPayPrice(280);
- record2.setStatus(2);
- record2.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
- record2.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2)));
- page.getList().add(record2);
-
- AppBargainRecordRespVO record3 = new AppBargainRecordRespVO();
- record3.setId(1L);
- record3.setUserId(1L);
- record3.setSpuId(1L);
- record3.setSkuId(1L);
- record3.setPrice(500);
- record3.setActivityId(1L);
- record3.setBargainPrice(150);
- record3.setPrice(200);
- record3.setPayPrice(380);
- record3.setStatus(2);
- record3.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
- record3.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2)));
- record3.setOrderId(100L);
- page.getList().add(record3);
-
- AppBargainRecordRespVO record4 = new AppBargainRecordRespVO();
- record4.setId(1L);
- record4.setUserId(1L);
- record4.setSpuId(1L);
- record4.setSkuId(1L);
- record4.setPrice(500);
- record4.setActivityId(1L);
- record4.setBargainPrice(150);
- record4.setPrice(200);
- record4.setPayPrice(380);
- record4.setStatus(3);
- record4.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
- record4.setExpireTime(LocalDateTimeUtils.addTime(Duration.ofDays(2)));
- record4.setOrderId(100L);
- page.getList().add(record4);
-
- page.setTotal(1L);
- return success(page);
+ // 拼接数据
+ List activityList = bargainActivityService.getBargainActivityList(
+ convertSet(pageResult.getList(), BargainRecordDO::getActivityId));
+ List spuList = productSpuApi.getSpuList(
+ convertSet(pageResult.getList(), BargainRecordDO::getSpuId));
+ List orderList = tradeOrderApi.getOrderList(
+ convertSet(pageResult.getList(), BargainRecordDO::getOrderId));
+ return success(BargainRecordConvert.INSTANCE.convertPage02(pageResult, activityList, spuList, orderList));
}
@PostMapping("/create")
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java
index ed18fc15b..f6e0193a5 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/activity/AppBargainActivityRespVO.java
@@ -30,13 +30,14 @@ public class AppBargainActivityRespVO {
@Schema(description = "砍价库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "512")
private Integer stock;
- @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, example = "4096") // 从 SPU 的 picUrl 读取
+ @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
+ example = "4096")
private String picUrl;
-
- @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "50") // 从 SPU 的 marketPrice 读取
+ @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
+ example = "50")
private Integer marketPrice;
@Schema(description = "砍价最低金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
- private Integer bargainPrice;
+ private Integer bargainMinPrice;
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java
index 73f2a713e..6aa6cd909 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordRespVO.java
@@ -9,24 +9,44 @@ import java.time.LocalDateTime;
@Data
public class AppBargainRecordRespVO {
- // TODO @芋艿:status;如果砍价对应的订单支付超时,算失败么?砍价的支付时间,以 expireTime 为准么?
-
+ @Schema(description = "砍价记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
private Long id;
- private Long userId;
+
+ @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
private Long spuId;
+ @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048")
private Long skuId;
+
+ @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901")
private Long activityId;
- private Integer bargainPrice;
- private Integer price;
- private Integer payPrice;
+
+ @Schema(description = "砍价记录状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
- private LocalDateTime expireTime;
- private Long orderId;
- private Boolean payStatus;
- private Long payOrderId;
+ @Schema(description = "当前价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "102")
+ private Integer bargainPrice;
+ // ========== 活动相关 ==========
+
+ @Schema(description = "活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
private String activityName;
+
+ @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
+ private LocalDateTime endTime;
+
+ @Schema(description = "商品图片", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
+ example = "https://www.iocoder.cn/xx.png")
private String picUrl;
+ // ========== 订单相关 ==========
+
+ @Schema(description = "订单编号", example = "1024")
+ private Long orderId;
+
+ @Schema(description = "支付状态", example = "true")
+ private Boolean payStatus;
+
+ @Schema(description = "支付订单编号", example = "1024")
+ private Long payOrderId;
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java
index f48227cc4..8523e00a0 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/vo/record/AppBargainRecordSummaryRespVO.java
@@ -10,10 +10,10 @@ import java.util.List;
public class AppBargainRecordSummaryRespVO {
@Schema(description = "砍价用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
- private Integer userCount;
+ private Integer successUserCount;
@Schema(description = "成功砍价的记录", requiredMode = Schema.RequiredMode.REQUIRED) // 只返回最近的 7 个
- private List successRecords;
+ private List successList;
@Schema(description = "成功砍价记录")
@Data
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
index ee1d5ed17..38cd948e3 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
@@ -27,7 +27,6 @@ import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
-import static cn.hutool.core.util.ObjectUtil.defaultIfNull;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
@@ -48,7 +47,7 @@ public class AppCombinationActivityController {
@Parameter(name = "count", description = "需要展示的数量", example = "6")
public CommonResult> getCombinationActivityList(
@RequestParam(name = "count", defaultValue = "6") Integer count) {
- List list = activityService.getCombinationActivityListByCount(defaultIfNull(count, 6));
+ List list = activityService.getCombinationActivityListByCount(6);
if (CollUtil.isEmpty(list)) {
return success(Collections.emptyList());
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
index 5e34621e6..5c85a6ff8 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
@@ -74,7 +74,7 @@ public class AppSeckillActivityController {
@GetMapping("/get-now")
@Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用")
public CommonResult getNowSeckillActivity() {
- return success(nowSeckillActivityCache.getUnchecked(""));
+ return success(nowSeckillActivityCache.getUnchecked("")); // 缓存
}
private AppSeckillActivityNowRespVO getNowSeckillActivity0() {
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java
index a8847e54a..2d94762f7 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainRecordConvert.java
@@ -4,15 +4,21 @@ 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.product.api.spu.dto.ProductSpuRespDTO;
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageItemRespVO;
+import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordRespVO;
+import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.record.AppBargainRecordSummaryRespVO;
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.trade.api.order.dto.TradeOrderRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
+
/**
* 砍价记录 Convert
*
@@ -29,7 +35,7 @@ public interface BargainRecordConvert {
Map userMap) {
PageResult pageResult = convertPage(page);
// 拼接数据
- Map activityMap = CollectionUtils.convertMap(activityList, BargainActivityDO::getId);
+ Map activityMap = convertMap(activityList, BargainActivityDO::getId);
pageResult.getList().forEach(record -> {
MapUtils.findAndThen(userMap, record.getUserId(),
user -> record.setNickname(user.getNickname()).setAvatar(user.getAvatar()));
@@ -40,4 +46,40 @@ public interface BargainRecordConvert {
}
PageResult convertPage(PageResult page);
+ default PageResult convertPage02(PageResult page,
+ List activityList,
+ List spuList,
+ List orderList) {
+ PageResult pageResult = convertPage02(page);
+ // 拼接数据
+ Map activityMap = convertMap(activityList, BargainActivityDO::getId);
+ Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId);
+ Map orderMap = convertMap(orderList, TradeOrderRespDTO::getId);
+ pageResult.getList().forEach(record -> {
+ MapUtils.findAndThen(activityMap, record.getActivityId(),
+ activity -> record.setActivityName(activity.getName()).setEndTime(activity.getEndTime()));
+ MapUtils.findAndThen(spuMap, record.getSpuId(),
+ spu -> record.setPicUrl(record.getPicUrl()));
+ MapUtils.findAndThen(orderMap, record.getOrderId(),
+ order -> record.setPayStatus(order.getPayStatus()).setPayOrderId(order.getPayOrderId()));
+ });
+ return pageResult;
+ }
+ PageResult convertPage02(PageResult page);
+
+ default AppBargainRecordSummaryRespVO convert(Integer successUserCount, List successList,
+ List activityList, Map userMap) {
+ AppBargainRecordSummaryRespVO summary = new AppBargainRecordSummaryRespVO().setSuccessUserCount(successUserCount);
+ Map activityMap = convertMap(activityList, BargainActivityDO::getId);
+ summary.setSuccessList(CollectionUtils.convertList(successList, record -> {
+ AppBargainRecordSummaryRespVO.Record recordVO = new AppBargainRecordSummaryRespVO.Record();
+ MapUtils.findAndThen(userMap, record.getUserId(),
+ user -> recordVO.setNickname(user.getNickname()).setAvatar(user.getAvatar()));
+ MapUtils.findAndThen(activityMap, record.getActivityId(),
+ activity -> recordVO.setActivityName(activity.getName()));
+ return recordVO;
+ }));
+ return summary;
+ }
+
}
diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java
index 7d283d5fc..222b78112 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainHelpMapper.java
@@ -26,7 +26,7 @@ public interface BargainHelpMapper extends BaseMapperX {
.eq(BargainHelpDO::getActivityId, activityId));
}
- default Long selectCountByRecordId(Long recordId) {
+ default Long selectUserCountMapByRecordId(Long recordId) {
return selectCount(BargainHelpDO::getRecordId, recordId);
}
@@ -36,7 +36,7 @@ public interface BargainHelpMapper extends BaseMapperX {
.eq(BargainHelpDO::getRecordId, recordId));
}
- default Map selectCountByActivityId(Collection activityIds) {
+ default Map selectUserCountMapByActivityId(Collection activityIds) {
// SQL count 查询
List