|
@@ -3672,65 +3672,64 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
Map<Integer, Integer> studentCLassMap = new HashMap<>();
|
|
|
List<Map<Integer, BigDecimal>> surplusCourseFeeMapList = new ArrayList<>();
|
|
|
List<Map<String,String>> classGroupStudents = (List<Map<String,String>>)JSON.parse(classGroupStudentMap);
|
|
|
+ //学员剩余课程价值
|
|
|
+ Map<Integer,BigDecimal> classGroupTotalPrice = new HashMap<>();
|
|
|
+ //主班剩余课程价值
|
|
|
+ Map<String, BigDecimal> masterTotalPriceMap = getMasterTotalPriceMap(masterClassGroupId);
|
|
|
+ BigDecimal masterTotalPrice = getMasterTotalPrice(masterClassGroupId);
|
|
|
for (Map<String, String> classGroupStudent : classGroupStudents) {
|
|
|
for (String integer : classGroupStudent.keySet()) {
|
|
|
//获取学员剩余课程费用
|
|
|
surplusCourseFeeMapList.addAll(studentRegistrationDao.querySurplusCourseFeeByClassGroupId(Integer.parseInt(integer),classGroupStudent.get(integer)));
|
|
|
String[] s = classGroupStudent.get(integer).split(",");
|
|
|
for (String s1 : s) {
|
|
|
+ classGroupTotalPrice.put(Integer.parseInt(s1),courseScheduleStudentPaymentDao.querySubCoursePriceMap(Integer.parseInt(s1),Integer.parseInt(integer),null));
|
|
|
studentCLassMap.put(Integer.parseInt(s1),Integer.parseInt(integer));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//学员剩余课程费用
|
|
|
Map<Integer, BigDecimal> surplusCourseFeeMap = MapUtil.convertIntegerMap(surplusCourseFeeMapList);
|
|
|
- //获取分布默认的课程类型单价
|
|
|
- MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
|
- Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
|
|
|
- Set<String> masterKeySet = masterMap.keySet();
|
|
|
- //计算主班课程类型剩余价值
|
|
|
- Map<String, BigDecimal> masterTotalPriceMap = new HashMap<>(masterKeySet.size());
|
|
|
- //学员缴费项目列表
|
|
|
+ List<String> courseTypes = new ArrayList(masterMap.keySet());
|
|
|
List<MusicGroupPaymentCalenderStudentDetail> musicGroupPaymentCalenderStudentDetails = new ArrayList<>();
|
|
|
- for (String s : masterKeySet) {
|
|
|
- BigDecimal unitPrice = unitPriceMap.get(s);
|
|
|
- if (unitPrice == null) {
|
|
|
- throw new BizException("分部默认课程类型单价不存在,请设置");
|
|
|
- }
|
|
|
- BigDecimal courseTime = masterMap.get(s);
|
|
|
- //获取主班剩余课程价值,按分部默认单价计算
|
|
|
- //总价四舍五入取整
|
|
|
- BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
- masterTotalPriceMap.put(s,totalPrice);
|
|
|
- //课程余额转移
|
|
|
- for (Integer studentId : studentCLassMap.keySet()) {
|
|
|
- //学员剩余课程余额
|
|
|
- BigDecimal bigDecimal = surplusCourseFeeMap.get(studentId);
|
|
|
- //创建学员缴费项目
|
|
|
+ for (Integer studentId : studentCLassMap.keySet()) {
|
|
|
+ //学员剩余课程价值
|
|
|
+ BigDecimal totalPrice = classGroupTotalPrice.get(studentId);
|
|
|
+ if(totalPrice == null){
|
|
|
+ totalPrice = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ //学员剩余课程余额
|
|
|
+ BigDecimal bigDecimal = surplusCourseFeeMap.get(studentId);
|
|
|
+ if(bigDecimal == null){
|
|
|
+ bigDecimal = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ //学员可带走的价值
|
|
|
+ BigDecimal subCourseAmount;
|
|
|
+ if(masterTotalPrice.doubleValue() >= totalPrice.doubleValue()){
|
|
|
+ subCourseAmount = totalPrice;
|
|
|
+ }else {
|
|
|
+ subCourseAmount = masterTotalPrice;
|
|
|
+ }
|
|
|
+ if(subCourseAmount.doubleValue() >= bigDecimal.doubleValue()){
|
|
|
+ subCourseAmount = bigDecimal;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < courseTypes.size(); i++) {
|
|
|
+ BigDecimal masterPrice = masterTotalPriceMap.get(courseTypes.get(i));
|
|
|
MusicGroupPaymentCalenderStudentDetail calenderDto = new MusicGroupPaymentCalenderStudentDetail();
|
|
|
calenderDto.setClassGroupId(studentCLassMap.get(studentId));
|
|
|
- //如果剩余课程余额小于等于0
|
|
|
- if(bigDecimal.doubleValue() <= 0d){
|
|
|
- calenderDto.setCourseCurrentPrice(totalPrice);
|
|
|
- calenderDto.setCourseOriginalPrice(totalPrice);
|
|
|
+ if(subCourseAmount.doubleValue() >= masterPrice.doubleValue()){
|
|
|
+ calenderDto.setSubCourseAmount(masterPrice);
|
|
|
+ calenderDto.setCutAmount(masterPrice);
|
|
|
+ subCourseAmount = subCourseAmount.subtract(masterPrice);
|
|
|
}else {
|
|
|
- //如果剩余课程余额大于等于总价值,那么补交0元
|
|
|
- if(bigDecimal.doubleValue() >= totalPrice.doubleValue()){
|
|
|
- calenderDto.setCutAmount(totalPrice);
|
|
|
- calenderDto.setCourseCurrentPrice(BigDecimal.ZERO);
|
|
|
- calenderDto.setCourseOriginalPrice(BigDecimal.ZERO);
|
|
|
- }else {
|
|
|
- calenderDto.setCourseCurrentPrice(totalPrice.subtract(bigDecimal));
|
|
|
- calenderDto.setCutAmount(bigDecimal);
|
|
|
- calenderDto.setCourseOriginalPrice(totalPrice.subtract(bigDecimal));
|
|
|
- }
|
|
|
- //剩余课程余额减去主班对应课程类型总的课程价值,负数就是需要补交的金额
|
|
|
-// bigDecimal = bigDecimal.subtract(totalPrice);
|
|
|
- surplusCourseFeeMap.put(studentId,bigDecimal.subtract(totalPrice));
|
|
|
- }
|
|
|
- calenderDto.setCourseTime(courseTime.intValue());
|
|
|
- calenderDto.setCourseType(s);
|
|
|
-
|
|
|
+ calenderDto.setSubCourseAmount(subCourseAmount);
|
|
|
+ calenderDto.setCutAmount(subCourseAmount);
|
|
|
+ subCourseAmount = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ calenderDto.setCourseTime(masterMap.get(courseTypes.get(i)).intValue());
|
|
|
+ calenderDto.setMasterSubCoursePrice(masterPrice);
|
|
|
+ calenderDto.setCourseCurrentPrice(masterPrice.subtract(calenderDto.getCutAmount()));
|
|
|
+ calenderDto.setCourseType(courseTypes.get(i));
|
|
|
calenderDto.setPhone(phoneMaps.get(studentId));
|
|
|
calenderDto.setUserId(studentId);
|
|
|
calenderDto.setUsername(userNames.get(studentId));
|
|
@@ -3745,8 +3744,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
public BigDecimal getMasterTotalPrice(Integer masterClassGroupId) {
|
|
|
//获取主班剩余时长
|
|
|
Map<String, BigDecimal> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(masterClassGroupId));
|
|
|
- if(masterMap.size() <= 0){
|
|
|
- throw new BizException("所选主班没有剩余课程,请重新选择");
|
|
|
+ if(masterMap.size() == 0){
|
|
|
+ throw new BizException("操作失败:所选主班没有剩余时长");
|
|
|
}
|
|
|
//获取分布默认的课程类型单价
|
|
|
MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
@@ -3760,6 +3759,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
throw new BizException("分部默认课程类型单价不存在,请设置");
|
|
|
}
|
|
|
BigDecimal courseTime = masterMap.get(s);
|
|
|
+ if(courseTime == null){
|
|
|
+ courseTime = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
//获取主班剩余课程价值,按分部默认单价计算
|
|
|
//总价四舍五入取整
|
|
|
BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
@@ -3768,6 +3770,34 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
|
|
|
return masterTotalPrice;
|
|
|
}
|
|
|
|
|
|
+ public Map<String,BigDecimal> getMasterTotalPriceMap(Integer masterClassGroupId) {
|
|
|
+ //获取主班剩余时长
|
|
|
+ Map<String, BigDecimal> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(masterClassGroupId));
|
|
|
+ if(masterMap.size() == 0){
|
|
|
+ throw new BizException("操作失败:所选主班没有剩余时长");
|
|
|
+ }
|
|
|
+ Map<String,BigDecimal> resultMap = new HashMap<>();
|
|
|
+ //获取分布默认的课程类型单价
|
|
|
+ MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
|
|
|
+ Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
|
|
|
+ Set<String> masterKeySet = masterMap.keySet();
|
|
|
+ //计算主班课程类型剩余价值
|
|
|
+ for (String s : masterKeySet) {
|
|
|
+ BigDecimal unitPrice = unitPriceMap.get(s);
|
|
|
+ if (unitPrice == null) {
|
|
|
+ throw new BizException("分部默认课程类型单价不存在,请设置");
|
|
|
+ }
|
|
|
+ BigDecimal courseTime = masterMap.get(s);
|
|
|
+ if(courseTime == null){
|
|
|
+ courseTime = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ //获取主班剩余课程价值,按分部默认单价计算
|
|
|
+ BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
+ resultMap.put(s,totalPrice);
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Long> querySubCourseTime(Integer classGroupId) {
|
|
|
return MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
|