| | |
| | | |
| | | 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(); |
| | | } |
| | |
| | | Integer count = orderService.getValidOrderCount(driver.getId(),new BigDecimal(14),new SimpleDateFormat("yyyy-MM").format(new Date())); |
| | | if(count < 30){ |
| | | driver.setIsException(2); |
| | | }else { |
| | | driver.setIsException(1); |
| | | } |
| | | TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() |
| | | .eq("driverId", driver.getId()) |
| | |
| | | } |
| | | } |
| | | }else { |
| | | // 没有上班记录,计算审核时间 |
| | | Period period = Period.between(DateUtil.dateToLocalDate(driver.getApprovalTime()), LocalDate.now()); |
| | | int day = Math.abs(period.getDays()); |
| | | if(day>14){ |
| | | driver.setIsException(2); |
| | | if(Objects.nonNull(driver.getApprovalTime())){ |
| | | // 没有上班记录,计算审核时间 |
| | | Period period = Period.between(DateUtil.dateToLocalDate(driver.getApprovalTime()), LocalDate.now()); |
| | | int day = Math.abs(period.getDays()); |
| | | if(day>14){ |
| | | driver.setIsException(2); |
| | | } |
| | | } |
| | | } |
| | | } |