zouxuan 5 년 전
부모
커밋
aa901e73d4

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

@@ -19,7 +19,8 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      * @author Joburgess
      * @date 2020.11.04
      */
-    MusicGroupPaymentStudentCourseDetail getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("studentId") Integer studentId,
+    MusicGroupPaymentStudentCourseDetail getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("musicGroupId") String musicGroupId,
+                                                                                          @Param("studentId") Integer studentId,
                                                                                           @Param("courseType") CourseSchedule.CourseScheduleType courseType,
                                                                                           @Param("courseMinutes") Integer courseMinutes);
 

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RouteScaleDto.java

@@ -21,6 +21,8 @@ public class RouteScaleDto {
 
     private FeeTypeEnum feeType;
 
+    private BigDecimal balance = BigDecimal.ZERO;
+
     public Integer getOrganId() {
         return organId;
     }
@@ -77,4 +79,12 @@ public class RouteScaleDto {
     public void setFeeType(FeeTypeEnum feeType) {
         this.feeType = feeType;
     }
+
+    public BigDecimal getBalance() {
+        return balance;
+    }
+
+    public void setBalance(BigDecimal balance) {
+        this.balance = balance;
+    }
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java

@@ -108,7 +108,7 @@ public class MusicGroupPaymentCalender {
 	@ApiModelProperty(value = "状态", required = false)
 	private PaymentCalenderStatusEnum status;
 
-	private Integer expectNum;
+	private Integer expectNum = 0;
 
 	private Integer actualNum;
 

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

@@ -9,6 +9,7 @@ import com.ym.mec.common.service.BaseService;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 
 public interface SellOrderService extends BaseService<Integer, SellOrder> {
@@ -75,6 +76,6 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
      * @param orderNo
      * @return
      */
-    BigDecimal getSellActualAmount(String orderNo);
+    Map<String,BigDecimal> getSellAmount(String orderNo);
 
 }

+ 25 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1687,9 +1687,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         //创建IM群组
         addImGroup(classGroup, userIds);
 
-        //5、插入班级排课信息
-        LocalDateTime now = LocalDate.parse(classGroup4MixDtos.get(0).getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
-
         Map<String, Integer> courseTypeMinutesMap = musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId, studentIdList);
 
         //计算每节课的课酬
@@ -1699,6 +1696,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
         for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
+            //5、插入班级排课信息
+            LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
+
             if(!courseTypeMinutesMap.containsKey(classGroup4MixDto.getCourseType().getCode())){
                 throw new BizException("{}课程类型暂无剩余课程时长", classGroup4MixDto.getCourseType().getMsg());
             }
@@ -1883,7 +1883,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public ClassGroup classGroupUpdate(List<ClassGroup4MixDto> classGroup4MixDtos) throws Exception {
+    public ClassGroup classGroupUpdate(List<ClassGroup4MixDto> classGroup4MixDtos) {
         Date date = new Date();
         Integer classGroupId = classGroup4MixDtos.get(0).getClassGroupId();
         String musicGroupId = classGroup4MixDtos.get(0).getMusicGroupId();
@@ -1919,6 +1919,21 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 imFeignService.groupJoin(new ImGroupModel(classGroupId.toString(), imGroupMembers, classGroup.getName()));
             });
         }
+        if (Objects.nonNull(classGroup4MixDtos.get(0).getCourseAddType())&&classGroup4MixDtos.get(0).getCourseAddType().equals("onlyUpdateTeacher")) {
+            List<Integer> classGroupIds = new ArrayList<Integer>();
+            classGroupIds.add(classGroupId);
+            // 删除历史记录
+            classGroupTeacherMapperDao.delClassGroupTeacherMapper(classGroupIds);
+            for (ClassGroupTeacherMapper tm : newTeacherMapperList) {
+                tm.setClassGroupId(classGroupId);
+                tm.setCreateTime(date);
+                tm.setGroupType(GroupType.MUSIC);
+                tm.setMusicGroupId(musicGroupId);
+                tm.setUpdateTime(date);
+                classGroupTeacherMapperDao.insert(tm);
+            }
+            return classGroup;
+        }
         if (classGroup4MixDtos.get(0).getCourseTimes().compareTo(0) <= 0) {
             throw new BizException("排课次数必须大于0");
         }
@@ -1978,9 +1993,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
         List<Integer> studentIds = studentList.stream().map(StudentRegistration::getUserId).collect(Collectors.toList());
 
-        //3、插入班级排课信息
-        LocalDateTime now = LocalDate.parse(classGroup4MixDtos.get(0).getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
-
         Map<String, Integer> courseTypeMinutesMap = musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId, studentIds);
 
         //计算每节课的课酬
@@ -1988,6 +2000,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         List<CourseSchedule> courseScheduleList = new ArrayList<>();
 
         for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
+            //3、插入班级排课信息
+            LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
+
             if(!courseTypeMinutesMap.containsKey(classGroup4MixDto.getCourseType().getCode())){
                 throw new BizException("{}课程类型暂无剩余课程时长", classGroup4MixDto.getCourseType().getMsg());
             }
@@ -2267,9 +2282,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         //创建IM群组
         addImGroup(classGroup, userIds);
 
-        //5、插入班级排课信息
-        LocalDateTime now = LocalDate.parse(classGroup4MixDtos.get(0).getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
-
         Map<String, Integer> courseTypeMinutesMap = musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId, studentIdList);
 
         //计算每节课的课酬
@@ -2278,6 +2290,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
         for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
+            //5、插入班级排课信息
+            LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
+
             if(!courseTypeMinutesMap.containsKey(classGroup4MixDto.getCourseType().getCode())){
                 throw new BizException("{}课程类型暂无剩余课程时长", classGroup4MixDto.getCourseType().getMsg());
             }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -438,7 +438,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
         //4、调整未上课课酬
         List<ClassGroupTeacherMapper> classGroupTeachers = classGroupTeacherMapperService.getClassGroupTeachers(classGroupId.intValue());
-        if (classGroup.getType().equals(ClassGroupTypeEnum.HIGH_ONLINE) && classGroupNotStartCourse.size() > 0) {
+        if ((classGroup.getType().equals(ClassGroupTypeEnum.HIGH_ONLINE)||classGroup.getType().equals(ClassGroupTypeEnum.HIGH)) && classGroupNotStartCourse.size() > 0) {
             Date nowDate = new Date();
             List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
             List<Long> courseScheduleIds = classGroupNotStartCourse.stream().map(CourseSchedule::getId).collect(Collectors.toList());

+ 16 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -312,14 +312,14 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			for (Map.Entry<CourseSchedule.CourseScheduleType, List<CourseSchedule>> courseScheduleTypeListEntry : typeCourseMap.entrySet()) {
 				//当前课程类型总课程时长
 				Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey());
-				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId, courseScheduleTypeListEntry.getKey(), typeCourseDuration);
+				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey(), typeCourseDuration);
 				if(Objects.isNull(musicGroupPaymentStudentCourseDetail)||musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes().compareTo(typeCourseDuration)<0){
 					SysUser user = teacherDao.getUser(studentId);
 					throw new BizException("{}在{}课程类型上的课程时长不足", user.getUsername(), courseScheduleTypeListEntry.getKey().getMsg());
 				}
 
 				MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(musicGroupPaymentStudentCourseDetail.getMusicGroupPaymentCalenderId());
-				if(Objects.isNull(musicGroupPaymentCalender)){
+				if(Objects.isNull(musicGroupPaymentCalender)||!musicGroupId.equals(musicGroupPaymentCalender.getMusicGroupId())){
 					throw new BizException("缴费设置异常");
 				}
 
@@ -335,6 +335,10 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				//课程每分钟现价
 				BigDecimal unitMinuteCurrentPrice = musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().divide(new BigDecimal(musicGroupPaymentCalenderCourseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 
+				if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(musicGroupPaymentCalender.getPayUserType())){
+					unitMinuteCurrentPrice = new BigDecimal("0");
+				}
+
 				List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
 				courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 				BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
@@ -362,8 +366,11 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 					cssp.setActualPrice(BigDecimal.ZERO);
 					typeCourseStudentPayments.add(cssp);
 				}
+
 				typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
-				typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
+				if(MusicGroupPaymentCalender.PayUserType.STUDENT.equals(musicGroupPaymentCalender.getPayUserType())) {
+					typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(musicGroupPaymentCalenderCourseSettings.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
+				}
 				courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
 				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(typeCourseDuration);
 				musicGroupPaymentStudentCourseDetailDao.update(musicGroupPaymentStudentCourseDetail);
@@ -400,18 +407,15 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			//学员总缴费金额
 			BigDecimal totalActualAmount = musicGroupPaymentCalenderDetails.stream().map(e -> Objects.isNull(e.getActualAmount())?BigDecimal.ZERO:e.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
 
-			for(int i=0;i<studentStudentPaymentMapEntry.getValue().size();i++){
-				if(totalActualAmount.compareTo(studentStudentPaymentMapEntry.getValue().get(i).getExpectPrice())>=0){
-					studentStudentPaymentMapEntry.getValue().get(i).setActualPrice(studentStudentPaymentMapEntry.getValue().get(i).getExpectPrice());
-					totalActualAmount=totalActualAmount.subtract(studentStudentPaymentMapEntry.getValue().get(i).getExpectPrice());
+			for (CourseScheduleStudentPayment courseScheduleStudentPayment : studentStudentPaymentMapEntry.getValue()) {
+				if(totalActualAmount.compareTo(courseScheduleStudentPayment.getExpectPrice())>=0){
+					courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
+					totalActualAmount=totalActualAmount.subtract(courseScheduleStudentPayment.getExpectPrice());
 				}else{
-					studentStudentPaymentMapEntry.getValue().get(i).setActualPrice(totalActualAmount);
+					courseScheduleStudentPayment.setActualPrice(totalActualAmount);
 					totalActualAmount=BigDecimal.ZERO;
 				}
-				updateStudentPayments.add(studentStudentPaymentMapEntry.getValue().get(i));
-				if(i==studentStudentPaymentMapEntry.getValue().size()-1){
-					studentStudentPaymentMapEntry.getValue().get(0).setActualPrice(studentStudentPaymentMapEntry.getValue().get(0).getExpectPrice().add(totalActualAmount));
-				}
+				updateStudentPayments.add(courseScheduleStudentPayment);
 			}
 		}
 

+ 11 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -21,6 +21,7 @@ import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
@@ -176,7 +177,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					if (defaultUnitPrice == null) {
 						throw new BizException("请先设置分部课程类型单价");
 					}
-					if (courseSettings.getCourseCurrentPrice().divide(new BigDecimal(courseSettings.getCourseTotalMinuties()))
+					if (courseSettings.getCourseCurrentPrice().divide(new BigDecimal(courseSettings.getCourseTotalMinuties()), CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN)
 							.compareTo(defaultUnitPrice.getUnitPrice()) != 0) {
 						musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
 						break;
@@ -184,7 +185,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				}
 			}
 		}
-
+		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+			musicGroupPaymentCalender.setPayUserType(STUDENT);
+			musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
+			musicGroupPaymentCalender.setExpectNum(1);
+		}
 		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
 			if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.OPEN);
@@ -193,13 +198,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			}else {
 				musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 			}
-			//如果是进行中加学生
-			if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-				musicGroupPaymentCalender.setPayUserType(STUDENT);
-				musicGroupPaymentCalender.setIsGiveMusicNetwork(false);
-				musicGroupPaymentCalender.setExpectNum(1);
-				addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettingsList);
-			}
 		}else {
             Set<Integer> roleIds = new HashSet<>(1);
             roleIds.add(SysUserRole.ADMINISTRATOR);
@@ -227,11 +225,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				musicGroupDao.update(musicGroup);
 			}
 		}
