Browse Source

Merge branch 'saas' of http://git.dayaedu.com/yonge/mec into 2022DoubleEleven

zouxuan 2 years ago
parent
commit
8edf4b4cfa

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

@@ -866,4 +866,6 @@ public interface ClassGroupDao extends BaseDAO<Integer, ClassGroup> {
     * @date 2022/9/29 18:14 
     */
     Boolean hasConvertCourse(@Param("classIdList") List<Integer> classIdList);
+
+    void addClassTimes(@Param("classGroupId") Integer classGroupId, @Param("num") Integer num);
 }

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

@@ -136,4 +136,6 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      * @return
      */
     int clearRemainCourseMinutesByMusicGroupId(String musicGroupId);
+
+    void deleteByUserIdAndCalenderId(@Param("userId") Integer userId, @Param("calenderIds") List<Long> calenderIds);
 }

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportCloudService.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.OperatingReportCloud;
 import com.ym.mec.common.service.BaseService;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -33,5 +34,7 @@ public interface OperatingReportCloudService extends BaseService<Integer, Operat
     */
     void updateSet(Long calenderId, List<Long> scheduleIdList);
 
+    public void updateSet(MusicGroupPaymentCalender calender,List<Long> scheduleIdList);
+
     void save(MusicGroupPaymentCalender musicGroupPaymentCalender);
 }

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

@@ -3765,18 +3765,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     }
 
     @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    @Transactional(rollbackFor = Exception.class)
     public boolean updateTotalClassTimes(Integer classGroupId, Integer num) {
-        ClassGroup classGroup = classGroupDao.lockClassGroup(classGroupId);
-        if (Objects.isNull(classGroup)) {
-            throw new BizException("班级不存在");
-        }
-        int totalClassTimes = classGroup.getTotalClassTimes() == null ? 0 : classGroup.getTotalClassTimes();
-        classGroup.setTotalClassTimes(totalClassTimes + num);
-        classGroup.setUpdateTime(new Date());
-
-        classGroupDao.update(classGroup);
-
+        classGroupDao.addClassTimes(classGroupId,num);
         return true;
     }
 

+ 21 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -391,8 +391,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
-		List<Long> operatingCourse = new ArrayList<>();
-		Long calenderId = null;
+		Map<Long,List<Long>> courseCalenderMap = new HashMap<>(10);
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
 			if(courseScheduleList != null && courseScheduleList.size() > 0){
@@ -462,10 +461,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								CourseScheduleStudentPayment cssp = this.init(courseSchedule);
 								cssp.setUserId(studentId);
 								//扣除可排课时长
-								if(this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders)){
-									//课程是否需要标记为云教练赠送
-									operatingCourse.add(courseSchedule.getId());
-								}
+								//处理经营报表
+								this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders,courseCalenderMap);
 								typeCourseStudentPayments.add(cssp);
 							}
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
@@ -476,15 +473,19 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 			}
 		}
-		if(!CollectionUtils.isEmpty(operatingCourse)){
-			operatingReportCloudService.updateSet(calenderId,operatingCourse);
+		if(!CollectionUtils.isEmpty(courseCalenderMap)){
+			for (Long calenderId : courseCalenderMap.keySet()) {
+				List<Long> courseIds = courseCalenderMap.get(calenderId);
+				operatingReportCloudService.updateSet(calenderId,courseIds);
+			}
 		}
 	}
 
 	private Boolean calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
 									  Integer courseDuration,
 									  CourseScheduleStudentPayment studentPayment,
-									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders){
+									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders,
+									  Map<Long,List<Long>> courseCalenderMap){
 		Boolean result = true;
 		Integer courseMinutes = courseDuration;
 		Map<Long, List<MusicGroupPaymentCalender>> calenderMap = musicGroupPaymentCalenders.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getId));
@@ -526,6 +527,17 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(calender.getPayUserType())){
 					studentPayment.setExpectPrice(BigDecimal.ZERO);
 				}
+				//处理经营报表缴费项目相关数据,线上存在问题,先让用户排课
+				if(result){
+					List<Long> courseIds = courseCalenderMap.get(calender.getId());
+					if(CollectionUtils.isEmpty(courseIds)){
+						courseIds = new ArrayList<>();
+					}
+					courseIds.add(studentPayment.getCourseScheduleId());
+//					ArrayList<Long> courseIds = new ArrayList<>();
+//					courseIds.add(studentPayment.getCourseScheduleId());
+//					operatingReportCloudService.updateSet(calender,courseIds);
+				}
 				if(courseMinutes == 0){
 					return result;
 				}

+ 6 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1032,7 +1032,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(goodsGroup.getPrice()));
 
                     //分部分润金额
-                    if(goodsGroup.getOrganShareProfit() != null){
+                    if(goodsGroup.getOrganShareProfit() != null && goodsGroup.getKitGroupPurchaseType() == KitGroupPurchaseTypeEnum.GROUP){
                     	goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(goodsGroup.getOrganShareProfit()));
                     }
                 }
@@ -2158,7 +2158,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Long id = reqMusicGroupQuit.getId();
         ApprovalStatus status = reqMusicGroupQuit.getStatus();
         String reason = reqMusicGroupQuit.getReason();
