过期未使用的券
This commit is contained in:
parent
607ac75210
commit
318defb5c7
@ -12,6 +12,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -55,6 +56,13 @@ public class PropCouponListQryExe {
|
||||
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);
|
||||
|
||||
|
||||
@ -25,12 +25,11 @@ public class PropCouponExpireTask {
|
||||
*/
|
||||
@Scheduled(cron = "0 0 * * * ?")
|
||||
public void expireCoupons() {
|
||||
// TODO: 实现过期逻辑
|
||||
// try {
|
||||
// Integer count = propCouponGateway.expireOverdueCoupons();
|
||||
// log.info("道具券过期定时任务执行完成,过期券数量:{}", count);
|
||||
// } catch (Exception e) {
|
||||
// log.error("道具券过期定时任务执行失败", e);
|
||||
// }
|
||||
try {
|
||||
Integer count = propCouponGateway.expireOverdueCoupons();
|
||||
log.info("道具券过期定时任务执行完成,过期券数量:{}", count);
|
||||
} catch (Exception e) {
|
||||
log.error("道具券过期定时任务执行失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import com.red.circle.framework.mybatis.dao.BaseDAO;
|
||||
import com.red.circle.other.infra.database.rds.entity.props.PropCouponDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -14,16 +15,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface PropCouponDAO extends BaseDAO<PropCouponDO> {
|
||||
|
||||
/**
|
||||
* 根据券编号查询(加锁)
|
||||
*/
|
||||
PropCouponDO selectForUpdate(@Param("couponNo") String couponNo);
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*/
|
||||
int batchInsert(@Param("list") List<PropCouponDO> list);
|
||||
|
||||
/**
|
||||
* 批量过期券
|
||||
*/
|
||||
|
||||
@ -14,6 +14,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -109,9 +110,7 @@ public class PropCouponGatewayImpl implements PropCouponGateway {
|
||||
|
||||
@Override
|
||||
public Integer expireOverdueCoupons() {
|
||||
// TODO: 实现批量过期逻辑
|
||||
// return propCouponDAO.expireOverdueCoupons();
|
||||
return 0;
|
||||
return propCouponDAO.expireOverdueCoupons();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,7 +118,7 @@ public class PropCouponGatewayImpl implements PropCouponGateway {
|
||||
List<PropCouponDO> propCouponDOS = propCoupons.stream()
|
||||
.map(this::convertToDO)
|
||||
.collect(Collectors.toList());
|
||||
propCouponDAO.batchInsert(propCouponDOS);
|
||||
propCouponDAO.insertBatchSomeColumn(propCouponDOS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.red.circle.other.infra.database.rds.dao.props.PropCouponDAO">
|
||||
|
||||
<update id="expireOverdueCoupons">
|
||||
UPDATE prop_coupon SET status = 2 WHERE status = 0 AND expire_time < NOW()
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@ -5,6 +5,7 @@ import org.junit.Test;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import static com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils.getCalcBillBelong;
|
||||
@ -16,6 +17,8 @@ public class ApiTest {
|
||||
String[] strings = TeamBillCycleUtils.parseBillBelongToDateRange(20251001);
|
||||
System.out.println(strings[0]);
|
||||
System.out.println(strings[1]);
|
||||
|
||||
System.out.println(LocalDateTime.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -8,8 +8,10 @@ import com.red.circle.external.inner.model.enums.message.GroupMessageTypeEnum;
|
||||
import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum;
|
||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||
import com.red.circle.other.app.util.OfficialNoticeUtils;
|
||||
import com.red.circle.other.domain.gateway.PropCouponGateway;
|
||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||
import com.red.circle.other.domain.gateway.user.ability.InviteUserGateway;
|
||||
import com.red.circle.other.domain.propcoupon.PropCoupon;
|
||||
import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService;
|
||||
import com.red.circle.other.infra.database.rds.entity.sys.GameListConfig;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.GameListConfigService;
|
||||
@ -22,6 +24,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -43,6 +46,15 @@ public class SpringTest {
|
||||
private UserProfileGateway userProfileGateway;
|
||||
@Autowired
|
||||
private ImGroupClient imGroupClient;
|
||||
@Autowired
|
||||
private PropCouponGateway propCouponGateway;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
PropCoupon vip004 = propCouponGateway.selectByCouponNo("VIP004");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
propCouponGateway.expireOverdueCoupons();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void execute() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user