|
@@ -10,6 +10,8 @@ import java.util.Map;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -22,11 +24,6 @@ import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
|
|
|
import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentFeeDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentInfo;
|
|
|
-import com.ym.mec.biz.dal.entity.Goods;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentRegistration;
|
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
@@ -54,6 +51,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
|
|
|
@Autowired
|
|
|
private TeacherDao teacherDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, StudentRegistration> getDAO() {
|
|
@@ -140,6 +139,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
}
|
|
|
studentRegistration.setUserId(sysUser.getId());
|
|
|
studentRegistrationDao.insert(studentRegistration);
|
|
|
+ //增加报名学生数
|
|
|
+ MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
|
|
|
+ musicOneSubjectClassPlan.setApplyStudentNum(musicOneSubjectClassPlan.getApplyStudentNum()+1);
|
|
|
return studentRegistration;
|
|
|
}
|
|
|
|
|
@@ -227,10 +229,91 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
return studentPaymentOrder;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public StudentRegistration queryByUserIdAndMusicGroupId(Integer userId, String musicGroupId) {
|
|
|
- return studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
- }
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public StudentPaymentOrder reAddOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId, StudentPaymentOrder oldOrder) {
|
|
|
+ //关闭老订单
|
|
|
+ oldOrder.setStatus(DealStatusEnum.CLOSE);
|
|
|
+ studentPaymentOrderService.update(oldOrder);
|
|
|
+ Date date = new Date();
|
|
|
+ StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
+ studentPaymentOrder.setUserId(userId);
|
|
|
+ studentPaymentOrder.setOrderNo(orderNo);
|
|
|
+ studentPaymentOrder.setType(OrderTypeEnum.APPLY);
|
|
|
+ studentPaymentOrder.setExpectAmount(amount);
|
|
|
+ studentPaymentOrder.setActualAmount(amount);
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
+ studentPaymentOrder.setPaymentChannel(paymentChannel);
|
|
|
+ studentPaymentOrder.setMusicGroupId(musicGroupId);
|
|
|
+ studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
+
|
|
|
+ ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
|
|
|
+ StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
|
|
|
+ studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
|
|
|
+ studentPaymentOrderDetail.setPrice(courseFee);
|
|
|
+ studentPaymentOrderDetail.setCreateTime(date);
|
|
|
+ studentPaymentOrderDetail.setUpdateTime(date);
|
|
|
+ studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
+ studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
|
|
|
+ //乐器及打包辅件
|
|
|
+ if (goodsGroups != null) {
|
|
|
+ for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
|
|
|
+ StudentPaymentOrderDetail studentPaymentOrderDetail4goodsGroup = new StudentPaymentOrderDetail();
|
|
|
+ OrderDetailTypeEnum type = null;
|
|
|
+ if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
|
|
|
+ type = OrderDetailTypeEnum.MUSICAL;
|
|
|
+ } else if (goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
|
|
|
+ type = OrderDetailTypeEnum.ACCESSORIES;
|
|
|
+ } else if (goodsGroup.getType().equals(GoodsType.OTHER)) {
|
|
|
+ type = OrderDetailTypeEnum.TEACHING;
|
|
|
+ }
|
|
|
+ studentPaymentOrderDetail4goodsGroup.setType(type);
|
|
|
+ studentPaymentOrderDetail4goodsGroup.setPrice(goodsGroup.getPrice());
|
|
|
+ studentPaymentOrderDetail4goodsGroup.setGoodsIdList(goodsGroup.getGoodsIdList());
|
|
|
+ studentPaymentOrderDetail4goodsGroup.setCreateTime(date);
|
|
|
+ studentPaymentOrderDetail4goodsGroup.setUpdateTime(date);
|
|
|
+ studentPaymentOrderDetail4goodsGroup.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
+ studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goodsGroup);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //单独辅件
|
|
|
+ if (goodsList != null) {
|
|
|
+ for (Goods goods : goodsList) {
|
|
|
+ StudentPaymentOrderDetail studentPaymentOrderDetail4goods = new StudentPaymentOrderDetail();
|
|
|
+ studentPaymentOrderDetail4goods.setType(OrderDetailTypeEnum.ACCESSORIES);
|
|
|
+ studentPaymentOrderDetail4goods.setPrice(goods.getGroupPurchasePrice());
|
|
|
+ studentPaymentOrderDetail4goods.setGoodsIdList(goods.getId().toString());
|
|
|
+ studentPaymentOrderDetail4goods.setCreateTime(date);
|
|
|
+ studentPaymentOrderDetail4goods.setUpdateTime(date);
|
|
|
+ studentPaymentOrderDetail4goods.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
+ studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goods);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //单独教谱
|
|
|
+ if (otherGoodsList != null) {
|
|
|
+ for (Goods goods : otherGoodsList) {
|
|
|
+ StudentPaymentOrderDetail studentPaymentOrderDetail4otherGoods = new StudentPaymentOrderDetail();
|
|
|
+ studentPaymentOrderDetail4otherGoods.setType(OrderDetailTypeEnum.TEACHING);
|
|
|
+ studentPaymentOrderDetail4otherGoods.setPrice(goods.getGroupPurchasePrice());
|
|
|
+ studentPaymentOrderDetail4otherGoods.setGoodsIdList(goods.getId().toString());
|
|
|
+ studentPaymentOrderDetail4otherGoods.setCreateTime(date);
|
|
|
+ studentPaymentOrderDetail4otherGoods.setUpdateTime(date);
|
|
|
+ studentPaymentOrderDetail4otherGoods.setPaymentOrderId(studentPaymentOrder.getId());
|
|
|
+ studentPaymentOrderDetailList.add(studentPaymentOrderDetail4otherGoods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
|
|
|
+
|
|
|
+ return studentPaymentOrder;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public StudentRegistration queryByUserIdAndMusicGroupId(Integer userId, String musicGroupId) {
|
|
|
+ return studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public StudentRegistration getByPhoneAndMusicGroupId(String musicGroupId, String parentsPhone) {
|