| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.system.enums.UserTypeEnum; |
| | | import com.stylefeng.guns.modular.system.model.TAppUser; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import com.stylefeng.guns.modular.system.model.TDriverWork; |
| | | import com.stylefeng.guns.modular.system.model.TOrder; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.Period; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | |
| | | private ITOrderService orderService; |
| | | @Autowired |
| | | private ITDriverWorkService tDriverWorkService; |
| | | @Autowired |
| | | private ITUserToCouponService userToCouponService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 每隔一分钟去处理的定时任务 |
| | | * 每隔一分钟去处理的定时任务,过期优惠券 |
| | | */ |
| | | @Scheduled(fixedRate = 1000 * 60) |
| | | public void taskMinute(){ |
| | | try { |
| | | // 查询所有优惠券 |
| | | List<TUserToCoupon> tUserToCoupons = userToCouponService.selectList(new EntityWrapper<TUserToCoupon>()); |
| | | List<TUserToCoupon> collect2 = tUserToCoupons.stream().filter(tUserToCoupon -> LocalDateTime.now().isAfter(DateUtil.dateToLocalDateTime(tUserToCoupon.getExpireTime()))).collect(Collectors.toList()); |
| | | for (TUserToCoupon userToCoupon : collect2) { |
| | | Integer validCount = userToCoupon.getValidCount(); |
| | | userToCoupon.setExpireCount(validCount); |
| | | userToCoupon.setValidCount(0); |
| | | } |
| | | userToCouponService.updateBatchById(collect2); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |