道具券列表改造

This commit is contained in:
tianfeng 2025-11-06 15:44:31 +08:00
parent cbf67d93b3
commit 61392d8810
3 changed files with 3 additions and 13 deletions

View File

@ -41,7 +41,7 @@ public class PropCouponRestController {
} }
/** /**
* 查询我的道具券列表 * 查询我的有效道具券列表
*/ */
@PostMapping("/list") @PostMapping("/list")
public PageResult<PropCouponCO> queryMyCoupons(@RequestBody @Validated PropCouponQueryCmd cmd) { public PageResult<PropCouponCO> queryMyCoupons(@RequestBody @Validated PropCouponQueryCmd cmd) {

View File

@ -42,10 +42,7 @@ public class PropCouponListQryExe {
couponType = PropCouponType.getByCode(cmd.getCouponType()); couponType = PropCouponType.getByCode(cmd.getCouponType());
} }
PropCouponStatus status = null; PropCouponStatus status = PropCouponStatus.UNUSED;
if (cmd.getStatus() != null) {
status = PropCouponStatus.getByCode(cmd.getStatus());
}
// 3. 查询券列表分页 // 3. 查询券列表分页
List<PropCoupon> propCoupons = propCouponGateway.selectByUserId( List<PropCoupon> propCoupons = propCouponGateway.selectByUserId(
@ -55,14 +52,6 @@ public class PropCouponListQryExe {
cmd.getCurrent().intValue(), cmd.getCurrent().intValue(),
cmd.getSize().intValue() cmd.getSize().intValue()
); );
// 过期未使用的券
propCoupons.forEach(coupon -> {
if (coupon.getStatus() == PropCouponStatus.UNUSED && coupon.getExpireTime().isBefore(LocalDateTime.now())) {
coupon.setStatus(PropCouponStatus.EXPIRED);
}
});
// 4. 统计总数 // 4. 统计总数
Long total = propCouponGateway.countByUserId(userId, couponType, status); Long total = propCouponGateway.countByUserId(userId, couponType, status);

View File

@ -85,6 +85,7 @@ public class PropCouponGatewayImpl implements PropCouponGateway {
if (status != null) { if (status != null) {
wrapper.eq(PropCouponDO::getStatus, status.getCode()); wrapper.eq(PropCouponDO::getStatus, status.getCode());
} }
wrapper.lt(PropCouponDO::getExpireTime, LocalDateTime.now());
wrapper.orderByDesc(PropCouponDO::getCreateTime); wrapper.orderByDesc(PropCouponDO::getCreateTime);
Page<PropCouponDO> page = new Page<>(pageNo, pageSize); Page<PropCouponDO> page = new Page<>(pageNo, pageSize);