|
@@ -14,6 +14,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -371,7 +372,41 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public StudentInstrument getStudentInstrument(Integer studentId,Integer goodsId) {
|
|
|
- return studentInstrumentDao.getStudentInstrument(studentId,goodsId);
|
|
|
+ public StudentInstrument getStudentInstrument(Integer studentId, Integer goodsId) {
|
|
|
+ return studentInstrumentDao.getStudentInstrument(studentId, goodsId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean addOldStudentInstrument() {
|
|
|
+ Date startTime = null;
|
|
|
+ Date nowDate = new Date();
|
|
|
+ StudentInstrument studentInstrument = studentInstrumentDao.getStudentInstrument(2094765, 60);
|
|
|
+ if (studentInstrument != null) {
|
|
|
+ startTime = DateUtil.addMinutes(nowDate, -30);
|
|
|
+ }
|
|
|
+ List<StudentInstrument> oldStudentInstruments = studentInstrumentDao.getOldStudentInstrument(startTime);
|
|
|
+ for (StudentInstrument oldStudentInstrument : oldStudentInstruments) {
|
|
|
+ oldStudentInstrument.setChangeOrderId(oldStudentInstrument.getOrderId());
|
|
|
+ if (oldStudentInstrument.getEndTime().compareTo(nowDate) > 0) {
|
|
|
+ oldStudentInstrument.setStatus(1);
|
|
|
+ } else {
|
|
|
+ oldStudentInstrument.setStatus(0);
|
|
|
+ }
|
|
|
+ StudentInstrument has = studentInstrumentDao.getStudentInstrument(oldStudentInstrument.getStudentId(), oldStudentInstrument.getGoodsId());
|
|
|
+ if (has == null) {
|
|
|
+ studentInstrumentDao.insert(oldStudentInstrument);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ oldStudentInstrument.setId(has.getId());
|
|
|
+ if (has.getEndTime() == null) {
|
|
|
+ studentInstrumentDao.update(oldStudentInstrument);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (has.getEndTime().compareTo(oldStudentInstrument.getEndTime()) >= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ studentInstrumentDao.update(oldStudentInstrument);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|