-
-		musicGroupPaymentCalender.setExpectNum(0);
 		// 设置批次号
 		musicGroupPaymentCalender.setBatchNo(idGeneratorService.generatorId() + "");
 		musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
+		//如果是进行中加学生
+		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+			addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettingsList);
+		}
 
 		if (musicGroupPaymentCalenderCourseSettingsList.size() > 0) {
 			MusicGroupOrganizationCourseSettings courseSettings = musicGroupOrganizationCourseSettingsDao.get(musicGroupPaymentCalender

+ 1 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1758,9 +1758,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
             studentPaymentOrder.setPaymentChannel("BALANCE");
             if (userCashAccount.getBalance().subtract(amount).doubleValue() >= 0) {
-                studentPaymentRouteOrderService.addRouteOrder(orderNo, organId, amount);
-
                 // 更新订单信息
+                balance = amount;
                 studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
                 studentPaymentOrder.setBalancePaymentAmount(amount);
                 studentPaymentOrder.setActualAmount(new BigDecimal(0));

+ 25 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -55,8 +55,8 @@ public class PayServiceImpl implements PayService {
         }
 
         //根据费用类型
-        if(routeScaleDtos == null){
-            routeScaleDtos = getTypeRouteChannel(organId, orderNo, amount);
+        if (routeScaleDtos == null) {
+            routeScaleDtos = getTypeRouteChannel(organId, orderNo, amount, balanceAmount);
         }
 
         //根据金额获取分润
@@ -313,9 +313,20 @@ public class PayServiceImpl implements PayService {
             if (routeScaleDto.getPayType().equals(PaymentChannelEnum.YQPAY)) {
                 routingAmount = yqAmount;
             }
-            BigDecimal routingFee = routingAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
-            BigDecimal routeBalanceAmount = balanceAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
-            BigDecimal routingMoney = amount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+
+            BigDecimal routingFee = null;
+            BigDecimal routeBalanceAmount = null;
+            BigDecimal routingMoney = null;
+
+            if (routeScaleDto.getFeeType() == null) {
+                routingFee = routingAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                routeBalanceAmount = balanceAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+                routingMoney = amount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
+            } else {
+                routingFee = routeScaleDto.getAmount();
+                routeBalanceAmount = routeScaleDto.getBalance();
+                routingMoney = routeScaleDto.getAmount();
+            }
             if (i == routeScaleDtos.size()) {
                 routingFee = routingAmount.subtract(hasRouteAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
                 routeBalanceAmount = balanceAmount.subtract(hasRouteBalanceAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
@@ -378,7 +389,7 @@ public class PayServiceImpl implements PayService {
      * @param amount
      * @return
      */
-    private List<RouteScaleDto> getTypeRouteChannel(Integer organId, String orderNo, BigDecimal amount) {
+    private List<RouteScaleDto> getTypeRouteChannel(Integer organId, String orderNo, BigDecimal amount, BigDecimal balanceAmount) {
         SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(organId);
         if (paymentConfig == null || StringUtils.isBlank(paymentConfig.getTypeRouteScale())) {
             return null;
@@ -389,8 +400,8 @@ public class PayServiceImpl implements PayService {
         List<Integer> organIds = routeScaleDtos.stream().map(RouteScaleDto::getOrganId).collect(Collectors.toList());
         List<SysPaymentConfig> paymentConfigByOrganIds = sysPaymentConfigService.findPaymentConfigByOrganIds(organIds);
 
-        BigDecimal sellActualAmount = sellOrderService.getSellActualAmount(orderNo);
-        if (sellActualAmount == null) {
+        Map<String, BigDecimal> sellAmount = sellOrderService.getSellAmount(orderNo);
+        if (sellAmount == null) {
             return null;
         }
 
@@ -400,9 +411,11 @@ public class PayServiceImpl implements PayService {
             RouteScaleDto routeScaleDto = iterator.next();
             routeScaleDto.setPayType(paymentConfig.getPayType());
             if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SELL)) {
-                routeScaleDto.setAmount(sellActualAmount);
+                routeScaleDto.setAmount(sellAmount.get("actualAmount"));
+                routeScaleDto.setBalance(sellAmount.get("balance"));
             } else {
-                routeScaleDto.setAmount(amount.subtract(sellActualAmount));
+                routeScaleDto.setAmount(amount.subtract(sellAmount.get("actualAmount")));
+                routeScaleDto.setBalance(balanceAmount.subtract(sellAmount.get("balance")));
             }
 
             if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
@@ -412,6 +425,8 @@ public class PayServiceImpl implements PayService {
             if (!hasFeeFlag && routeScaleDto.getAmount().compareTo(amount.divide(new BigDecimal(2), 2, BigDecimal.ROUND_DOWN)) >= 0) {
                 routeScaleDto.setFeeFlag("Y");
                 hasFeeFlag = true;
+            }else {
+                routeScaleDto.setFeeFlag("N");
             }
 
             for (SysPaymentConfig paymentConfigByOrganId : paymentConfigByOrganIds) {

+ 21 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -343,7 +343,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     }
 
     @Override
-    public BigDecimal getSellActualAmount(String orderNo) {
+    public Map<String, BigDecimal> getSellAmount(String orderNo) {
         StudentPaymentOrder order = studentPaymentOrderDao.findOrderByOrderNo(orderNo);
         if (order == null) {
             return null;
@@ -356,9 +356,12 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 return null;
             }
         }
+        Map<String, BigDecimal> sellAmount = new HashMap<>();
         //乐器销售,声部更改
         if (order.getType().equals(OrderTypeEnum.GOODS_SELL) || order.getType().equals(OrderTypeEnum.SUBJECT_CHANGE)) {
-            return order.getActualAmount();
+            sellAmount.put("actualAmount", order.getActualAmount());
+            sellAmount.put("balance", order.getBalancePaymentAmount() == null ? BigDecimal.ZERO : order.getBalancePaymentAmount());
+            return sellAmount;
         }
 
         //乐器维修
@@ -366,12 +369,16 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             StudentRepair repairInfo = studentRepairDao.getRepairInfo(Integer.parseInt(order.getMusicGroupId()));
 
             if (StringUtils.isBlank(repairInfo.getGoodsJson())) {
-                return BigDecimal.ZERO;
+                sellAmount.put("actualAmount", BigDecimal.ZERO);
+                sellAmount.put("balance", BigDecimal.ZERO);
+                return sellAmount;
             }
             List<Goods> goodies = JSONObject.parseArray(repairInfo.getGoodsJson(), Goods.class);
             List<Integer> goodsIds = goodies.stream().map(Goods::getId).collect(Collectors.toList());
             if (goodsIds.size() <= 0) {
-                return BigDecimal.ZERO;
+                sellAmount.put("actualAmount", BigDecimal.ZERO);
+                sellAmount.put("balance", BigDecimal.ZERO);
+                return sellAmount;
             }
 
             BigDecimal goodsTotalPrice = BigDecimal.ZERO;
@@ -387,7 +394,9 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             }
             BigDecimal balance = order.getBalancePaymentAmount() == null ? BigDecimal.ZERO : order.getBalancePaymentAmount();
             BigDecimal goodsTotalBalance = goodsTotalPrice.multiply(balance).divide(order.getExpectAmount(), 2, BigDecimal.ROUND_HALF_UP);
-            return goodsTotalPrice.subtract(goodsTotalBalance);
+            sellAmount.put("actualAmount", goodsTotalPrice.subtract(goodsTotalBalance));
+            sellAmount.put("balance", goodsTotalBalance);
+            return sellAmount;
         }
 
         //乐团报名
@@ -401,10 +410,15 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             BigDecimal detailTotalPrice = orderDetails.stream().map(StudentPaymentOrderDetail::getPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
             //商品销售占的余额
             BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_HALF_UP);
-            return detailTotalPrice.subtract(detailTotalBalance);
+
+            sellAmount.put("actualAmount", detailTotalPrice.subtract(detailTotalBalance));
+            sellAmount.put("balance", detailTotalBalance);
+            return sellAmount;
         }
 
-        return BigDecimal.ZERO;
+        sellAmount.put("actualAmount", BigDecimal.ZERO);
+        sellAmount.put("balance", BigDecimal.ZERO);
+        return sellAmount;
     }
 
 }

+ 13 - 15
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -41,7 +41,7 @@
             AS ID FROM DUAL </selectKey> -->
         INSERT INTO music_group_payment_student_course_detail
         (id_,music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,course_type_,total_course_minutes_,used_course_minutes_,create_time_,update_time_)
-        VALUES(#{id},#{musicGroupPaymentCalenderId},#{musicGroupPaymentCalenderDetailId},#{userId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{totalCourseMinutes},#{usedCourseMinutes},#{createTime},#{updateTime})
+        VALUES(#{id},#{musicGroupPaymentCalenderId},#{musicGroupPaymentCalenderDetailId},#{userId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{totalCourseMinutes},#{usedCourseMinutes},NOW(),NOW())
     </insert>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
@@ -50,7 +50,7 @@
         (id_,music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,course_type_,total_course_minutes_,used_course_minutes_,create_time_,update_time_)
         VALUES
         <foreach collection="list" item="item" separator=",">
-            (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.createTime},#{item.updateTime})
+            (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.totalCourseMinutes},#{item.usedCourseMinutes},NOW(),NOW())
         </foreach>
     </insert>
 
@@ -74,18 +74,13 @@
             <if test="id != null">
                 id_ = #{id},
             </if>
-            <if test="updateTime != null">
-                update_time_ = #{updateTime},
-            </if>
             <if test="musicGroupPaymentCalenderId != null">
                 music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
             </if>
             <if test="courseType != null">
                 course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
-            <if test="createTime != null">
-                create_time_ = #{createTime},
-            </if>
+                update_time_ = #{updateTime}
         </set>
         WHERE id_ = #{id}
     </update>
@@ -110,13 +105,16 @@
         FROM music_group_payment_student_course_detail
     </select>
     <select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
-        SELECT *
-        FROM music_group_payment_student_course_detail
-        WHERE user_id_ = #{studentId}
-          AND course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-          AND total_course_minutes_ &gt;= #{courseMinutes}
-          AND used_course_minutes_ &lt;= 0
-        ORDER BY id_
+        SELECT mgpscd.*
+        FROM music_group_payment_student_course_detail mgpscd
+        LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
+        WHERE
+          mgpc.music_group_id_ = #{musicGroupId}
+          AND mgpscd.user_id_ = #{studentId}
+          AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND mgpscd.total_course_minutes_ &gt;= #{courseMinutes}
+          AND mgpscd.used_course_minutes_ &lt;= 0
+        ORDER BY mgpscd.id_
         LIMIT 1;
     </select>
     <select id="getUnUseWithStudents" resultMap="MusicGroupPaymentStudentCourseDetail">

+ 0 - 1
mec-web/src/main/java/com/ym/mec/web/controller/SysPaymentConfigController.java

@@ -6,7 +6,6 @@ import com.ym.mec.biz.dal.page.SysPaymentConfigQueryInfo;
 import com.ym.mec.biz.service.SysPaymentConfigService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
-import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;