| 
					
				 | 
			
			
				@@ -4,6 +4,7 @@ import static com.ym.mec.biz.dal.entity.ApprovalStatus.PROCESSING; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static com.ym.mec.biz.dal.enums.DealStatusEnum.ING; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.IOException; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -21,6 +22,8 @@ import java.util.Objects; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Set; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.dal.dto.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.ym.mec.biz.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -74,18 +77,6 @@ import com.ym.mec.biz.dal.dao.SysConfigDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.SysUserCashAccountDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.TeacherAttendanceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.dao.TeacherDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.BasicUserDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.CloseMusicGroupDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.HighClassGroupDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.MusicCardDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.MusicGroupBasicDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.RegisterPayDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.SporadicPayDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.SubFeeSettingDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.SubjectRegisterDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.ApprovalStatus; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.ChargeType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.entity.ClassGroup; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -152,29 +143,6 @@ import com.ym.mec.biz.dal.enums.YesOrNoEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.page.MusicGroupQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.dal.page.MusicMemberQueryInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.biz.event.source.GroupEventSource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.ClassGroupService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.ClassGroupStudentMapperService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.CloudTeacherOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.ContractService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.GoodsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.ImGroupMemberService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.ImGroupService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.ImUserFriendService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.MusicGroupService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.MusicGroupSubjectPlanService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.PayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.StudentPaymentOrderDetailService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.StudentPaymentOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.StudentPaymentRouteOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.StudentRegistrationService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.StudentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysMessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysUserCashAccountDetailService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.ym.mec.biz.service.SysUserCashAccountService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.dal.BaseDAO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.entity.HttpResponseResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.ym.mec.common.entity.ImGroupMember; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -352,6 +320,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StudentService studentService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private SysCouponCodeService sysCouponCodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private SimpleDateFormat sdf_hms = new SimpleDateFormat("HH:mm:ss"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -656,9 +627,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (chargeInfo.getDiscountAmount() != null && chargeInfo.getDiscountAmount().compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             amount = amount.subtract(chargeInfo.getDiscountAmount().multiply(new BigDecimal(sporadicPayDto.getNum()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (!(amount.compareTo(sporadicPayDto.getAmount()) == 0)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new BizException("订单金额异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (chargeInfo.getMaxAmount() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (chargeInfo.getOpenMaxTerm().equals(YesOrNoEnum.YES) && chargeInfo.getMaxAmount().compareTo(chargeInfo.getPaidAmount()) <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new Exception("活动名额已满,谢谢您的支持!"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -689,13 +657,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Integer userId = sporadicPayDto.getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String channelType = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(sporadicPayDto.getCouponIdList(),amount,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        amount = studentPaymentOrder.getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!(amount.compareTo(sporadicPayDto.getAmount()) == 0)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BizException("订单金额异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setUserId(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setGroupType(GroupType.SPORADIC); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setOrderNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setType(type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrder.setExpectAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrder.setActualAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setStatus(DealStatusEnum.ING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setMusicGroupId(sporadicPayDto.getSporadicId().toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setClassGroupId(sporadicPayDto.getNum()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -900,19 +870,28 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     		cloudTeacherOrder.setStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cloudTeacherOrder.setMusicGroupId(musicGroup.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String channelType = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orderAmount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orderNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                channelType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                courseFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                goodsGroups, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                remitFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                courseRemitFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                newCourses, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                registerPayDto.getBuyMaintenance(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                registerPayDto.getBuyCloudTeacher(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                registerPayDto.getBuyCloudTeacherPlus(),registerPayDto.getCouponIdList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        orderAmount = studentPaymentOrder.getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (amount.compareTo(orderAmount) != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("商品价格不符"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (amount.compareTo(BigDecimal.ZERO) < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("价格异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String channelType = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -924,7 +903,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal balance = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (registerPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (userCashAccount == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new BizException("用户账户找不到"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1162,20 +1141,29 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             cloudTeacherOrder.setMusicGroupId(musicGroup.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String channelType = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orderAmount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orderNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                channelType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                courseFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                goodsGroups, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                remitFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                courseRemitFee, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                newCourses, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                registerPayDto.getBuyMaintenance(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                registerPayDto.getBuyCloudTeacher(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                registerPayDto.getBuyCloudTeacherPlus(),registerPayDto.getCouponIdList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        orderAmount = studentPaymentOrder.getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (amount.compareTo(orderAmount) != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("商品价格不符"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (amount.compareTo(BigDecimal.ZERO) < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("价格异常"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String channelType = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(cloudTeacherOrder != null){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1186,7 +1174,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal balance = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (registerPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             SysUserCashAccount userCashAccount = sysUserCashAccountService.get(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (userCashAccount == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new BizException("用户账户找不到"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2342,7 +2330,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    			if (studentLastChange != null && minPaymentOrderId <= studentLastChange.getOriginalOrderId()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    			if (studentLastChange != null && (studentLastChange.getOriginalOrderId() == null || minPaymentOrderId <= studentLastChange.getOriginalOrderId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     				if (returnFeeDto.getIsReturnMusicalFee()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     					amount = amount.add(studentLastChange.getChangeMusicalPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     					 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2360,7 +2348,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     				for (StudentPaymentOrderDetail detail : orderDetailList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     					// 退乐器费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    					if (returnFeeDto.getIsReturnMusicalFee() && detail.getType() == OrderDetailTypeEnum.MUSICAL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    					if (returnFeeDto.getIsReturnMusicalFee() && detail.getType() == MUSICAL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     						StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2372,7 +2360,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     					// 退教辅费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     					if (returnFeeDto.getIsReturnAccessoriesFee() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    							&& (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    							&& (detail.getType() == ACCESSORIES || detail.getType() == TEACHING)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     				} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2682,7 +2670,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				for (StudentPaymentOrderDetail detail : orderDetailList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					// 退乐器费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (isRefundInstrumentFee && detail.getType() == OrderDetailTypeEnum.MUSICAL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (isRefundInstrumentFee && detail.getType() == MUSICAL) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2694,7 +2682,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					// 退教辅费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					if (isRefundTeachingAssistantsFee 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							&& (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							&& (detail.getType() == ACCESSORIES || detail.getType() == TEACHING)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2730,7 +2718,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Map renew(Long calenderId, Integer userId, boolean isUseBalancePayment) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Map renew(RenewParamDto renewParamDto) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Long calenderId = renewParamDto.getCalenderId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Integer userId = renewParamDto.getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (calender == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("缴费项目不存在"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2755,12 +2745,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 		throw new BizException("订单还在交易中,请稍后重试"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 oldStudentPaymentOrder.setStatus(CLOSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 studentPaymentOrderService.update(oldStudentPaymentOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (oldStudentPaymentOrder.getBalancePaymentAmount() != null && oldStudentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     sysUserCashAccountService.updateBalance(oldStudentPaymentOrder.getUserId(), oldStudentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "关闭订单"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sysCouponCodeService.quit(oldStudentPaymentOrder.getCouponCodeId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String orderNo = idGeneratorService.generatorId("payment") + ""; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2768,7 +2758,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal amount = calenderDetail.getExpectAmount().add(calenderDetail.getExpectMemberAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //使用优惠券 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(renewParamDto.getCouponIdList(),amount,true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        amount = studentPaymentOrder.getActualAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setGroupType(GroupType.MUSIC); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setUserId(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setOrderNo(orderNo); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2778,8 +2770,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			studentPaymentOrder.setType(OrderTypeEnum.RENEW); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrder.setExpectAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrder.setActualAmount(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setStatus(DealStatusEnum.ING); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setMusicGroupId(calender.getMusicGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         studentPaymentOrder.setBatchNo(calender.getId() + ""); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2814,19 +2804,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     		cloudTeacherOrderService.insert(cloudTeacherOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /*ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetail.setPrice(amount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetail.setCreateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetail.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetailList.add(studentPaymentOrderDetail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal balance = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (isUseBalancePayment || amount.doubleValue() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (renewParamDto.getUseBalancePayment() || amount.doubleValue() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (userCashAccount == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new BizException("用户账户找不到"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2984,6 +2963,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cloudTeacherOrder.setAmount(calenderDetail.getExpectMemberAmount()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				cloudTeacherOrderService.update(cloudTeacherOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// 添加会员有效时长 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				studentService.updateMemberRank(cloudTeacherOrder, periodEnum); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3047,7 +3027,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (paymentOrderDetails.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                studentPaymentOrderDetailService.batchAdd(paymentOrderDetails); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                studentPaymentOrderDetailService.batchAdd(paymentOrderDetails,studentPaymentOrder.getCouponRemitFee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //获取实际支付课程费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                courseFee = paymentOrderDetails.stream().filter(e->e.getType() != MUSICAL && e.getType() != ACCESSORIES 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        && e.getType() != TEACHING && e.getType() != OTHER && e.getType() != DEGREE_REGISTRATION 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        && e.getType() != MAINTENANCE && e.getType() != CLOUD_TEACHER && e.getType() != CLOUD_TEACHER_PLUS).map(t -> t.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //获取云教练订单费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(cloudTeacherOrder != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    CloudTeacherOrder teacherOrder = cloudTeacherOrderService.get(cloudTeacherOrder.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    BigDecimal cloudTeacherFee = paymentOrderDetails.stream().filter(e->e.getType() == CLOUD_TEACHER).map(t -> t.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    teacherOrder.setAmount(cloudTeacherFee); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    cloudTeacherOrderService.update(teacherOrder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //缴费 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3086,7 +3077,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     		calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     		calenderDetail.setUpdateTime(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     		musicGroupPaymentCalenderDetailDao.update(calenderDetail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().doubleValue() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         "乐团续费失败"); 
			 |