|
@@ -4,16 +4,22 @@ import com.keao.edu.common.dal.BaseDAO;
|
|
|
import com.keao.edu.common.exception.BizException;
|
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
|
import com.keao.edu.user.dao.ExamRegistrationPaymentDao;
|
|
|
+import com.keao.edu.user.entity.ExamRegistration;
|
|
|
import com.keao.edu.user.entity.ExamRegistrationPayment;
|
|
|
+import com.keao.edu.user.enums.StudentRegistrationStatusEnum;
|
|
|
import com.keao.edu.user.service.ExamRegistrationPaymentService;
|
|
|
+import com.keao.edu.user.service.ExamRegistrationService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@Service
|
|
|
public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, ExamRegistrationPayment> implements ExamRegistrationPaymentService {
|
|
|
|
|
|
@Autowired
|
|
|
private ExamRegistrationPaymentDao examRegistrationPaymentDao;
|
|
|
+ @Autowired
|
|
|
+ private ExamRegistrationService examRegistrationService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, ExamRegistrationPayment> getDAO() {
|
|
@@ -31,11 +37,22 @@ public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, Ex
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public ExamRegistrationPayment updateOrder(ExamRegistrationPayment examRegistrationPayment) {
|
|
|
- if (examRegistrationPayment.getTransStatus().equals("SUCCESS")) {
|
|
|
- throw new BizException("订单状态不在支付中");
|
|
|
+ if (examRegistrationPaymentDao.update(examRegistrationPayment) <= 0) {
|
|
|
+ throw new BizException("订单更新失败");
|
|
|
+ }
|
|
|
+ ExamRegistration examRegistration = examRegistrationService.get(examRegistrationPayment.getId());
|
|
|
+ if (!examRegistration.getStatus().equals(StudentRegistrationStatusEnum.PAY_WAIT)) {
|
|
|
+ return examRegistrationPayment;
|
|
|
+ }
|
|
|
+ if (!examRegistrationPayment.getTransStatus().equals("SUCCESS")) {
|
|
|
+ return examRegistrationPayment;
|
|
|
+ }
|
|
|
+ examRegistration.setStatus(StudentRegistrationStatusEnum.AUDIT_WAIT);
|
|
|
+ if (examRegistrationService.update(examRegistration) <= 0) {
|
|
|
+ throw new BizException("报名状态更新失败");
|
|
|
}
|
|
|
- examRegistrationPaymentDao.update(examRegistrationPayment);
|
|
|
return examRegistrationPayment;
|
|
|
}
|
|
|
}
|