|
@@ -9,8 +9,11 @@ import com.ym.mec.biz.dal.dto.DegreeRegistrationActivityDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
|
import com.ym.mec.common.constant.CommonConstants;
|
|
|
+import com.ym.mec.common.controller.BaseController;
|
|
|
+import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -28,6 +31,7 @@ import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@Service
|
|
|
public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, DegreeRegistration> implements DegreeRegistrationService {
|
|
@@ -45,6 +49,9 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private StudentPaymentOrderDao studentPaymentOrderDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
|
|
|
@Autowired
|
|
@@ -66,10 +73,11 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public Map pay(DegreeRegistrationActivityDto degreeRegistration) throws Exception {
|
|
|
+ public HttpResponseResult pay(DegreeRegistrationActivityDto degreeRegistration) throws Exception {
|
|
|
Student student = studentDao.getLocked(degreeRegistration.getUserId());
|
|
|
|
|
|
- DegreeRegistration degree = degreeRegistrationDao.getWithUserIdAndActivityTag(degreeRegistration.getUserId(), ACTIVITY_TAG);
|
|
|
+ degreeRegistration.setActivityTag(ACTIVITY_TAG);
|
|
|
+ DegreeRegistration degree = degreeRegistrationDao.getWithSubjectAndLevel(degreeRegistration);
|
|
|
|
|
|
Date nowDate = new Date();
|
|
|
|
|
@@ -118,9 +126,20 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
degreeRegistration.setUpdateTime(nowDate);
|
|
|
degreeRegistrationDao.insert(degreeRegistration);
|
|
|
} else if (degree.getStatus().equals(2)) {
|
|
|
- degreeRegistration.setMoney(BigDecimal.ZERO);
|
|
|
- degreeRegistration.setTheoryMoney(BigDecimal.ZERO);
|
|
|
+ throw new BizException("您已报考过选择的考级项目");
|
|
|
} else {
|
|
|
+ if (!degreeRegistration.getIsRepay() && degree.getStatus().equals(1)) {
|
|
|
+ List<StudentPaymentOrder> orders = studentPaymentOrderDao.findPaymentOrderByGroupType(degreeRegistration.getUserId(), degreeRegistration.getSporadicId(), "SPORADIC", DealStatusEnum.ING);
|
|
|
+ if (orders != null && orders.size() > 0) {
|
|
|
+ List<StudentPaymentOrderDetail> studentPaymentOrderDetails = studentPaymentOrderDetailDao.getOrderDetail(orders.get(0).getId());
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("degree", degreeRegistration);
|
|
|
+ if(!CollectionUtils.isEmpty(studentPaymentOrderDetails)){
|
|
|
+ result.put("additionCourseInfo", studentPaymentOrderDetails.get(0).getGoodsIdList());
|
|
|
+ }
|
|
|
+ return BaseController.failed(HttpStatus.CONTINUE, result, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
degreeRegistration.setMoney(degree.getMoney());
|
|
|
degreeRegistration.setTheoryMoney(degree.getTheoryMoney());
|
|
|
degreeRegistration.setId(degree.getId());
|
|
@@ -135,7 +154,6 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
}
|
|
|
|
|
|
BigDecimal additionCoursePrice = new BigDecimal("0");
|
|
|
- Map<CourseSchedule.CourseScheduleType, Integer> typeCourseTime = new HashMap<>();
|
|
|
if(Objects.nonNull(degreeRegistration.getAdditionCourseInfo())){
|
|
|
Map<CourseSchedule.CourseScheduleType, Integer> additionCourseInfo = degreeRegistration.getAdditionCourseInfo();
|
|
|
PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(degreeRegistration.getOrganId());
|
|
@@ -174,15 +192,12 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
switch (courseScheduleTypeIntegerEntry.getKey()){
|
|
|
case VIP:
|
|
|
additionCoursePrice = additionCoursePrice.add(vipUnitPrice.multiply(courseTime));
|
|
|
- typeCourseTime.put(courseScheduleTypeIntegerEntry.getKey(), courseScheduleTypeIntegerEntry.getValue()*12);
|
|
|
break;
|
|
|
case PRACTICE:
|
|
|
additionCoursePrice = additionCoursePrice.add(practiceUnitPrice.multiply(courseTime));
|
|
|
- typeCourseTime.put(courseScheduleTypeIntegerEntry.getKey(), courseScheduleTypeIntegerEntry.getValue()*12);
|
|
|
break;
|
|
|
case HIGH:
|
|
|
additionCoursePrice = additionCoursePrice.add(highUnitPrice.multiply(courseTime));
|
|
|
- typeCourseTime.put(courseScheduleTypeIntegerEntry.getKey(), courseScheduleTypeIntegerEntry.getValue()*10);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -198,7 +213,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
|
|
|
OrderTypeEnum type = OrderTypeEnum.DEGREE_REGISTRATION;
|
|
|
|
|
|
- Integer userId = degreeRegistration.getId();
|
|
|
+ Integer userId = degreeRegistration.getUserId();
|
|
|
String channelType = "";
|
|
|
StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
studentPaymentOrder.setUserId(userId);
|
|
@@ -226,13 +241,15 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
notifyMap.put("channelType", channelType);
|
|
|
notifyMap.put("orderNo", "");
|
|
|
studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
- return notifyMap;
|
|
|
+ return BaseController.failed(HttpStatus.CREATED, "恭喜您,支付成功!");
|
|
|
}
|
|
|
|
|
|
if(BigDecimal.ZERO.compareTo(additionCoursePrice)<0){
|
|
|
StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
|
|
|
studentPaymentOrderDetail.setType(OrderDetailTypeEnum.DEGREE_REGISTRATION);
|
|
|
- studentPaymentOrderDetail.setGoodsIdList(JSON.toJSONString(typeCourseTime));
|
|
|
+ if(Objects.nonNull(degreeRegistration.getAdditionCourseInfo())){
|
|
|
+ studentPaymentOrderDetail.setGoodsIdList(JSON.toJSONString(degreeRegistration.getAdditionCourseInfo()));
|
|
|
+ }
|
|
|
studentPaymentOrderDetail.setPrice(additionCoursePrice);
|
|
|
studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
|
|
|
studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
|
|
@@ -261,7 +278,7 @@ public class DegreeRegistrationServiceImpl extends BaseServiceImpl<Integer, Degr
|
|
|
studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
- return payMap;
|
|
|
+ return BaseController.succeed(payMap);
|
|
|
}
|
|
|
|
|
|
@Override
|