|
|
@@ -47,6 +47,7 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.SignInStatusEnum.*;
|
|
|
+import static java.math.BigDecimal.ROUND_DOWN;
|
|
|
|
|
|
@Service
|
|
|
public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGroup> implements PracticeGroupService {
|
|
|
@@ -143,6 +144,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
private StudentService studentService;
|
|
|
@Autowired
|
|
|
private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
|
|
|
+ @Autowired
|
|
|
+ private ImGroupService imGroupService;
|
|
|
+ @Autowired
|
|
|
+ private ImGroupMemberService imGroupMemberService;
|
|
|
|
|
|
private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
|
|
|
|
|
|
@@ -3058,11 +3065,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(teacherDefaultSalary == null){
|
|
|
throw new BizException("请设置教师课酬");
|
|
|
}
|
|
|
- BigDecimal studentSingleCourseCost = amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal studentSingleCourseCost = amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
|
|
|
BigDecimal oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
|
|
|
BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
|
|
|
- BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
|
|
|
for (CourseSchedule courseSchedule : practiceCourses) {
|
|
|
//课程与老师薪水表
|
|
|
@@ -3506,11 +3513,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(teacherDefaultSalary == null){
|
|
|
throw new BizException("请设置教师课酬");
|
|
|
}
|
|
|
- BigDecimal studentSingleCourseCost = amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal studentSingleCourseCost = amount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
|
|
|
BigDecimal oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
|
|
|
BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
|
|
|
- BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ BigDecimal studentSingleCourseOriginalCost=originalAmount.divide(new BigDecimal(practiceCourses.size()), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
|
|
|
for (CourseSchedule courseSchedule : practiceCourses) {
|
|
|
//课程与老师薪水表
|
|
|
@@ -3696,6 +3703,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
return;
|
|
|
}
|
|
|
PracticeGroup practiceGroup = practiceGroupDao.get(Long.valueOf(order.getMusicGroupId()));
|
|
|
+ ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(order.getMusicGroupId(), GroupType.PRACTICE.getCode());
|
|
|
if (order.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
Integer activityUserMapperId = studentPaymentOrderService.activityGive(practiceGroup.getVipGroupActivityId(),
|
|
|
order.getUserId(),
|
|
|
@@ -3703,7 +3711,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
null,
|
|
|
practiceGroup.getId(),order.getActivityBuyNum());
|
|
|
practiceGroup.setActivityUserMapperId(activityUserMapperId);
|
|
|
- courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(), GroupType.PRACTICE, 0);
|
|
|
+ if(classGroup.getDelFlag() == 1){
|
|
|
+ updatePracticeGroupStudentNumAndStatus(practiceGroup, classGroup,order);
|
|
|
+ }else {
|
|
|
+ courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(), GroupType.PRACTICE, 0);
|
|
|
+ }
|
|
|
} else {
|
|
|
if (Objects.nonNull(order.getBalancePaymentAmount()) && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
|
|
|
@@ -3760,7 +3772,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
sysCouponCodeService.quit(order.getCouponCodeId());
|
|
|
return;
|
|
|
}
|
|
|
- ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(order.getMusicGroupId(), GroupType.PRACTICE.getCode());
|
|
|
|
|
|
practiceGroup.setGroupStatus(GroupStatusEnum.NORMAL);
|
|
|
practiceGroupDao.update(practiceGroup);
|
|
|
@@ -3776,7 +3787,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error(MessageFormatter.arrayFormat("网管课[{}]购买协议错误:{}", order.getMusicGroupId(), e.getMessage()), e);
|
|
|
}
|
|
|
-
|
|
|
try {
|
|
|
teacherCourseRewardService.addConvertReward(practiceGroup.getStudentId(), practiceGroup.getUserId());
|
|
|
} catch (Exception e) {
|
|
|
@@ -3842,6 +3852,67 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
imUserFriendService.refreshGroupImUserFriend(practiceGroup.getId().toString(),GroupType.PRACTICE);
|
|
|
}
|
|
|
|
|
|
+ private void updatePracticeGroupStudentNumAndStatus(PracticeGroup practiceGroup, ClassGroup classGroup,StudentPaymentOrder order) {
|
|
|
+ classGroup.setStudentNum(1);
|
|
|
+ classGroup.setDelFlag(0);
|
|
|
+ classGroupDao.update(classGroup);
|
|
|
+
|
|
|
+ List<CourseSchedule> courseSchedules = JSON.parseArray(practiceGroup.getCourseScheduleJson(),CourseSchedule.class);
|
|
|
+ int courseNum = courseScheduleDao.countVipGroupCourses(practiceGroup.getId().intValue(),"PRACTICE");
|
|
|
+ if(courseNum == 0){
|
|
|
+ courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
+ }
|
|
|
+
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setMusicGroupId(practiceGroup.getId().toString());
|
|
|
+ classGroupStudentMapper.setUserId(practiceGroup.getStudentId());
|
|
|
+ classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+
|
|
|
+ List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
+
|
|
|
+ PracticeGroupSellPrice practiceGroupSellPrice = practiceGroupSellPriceDao.get(practiceGroup.getOrganId());
|
|
|
+ BigDecimal singleClassMinutesPrice = practiceGroupSellPrice.getSingleClassMinutesPrice();
|
|
|
+ //实际支付金额,去除优惠券
|
|
|
+ BigDecimal actualPrice = order.getExpectAmount().subtract(order.getCouponRemitFee());
|
|
|
+ BigDecimal divide = actualPrice.divide(new BigDecimal(courseSchedules.size()), ROUND_DOWN);
|
|
|
+ BigDecimal firstAmount = actualPrice.subtract(divide.multiply(new BigDecimal(courseSchedules.size()))).add(divide);
|
|
|
+
|
|
|
+ for (int i = 0; i < courseSchedules.size(); i++) {
|
|
|
+ CourseSchedule courseSchedule = courseSchedules.get(i);
|
|
|
+ //学生缴费记录
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(practiceGroup.getId().toString());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setUserId(practiceGroup.getStudentId());
|
|
|
+ if(i == 0){
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(firstAmount);
|
|
|
+ courseScheduleStudentPayment.setActualPrice(firstAmount);
|
|
|
+ }else {
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(divide);
|
|
|
+ courseScheduleStudentPayment.setActualPrice(divide);
|
|
|
+ }
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(singleClassMinutesPrice);
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+
|
|
|
+ //教师签到记录
|
|
|
+ TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
|
+ teacherAttendance.setMusicGroupId(practiceGroup.getId().toString());
|
|
|
+ teacherAttendance.setTeacherId(practiceGroup.getStudentId());
|
|
|
+ teacherAttendance.setClassGroupId(classGroup.getId());
|
|
|
+ teacherAttendance.setGroupType(GroupType.PRACTICE);
|
|
|
+ teacherAttendance.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ teacherAttendances.add(teacherAttendance);
|
|
|
+ }
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
+ teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public void activityOrderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
|
@@ -4120,18 +4191,21 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(Objects.nonNull(practiceGroup.getType())&&(PracticeGroupType.CARE_PACKAGE.equals(practiceGroup.getType())||PracticeGroupType.COME_ON_PACKAGE.equals(practiceGroup.getType()))){
|
|
|
practiceCourseMinutes = 50;
|
|
|
}
|
|
|
- JSONArray coursesArry = new JSONArray();
|
|
|
- JSONObject courseJson = JSON.parseObject(practiceGroup.getDrillTimesJson());
|
|
|
- for (String weekNumStr : courseJson.keySet()) {
|
|
|
- JSONObject newCourseJson = new JSONObject();
|
|
|
- newCourseJson.put("weekName", DateUtil.weekNumNormalWeekNameMap.get(Integer.parseInt(weekNumStr)));
|
|
|
- LocalTime courseStartTime = LocalTime.parse(courseJson.getString(weekNumStr), DateUtil.timeFormatter);
|
|
|
- LocalTime courseEndTime = courseStartTime.plusMinutes(practiceCourseMinutes);
|
|
|
- newCourseJson.put("startTime", courseStartTime.format(DateUtil.timeFormatter));
|
|
|
- newCourseJson.put("endTime", courseEndTime.format(DateUtil.timeFormatter));
|
|
|
- coursesArry.add(newCourseJson);
|
|
|
- }
|
|
|
- practiceBuyResult.setDrillTimesJson(coursesArry.toJSONString());
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(practiceGroup.getDrillTimesJson())){
|
|
|
+ JSONArray coursesArry = new JSONArray();
|
|
|
+ JSONObject courseJson = JSON.parseObject(practiceGroup.getDrillTimesJson());
|
|
|
+ for (String weekNumStr : courseJson.keySet()) {
|
|
|
+ JSONObject newCourseJson = new JSONObject();
|
|
|
+ newCourseJson.put("weekName", DateUtil.weekNumNormalWeekNameMap.get(Integer.parseInt(weekNumStr)));
|
|
|
+ LocalTime courseStartTime = LocalTime.parse(courseJson.getString(weekNumStr), DateUtil.timeFormatter);
|
|
|
+ LocalTime courseEndTime = courseStartTime.plusMinutes(practiceCourseMinutes);
|
|
|
+ newCourseJson.put("startTime", courseStartTime.format(DateUtil.timeFormatter));
|
|
|
+ newCourseJson.put("endTime", courseEndTime.format(DateUtil.timeFormatter));
|
|
|
+ coursesArry.add(newCourseJson);
|
|
|
+ }
|
|
|
+ practiceBuyResult.setDrillTimesJson(coursesArry.toJSONString());
|
|
|
+ }
|
|
|
practiceBuyResult.setCourseStartTime(practiceGroup.getCoursesStartDate());
|
|
|
practiceBuyResult.setCourseEndTime(practiceGroup.getCoursesExpireDate());
|
|
|
Teacher teacher = teacherDao.get(practiceGroup.getUserId());
|
|
|
@@ -4530,7 +4604,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
throw new BizException("课酬结算方案错误");
|
|
|
}
|
|
|
salarySettlement = vipGroupSalarySettlementDto.getPracticeSalarySettlement();
|
|
|
- totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
}
|
|
|
//教师课酬线上单课酬计算
|
|
|
teacherDefaultSalary = teacherDefaultPracticeGroupSalary.getMainTeacherSalary();
|
|
|
@@ -4685,7 +4759,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
classGroupDao.insert(classGroup);
|
|
|
|
|
|
//创建班级老师关联记录
|
|
|
- ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
|
|
|
+ ClassGroupTeacherMapper classGroupTeacherMapper = new ClassGroupTeacherMapper();
|
|
|
classGroupTeacherMapper.setMusicGroupId(applyBaseInfoDto.getId().toString());
|
|
|
classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
|
classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
@@ -5224,7 +5298,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
default:
|
|
|
throw new BizException("错误的会员周期");
|
|
|
}
|
|
|
- activityFee = activityFee.multiply(activity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
+ activityFee = activityFee.multiply(activity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
}
|
|
|
//计算订单金额
|
|
|
StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(), activityFee, true);
|