Browse Source

update:
1.乐团报名支持多笔缴费
2.进行中加学员,订单类型改成“Apply”

yonge 4 years ago
parent
commit
a96e644424

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -10,6 +10,7 @@ import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -88,6 +89,14 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @return
      */
     StudentPaymentOrder findOrderByOrderNo(@Param("orderNo") String orderNo);
+    
+    /**
+     * 根据批次号查询
+     * @param batchNo 批次号
+     * @param status 状态
+     * @return
+     */
+    List<StudentPaymentOrder> queryByBatchNo(@Param("batchNo") String batchNo, @Param("status") DealStatusEnum status);
 
     /**
      * 查询指定交易状态的乐团报名的订单信息

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java

@@ -119,6 +119,8 @@ public class StudentPaymentOrder {
 
 	//课程优惠金额
 	private BigDecimal courseRemitFee;
+	
+	private String batchNo;
 
 	public String getReceiveStatus() {
 		return receiveStatus;
@@ -364,4 +366,12 @@ public class StudentPaymentOrder {
 	public void setCourseRemitFee(BigDecimal courseRemitFee) {
 		this.courseRemitFee = courseRemitFee;
 	}
+
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRegistration.java

@@ -138,6 +138,8 @@ public class StudentRegistration {
 
     @ApiModelProperty(value = "会员截止时间",required = true)
     private Date membershipEndTime;
+    
+    private Long musicGroupPaymentCalenderId;
 
     public Date getMembershipEndTime() {
         return membershipEndTime;
@@ -489,4 +491,12 @@ public class StudentRegistration {
     public void setNoneNeedCloudTeacher(Integer noneNeedCloudTeacher) {
         this.noneNeedCloudTeacher = noneNeedCloudTeacher;
     }
+
+	public Long getMusicGroupPaymentCalenderId() {
+		return musicGroupPaymentCalenderId;
+	}
+
+	public void setMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId) {
+		this.musicGroupPaymentCalenderId = musicGroupPaymentCalenderId;
+	}
 }

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/DealStatusEnum.java

@@ -6,7 +6,6 @@ import com.ym.mec.common.enums.BaseEnum;
  * '交易状态(1,交易中;2,成功交易;3,交易失败,4交易关闭;)',
  */
 public enum DealStatusEnum implements BaseEnum<String, DealStatusEnum> {
-	WAIT_PAY("WAIT_PAY", "等待支付"),
 	ING("ING", "交易中"),
 	SUCCESS("SUCCESS", "成功交易"),
 	FAILED("FAILED", "交易失败"),

+ 0 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupSubjectPlanService.java

@@ -66,16 +66,6 @@ public interface MusicGroupSubjectPlanService extends BaseService<Integer, Music
     MusicGroupSubjectPlan findSubjectPlan(String musicGroupId, Integer subjectId);
 
     /**
-     * 中途添加的学生的缴费信息
-     *
-     * @param musicGroupId
-     * @param subjectId
-     * @return
-     */
-    MusicGroupSubjectGoodsAndInfoDto getStudentGoodsAndInfo(String musicGroupId, Integer subjectId, StudentRegistration studentRegistration);
-
-
-    /**
      * 获取声部的乐器、辅件(包含折扣)
      * @param subjectId
      * @param type

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -61,6 +61,14 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
      * @return
      */
     StudentPaymentOrder findOrderByOrderNo(String orderNo);
+    
+    /**
+     * 根据批次号查询
+     * @param batchNo 批次号
+     * @param status 状态
+     * @return
+     */
+    List<StudentPaymentOrder> queryByBatchNo(String batchNo, DealStatusEnum status);
 
     /**
      * 查找支付成功和支付中订单

+ 18 - 23
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -6,15 +6,13 @@ import java.math.BigDecimal;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 
-import com.ym.mec.auth.api.enums.CertificateTypeEnum;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
-import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.entity.HttpResponseResult;
-import com.ym.mec.util.http.HttpUtil;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -32,6 +30,13 @@ import org.springframework.util.CollectionUtils;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.auth.api.enums.CertificateTypeEnum;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
+import com.ym.mec.biz.dal.dao.SysUserContractsDao;
 import com.ym.mec.biz.dal.dto.StudentInfo;
 import com.ym.mec.biz.dal.entity.CooperationOrgan.OwnershipType;
 import com.ym.mec.biz.dal.entity.Goods;
@@ -48,6 +53,7 @@ import com.ym.mec.biz.dal.entity.SysUserContracts;
 import com.ym.mec.biz.dal.entity.SysUserContracts.ContractType;
 import com.ym.mec.biz.dal.entity.SysUserTsign;
 import com.ym.mec.biz.dal.entity.VipGroup;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
@@ -62,6 +68,8 @@ import com.ym.mec.biz.service.SubjectService;
 import com.ym.mec.biz.service.SysUserContractsService;
 import com.ym.mec.biz.service.SysUserTsignService;
 import com.ym.mec.biz.service.VipGroupService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.eseal.ESealPlugin;
 import com.ym.mec.thirdparty.storage.StoragePluginContext;
@@ -811,22 +819,9 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 
 		double depositFee = 0d;
 		if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
-			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService
-					.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.WAIT_PAY);
-
-			if (studentPaymentOrder == null) {
-				MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
-				if (musicGroupSubjectPlan != null) {
-					depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
-				}
-			} else {
-
-				List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
-				for (StudentPaymentOrderDetail detail : orderDetailList) {
-					if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
-						depositFee = detail.getPrice().doubleValue();
-					}
-				}
+			MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
+			if (musicGroupSubjectPlan != null) {
+				depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
 			}
 		}
 		params.put("depositFee", depositFee);

+ 100 - 34
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -653,6 +653,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (studentRegistration == null) {
             throw new BizException("报名信息有误,请核查");
         }
+        
+        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.getMusicGroupRegCalender(studentRegistration.getMusicGroupId());
+        if(musicGroupRegCalender == null){
+        	throw new BizException("缴费信息不存在");
+        }
 
         Integer userId = studentRegistration.getUserId();
 
@@ -715,6 +720,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+        
+        studentRegistration.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
         studentRegistration.setOrganId(musicGroup.getOrganId());
         studentRegistration.setPayingStatus(1);
 
@@ -723,10 +730,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         CloudTeacherOrder cloudTeacherOrder = null;
         //云教练/云教练+
         if (registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus()) {
-            MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.getMusicGroupRegCalender(studentRegistration.getMusicGroupId());
-            if(musicGroupRegCalender == null){
-            	throw new BizException("缴费信息不存在");
-            }
+            
             BigDecimal cloudTeacherPrice = musicGroupRegCalender.getMemberPaymentAmount();
             //OrganizationCloudTeacherFee cloudTeacher = organizationCloudTeacherFeeDao.getByOrganId(studentRegistration.getOrganId());
             //BigDecimal cloudTeacherPrice = registerPayDto.getBuyCloudTeacher() ? cloudTeacher.getPrice() : cloudTeacher.getPlusPrice();
@@ -785,6 +789,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团报名");
             }
         }
+        studentPaymentOrder.setBatchNo(musicGroupRegCalender.getId() + "");
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setRemitFee(remitFee);
         studentPaymentOrder.setCourseRemitFee(courseRemitFee);
@@ -872,6 +877,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (ApplyOrder == null) {
             throw new BizException("没有支付中订单,请在我的订单中查看订单状态");
         }
+
+    	MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.getMusicGroupRegCalender(studentRegistration.getMusicGroupId());
+        if(musicGroupRegCalender == null){
+        	throw new BizException("缴费信息不存在");
+        }
+        
         //手动关闭订单
         ApplyOrder.setStatus(DealStatusEnum.FAILED);
         ApplyOrder.setMemo("用户手动关闭");
@@ -936,6 +947,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+        
+        studentRegistration.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
         studentRegistration.setOrganId(musicGroup.getOrganId());
         studentRegistration.setPayingStatus(1);
 
@@ -946,10 +959,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         //云教练/云教练+
         if (registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus()) {
         	
-        	MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.getMusicGroupRegCalender(studentRegistration.getMusicGroupId());
-            if(musicGroupRegCalender == null){
-            	throw new BizException("缴费信息不存在");
-            }
             BigDecimal cloudTeacherPrice = musicGroupRegCalender.getMemberPaymentAmount();
             //OrganizationCloudTeacherFee cloudTeacher = organizationCloudTeacherFeeDao.getByOrganId(studentRegistration.getOrganId());
             //BigDecimal cloudTeacherPrice = registerPayDto.getBuyCloudTeacher() ? cloudTeacher.getPrice() : cloudTeacher.getPlusPrice();
@@ -1009,6 +1018,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团报名");
             }
         }
+        studentPaymentOrder.setBatchNo(musicGroupRegCalender.getId() + "");
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setRemitFee(remitFee);
         studentPaymentOrder.setCourseRemitFee(courseRemitFee);
@@ -1927,9 +1937,20 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
 
             BigDecimal amount = new BigDecimal(0);
+            
+            List<StudentPaymentOrder> studentPaymentOrderList = new ArrayList<StudentPaymentOrder>();
+            
+			if (studentRegistration.getMusicGroupPaymentCalenderId() == null) {
+				StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
+				if (studentPaymentOrder != null) {
+					studentPaymentOrderList.add(studentPaymentOrder);
+				}
+			} else {
+				studentPaymentOrderList = studentPaymentOrderService.queryByBatchNo(studentRegistration.getMusicGroupPaymentCalenderId() + "",
+						DealStatusEnum.SUCCESS);
+			}
 
-            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
-
+            
             boolean hasPaid = studentRegistration.getMusicGroupStatus().equals(StudentMusicGroupStatusEnum.NORMAL);
             // 缴费人数更新
             MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
@@ -1937,12 +1958,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 musicGroupSubjectPlan.setUpdateTime(date);
                 //减去缴费人数(器乐收费,0元时不减缴费人数)
                 if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE)) {
-                    if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() != null && studentPaymentOrder.getPaymentAccountNo().equals("200")) {
-                        musicGroupSubjectPlan.setPaidZeroNum(musicGroupSubjectPlan.getPaidZeroNum() - 1);
-                        musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
-                    } else if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() == null) {
-                        musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
-                    }
+                    
+                	for(StudentPaymentOrder studentPaymentOrder : studentPaymentOrderList){
+                		if (studentPaymentOrder != null && "200".equals(studentPaymentOrder.getPaymentAccountNo())) {
+                            musicGroupSubjectPlan.setPaidZeroNum(musicGroupSubjectPlan.getPaidZeroNum() - 1);
+                            musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
+                            break;
+                        } else if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() == null) {
+                            musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
+                            break;
+                        }
+                	}
+                	
                 } else {
                     musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
                 }
@@ -1963,15 +1990,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 amount = amount.add(surplusCourseFee);
             }
 
-            if (studentPaymentOrder != null) {
-                List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
+            if (studentPaymentOrderList.size() > 0) {
+            	
+            	BigDecimal remitFee = BigDecimal.ZERO;
+            			
+            	for(StudentPaymentOrder studentPaymentOrder : studentPaymentOrderList){
+            		remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
+            	}
+            	
+            	List<Long> paymentOrderIdList = studentPaymentOrderList.stream().map(t -> t.getId()).collect(Collectors.toList());
+
+                List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.getWithIds(paymentOrderIdList);
 
                 SubjectChange studentLastChange = null;
                 if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
                     studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
                 }
-
-                BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
+                
                 for (StudentPaymentOrderDetail detail : orderDetailList) {
                     if (remitFee.compareTo(detail.getPrice()) >= 0) {
                         remitFee = remitFee.subtract(detail.getPrice());
@@ -1998,6 +2033,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 if (studentLastChange != null) {
                     amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
                 }
+            
             }
 
             //退乐保费用
@@ -2092,7 +2128,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (studentRegistration == null) {
             throw new BizException("用户注册信息不存在");
         }
-        boolean hasPaid = studentRegistration.getMusicGroupStatus().equals(StudentMusicGroupStatusEnum.NORMAL);
 
         Date date = new Date();
 
@@ -2181,8 +2216,20 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
 
         BigDecimal amount = new BigDecimal(0);
-
-        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
+        
+        List<StudentPaymentOrder> studentPaymentOrderList = new ArrayList<StudentPaymentOrder>();
+        
+		if (studentRegistration.getMusicGroupPaymentCalenderId() == null) {
+			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
+			if (studentPaymentOrder != null) {
+				studentPaymentOrderList.add(studentPaymentOrder);
+			}
+		} else {
+			studentPaymentOrderList = studentPaymentOrderService.queryByBatchNo(studentRegistration.getMusicGroupPaymentCalenderId() + "",
+					DealStatusEnum.SUCCESS);
+		}
+		
+        boolean hasPaid = studentRegistration.getMusicGroupStatus().equals(StudentMusicGroupStatusEnum.NORMAL);
 
         // 判断乐器是否是租赁
         MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
@@ -2190,12 +2237,17 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             musicGroupSubjectPlan.setUpdateTime(date);
             //减去缴费人数(器乐收费,0元时不减缴费人数)
             if (musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) || musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE)) {
-                if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() != null && studentPaymentOrder.getPaymentAccountNo().equals("200")) {
-                    musicGroupSubjectPlan.setPaidZeroNum(musicGroupSubjectPlan.getPaidZeroNum() - 1);
-                    musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
-                } else if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() == null) {
-                    musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
-                }
+            	
+            	for(StudentPaymentOrder studentPaymentOrder : studentPaymentOrderList){
+            		if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() != null && studentPaymentOrder.getPaymentAccountNo().equals("200")) {
+                        musicGroupSubjectPlan.setPaidZeroNum(musicGroupSubjectPlan.getPaidZeroNum() - 1);
+                        musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
+                        break;
+                    } else if (studentPaymentOrder != null && studentPaymentOrder.getPaymentAccountNo() == null) {
+                        musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
+                        break;
+                    }
+            	}
             } else {
                 musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
             }
@@ -2216,16 +2268,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             amount = amount.add(surplusCourseFee);
         }
 
-        if (studentPaymentOrder != null) {
-            List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
+        if (studentPaymentOrderList.size() > 0) {
+        	
+        	BigDecimal remitFee = BigDecimal.ZERO;
+			
+        	for(StudentPaymentOrder studentPaymentOrder : studentPaymentOrderList){
+        		remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
+        	}
+        	
+        	List<Long> paymentOrderIdList = studentPaymentOrderList.stream().map(t -> t.getId()).collect(Collectors.toList());
+
+            List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.getWithIds(paymentOrderIdList);
 
             SubjectChange studentLastChange = null;
             if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
                 studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
             }
 
-            BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
-
             for (StudentPaymentOrderDetail detail : orderDetailList) {
                 if (remitFee.compareTo(detail.getPrice()) >= 0) {
                     remitFee = remitFee.subtract(detail.getPrice());
@@ -2340,11 +2399,17 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setGroupType(GroupType.MUSIC);
         studentPaymentOrder.setUserId(userId);
         studentPaymentOrder.setOrderNo(orderNo);
-        studentPaymentOrder.setType(OrderTypeEnum.RENEW);
+        
+		if (calender.getPaymentType() == PaymentType.ADD_STUDENT) {
+			studentPaymentOrder.setType(OrderTypeEnum.APPLY);
+		} else {
+			studentPaymentOrder.setType(OrderTypeEnum.RENEW);
+		}
         studentPaymentOrder.setExpectAmount(amount);
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setMusicGroupId(calender.getMusicGroupId());
+        studentPaymentOrder.setBatchNo(calender.getId() + "");
         studentPaymentOrder.setCreateTime(date);
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrder.setVersion(0);
@@ -2483,6 +2548,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (paymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT) {
                 studentRegistration.setPaymentStatus(YES);
                 studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
+                studentRegistration.setMusicGroupPaymentCalenderId(paymentCalender.getId());
                 studentRegistrationDao.update(studentRegistration);
                 
                 //统计变更学员数

+ 18 - 58
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java

@@ -1,23 +1,35 @@
 package com.ym.mec.biz.service.impl;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.MusicGroupGoodsAndDiscountDto;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
-
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.alibaba.fastjson.JSON;
+import com.ym.mec.biz.dal.dao.ChargeTypeSubjectMapperDao;
+import com.ym.mec.biz.dal.dao.GoodsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
+import com.ym.mec.biz.dal.dao.OrganizationCloudTeacherFeeDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dto.MusicGroupGoodsAndDiscountDto;
 import com.ym.mec.biz.dal.dto.MusicGroupRegRespDto;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
+import com.ym.mec.biz.dal.entity.ChargeTypeSubjectMapper;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
+import com.ym.mec.biz.dal.enums.GoodsType;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.MemberRankPrivilegesService;
 import com.ym.mec.biz.service.MusicGroupService;
@@ -189,58 +201,6 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
     }
 
     @Override
-    public MusicGroupSubjectGoodsAndInfoDto getStudentGoodsAndInfo(String musicGroupId, Integer subjectId, StudentRegistration studentRegistration) {
-        MusicGroup musicGroup = musicGroupService.get(musicGroupId);
-
-        //课程形态
-        Map<String, Object> courseForm = JSON.parseObject(musicGroup.getCourseForm(), Map.class);
-
-        //乐团计划及收费信息
-        MusicGroupSubjectPlan musicOneSubjectClassPlan = this.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
-        musicOneSubjectClassPlan.setFee(studentRegistration.getTemporaryCourseFee());
-        musicOneSubjectClassPlan.setDepositFee(studentRegistration.getTemporaryCourseFee());
-
-        //乐团乐器及辅件信息
-        List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
-
-        List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.findUserApplyOrder(studentRegistration.getUserId(), musicGroupId, DealStatusEnum.WAIT_PAY);
-        for (StudentPaymentOrderDetail orderDetail : orderDetails) {
-            if (orderDetail == null || orderDetail.getGoodsIdList() == null || orderDetail.getGoodsIdList().isEmpty())
-                continue;
-            MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
-            if (orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL)) {
-                musicGroupSubjectGoodsGroup.setName("乐器");
-                musicGroupSubjectGoodsGroup.setType(GoodsType.INSTRUMENT);
-            } else {
-                musicGroupSubjectGoodsGroup.setName("辅件");
-                musicGroupSubjectGoodsGroup.setType(GoodsType.ACCESSORIES);
-            }
-            if (orderDetail.getKitGroupPurchaseType() != null) {
-                if (orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    musicGroupSubjectGoodsGroup.setDepositFee(orderDetail.getPrice());
-                }
-                String kitGroupPurchaseTypeJson = "{\"" + orderDetail.getKitGroupPurchaseType().getCode() + "\":0}";
-                musicGroupSubjectGoodsGroup.setKitGroupPurchaseTypeJson(kitGroupPurchaseTypeJson);
-            }
-
-            musicGroupSubjectGoodsGroup.setId(orderDetail.getId());
-            musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
-            musicGroupSubjectGoodsGroup.setMusicGroupId(musicGroupId);
-            musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
-            List<Goods> goodies = goodsService.findGoodsByIds(orderDetail.getGoodsIdList());
-            musicGroupSubjectGoodsGroup.setGoodsList(goodies);
-            goodsGroups.add(musicGroupSubjectGoodsGroup);
-        }
-
-        //获取声部(科目)下其他商品
-        MusicGroupSubjectGoodsAndInfoDto musicGroupSubjectGoodsAndInfo = new MusicGroupSubjectGoodsAndInfoDto();
-        musicGroupSubjectGoodsAndInfo.setMusicGroupSubjectPlan(musicOneSubjectClassPlan);
-        musicGroupSubjectGoodsAndInfo.setCourseScheduleInfo(courseForm);
-        musicGroupSubjectGoodsAndInfo.setMusicGroupSubjectGoodsGroupList(goodsGroups);
-        return musicGroupSubjectGoodsAndInfo;
-    }
-
-    @Override
     public MusicGroupSubjectPlan findSubjectPlan(String musicGroupId, Integer subjectId) {
         return musicGroupSubjectPlanDao.findSubjectPlan(musicGroupId, subjectId);
     }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -14,6 +14,7 @@ import java.util.stream.Collectors;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.*;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -193,6 +194,11 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
     @Override
+	public List<StudentPaymentOrder> queryByBatchNo(String batchNo, DealStatusEnum status) {
+		return studentPaymentOrderDao.queryByBatchNo(batchNo, status);
+	}
+
+	@Override
     public int findPayOrderNum() {
         return studentPaymentOrderDao.findPayOrderNum();
     }

+ 111 - 174
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -705,159 +705,126 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         StudentRegistration phoneAndMusicGroupId = studentRegistrationDao.getByPhoneAndMusicGroupId(musicGroupId, studentRegistration.getParentsPhone());
         if (phoneAndMusicGroupId != null && phoneAndMusicGroupId.getMusicGroupStatus() != StudentMusicGroupStatusEnum.QUIT && phoneAndMusicGroupId.getMusicGroupStatus() != StudentMusicGroupStatusEnum.APPLY) {
             throw new BizException("该学员已存在");
+        }
+
+        SysUser sysUser = studentRegistrationDao.getSysUserByPhone(studentRegistration.getParentsPhone());
+        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
+        Integer userId;
+        if (sysUser == null) {
+            //新增user
+            sysUser = new SysUser();
+            sysUser.setPhone(studentRegistration.getParentsPhone());
+//            sysUser.setRealName(studentRegistration.getParentsName());
+            sysUser.setUsername(studentRegistration.getName());
+            sysUser.setGender(studentRegistration.getGender());
+            sysUser.setUserType("STUDENT");
+//            sysUser.setIdCardNo(studentRegistration.getIdCardNo());
+            sysUser.setOrganId(musicGroup.getOrganId());
+            sysUser.setBirthdate(studentRegistration.getBirthdate());
+            teacherDao.addSysUser(sysUser);
+            userId = sysUser.getId();
+            studentDao.insert(new Student(userId, studentRegistration.getSubjectId().toString()));
+            //添加用户现金账户
+            sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
+            ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getUsername(), null));
+            sysUser.setImToken(register.getToken());
+            teacherDao.updateUser(sysUser);
         } else {
-            SysUser sysUser = studentRegistrationDao.getSysUserByPhone(studentRegistration.getParentsPhone());
-            MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
-            Integer userId;
-            if (sysUser == null) {
-                //新增user
-                sysUser = new SysUser();
-                sysUser.setPhone(studentRegistration.getParentsPhone());
-//                sysUser.setRealName(studentRegistration.getParentsName());
-                sysUser.setUsername(studentRegistration.getName());
-                sysUser.setGender(studentRegistration.getGender());
-                sysUser.setUserType("STUDENT");
-//                sysUser.setIdCardNo(studentRegistration.getIdCardNo());
-                sysUser.setOrganId(musicGroup.getOrganId());
-                sysUser.setBirthdate(studentRegistration.getBirthdate());
-                teacherDao.addSysUser(sysUser);
-                userId = sysUser.getId();
-                studentDao.insert(new Student(userId, studentRegistration.getSubjectId().toString()));
-                //添加用户现金账户
-                sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
-                ImResult register = imFeignService.register(new ImUserModel(userId.toString(), sysUser.getUsername(), null));
-                sysUser.setImToken(register.getToken());
-                teacherDao.updateUser(sysUser);
-            } else {
-                if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
-                    //该学员是否在其他的会员团
-                    boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroupId,sysUser.getId());
-                    if(hasMemberGroup){
-                        throw new BizException("操作失败:该学员已在其他系统收费乐团中,不可报名该乐团请联系教务老师");
-                    }
-                }
-                StudentRegistration oldReg = studentRegistrationDao.getByUserIdAndMusicGroupId(musicGroupId, sysUser.getId());
-                if (oldReg != null && oldReg.getMusicGroupStatus() != StudentMusicGroupStatusEnum.QUIT && oldReg.getMusicGroupStatus() != StudentMusicGroupStatusEnum.APPLY) {
-                    throw new BizException("该学员已存在,原手机号为" + oldReg.getParentsPhone());
-                }
-                if (oldReg != null) {
-                    phoneAndMusicGroupId = oldReg;
-                }
-                if (StringUtils.isNotEmpty(sysUser.getUsername())) {
-                    if (!sysUser.getUsername().equals(studentRegistration.getName())) {
-                        throw new BizException("操作失败:账户已被注册");
-                    }
-                }
-                if (!sysUser.getUserType().contains("STUDENT")) {
-                    sysUser.setUserType(sysUser.getUserType() + ",STUDENT");
+            if(musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE){
+                //该学员是否在其他的会员团
+                boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroupId,sysUser.getId());
+                if(hasMemberGroup){
+                    throw new BizException("操作失败:该学员已在其他系统收费乐团中,不可报名该乐团请联系教务老师");
                 }
-                sysUser.setPhone(studentRegistration.getParentsPhone());
-//                sysUser.setRealName(studentRegistration.getParentsName());
-                sysUser.setUsername(studentRegistration.getName());
-                sysUser.setGender(studentRegistration.getGender());
-                sysUser.setOrganId(musicGroup.getOrganId());
-                sysUser.setBirthdate(studentRegistration.getBirthdate());
-                teacherDao.updateUser(sysUser);
-                userId = sysUser.getId();
-                Student student = studentDao.get(userId);
-                if (student == null) {
-                    studentDao.insert(new Student(userId, studentRegistration.getSubjectId().toString()));
-                } else if (StringUtils.isEmpty(student.getSubjectIdList())) {
-                    student.setSubjectIdList(studentRegistration.getSubjectId().toString());
-                    student.setUpdateTime(date);
-                    studentDao.update(student);
-                } else if (StringUtils.isNotEmpty(student.getSubjectIdList())) {
-                    String[] split = student.getSubjectIdList().split(",");
-                    List<String> list = new ArrayList<>(Arrays.asList(split));
-                    if (!list.contains(studentRegistration.getSubjectId().toString())) {
-                        list.add(studentRegistration.getSubjectId().toString());
-                        student.setSubjectIdList(StringUtils.join(list, ","));
-                        student.setUpdateTime(date);
-                        studentDao.update(student);
-                    }
-                }
-                imGroupDao.updateNickname(userId, sysUser.getUsername());
-                imGroupDao.updateUserFriendNickname(userId, sysUser.getUsername());
             }
-            MusicGroupStudentFee studentFeeDaoByUser = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
-            if (studentFeeDaoByUser != null) {
-                throw new BizException("该学员已存在");
+            StudentRegistration oldReg = studentRegistrationDao.getByUserIdAndMusicGroupId(musicGroupId, sysUser.getId());
+            if (oldReg != null && oldReg.getMusicGroupStatus() != StudentMusicGroupStatusEnum.QUIT && oldReg.getMusicGroupStatus() != StudentMusicGroupStatusEnum.APPLY) {
+                throw new BizException("该学员已存在,原手机号为" + oldReg.getParentsPhone());
             }
-            Organization organization = organizationDao.get(musicGroup.getOrganId());
-            String studentGrade = studentService.getStudentGrade(organization.getGradeType(), studentRegistration.getCurrentGradeNum());
-            studentRegistration.setCurrentGrade(studentGrade);
-            studentRegistration.setActualSubjectId(studentRegistration.getSubjectId());
-            studentRegistration.setUserId(userId);
-            studentRegistration.setPaymentStatus(PaymentStatusEnum.OPEN);
-            studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.APPLY);
-            studentRegistration.setTemporaryCourseFee(studentAddDto.getTemporaryCourseFee());
-            //学生报名表
-            Set<Integer> roleIds = new HashSet<>(1);
-            roleIds.add(SysUserRole.SECTION_MANAGER);
-            Set<Integer> integers = musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId());
-            integers.add(musicGroup.getEducationalTeacherId());
-            sysMessageService.batchSeoMessage(integers, MessageTypeEnum.BACKSTAGE_MUSIC_GROUP_ADD_STUDENT, "", musicGroup.getName(), studentRegistration.getName());
-            //增加报名学生数
-            musicGroupSubjectPlanService.addApplyStudentNum(musicGroupId, studentRegistration.getSubjectId(), 1);
-            //汇总金额
-
-            MusicGroupStudentFee musicGroupStudentFee = new MusicGroupStudentFee(musicGroupId,
-                    userId, studentRegistration.getSubjectId(), studentAddDto.getCourseFee(),
-                    null, studentAddDto.getTemporaryCourseFee(), null);
-
-            /*if (musicGroup.getFeeType() != null && musicGroup.getFeeType() != MusicGroupPaymentCalender.FeeType.OFFLINE && musicGroupStudentFee.getTemporaryCourseFee().doubleValue() * 100 == 0) {
-                musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
-            }*/
-            musicGroupStudentFeeDao.insert(musicGroupStudentFee);
-
-            StudentPaymentOrder waitPayOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-
-            if (waitPayOrder != null) {
-                waitPayOrder.setStatus(DealStatusEnum.CLOSE);
-                studentPaymentOrderService.update(waitPayOrder);
+            if (StringUtils.isNotEmpty(sysUser.getUsername())) {
+                if (!sysUser.getUsername().equals(studentRegistration.getName())) {
+                    throw new BizException("操作失败:账户已被注册");
+                }
             }
-            //生成订单
-            StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-            studentPaymentOrder.setUserId(userId);
-            studentPaymentOrder.setGroupType(GroupType.MUSIC);
-            studentPaymentOrder.setType(OrderTypeEnum.APPLY);
-            studentPaymentOrder.setStatus(DealStatusEnum.WAIT_PAY);
-            studentPaymentOrder.setMusicGroupId(musicGroupId);
-            studentPaymentOrder.setClassGroupId(studentAddDto.getSignClassId());
-            studentPaymentOrder.setOrganId(musicGroup.getOrganId());
-            studentPaymentOrder.setRoutingOrganId(musicGroup.getOrganId());
-
-            //生成订单明细
-            List<StudentPaymentOrderDetail> studentPaymentOrderDetails = studentAddDto.getStudentPaymentOrderDetails();
-            if (studentPaymentOrderDetails == null) {
-                studentPaymentOrderDetails = new ArrayList<>();
+            if (!sysUser.getUserType().contains("STUDENT")) {
+                sysUser.setUserType(sysUser.getUserType() + ",STUDENT");
             }
-            //汇总金额
-
-            BigDecimal reduce = studentPaymentOrderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-            if (reduce.compareTo(BigDecimal.ZERO) == 0) {
-                studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
-                studentPaymentOrder.setActualAmount(reduce);
-                studentPaymentOrder.setPayTime(date);
+            sysUser.setPhone(studentRegistration.getParentsPhone());
+//            sysUser.setRealName(studentRegistration.getParentsName());
+            sysUser.setUsername(studentRegistration.getName());
+            sysUser.setGender(studentRegistration.getGender());
+            sysUser.setOrganId(musicGroup.getOrganId());
+            sysUser.setBirthdate(studentRegistration.getBirthdate());
+            teacherDao.updateUser(sysUser);
+            userId = sysUser.getId();
+            Student student = studentDao.get(userId);
+            if (student == null) {
+                studentDao.insert(new Student(userId, studentRegistration.getSubjectId().toString()));
+            } else if (StringUtils.isEmpty(student.getSubjectIdList())) {
+                student.setSubjectIdList(studentRegistration.getSubjectId().toString());
+                student.setUpdateTime(date);
+                studentDao.update(student);
+            } else if (StringUtils.isNotEmpty(student.getSubjectIdList())) {
+                String[] split = student.getSubjectIdList().split(",");
+                List<String> list = new ArrayList<>(Arrays.asList(split));
+                if (!list.contains(studentRegistration.getSubjectId().toString())) {
+                    list.add(studentRegistration.getSubjectId().toString());
+                    student.setSubjectIdList(StringUtils.join(list, ","));
+                    student.setUpdateTime(date);
+                    studentDao.update(student);
+                }
             }
-            studentPaymentOrder.setExpectAmount(reduce);
-            studentPaymentOrderService.insert(studentPaymentOrder);
+            imGroupDao.updateNickname(userId, sysUser.getUsername());
+            imGroupDao.updateUserFriendNickname(userId, sysUser.getUsername());
+        }
+        MusicGroupStudentFee studentFeeDaoByUser = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
+        if (studentFeeDaoByUser != null) {
+            throw new BizException("该学员已存在");
+        }
+        Organization organization = organizationDao.get(musicGroup.getOrganId());
+        String studentGrade = studentService.getStudentGrade(organization.getGradeType(), studentRegistration.getCurrentGradeNum());
+        studentRegistration.setCurrentGrade(studentGrade);
+        studentRegistration.setActualSubjectId(studentRegistration.getSubjectId());
+        studentRegistration.setUserId(userId);
+        studentRegistration.setPaymentStatus(PaymentStatusEnum.OPEN);
+        studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.APPLY);
+        studentRegistration.setTemporaryCourseFee(studentAddDto.getTemporaryCourseFee());
+        
+        //增加报名学生数
+        musicGroupSubjectPlanService.addApplyStudentNum(musicGroupId, studentRegistration.getSubjectId(), 1);
+        //汇总金额
+
+        MusicGroupStudentFee musicGroupStudentFee = new MusicGroupStudentFee(musicGroupId,
+                userId, studentRegistration.getSubjectId(), studentAddDto.getCourseFee(),
+                null, studentAddDto.getTemporaryCourseFee(), null);
+
+        /*if (musicGroup.getFeeType() != null && musicGroup.getFeeType() != MusicGroupPaymentCalender.FeeType.OFFLINE && musicGroupStudentFee.getTemporaryCourseFee().doubleValue() * 100 == 0) {
+            musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
+        }*/
+        musicGroupStudentFeeDao.insert(musicGroupStudentFee);
 
-            //当前学员是否以前存在过当前乐团
-            if (phoneAndMusicGroupId != null) {
-                studentRegistration.setId(phoneAndMusicGroupId.getId());
-                studentRegistrationDao.update(studentRegistration);
-            } else {
-                studentRegistrationDao.insertBasic(studentRegistration);
-            }
-            Student student = studentDao.get(userId);
-            student.setCurrentGradeNum(studentRegistration.getCurrentGradeNum());
-            student.setCurrentClass(studentRegistration.getCurrentClass());
-            studentDao.update(student);
-            //studentRegistrationDao.updateCurrentClass(studentRegistration);
-            imFeignService.update(new ImUserModel(userId.toString(), sysUser.getUsername(), sysUser.getAvatar()));
-            return userId;
+        //当前学员是否以前存在过当前乐团
+        if (phoneAndMusicGroupId != null) {
+            studentRegistration.setId(phoneAndMusicGroupId.getId());
+            studentRegistrationDao.update(studentRegistration);
+        } else {
+            studentRegistrationDao.insertBasic(studentRegistration);
         }
+        Student student = studentDao.get(userId);
+        student.setCurrentGradeNum(studentRegistration.getCurrentGradeNum());
+        student.setCurrentClass(studentRegistration.getCurrentClass());
+        studentDao.update(student);
+        //studentRegistrationDao.updateCurrentClass(studentRegistration);
+        imFeignService.update(new ImUserModel(userId.toString(), sysUser.getUsername(), sysUser.getAvatar()));
+        
+        //学生报名表
+        Set<Integer> roleIds = new HashSet<>(1);
+        roleIds.add(SysUserRole.SECTION_MANAGER);
+        Set<Integer> integers = musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId());
+        integers.add(musicGroup.getEducationalTeacherId());
+        sysMessageService.batchSeoMessage(integers, MessageTypeEnum.BACKSTAGE_MUSIC_GROUP_ADD_STUDENT, "", musicGroup.getName(), studentRegistration.getName());
+        
+        return userId;
     }
 
     @Override
