|  | @@ -1,62 +1,18 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.io.IOException;
 | 
	
		
			
				|  |  | -import java.math.BigDecimal;
 | 
	
		
			
				|  |  | -import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | -import java.util.ArrayList;
 | 
	
		
			
				|  |  | -import java.util.Arrays;
 | 
	
		
			
				|  |  | -import java.util.Collections;
 | 
	
		
			
				|  |  | -import java.util.Date;
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.HashSet;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | -import java.util.Set;
 | 
	
		
			
				|  |  | -import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dao.*;
 | 
	
		
			
				|  |  | -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 org.springframework.transaction.annotation.Propagation;
 | 
	
		
			
				|  |  | -import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.TypeReference;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUserRole;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.BasicUserDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.CourseFormDto;
 | 
	
		
			
				|  |  | -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.RegisterPayDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.SporadicPayDto;
 | 
	
		
			
				|  |  | -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.dao.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.ClassGroupService;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.ClassGroupStudentMapperService;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.GoodsService;
 | 
	
		
			
				|  |  | -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.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.biz.service.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupMember;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupModel;
 | 
	
	
		
			
				|  | @@ -69,6 +25,20 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Propagation;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE;
 | 
	
		
			
				|  |  | +import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
 | 
	
	
		
			
				|  | @@ -331,11 +301,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          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) {
 | 
	
		
			
				|  |  | +        if (chargeInfo.getMaxNum() != null) {
 | 
	
		
			
				|  |  | +            if (chargeInfo.getMaxNum() <= chargeInfo.getPaidNum()) {
 | 
	
		
			
				|  |  |                  throw new Exception("活动人数暂时已满,请稍后再试");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            chargeInfo.setPaidAmount(chargeInfo.getPaidAmount().add(chargeInfo.getAmount()));
 | 
	
		
			
				|  |  | +            chargeInfo.setPaidNum(chargeInfo.getPaidNum() + 1);
 | 
	
		
			
				|  |  |              chargeInfo.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |              int update = sporadicChargeInfoDao.update(chargeInfo);
 | 
	
		
			
				|  |  |              if (update <= 0) {
 | 
	
	
		
			
				|  | @@ -1255,13 +1225,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          teacherAttendanceDao.deleteByMusicGroupId(musicGroupId, GroupType.MUSIC);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 查询已缴费信息
 | 
	
		
			
				|  |  | -        studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +        studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(musicGroupId, OrderTypeEnum.APPLY, SUCCESS);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 退费
 | 
	
		
			
				|  |  |          for (StudentPaymentOrder order : studentPaymentOrders) {
 | 
	
		
			
				|  |  |              // 增加交易流水
 | 
	
		
			
				|  |  |              sysUserCashAccountDetailService.addCashAccountDetail(order.getUserId(), order.getActualAmount().add(order.getBalancePaymentAmount()), SysUserCashAccountDetailService.MUSIC_GROUP
 | 
	
		
			
				|  |  | -                    + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "取消乐团", null);
 | 
	
		
			
				|  |  | +                    + musicGroupId, "", PlatformCashAccountDetailTypeEnum.REFUNDS, null, SUCCESS, "取消乐团", null);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //获取当前乐团所有已报名学员
 | 
	
		
			
				|  |  |          if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
 | 
	
	
		
			
				|  | @@ -1528,7 +1498,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              // 判断乐器是否是租赁
 | 
	
		
			
				|  |  |              // MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (studentPaymentOrder == null) {
 | 
	
		
			
				|  |  |                  //兼容历史数据
 | 
	
	
		
			
				|  | @@ -1570,7 +1540,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              if (amount.doubleValue() > 0) {
 | 
	
		
			
				|  |  |                  // 增加交易流水
 | 
	
		
			
				|  |  |                  sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
 | 
	
		
			
				|  |  | -                        PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团", null);
 | 
	
		
			
				|  |  | +                        PlatformCashAccountDetailTypeEnum.REFUNDS, null, SUCCESS, "退出乐团", null);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return true;
 | 
	
	
		
			
				|  | @@ -1631,7 +1601,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          // 判断乐器是否是租赁
 | 
	
		
			
				|  |  |          // MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (studentPaymentOrder == null) {
 | 
	
		
			
				|  |  |              return true;
 | 
	
	
		
			
				|  | @@ -1671,7 +1641,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (amount.doubleValue() > 0) {
 | 
	
		
			
				|  |  |              // 增加交易流水
 | 
	
		
			
				|  |  |              sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
 | 
	
		
			
				|  |  | -                    PlatformCashAccountDetailTypeEnum.REFUNDS, null, DealStatusEnum.SUCCESS, "退出乐团", null);
 | 
	
		
			
				|  |  | +                    PlatformCashAccountDetailTypeEnum.REFUNDS, null, SUCCESS, "退出乐团", null);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return true;
 | 
	
	
		
			
				|  | @@ -1679,41 +1649,31 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -    public Map renew(String musicGroupId, Integer userId, boolean isUseBalancePayment) throws Exception {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        MusicGroup musicGroup = this.get(musicGroupId);
 | 
	
		
			
				|  |  | -        if (musicGroup == null) {
 | 
	
		
			
				|  |  | -            throw new BizException("乐团不存在");
 | 
	
		
			
				|  |  | +    public Map renew(Long calenderId, Integer userId, boolean isUseBalancePayment) throws Exception {
 | 
	
		
			
				|  |  | +        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
 | 
	
		
			
				|  |  | +        if (calender == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("缴费项目不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if (musicGroupStudentFee == null) {
 | 
	
		
			
				|  |  | -            throw new BizException("个人续费信息错误");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  | +        StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, calender.getMusicGroupId());
 | 
	
		
			
				|  |  |          if (studentRegistration == null || studentRegistration.getPaymentStatus() != PaymentStatusEnum.YES) {
 | 
	
		
			
				|  |  |              throw new BizException("请走报名缴费流程");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(musicGroupId, userId);
 | 
	
		
			
				|  |  | -        if (userLastCalenderDetail == null) {
 | 
	
		
			
				|  |  | -            throw new BizException("当前续费时间已截止,请联系指导老师");
 | 
	
		
			
				|  |  | +        Integer organId = studentRegistration.getOrganId();
 | 
	
		
			
				|  |  | +        MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByCalenderIdAndUserId(calenderId, userId);
 | 
	
		
			
				|  |  | +        //关闭之前的订单
 | 
	
		
			
				|  |  | +        if(calenderDetail.getPaymentOrderId() != null){
 | 
	
		
			
				|  |  | +            StudentPaymentOrder oldStudentPaymentOrder = studentPaymentOrderDao.get(calenderDetail.getPaymentOrderId());
 | 
	
		
			
				|  |  | +            if(oldStudentPaymentOrder != null){
 | 
	
		
			
				|  |  | +                if(oldStudentPaymentOrder.getStatus() == SUCCESS){
 | 
	
		
			
				|  |  | +                    throw new BizException("您已支付请勿重复提交");
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                oldStudentPaymentOrder.setStatus(CLOSE);
 | 
	
		
			
				|  |  | +                studentPaymentOrderService.update(oldStudentPaymentOrder);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //判断是否是续费
 | 
	
		
			
				|  |  | -		/*List<StudentPaymentOrder> orderList = studentPaymentOrderDao.queryByCondition(GroupType.MUSIC, musicGroupId, userId, DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | -		if (orderList == null || orderList.size() == 0) {
 | 
	
		
			
				|  |  | -			throw new BizException("请走报名缴费流程");
 | 
	
		
			
				|  |  | -		}*/
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          String orderNo = idGeneratorService.generatorId("payment") + "";
 | 
	
		
			
				|  |  | -        // 判断当前是否是续费状态
 | 
	
		
			
				|  |  | -        if (musicGroupStudentFee.getPaymentStatus() != PaymentStatus.NON_PAYMENT) {
 | 
	
		
			
				|  |  | -            throw new BizException("已缴费");
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        BigDecimal amount = userLastCalenderDetail.getExpectAmount();
 | 
	
		
			
				|  |  | +        BigDecimal amount = calenderDetail.getExpectAmount();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Date date = new Date();
 | 
	
		
			
				|  |  |          StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 | 
	
	
		
			
				|  | @@ -1724,11 +1684,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          studentPaymentOrder.setExpectAmount(amount);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setActualAmount(amount);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setStatus(DealStatusEnum.ING);
 | 
	
		
			
				|  |  | -        studentPaymentOrder.setMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setMusicGroupId(calender.getMusicGroupId());
 | 
	
		
			
				|  |  |          studentPaymentOrder.setCreateTime(date);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setVersion(0);
 | 
	
		
			
				|  |  |          studentPaymentOrderService.insert(studentPaymentOrder);
 | 
	
		
			
				|  |  | +        calenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +        musicGroupPaymentCalenderDetailDao.update(calenderDetail);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
 | 
	
		
			
				|  |  |          StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
 | 
	
	
		
			
				|  | @@ -1749,45 +1711,19 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              studentPaymentOrder.setPaymentChannel("BALANCE");
 | 
	
		
			
				|  |  |              if (userCashAccount.getBalance().subtract(amount).doubleValue() >= 0) {
 | 
	
		
			
				|  |  | -                studentPaymentRouteOrderService.addRouteOrder(orderNo, musicGroup.getOrganId(), amount);
 | 
	
		
			
				|  |  | +                studentPaymentRouteOrderService.addRouteOrder(orderNo, organId, amount);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  // 更新订单信息
 | 
	
		
			
				|  |  |                  studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
 | 
	
		
			
				|  |  |                  studentPaymentOrder.setBalancePaymentAmount(amount);
 | 
	
		
			
				|  |  |                  studentPaymentOrder.setActualAmount(new BigDecimal(0));
 | 
	
		
			
				|  |  | -                studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +                studentPaymentOrder.setStatus(SUCCESS);
 | 
	
		
			
				|  |  |                  studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  | -                studentPaymentOrder.setOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | -                studentPaymentOrder.setRoutingOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | +                studentPaymentOrder.setOrganId(organId);
 | 
	
		
			
				|  |  | +                studentPaymentOrder.setRoutingOrganId(organId);
 | 
	
		
			
				|  |  |                  studentPaymentOrderService.update(studentPaymentOrder);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  sysUserCashAccountService.updateBalance(userId, amount.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(userLastCalenderDetail.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  | -                //更新下次续费时间
 | 
	
		
			
				|  |  | -                musicGroupStudentFee.setUpdateTime(date);
 | 
	
		
			
				|  |  | -                musicGroupStudentFee.setLatestPaidTime(date);
 | 
	
		
			
				|  |  | -                musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | -                musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
 | 
	
		
			
				|  |  | -                /*if (musicGroupPaymentCalender.getType().equals(MusicGroupPaymentCalender.FeeType.ONLINE)) {
 | 
	
		
			
				|  |  | -                    Integer getRemainNetworkClassTimes = musicGroupStudentFee.getRemainNetworkClassTimes() == null ? 0 : musicGroupStudentFee.getRemainNetworkClassTimes();
 | 
	
		
			
				|  |  | -                    musicGroupStudentFee.setRemainNetworkClassTimes(getRemainNetworkClassTimes + 1);
 | 
	
		
			
				|  |  | -                }*/
 | 
	
		
			
				|  |  | -//                musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate(), musicGroupStudentFee));
 | 
	
		
			
				|  |  | -                musicGroupStudentFeeDao.update(musicGroupStudentFee);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                //更新学生的缴费记录状态
 | 
	
		
			
				|  |  | -                userLastCalenderDetail.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | -                userLastCalenderDetail.setActualAmount(userLastCalenderDetail.getExpectAmount());
 | 
	
		
			
				|  |  | -                userLastCalenderDetail.setPayTime(date);
 | 
	
		
			
				|  |  | -                userLastCalenderDetail.setUpdateTime(date);
 | 
	
		
			
				|  |  | -                musicGroupPaymentCalenderDetailDao.update(userLastCalenderDetail);
 | 
	
		
			
				|  |  | -                //更新实际缴费人数
 | 
	
		
			
				|  |  | -                Integer actualNum = musicGroupPaymentCalender.getActualNum() == null ? 0 : musicGroupPaymentCalender.getActualNum();
 | 
	
		
			
				|  |  | -                musicGroupPaymentCalender.setActualNum(actualNum + 1);
 | 
	
		
			
				|  |  | -                musicGroupPaymentCalender.setUpdateTime(date);
 | 
	
		
			
				|  |  | -                musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
 | 
	
		
			
				|  |  | -                return null;
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  if (userCashAccount.getBalance().doubleValue() > 0) {
 | 
	
		
			
				|  |  |                      balance = userCashAccount.getBalance();
 | 
	
	
		
			
				|  | @@ -1802,12 +1738,16 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //分类费用 course,instrument,accessories,other
 | 
	
		
			
				|  |  | -        Map<String, BigDecimal> classFee = new HashMap<>();
 | 
	
		
			
				|  |  | -        classFee.put("course", amount);
 | 
	
		
			
				|  |  | -        classFee.put("instrument", BigDecimal.ZERO);
 | 
	
		
			
				|  |  | -        classFee.put("accessories", BigDecimal.ZERO);
 | 
	
		
			
				|  |  | -        classFee.put("other", BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +        if (amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
	
		
			
				|  |  | +            studentPaymentRouteOrderService.addRouteOrder(orderNo,organId, balance);
 | 
	
		
			
				|  |  | +            Map<String, String> notifyMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            notifyMap.put("tradeState", "1");
 | 
	
		
			
				|  |  | +            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
 | 
	
		
			
				|  |  | +            notifyMap.put("channelType", "");
 | 
	
		
			
				|  |  | +            notifyMap.put("orderNo", "");
 | 
	
		
			
				|  |  | +            studentPaymentOrderService.updateOrder(notifyMap);
 | 
	
		
			
				|  |  | +            return notifyMap;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Map<String, Object> payMap = payService.getPayMap(
 | 
	
		
			
				|  |  |                  amount,
 | 
	
	
		
			
				|  | @@ -1817,17 +1757,16 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + studentPaymentOrder.getOrderNo(),
 | 
	
		
			
				|  |  |                  "续费",
 | 
	
		
			
				|  |  |                  "乐团续费",
 | 
	
		
			
				|  |  | -                musicGroup.getOrganId(),
 | 
	
		
			
				|  |  | +                organId,
 | 
	
		
			
				|  |  |                  "renew"
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          studentPaymentOrder.setActualAmount(amount);
 | 
	
		
			
				|  |  | -        studentPaymentOrder.setOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setOrganId(organId);
 | 
	
		
			
				|  |  |          studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
 | 
	
		
			
				|  |  |          studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 | 
	
		
			
				|  |  |          studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  |          studentPaymentOrderService.update(studentPaymentOrder);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          return payMap;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1848,9 +1787,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          Map<Integer, String> push = new HashMap<>(1);
 | 
	
		
			
				|  |  |          push.put(userId, userId.toString());
 | 
	
		
			
				|  |  |          yimei.put(userId, studentRegistration.getParentsPhone());
 | 
	
		
			
				|  |  | -        if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
 | 
	
		
			
				|  |  | +        if (studentPaymentOrder.getStatus() == SUCCESS) {
 | 
	
		
			
				|  |  |              //当前乐团报名是否赠送乐团网管课
 | 
	
		
			
				|  |  | -            MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByOrderNo(studentPaymentOrder.getOrderNo());
 | 
	
		
			
				|  |  | +            MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  |              MusicGroupStudentFee musicGroupStudentFee = musicGroupPaymentCalenderService.updateCalender(calenderDetail.getId(),studentRegistration.getUserId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              musicGroupStudentFee.setUpdateTime(date);
 | 
	
	
		
			
				|  | @@ -1873,7 +1812,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
 | 
	
		
			
				|  |  |              rechargeDetail.setComment("缴费前充值");
 | 
	
		
			
				|  |  |              rechargeDetail.setCreateTime(date);
 | 
	
		
			
				|  |  | -            rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +            rechargeDetail.setStatus(SUCCESS);
 | 
	
		
			
				|  |  |              rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
 | 
	
		
			
				|  |  |              rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
 | 
	
		
			
				|  |  |              rechargeDetail.setUpdateTime(date);
 | 
	
	
		
			
				|  | @@ -1889,7 +1828,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              paymentDetail.setBalance(cashAccount.getBalance());
 | 
	
		
			
				|  |  |              paymentDetail.setComment("续费");
 | 
	
		
			
				|  |  |              paymentDetail.setCreateTime(date);
 | 
	
		
			
				|  |  | -            paymentDetail.setStatus(DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +            paymentDetail.setStatus(SUCCESS);
 | 
	
		
			
				|  |  |              paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
 | 
	
		
			
				|  |  |              paymentDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
 | 
	
		
			
				|  |  |              paymentDetail.setUpdateTime(date);
 | 
	
	
		
			
				|  | @@ -1913,7 +1852,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  |          if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
 | 
	
		
			
				|  |  | -            if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
 | 
	
		
			
				|  |  | +            if (studentPaymentOrder.getStatus() == CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
 | 
	
		
			
				|  |  |                  String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
 | 
	
		
			
				|  |  |                  String memo = baseUrl + "/#/renew?musicGroupId=" + musicGroupId;
 | 
	
		
			
				|  |  |                  //4?http://mstudev.dayaedu.com/#/renew?musicGroupId=" +musicGroupId
 |