diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java index 7fa5cca98..2152bb852 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java @@ -1,5 +1,10 @@ package com.iformall.schedule; +import com.iformall.domain.po.WxCouponChannel; +import com.iformall.domain.po.WxGame; +import com.iformall.enums.EnumCouponChannelStatus; +import com.iformall.enums.EnumCouponChannelType; +import com.iformall.enums.EnumGameStatus; import com.iformall.mapper.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -9,6 +14,8 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + @Component public class CouponExpiringSchedule { @@ -26,6 +33,9 @@ public class CouponExpiringSchedule { @Autowired private WxScreenAdMapper wxScreenAdMapper; + @Autowired + private WxGameMapper wxGameMapper; + @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨00:05 作废过期券,商户禁用券 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 @@ -64,4 +74,29 @@ public class CouponExpiringSchedule { public void couponChannel2ExpiringSchedule() { wxCouponChannelMapper.offExpiriedCouponChannel2ByEndTime(); } + + @Scheduled(cron = "0 20 0 * * ?") // 每天凌晨00:20 下架游戏 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + public void gameExpiringSchedule() { + WxGame wxGame = new WxGame(); + wxGame.setStatus(EnumGameStatus.STATUS_THROW_IN.getCode()); + + List list = wxGameMapper.findList(wxGame); + list.stream().forEach(g->{ + WxCouponChannel couponChannel = new WxCouponChannel(); + couponChannel.setTenantId(g.getTenantId()); + couponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_GAME.getCode()); + couponChannel.setSubTargetId(g.getId()); + couponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); + int count = wxCouponChannelMapper.countCouponChannel(couponChannel); + if (count == 0) { + WxGame record = new WxGame(); + record.setId(g.getId()); + record.setStatus(EnumGameStatus.STATUS_TAKE_OFFF.getCode()); + wxGameMapper.updateByPrimaryKeySelective(record); + } + }); + } + + } \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 26d47c922..878ddcff9 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -13,6 +13,8 @@ public interface WxCouponChannelMapper extends CommonMapper findVoList(WxCouponChannel wxCouponChannel); WxCouponCVo findVoDetail(@Param("id")Long id); diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 5f8c5da63..ca576200d 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -220,6 +220,11 @@ + + update wx_coupon_channel SET status = 1, update_date = now() where status = 0 and end_time < now()