|
@@ -0,0 +1,41 @@
|
|
|
+package com.gree.mall.manager.schedule;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.gree.mall.manager.enums.material.StateEnum;
|
|
|
+import com.gree.mall.manager.plus.entity.ContractTemplate;
|
|
|
+import com.gree.mall.manager.plus.service.ContractTemplateService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 合同相关任务
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@ConditionalOnProperty(name = "schedule.enable", havingValue = "true", matchIfMissing = true)
|
|
|
+@Component
|
|
|
+public class ContractExceSchedule {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ ContractTemplateService contractTemplateService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 过期的合同设为无效
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Scheduled(cron = "30 0 0 * * * ")
|
|
|
+ public void task() throws Exception {
|
|
|
+ contractTemplateService.lambdaUpdate()
|
|
|
+ .set(ContractTemplate::getStatus, StateEnum.OFF.getKey())
|
|
|
+ .lt(ContractTemplate::getExpireDate, DateUtil.date())
|
|
|
+ .eq(ContractTemplate::getStatus, StateEnum.ON.getKey())
|
|
|
+ .update();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|