-        Date visitDate = reqMusicGroupQuit.getVisitTime();
         MusicGroupReturnFeeDto returnFeeDto = reqMusicGroupQuit.getReturnFeeDto();
 
         MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
@@ -2225,18 +2224,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		musicGroupQuit.setVisitTime(reqMusicGroupQuit.getVisitTime());
 		musicGroupQuit.setUserComment(reqMusicGroupQuit.getUserComment());
 
-
-/*        if (visitDate != null) {
-            musicGroupQuit.setVisitTime(visitDate);
-            musicGroupQuit.setIsVisit(true);
-        } else {
-            musicGroupQuit.setIsVisit(false);
-        }
-
-        if (StringUtils.isBlank(musicGroupQuit.getUserComment())) {
-            musicGroupQuit.setUserComment(reqMusicGroupQuit.getUserComment());
-        }*/
-
         BigDecimal returnTotalFee = BigDecimal.ZERO;
 
         if (returnFeeDto == null) {
@@ -2252,9 +2239,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (returnFeeDto.getIsReturnMaintenanceFee()) {
             returnTotalFee = returnTotalFee.add(returnFeeDto.getMaintenanceFee());
         }
-//        if (returnFeeDto.getIsReturnMemberFee()) {
-//            returnTotalFee = returnTotalFee.add(returnFeeDto.getMemberFee());
-//        }
         if (returnFeeDto.getIsReturnMusicalFee()) {
             returnTotalFee = returnTotalFee.add(returnFeeDto.getMusicalFee());
         }
@@ -2316,7 +2300,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
             }
             //删除用户购买的课程记录
-            musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
+            List<MusicGroupPaymentCalender> paymentCalenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
+            if(CollectionUtils.isNotEmpty(paymentCalenders)){
+                List<Long> calenderIds = paymentCalenders.stream().map(e -> e.getId()).collect(Collectors.toList());
+                musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndCalenderId(userId, calenderIds);
+            }
 
             BigDecimal amount = new BigDecimal(0);
 

+ 9 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportCloudServiceImpl.java

@@ -106,17 +106,24 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 	public void updateSet(Long calenderId,List<Long> scheduleIdList) {
 		//如果是进行中加学员,全部算在当月云教练结转。不用摊到课程
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
+		this.updateSet(calender,scheduleIdList);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateSet(MusicGroupPaymentCalender calender,List<Long> scheduleIdList) {
+		//如果是进行中加学员,全部算在当月云教练结转。不用摊到课程
 		if(calender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){
 			return;
 		}
-		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId);
+		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId());
 		if(Objects.isNull(reportCloud)){
 			throw new BizException("操作失败,请联系管理员");
 		}
 		if(reportCloud.getSettlementFlag()){
 			return;
 		}
-		cloudTeacherFreeCourseService.batchInsert(scheduleIdList,calenderId);
+		cloudTeacherFreeCourseService.batchInsert(scheduleIdList,calender.getId());
 		//计算课程预收
 		BigDecimal costPrice = organCourseTypeOriginalCostDao.getCourseCostPrice(StringUtils.join(scheduleIdList,","));
 		if(Objects.isNull(costPrice)){

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

@@ -704,11 +704,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                     maintenanceGoodsId = goodsGroup.getGoodsIdList();
                 }
                 
-                if(goodsGroup.getOrganShareProfit() != null){
+                if(goodsGroup.getOrganShareProfit() != null && goodsGroup.getKitGroupPurchaseType() == KitGroupPurchaseTypeEnum.GROUP){
                 	organShareProfit = organShareProfit.add(goodsGroup.getOrganShareProfit());
                 }
             }
-            
             //分部分润
             if(organShareProfit.compareTo(BigDecimal.ZERO) > 0) {
             	StudentPaymentOrderDetail spod = new StudentPaymentOrderDetail();

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -87,6 +87,9 @@
             <if test="tenantId!=null">#{tenantId},</if>
         </trim>
     </insert>
+    <update id="addClassTimes">
+        UPDATE class_group SET total_class_times_ = total_class_times_ + #{num} where id_ = #{classGroupId}
+    </update>
 
     <delete id="deleteByGroup">
         DELETE FROM class_group WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleConvert.xml

@@ -49,7 +49,7 @@
         </foreach>
     </select>
     <select id="queryStudents" resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
-        select cssp.user_id_ userId,su.username_ name,su.phone_ phone from course_schedule_student_payment cssp
+        select cssp.user_id_ userId,su.username_ name,su.phone_ phone,su.gender_ gender from course_schedule_student_payment cssp
         LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
         where cssp.course_schedule_id_ IN
         <foreach collection="courseIdList" item="id" open="(" close=")" separator=",">

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -277,6 +277,14 @@
             WHERE music_group_id_ = #{musicGroupId}
         )
     </delete>
+    <delete id="deleteByUserIdAndCalenderId">
+        DELETE
+        FROM music_group_payment_student_course_detail
+        WHERE user_id_ = #{userId} AND music_group_payment_calender_id_ IN
+        <foreach collection="calenderIds" open="(" close=")" item="id" separator=",">
+            #{id}
+        </foreach>
+    </delete>
 
     <resultMap id="StudentSubTotalCourseTimesDto" type="com.ym.mec.biz.dal.dto.StudentSubTotalCourseTimesDto">
         <result property="userId" column="user_id_"/>