diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/props/PropCouponRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/props/PropCouponRestController.java index 6ae2b2d1..740ec1fa 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/props/PropCouponRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/props/PropCouponRestController.java @@ -41,7 +41,7 @@ public class PropCouponRestController { } /** - * 查询我的道具券列表 + * 查询我的有效道具券列表 */ @PostMapping("/list") public PageResult queryMyCoupons(@RequestBody @Validated PropCouponQueryCmd cmd) { diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/query/PropCouponListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/query/PropCouponListQryExe.java index f9c91398..4ce8d350 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/query/PropCouponListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/propcoupon/query/PropCouponListQryExe.java @@ -42,10 +42,7 @@ public class PropCouponListQryExe { couponType = PropCouponType.getByCode(cmd.getCouponType()); } - PropCouponStatus status = null; - if (cmd.getStatus() != null) { - status = PropCouponStatus.getByCode(cmd.getStatus()); - } + PropCouponStatus status = PropCouponStatus.UNUSED; // 3. 查询券列表(分页) List propCoupons = propCouponGateway.selectByUserId( @@ -55,14 +52,6 @@ public class PropCouponListQryExe { cmd.getCurrent().intValue(), cmd.getSize().intValue() ); - - // 过期未使用的券 - propCoupons.forEach(coupon -> { - if (coupon.getStatus() == PropCouponStatus.UNUSED && coupon.getExpireTime().isBefore(LocalDateTime.now())) { - coupon.setStatus(PropCouponStatus.EXPIRED); - } - }); - // 4. 统计总数 Long total = propCouponGateway.countByUserId(userId, couponType, status); diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java index 95f5d395..fefc024f 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/gateway/PropCouponGatewayImpl.java @@ -85,6 +85,7 @@ public class PropCouponGatewayImpl implements PropCouponGateway { if (status != null) { wrapper.eq(PropCouponDO::getStatus, status.getCode()); } + wrapper.lt(PropCouponDO::getExpireTime, LocalDateTime.now()); wrapper.orderByDesc(PropCouponDO::getCreateTime); Page page = new Page<>(pageNo, pageSize);