| 
					
				 | 
			
			
				@@ -1,5 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.ym.mec.biz.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.HashMap; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -8,6 +9,13 @@ import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.VipGroupBuyParamsDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.enums.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.StudentPaymentOrderDetailService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.StudentPaymentOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.common.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -20,8 +28,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.StudentRegistration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.enums.YesOrNoEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.service.StudentRegistrationService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -36,6 +42,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentRegistrationDao studentRegistrationDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SysUserFeignService sysUserFeignService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private StudentPaymentOrderService studentPaymentOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public BaseDAO<Long, StudentRegistration> getDAO() { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -123,8 +133,86 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return studentRegistration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	@Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	public StudentInfo queryStudentInfo(Integer userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		return studentRegistrationDao.queryStudentInfo(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public StudentInfo queryStudentInfo(Integer userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return studentRegistrationDao.queryStudentInfo(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public StudentPaymentOrder addOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setUserId(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setType(OrderTypeEnum.APPLY); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setExpectAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setActualAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setStatus(DealStatusEnum.ING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder.setPaymentChannel(paymentChannel); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |