From 1bda3c8b53bdfa877cd14e1270d67f20d310d4a1 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 5 Oct 2023 17:22:17 +0800 Subject: [PATCH] =?UTF-8?q?promotion=EF=BC=9A=E5=AE=8C=E5=96=84=E7=A0=8D?= =?UTF-8?q?=E4=BB=B7=20API=20~=20=E6=8F=90=E4=BA=A4=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E5=87=86=E5=A4=87=E5=87=BA=E9=97=A8=E5=90=83=E9=A5=AD=EF=BC=81?= =?UTF-8?q?=EF=BC=81=EF=BC=81=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/core/mapper/BaseMapperX.java | 1 + .../api/bargain/BargainRecordApi.java | 12 -- .../dto/BargainRecordCreateReqDTO.java | 61 -------- .../bargain/AppBargainActivityController.java | 52 ++++--- .../bargain/AppBargainRecordController.java | 134 +++++++----------- .../vo/activity/AppBargainActivityRespVO.java | 9 +- .../vo/record/AppBargainRecordRespVO.java | 40 ++++-- .../record/AppBargainRecordSummaryRespVO.java | 4 +- .../AppCombinationActivityController.java | 3 +- .../seckill/AppSeckillActivityController.java | 2 +- .../convert/bargain/BargainRecordConvert.java | 44 +++++- .../dal/mysql/bargain/BargainHelpMapper.java | 6 +- .../mysql/bargain/BargainRecordMapper.java | 20 ++- .../bargain/BargainActivityServiceImpl.java | 2 +- .../bargain/BargainHelpServiceImpl.java | 6 +- .../service/bargain/BargainRecordService.java | 30 +++- .../bargain/BargainRecordServiceImpl.java | 19 ++- .../module/trade/api/order/TradeOrderApi.java | 11 ++ .../api/order/dto/TradeOrderRespDTO.java | 10 ++ .../trade/api/order/TradeOrderApiImpl.java | 9 ++ .../convert/order/TradeOrderConvert.java | 2 + .../service/order/TradeOrderQueryService.java | 8 ++ .../order/TradeOrderQueryServiceImpl.java | 8 ++ .../TradePriceCalculatorHelper.java | 4 +- 24 files changed, 296 insertions(+), 201 deletions(-) delete mode 100644 yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/bargain/dto/BargainRecordCreateReqDTO.java 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> result = selectMaps(new QueryWrapper() .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") @@ -51,7 +51,7 @@ public interface BargainHelpMapper extends BaseMapperX { record -> MapUtil.getInt(record, "userCount" )); } - default Map selectCountByRecordId(Collection recordIds) { + default Map selectUserCountMapByRecordId(Collection recordIds) { // SQL count 查询 List> result = selectMaps(new QueryWrapper() .select("COUNT(1) AS userCount, record_id AS recordId") diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java index 5292f97df..92b946e32 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainRecordMapper.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.bargain; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.map.MapUtil; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; @@ -11,6 +12,8 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import java.util.Collection; import java.util.Collections; @@ -52,7 +55,7 @@ public interface BargainRecordMapper extends BaseMapperX { .eq(BargainRecordDO::getBargainPrice, whereBargainPrice)); } - default Map selectCountByActivityIdsAndStatus(Collection activityIds, Integer status) { + default Map selectUserCountByActivityIdsAndStatus(Collection activityIds, Integer status) { // SQL count 查询 List> result = selectMaps(new QueryWrapper() .select("COUNT(DISTINCT(user_id)) AS userCount, activity_id AS activityId") @@ -68,6 +71,9 @@ public interface BargainRecordMapper extends BaseMapperX { record -> MapUtil.getInt(record, "userCount" )); } + @Select("SELECT COUNT(DISTINCT(user_id)) FROM promotion_bargain_record WHERE status = #{status}") + Integer selectUserCountByStatus(@Param("status") Integer status); + default PageResult selectPage(BargainRecordPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(BargainRecordDO::getStatus, reqVO.getStatus()) @@ -75,4 +81,16 @@ public interface BargainRecordMapper extends BaseMapperX { .orderByDesc(BargainRecordDO::getId)); } + default PageResult selectBargainRecordPage(Long userId, PageParam pageParam) { + return selectPage(pageParam, new LambdaQueryWrapperX() + .eq(BargainRecordDO::getUserId, userId) + .orderByDesc(BargainRecordDO::getId)); + } + + default List selectListByStatusAndCount(Integer status, Integer count) { + return selectList(new LambdaQueryWrapper<>(BargainRecordDO.class) + .eq(BargainRecordDO::getStatus, status) + .last("LIMIT " + count)); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java index 36f5faa04..46477b918 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java @@ -162,7 +162,7 @@ public class BargainActivityServiceImpl implements BargainActivityService { if (activity.getStock() <= 0) { throw exception(BARGAIN_ACTIVITY_STOCK_NOT_ENOUGH); } - if (LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { + if (!LocalDateTimeUtils.isBetween(activity.getStartTime(), activity.getEndTime())) { throw exception(BARGAIN_ACTIVITY_TIME_END); } return activity; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java index bf3557213..238e8a70e 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainHelpServiceImpl.java @@ -83,7 +83,7 @@ public class BargainHelpServiceImpl implements BargainHelpService { // 5. 判断砍价记录是否完成 Boolean success = record.getBargainPrice() - reducePrice <= activity.getBargainMinPrice() // 情况一:砍价已经砍到最低价 - || bargainHelpMapper.selectCountByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限 + || bargainHelpMapper.selectUserCountMapByRecordId(reqVO.getRecordId()) >= activity.getHelpMaxCount(); // 情况二:砍价助力已经达到上限 if (!bargainRecordService.updateBargainRecordBargainPrice( record.getId(), record.getBargainPrice(), reducePrice, success)) { // 多人一起砍价,需要重试 @@ -106,12 +106,12 @@ public class BargainHelpServiceImpl implements BargainHelpService { @Override public Map getBargainHelpUserCountMapByActivity(Collection activityIds) { - return bargainHelpMapper.selectCountByActivityId(activityIds); + return bargainHelpMapper.selectUserCountMapByActivityId(activityIds); } @Override public Map getBargainHelpUserCountMapByRecord(Collection recordIds) { - return bargainHelpMapper.selectCountByRecordId(recordIds); + return bargainHelpMapper.selectUserCountMapByRecordId(recordIds); } @Override diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java index d0b125cc5..2e1169ea2 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.promotion.service.bargain; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; @@ -9,6 +10,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainRecordDO; import javax.annotation.Nullable; import java.util.Collection; +import java.util.List; import java.util.Map; /** @@ -71,11 +73,37 @@ public interface BargainRecordService { Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status); /** - * 获得砍价记录分页 + * 获得砍价人数 Map + * + * @param status 砍价记录状态 + * @return 砍价人数 + */ + Integer getBargainRecordUserCount(Integer status); + + /** + * 【管理员】获得砍价记录分页 * * @param pageReqVO 分页查询 * @return 砍价记录分页 */ PageResult getBargainRecordPage(BargainRecordPageReqVO pageReqVO); + /** + * 【会员】获得砍价记录分页 + * + * @param userId 用户编号 + * @param pageParam 分页查询 + * @return 砍价记录分页 + */ + PageResult getBargainRecordPage(Long userId, PageParam pageParam); + + /** + * 获得砍价记录列表 + * + * @param status 砍价记录状态 + * @param count 条数 + * @return 砍价记录列表 + */ + List getBargainRecordList(Integer status, Integer count); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java index abe2b3c96..079d89136 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainRecordServiceImpl.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.bargain; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.lang.Assert; import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.promotion.api.bargain.dto.BargainValidateJoinRespDTO; import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.recrod.BargainRecordPageReqVO; @@ -17,6 +18,7 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Nullable; import javax.annotation.Resource; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -99,7 +101,12 @@ public class BargainRecordServiceImpl implements BargainRecordService { @Override public Map getBargainRecordUserCountMap(Collection activityIds, @Nullable Integer status) { - return bargainRecordMapper.selectCountByActivityIdsAndStatus(activityIds, status); + return bargainRecordMapper.selectUserCountByActivityIdsAndStatus(activityIds, status); + } + + @Override + public Integer getBargainRecordUserCount(Integer status) { + return bargainRecordMapper.selectUserCountByStatus(status); } @Override @@ -107,4 +114,14 @@ public class BargainRecordServiceImpl implements BargainRecordService { return bargainRecordMapper.selectPage(pageReqVO); } + @Override + public PageResult getBargainRecordPage(Long userId, PageParam pageParam) { + return bargainRecordMapper.selectBargainRecordPage(userId, pageParam); + } + + @Override + public List getBargainRecordList(Integer status, Integer count) { + return bargainRecordMapper.selectListByStatusAndCount(status, count); + } + } diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java index 0c0022bb5..5b7594d40 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApi.java @@ -1,8 +1,11 @@ package cn.iocoder.yudao.module.trade.api.order; +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; import java.time.LocalDateTime; +import java.util.Collection; +import java.util.List; /** * 订单 API 接口 @@ -11,6 +14,14 @@ import java.time.LocalDateTime; */ public interface TradeOrderApi { + /** + * 获得订单列表 + * + * @param ids 订单编号数组 + * @return 订单列表 + */ + List getOrderList(Collection ids); + // TODO 芋艿:看看是不是可以删除掉; /** * 获取订单状态 diff --git a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java index 27b0a8af1..52b167cd4 100644 --- a/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java +++ b/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java @@ -84,4 +84,14 @@ public class TradeOrderRespDTO { */ private Boolean commentStatus; + // ========== 价格 + 支付基本信息 ========== + /** + * 支付订单编号 + */ + private Long payOrderId; + /** + * 是否已支付 + */ + private Boolean payStatus; + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java index d9ab02e34..5ad0cb107 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderApiImpl.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.trade.api.order; +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderSummaryRespDTO; +import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; import org.springframework.stereotype.Service; @@ -9,6 +11,8 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.time.LocalDateTime; +import java.util.Collection; +import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; @@ -25,6 +29,11 @@ public class TradeOrderApiImpl implements TradeOrderApi { @Resource private TradeOrderQueryService tradeOrderQueryService; + @Override + public List getOrderList(Collection ids) { + return TradeOrderConvert.INSTANCE.convertList04(tradeOrderQueryService.getOrderList(ids)); + } + @Override public Integer getOrderStatus(Long id) { TradeOrderDO order = tradeOrderQueryService.getOrder(id); diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java index 1aa000034..9255460b3 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java @@ -261,4 +261,6 @@ public interface TradeOrderConvert { return bo; } + List convertList04(List list); + } diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java index 3544864bf..c2a7933e0 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryService.java @@ -40,6 +40,14 @@ public interface TradeOrderQueryService { */ TradeOrderDO getOrder(Long userId, Long id); + /** + * 获得订单列表 + * + * @param ids 订单编号数组 + * @return 订单列表 + */ + List getOrderList(Collection ids); + /** * 【管理员】获得交易订单分页 * diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java index b4d1a4af8..4f4fd4f68 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java @@ -69,6 +69,14 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService { return order; } + @Override + public List getOrderList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } + return tradeOrderMapper.selectBatchIds(ids); + } + @Override public PageResult getOrderPage(TradeOrderPageReqVO reqVO) { // 获得 userId 相关的查询 diff --git a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java index efe96f876..7def3e34e 100644 --- a/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java +++ b/yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradePriceCalculatorHelper.java @@ -86,7 +86,9 @@ public class TradePriceCalculatorHelper { if (param.getCombinationActivityId() != null) { return TradeOrderTypeEnum.COMBINATION.getType(); } - // TODO 砍价敬请期待 + if (param.getBargainRecordId() != null) { + return TradeOrderTypeEnum.BARGAIN.getType(); + } return TradeOrderTypeEnum.NORMAL.getType(); }