@@ -904,13 +871,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //修改原有乐团注册信息
                 studentRegistrationDao.update(studentRegistration);
             }
-            Boolean orderFlag = true;
             //用户是否在主乐团
             StudentRegistration registration = studentRegistrationDao.getStudentRegister(newMusicGroupId, studentRegistration.getUserId());
             if (registration != null) {
-                if (registration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.NORMAL) {
-                    orderFlag = false;
-                }
                 //修改剩余课程余额
                 Date date = new Date();
                 registration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
@@ -937,28 +900,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                     musicGroupStudentFeeDao.insert(musicGroupStudentFee);
                 }
             }
-            StudentPaymentOrder waitPayOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(registration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-
-            if (waitPayOrder != null) {
-                waitPayOrder.setStatus(DealStatusEnum.CLOSE);
-                studentPaymentOrderService.update(waitPayOrder);
-            }
-            if (orderFlag) {
-                //生成订单
-                StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
-                studentPaymentOrder.setUserId(registration.getUserId());
-                studentPaymentOrder.setGroupType(GroupType.MUSIC);
-                studentPaymentOrder.setType(OrderTypeEnum.APPLY);
-                studentPaymentOrder.setMusicGroupId(registration.getMusicGroupId());
-                studentPaymentOrder.setClassGroupId(registration.getClassGroupId());
-                studentPaymentOrder.setOrganId(registration.getOrganId());
-                studentPaymentOrder.setRoutingOrganId(registration.getOrganId());
-                studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
-                studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
-                studentPaymentOrder.setPayTime(new Date());
-                studentPaymentOrder.setExpectAmount(BigDecimal.ZERO);
-                studentPaymentOrderService.insert(studentPaymentOrder);
-            }
             //主班新增余额日志
             if (amount.doubleValue() != 0d && masterTotalPrice.doubleValue() > 0d) {
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
@@ -1132,10 +1073,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), studentRegistration.getMusicGroupId());
             //进行中乐团加入学生缴费
             if (studentRegistration.getTemporaryCourseFee() != null) {
-                //关闭待支付订单
-                StudentPaymentOrder waitPayOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-                waitPayOrder.setStatus(DealStatusEnum.CLOSE);
-                studentPaymentOrderService.update(waitPayOrder);
                 musicGroupStudentFee.setLatestPaidTime(nowDate);
                 musicGroupStudentFee.setPaymentStatus(PAID_COMPLETED);
                 musicGroupStudentFee.setTemporaryCourseFee(BigDecimal.ZERO);

+ 8 - 1
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -349,6 +349,13 @@
         ORDER BY id_ DESC
         LIMIT 1
     </select>
+    
+    <select id="queryByBatchNo" resultMap="StudentPaymentOrder" parameterType="map">
+        SELECT *
+        FROM student_payment_order
+        WHERE batch_no_ = #{batchNo}
+          AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+    </select>
 
     <!-- 根据订单号查询订单 -->
     <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
@@ -371,7 +378,7 @@
         <![CDATA[
         SELECT COUNT(*)
         FROM student_payment_order
-        WHERE FIND_IN_SET(status_, 'SUCCESS,ING,WAIT_PAY')
+        WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
         ]]>
     </select>
 

+ 2 - 11
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -146,13 +146,6 @@ public class MusicGroupController extends BaseController {
             @ApiImplicitParam(name = "subjectId", value = "声部编号", required = true, dataType = "Integer")})
     public HttpResponseResult getSubjectGoodsAndInfo(String musicGroupId, Integer subjectId) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if (sysUser != null && sysUser.getId() > 0) {
-            Integer userId = sysUser.getId();
-            StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
-            if (studentRegistration != null && studentRegistration.getTemporaryCourseFee() != null) {
-                return succeed(musicGroupSubjectPlanService.getStudentGoodsAndInfo(musicGroupId, subjectId, studentRegistration));
-            }
-        }
         return succeed(musicGroupSubjectPlanService.getSubjectGoodsAndInfo(musicGroupId, subjectId));
     }
 
@@ -300,8 +293,7 @@ public class MusicGroupController extends BaseController {
         Integer userId = studentRegistration.getUserId();
 
         StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.SUCCESS);
-        StudentPaymentOrder waitPay = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-        if (ApplyOrder != null && waitPay == null) {
+        if (ApplyOrder != null) {
             return failed("您已支付成功,请勿重复支付");
         }
         //判断用户是否已存在订单
@@ -334,8 +326,7 @@ public class MusicGroupController extends BaseController {
         }
         Integer userId = studentRegistration.getUserId();
         StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.SUCCESS);
-        StudentPaymentOrder waitPay = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-        if (ApplyOrder != null && waitPay == null) {
+        if (ApplyOrder != null) {
             return failed("您已支付成功,请勿重复支付");
         }
         Map payMap = musicGroupService.rePay(registerPayDto);