|
@ -0,0 +1,68 @@
|
|
|
package com.yihu.wlyy.job;
|
|
|
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
|
|
|
import com.yihu.wlyy.repository.dict.SystemDictDao;
|
|
|
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import org.quartz.Job;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.quartz.JobExecutionException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 续方订单确认收货接口(支付完成后7天自动确认收货,延长收货1次支付完成后14天自动确认收货)
|
|
|
* Created by Reece on 2018/02/07
|
|
|
*
|
|
|
*/
|
|
|
public class PatientConfirmReceiptJob implements Job {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(PatientConfirmReceiptJob.class);
|
|
|
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private SystemDictDao systemDictDao;
|
|
|
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
|
|
logger.info("PatientConfirmReceiptJob start ..........");
|
|
|
try {
|
|
|
//job执行开关
|
|
|
String jobRunning = systemDictDao.findByDictNameAndCode("JOB_RUNNING","PatientConfirmReceiptJob");
|
|
|
if("1".equals(jobRunning)) {
|
|
|
List<Prescription> list = new ArrayList<>();
|
|
|
//1.找出状态是已支付未完成且取药方式不是健管师配送的续方
|
|
|
List<Prescription> PrescriptionList = prescriptionDao.findUndelivered();
|
|
|
for (Prescription prescription : PrescriptionList) {
|
|
|
//2.取出延长收货的次数及支付时间
|
|
|
int extendCount = prescription.getExtendCount();
|
|
|
Date payTime = prescription.getPayTime();
|
|
|
if (payTime != null) {
|
|
|
//3.根据延长收货次数确定确认收货时间
|
|
|
Date today = new Date();
|
|
|
Date confirm = DateUtil.getPreDays(payTime, ((extendCount + 1) * 7));
|
|
|
int result = today.compareTo(confirm);
|
|
|
if (result >= 0) {
|
|
|
prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
|
|
|
list.add(prescription);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (list.size() > 0) {
|
|
|
prescriptionDao.save(list);
|
|
|
}
|
|
|
}
|
|
|
logger.info("PatientConfirmReceiptJob end ..........");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
logger.info("PatientConfirmReceiptJob error ..........,message:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|