소스 검색

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
周箭河 4 년 전
부모
커밋
ddeb2f8a61

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -194,8 +194,8 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @author zouxuan
 	 * @date 2020/11/3
 	 * @time 15:41
-	 * @param orderNo:
+	 * @param orderId:
 	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail
 	 */
-	MusicGroupPaymentCalenderDetail findByOrderNo(@Param("orderNo") String orderNo);
+	MusicGroupPaymentCalenderDetail findByOrderId(@Param("orderId") Long orderId);
 }

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -147,12 +147,12 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 
 	/**
 	 *  续费
-	 * @param musicGroupId 乐团编号
+	 * @param calenderId 缴费项目编号
 	 * @param userId 用户编号
 	 * @param isUseBalancePayment 是否使用余额付款
 	 * @return
 	 */
-	Map renew(String musicGroupId, Integer userId, boolean isUseBalancePayment) throws Exception;
+	Map renew(Long calenderId, Integer userId, boolean isUseBalancePayment) throws Exception;
 
 	/**
 	 * 学生支付订单

+ 70 - 131
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -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

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

@@ -237,6 +237,44 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         callOrderCallBack(order);
     }
 
+    //Date date = new Date();
+    //        BigDecimal balance = BigDecimal.ZERO;
+    //        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+    //        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+    //            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+    //            if (userCashAccount == null) {
+    //                throw new BizException("用户账户找不到");
+    //            }
+    //            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+    //                balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+    //                amount = amount.subtract(balance);
+    //                studentPaymentOrder.setPaymentChannel("BALANCE");
+    //                studentPaymentOrder.setActualAmount(amount);
+    //                studentPaymentOrder.setBalancePaymentAmount(balance);
+    //                sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团报名");
+    //            }
+    //        }
+    //        studentPaymentOrder.setPaymentChannel("BALANCE");
+    //        studentPaymentOrder.setRemitFee(remitFee);
+    //        studentPaymentOrder.setCourseRemitFee(courseRemitFee);
+    //        studentPaymentOrder.setOrganId(musicGroup.getOrganId());
+    //        studentPaymentOrder.setRoutingOrganId(musicGroup.getOrganId());
+    //        studentPaymentOrder.setUpdateTime(date);
+    //        studentPaymentOrderService.update(studentPaymentOrder);
+    //        studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+    //
+    //        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+    //            //如果赠送网管课
+    //            studentPaymentRouteOrderService.addRouteOrder(orderNo, musicGroup.getOrganId(), balance);
+    //            Map<String, String> notifyMap = new HashMap<>();
+    //            notifyMap.put("tradeState", "1");
+    //            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+    //            notifyMap.put("channelType", channelType);
+    //            notifyMap.put("orderNo", "");
+    //            studentPaymentOrderService.updateOrder(notifyMap);
+    //            return notifyMap;
+    //        }
+
     //调用相应业务回调接口
     private void callOrderCallBack(StudentPaymentOrder order) throws Exception {
         if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -366,7 +366,7 @@
 	<select id="findByCalenderIdAndUserId" resultMap="MusicGroupPaymentCalenderDetail">
 		SELECT * FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{calenderId} AND user_id_ = #{userId} LIMIT 1
 	</select>
-	<select id="findByOrderNo" resultMap="MusicGroupPaymentCalenderDetail">
-		SELECT * FROM music_group_payment_calender_detail WHERE payment_order_id_ = #{orderNo} LIMIT 1
+	<select id="findByOrderId" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT * FROM music_group_payment_calender_detail WHERE payment_order_id_ = #{orderId} LIMIT 1
 	</select>
 </mapper>

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml

@@ -32,6 +32,7 @@
         <result column="birthdate_" property="birthdate" />
         <result column="gender_" property="gender" />
         <result column="organ_name_" property="organName" />
+        <result column="organ_id_" property="organId" />
         <result column="school_name_" property="schoolName" />
         <result column="subject_name_" property="subjectName" />
         <result column="kit_group_purchase_type_" property="kitType" />
@@ -349,8 +350,8 @@
     </select>
 
     <select id="queryByUserIdAndMusicGroupId" resultMap="StudentRegistration">
-        SELECT sr.*,su.id_card_no_ FROM student_registration sr
-        LEFT JOIN sys_user su ON su.id_ =sr.user_id_
+        SELECT sr.*,su.id_card_no_,su.organ_id_ FROM student_registration sr
+        LEFT JOIN sys_user su ON su.id_ = sr.user_id_
         WHERE sr.music_group_id_ = #{musicGroupId} AND sr.user_id_ = #{userId} AND sr.music_group_status_ != 'QUIT' LIMIT 1
     </select>
 

+ 26 - 19
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.entity.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -30,16 +31,8 @@ import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
-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.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
@@ -220,30 +213,46 @@ public class MusicGroupController extends BaseController {
 
     @ApiOperation(value = "续费")
     @GetMapping("/renew")
-    @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String"),
+    @ApiImplicitParams({@ApiImplicitParam(name = "calenderId", value = "缴费项目编号", required = true, dataType = "Long"),
             @ApiImplicitParam(name = "isUseBalancePayment", value = "是否使用余额付款", required = true, dataType = "Boolean")})
-    public HttpResponseResult renew(String musicGroupId, Boolean isUseBalancePayment, boolean isRepeatPay) throws Exception {
+    public HttpResponseResult renew(Long calenderId, Boolean isUseBalancePayment, boolean isRepeatPay) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer userId = sysUser.getId();
 
         if (isUseBalancePayment == null) {
             isUseBalancePayment = false;
         }
+        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
         if (isRepeatPay == false) {
             // 判断是否存在支付中的记录
-            List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.MUSIC, musicGroupId, userId, DealStatusEnum.ING,
+            List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.MUSIC, calender.getMusicGroupId(), userId, DealStatusEnum.ING,
                     OrderTypeEnum.RENEW);
             if (list.size() > 0) {
                 return failed(HttpStatus.CONTINUE, "您有待支付的订单");
             }
         }
-        MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(musicGroupId, userId);
-        if (userLastCalenderDetail == null) {
-            MusicGroupPaymentCalender lastCalender = musicGroupPaymentCalenderDao.getLastStartOne(musicGroupId);
-            String tips = (lastCalender != null && lastCalender.getStatus() == PaymentCalenderStatusEnum.OVER) ? "当前续费时间已截止,如有问题请联系指导老师" : "当前续费未开始,如有问题请联系指导老师";
-            throw new BizException(tips);
+        MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByCalenderIdAndUserId(calenderId,userId);
+        if (calenderDetail == null) {
+            throw new BizException("缴费项不存在该学员,请联系教务老师");
         }
-        return succeed(musicGroupService.renew(musicGroupId, userId, isUseBalancePayment));
+        if(calenderDetail.getPaymentStatus() == PaymentStatus.PAID_COMPLETED){
+            throw new BizException("当前缴费项已缴费");
+        }else if(calenderDetail.getPaymentStatus() == PaymentStatus.PROCESSING){
+            throw new BizException("当前缴费项存在待处理的订单,请稍候尝试");
+        }
+        //缴费项目已开启或者单独开启
+        Map renew;
+        if(calender.getStatus() == PaymentCalenderStatusEnum.OPEN || calenderDetail.getOpen() == 1){
+            renew = musicGroupService.renew(calenderId, userId, isUseBalancePayment);
+        }else if(calender.getStatus() == PaymentCalenderStatusEnum.OVER){
+            throw new BizException("当前缴费项时间已截止,如有问题请联系指导老师");
+        }else {
+            throw new BizException("当前缴费项未开始,如有问题请联系指导老师");
+        }
+        if (renew.containsKey("tradeState")) {
+            return failed(HttpStatus.CREATED, "恭喜您,缴费成功!");
+        }
+        return succeed(renew);
     }
 
     @ApiOperation(value = "退团")
@@ -270,7 +279,6 @@ public class MusicGroupController extends BaseController {
         if (ApplyOrder != null && waitPay == null) {
             return failed("您已支付成功,请勿重复支付");
         }
-
         //判断用户是否已存在订单
         ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.ING);
         if (ApplyOrder != null) {
@@ -280,7 +288,6 @@ public class MusicGroupController extends BaseController {
         if (payMap.containsKey("tradeState")) {
             return failed(HttpStatus.CREATED, "恭喜您,报名成功!");
         }
-
         return succeed(payMap);
     }
 

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

@@ -62,14 +62,14 @@ public class MusicGroupPaymentCalenderController extends BaseController {
             throw new BizException("缴费项不存在该学员,请联系教务老师");
         }
         if(calenderDetail.getPaymentStatus() == PaymentStatus.PAID_COMPLETED){
-            throw new BizException("当前缴费项已缴费");
+            throw new BizException("您已缴费,请勿重复提交");
         }else if(calenderDetail.getPaymentStatus() == PaymentStatus.PROCESSING){
             throw new BizException("当前缴费项存在待处理的订单,请稍候尝试");
         }
         if(calender.getStatus() == PaymentCalenderStatusEnum.OPEN){
             StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId,musicGroupId);
             if (studentRegistration == null) {
-                return failed("乐团报名信息找不到");
+                return failed("乐团报名信息不存在");
             }
             List<MusicGroupPaymentCalenderCourseSettings> calenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(calenderId);
             ModelMap model = new ModelMap();

+ 21 - 4
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -2,16 +2,20 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -20,10 +24,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 @RequestMapping("musicGroupPaymentCalender")
@@ -39,6 +46,8 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeDao employeeDao;
+    @Autowired
+    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 
     @ApiOperation(value = "分页查询乐团缴费日历列表")
     @GetMapping(value = "/queryPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@@ -132,10 +141,18 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @ApiOperation(value = "获取指定学员在指定乐团下本次课排课时长")
     @GetMapping("/getMusicCourseSettingsWithStudents")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getMusicCourseSettingsWithStudents')")
-    public HttpResponseResult<List<MusicGroupPaymentCalenderCourseSettings>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds){
-        if(StringUtils.isBlank(studentIds)){
-            return failed("请指定学员编号");
+    public HttpResponseResult<List<MusicGroupPaymentCalenderCourseSettings>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds, Long classGroupId){
+        List<Integer> studentIdList = new ArrayList<>();
+        if(StringUtils.isNotBlank(studentIds)){
+            studentIdList = Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
+        }
+        if(Objects.nonNull(classGroupId)){
+            List<StudentRegistration> studentList = classGroupStudentMapperDao.findClassStudentList(classGroupId.intValue(), ClassGroupStudentStatusEnum.NORMAL);
+            studentIdList = studentList.stream().map(StudentRegistration::getUserId).collect(Collectors.toList());
+        }
+        if(CollectionUtils.isEmpty(studentIdList)){
+            throw new BizException("未指定学员");
         }
-        return succeed(musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId,Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList())));
+        return succeed(musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId,studentIdList));
     }
 }