|
@@ -47,6 +47,7 @@ import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.SignInStatusEnum.*;
|
|
import static com.ym.mec.biz.dal.enums.SignInStatusEnum.*;
|
|
|
|
+import static java.math.BigDecimal.ROUND_DOWN;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGroup> implements PracticeGroupService {
|
|
public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGroup> implements PracticeGroupService {
|
|
@@ -3064,11 +3065,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
if(teacherDefaultSalary == null){
|
|
if(teacherDefaultSalary == null){
|
|
throw new BizException("请设置教师课酬");
|
|
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 oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
|
|
BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
|
|
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) {
|
|
for (CourseSchedule courseSchedule : practiceCourses) {
|
|
//课程与老师薪水表
|
|
//课程与老师薪水表
|
|
@@ -3512,11 +3513,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
if(teacherDefaultSalary == null){
|
|
if(teacherDefaultSalary == null){
|
|
throw new BizException("请设置教师课酬");
|
|
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 oneMonthOriginalPrice=practiceGroupBuyParams.getDrillTimesOnWeek()==1?practiceGroupSellPrice.getOnceOriginalPrice():practiceGroupSellPrice.getTwiceOriginalPrice();
|
|
BigDecimal originalAmount = oneMonthOriginalPrice.multiply(new BigDecimal(practiceGroupBuyParams.getBuyMonths()));
|
|
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) {
|
|
for (CourseSchedule courseSchedule : practiceCourses) {
|
|
//课程与老师薪水表
|
|
//课程与老师薪水表
|
|
@@ -3711,9 +3712,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
practiceGroup.getId(),order.getActivityBuyNum());
|
|
practiceGroup.getId(),order.getActivityBuyNum());
|
|
practiceGroup.setActivityUserMapperId(activityUserMapperId);
|
|
practiceGroup.setActivityUserMapperId(activityUserMapperId);
|
|
if(classGroup.getDelFlag() == 1){
|
|
if(classGroup.getDelFlag() == 1){
|
|
- updatePracticeGroupStudentNumAndStatus(practiceGroup, classGroup);
|
|
|
|
|
|
+ updatePracticeGroupStudentNumAndStatus(practiceGroup, classGroup,order);
|
|
|
|
+ }else {
|
|
|
|
+ courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(), GroupType.PRACTICE, 0);
|
|
}
|
|
}
|
|
- courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(), GroupType.PRACTICE, 0);
|
|
|
|
} else {
|
|
} else {
|
|
if (Objects.nonNull(order.getBalancePaymentAmount()) && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
if (Objects.nonNull(order.getBalancePaymentAmount()) && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
|
|
sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
|
|
@@ -3785,7 +3787,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
LOGGER.error(MessageFormatter.arrayFormat("网管课[{}]购买协议错误:{}", order.getMusicGroupId(), e.getMessage()), e);
|
|
LOGGER.error(MessageFormatter.arrayFormat("网管课[{}]购买协议错误:{}", order.getMusicGroupId(), e.getMessage()), e);
|
|
}
|
|
}
|
|
-
|
|
|
|
try {
|
|
try {
|
|
teacherCourseRewardService.addConvertReward(practiceGroup.getStudentId(), practiceGroup.getUserId());
|
|
teacherCourseRewardService.addConvertReward(practiceGroup.getStudentId(), practiceGroup.getUserId());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -3851,7 +3852,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
imUserFriendService.refreshGroupImUserFriend(practiceGroup.getId().toString(),GroupType.PRACTICE);
|
|
imUserFriendService.refreshGroupImUserFriend(practiceGroup.getId().toString(),GroupType.PRACTICE);
|
|
}
|
|
}
|
|
|
|
|
|
- private void updatePracticeGroupStudentNumAndStatus(PracticeGroup practiceGroup, ClassGroup classGroup) {
|
|
|
|
|
|
+ private void updatePracticeGroupStudentNumAndStatus(PracticeGroup practiceGroup, ClassGroup classGroup,StudentPaymentOrder order) {
|
|
classGroup.setStudentNum(1);
|
|
classGroup.setStudentNum(1);
|
|
classGroup.setDelFlag(0);
|
|
classGroup.setDelFlag(0);
|
|
classGroupDao.update(classGroup);
|
|
classGroupDao.update(classGroup);
|
|
@@ -3861,6 +3862,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
if(courseNum == 0){
|
|
if(courseNum == 0){
|
|
courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
}
|
|
}
|
|
|
|
+
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
|
|
classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
|
|
@@ -3868,77 +3870,47 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
classGroupStudentMapper.setMusicGroupId(practiceGroup.getId().toString());
|
|
classGroupStudentMapper.setMusicGroupId(practiceGroup.getId().toString());
|
|
classGroupStudentMapper.setUserId(practiceGroup.getStudentId());
|
|
classGroupStudentMapper.setUserId(practiceGroup.getStudentId());
|
|
classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
|
+
|
|
|
|
+ List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
- courseSchedules.forEach(e->{
|
|
|
|
- CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
|
- courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
|
|
|
|
- courseScheduleStudentPayment.setMusicGroupId(practiceGroup.getId().toString());
|
|
|
|
- courseScheduleStudentPayment.setCourseScheduleId(e.getId());
|
|
|
|
- courseScheduleStudentPayment.setUserId(practiceGroup.getStudentId());
|
|
|
|
- courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
|
|
|
|
- courseScheduleStudentPayment.setActualPrice(BigDecimal.ZERO);
|
|
|
|
- courseScheduleStudentPayment.setOriginalPrice(BigDecimal.ZERO);
|
|
|
|
- courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
|
- courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
|
- });
|
|
|
|
- for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
|
- //课程与老师薪水表
|
|
|
|
- CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
|
- courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
|
- courseScheduleTeacherSalary.setGroupType(GroupType.PRACTICE);
|
|
|
|
- courseScheduleTeacherSalary.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
|
- courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
|
|
|
|
- courseScheduleTeacherSalary.setUserId(practiceGroupBuyParams.getUserId());
|
|
|
|
- courseScheduleTeacherSalary.setExpectSalary(teacherDefaultSalary);
|
|
|
|
- courseScheduleTeacherSalary.setCreateTime(now);
|
|
|
|
- courseScheduleTeacherSalary.setUpdateTime(now);
|
|
|
|
- courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
|
- courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);
|
|
|
|
|
|
|
|
|
|
+ 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 courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
|
|
courseScheduleStudentPayment.setGroupType(GroupType.PRACTICE);
|
|
- courseScheduleStudentPayment.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(practiceGroup.getId().toString());
|
|
courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
- courseScheduleStudentPayment.setUserId(practiceGroupBuyParams.getStudentId());
|
|
|
|
- courseScheduleStudentPayment.setExpectPrice(studentSingleCourseCost);
|
|
|
|
- courseScheduleStudentPayment.setActualPrice(studentSingleCourseCost);
|
|
|
|
- courseScheduleStudentPayment.setOriginalPrice(studentSingleCourseOriginalCost);
|
|
|
|
|
|
+ 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());
|
|
courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
- courseScheduleStudentPayment.setCreateTime(now);
|
|
|
|
- courseScheduleStudentPayment.setUpdateTime(now);
|
|
|
|
courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
|
|
|
//教师签到记录
|
|
//教师签到记录
|
|
TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
- teacherAttendance.setMusicGroupId(practiceGroupBuyParams.getId().toString());
|
|
|
|
- teacherAttendance.setTeacherId(practiceGroupBuyParams.getUserId());
|
|
|
|
|
|
+ teacherAttendance.setMusicGroupId(practiceGroup.getId().toString());
|
|
|
|
+ teacherAttendance.setTeacherId(practiceGroup.getStudentId());
|
|
teacherAttendance.setClassGroupId(classGroup.getId());
|
|
teacherAttendance.setClassGroupId(classGroup.getId());
|
|
teacherAttendance.setGroupType(GroupType.PRACTICE);
|
|
teacherAttendance.setGroupType(GroupType.PRACTICE);
|
|
teacherAttendance.setCourseScheduleId(courseSchedule.getId());
|
|
teacherAttendance.setCourseScheduleId(courseSchedule.getId());
|
|
- teacherAttendance.setCreateTime(now);
|
|
|
|
teacherAttendances.add(teacherAttendance);
|
|
teacherAttendances.add(teacherAttendance);
|
|
}
|
|
}
|
|
- courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
|
courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
-
|
|
|
|
- courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForPracticeGroup(practiceGroup.getId(),classGroupStudentMapper.getUserId());
|
|
|
|
- studentDao.updateStudentServiceTag(classGroupStudentMapper.getUserId(), null, YesOrNoEnum.YES.getCode());
|
|
|
|
-
|
|
|
|
- Map<Integer,String> userRoleMap = new HashMap<Integer, String>();
|
|
|
|
- userRoleMap.put(classGroupStudentMapper.getUserId(),null);
|
|
|
|
- if(Objects.nonNull(practiceGroup.getEducationalTeacherId())){
|
|
|
|
- userRoleMap.put(practiceGroup.getEducationalTeacherId(),"乐团主管");
|
|
|
|
- }
|
|
|
|
- userRoleMap.put(practiceGroup.getUserId(),"指导老师");
|
|
|
|
- try {
|
|
|
|
- imGroupService.create(classGroup.getId().longValue(), null, classGroup.getName(), classGroup.getName(), practiceGroup.getName(), null, null, GroupType.VIP.getCode());
|
|
|
|
- imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
|
|
|
|
- imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(),classGroup.getGroupType());
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -4632,7 +4604,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
throw new BizException("课酬结算方案错误");
|
|
throw new BizException("课酬结算方案错误");
|
|
}
|
|
}
|
|
salarySettlement = vipGroupSalarySettlementDto.getPracticeSalarySettlement();
|
|
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();
|
|
teacherDefaultSalary = teacherDefaultPracticeGroupSalary.getMainTeacherSalary();
|
|
@@ -5326,7 +5298,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
default:
|
|
default:
|
|
throw new BizException("错误的会员周期");
|
|
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);
|
|
StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(), activityFee, true);
|