Browse Source

活动排课

zouxuan 3 years ago
parent
commit
61bc6a03f1

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -607,4 +607,22 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @return
      */
     List<StudentOrganDto> queryRemainCourseStudent(@Param("organIds") List<Integer> organIds);
+
+    /**
+    * @description: 获取课程组关联的活动资格
+     * @param feeDto
+    * @return java.lang.String
+    * @author zx
+    * @date 2022/7/27 17:22
+    */
+    List<SurplusCourseFeeDto> queryActivityUserMapperId(@Param("feeDto") SurplusCourseFeeDto feeDto);
+
+    /**
+    * @description: 获取活动关联的课程组
+     * @param feeDto
+    * @return java.lang.String
+    * @author zx
+    * @date 2022/7/27 17:22
+    */
+    List<SurplusCourseFeeDto> queryGroupIdByActivity(@Param("feeDto") SurplusCourseFeeDto feeDto);
 }

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

@@ -10,6 +10,8 @@ public class ActivityUserDto {
 
     private String username;
 
+    private String phone;
+
     private String subjectId;
 
     private String subjectName;
@@ -17,6 +19,14 @@ public class ActivityUserDto {
     @ApiModelProperty(value = "剩余可排课次数")
     private String subCourseNum;
 
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
     public String getSubjectId() {
         return subjectId;
     }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/BaseMapDto.java

@@ -10,6 +10,14 @@ public class BaseMapDto<K, V> {
 
     private V value;
 
+    public BaseMapDto() {
+    }
+
+    public BaseMapDto(K key, V value) {
+        this.key = key;
+        this.value = value;
+    }
+
     public K getKey() {
         return key;
     }

+ 59 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SurplusCourseFeeDto.java

@@ -0,0 +1,59 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class SurplusCourseFeeDto {
+
+    @ApiModelProperty(value = "学员编号",required = true)
+    private Integer studentId;
+
+    @ApiModelProperty(value = "课程组编号",required = true)
+    private String groupId;
+
+    @ApiModelProperty(value = "课程类型 VIP/PRACTICE",required = true)
+    private String groupType;
+
+    private Integer activityUserMapperId;
+
+    private String ignoreGroupId;
+
+    public Integer getActivityUserMapperId() {
+        return activityUserMapperId;
+    }
+
+    public void setActivityUserMapperId(Integer activityUserMapperId) {
+        this.activityUserMapperId = activityUserMapperId;
+    }
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(String groupType) {
+        this.groupType = groupType;
+    }
+
+    public String getIgnoreGroupId() {
+        return ignoreGroupId;
+    }
+
+    public void setIgnoreGroupId(String ignoreGroupId) {
+        this.ignoreGroupId = ignoreGroupId;
+    }
+}

+ 13 - 47
mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java

@@ -1,24 +1,17 @@
 package com.ym.mec.biz.service;
 
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.StudentApplyRefunds.StudentApplyRefundsStatus;
 import com.ym.mec.biz.dal.enums.AuditStatusEnum;
-import com.ym.mec.biz.dal.page.StudentVipGroupQueryInfo;
-import com.ym.mec.biz.dal.page.VipGroupAttendanceQueryInfo;
-import com.ym.mec.biz.dal.page.VipGroupQueryInfo;
-import com.ym.mec.biz.dal.page.VipGroupSalaryQueryInfo;
-import com.ym.mec.biz.dal.page.VipGroupTeachingRecordQueryInfo;
+import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
-import org.springframework.web.multipart.MultipartFile;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
 
 public interface VipGroupService extends BaseService<Long, VipGroup> {
 
@@ -179,17 +172,6 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      */
     VipGroupManageDetailDto getVipGroupDetailForAudit(Long vipGroupId);
 
-    /**
-     * @describe 计算vip课程购买总价,及老师课酬
-     * @author Joburgess
-     * @date 2019/10/23
-     * @param vipGroup: vip课程
-     * @param teacherId: 要计算课酬的老师的编号
-     * @return java.util.Map
-     */
-//    <K extends VipGroup> Map<String, BigDecimal> countVipGroupPredictFee(K vipGroup,
-//                                                                         Integer teacherId,
-//                                                                         Long courseId);
 
     /**
      * @describe 计算vip课程购买总价,及老师课酬
@@ -231,25 +213,6 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      */
     StudentVipGroupDetailDto getVipGroupShowDetail(Long groupId,String groupType);
 
-    /**
-     * @Author: Joburgess
-     * @Date: 2019/10/3
-     * @params [vipGroupCostCountParamsDto]
-     * @return com.ym.mec.biz.dal.dto.VipGroupCostCountDto
-     * @describe vip课程费用计算
-     */
-//    VipGroupCostCountDto vipGroupCostCount(VipGroupCostCountParamsDto vipGroupCostCountParamsDto);
-
-    /**
-     * @describe 更新vip课班级人数及状态
-     * @author Joburgess
-     * @date 2019/10/20
-     * @param vipGroupId: vip课编号
-     * @param num: 人数
-     * @param updateVipStatus: 是否修改VIP课状态
-     * @return void
-     */
-    void updateVipGroupStudentNumAndStatus(Long vipGroupId, ClassGroup classGroup, Integer num, boolean updateVipStatus);
 
     /**
      * @describe 课程购买成功后,创建课程相关信息
@@ -366,6 +329,15 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     Map<String,BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId);
 
     /**
+    * @description: 获取指定学生的剩余课时费用
+     * @param feeDto
+    * @return java.util.Map<java.lang.String,java.math.BigDecimal>
+    * @author zx
+    * @date 2022/7/28 09:45
+    */
+    Map<String,BigDecimal> getStudentSurplusCourseFee1(SurplusCourseFeeDto feeDto);
+
+    /**
      * @Author: Joburgess
      * @Date: 2019/10/3
      * @params [studentApplyRefunds]
@@ -403,12 +375,6 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     void stopGroup(Long vipGroupId,String stopReason);
 
     /**
-     * 发放月度奖励
-     * @return
-     */
-    boolean awardedMonthlyRewards();
-
-    /**
      * 根据老师查询vip课教学点
      * @param userId
      * @return

+ 30 - 93
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -2479,37 +2479,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void updateVipGroupStudentNumAndStatus(Long vipGroupId, ClassGroup classGroup, Integer num, boolean updateVipStatus) {
-        VipGroup vipGroup = vipGroupDao.get(vipGroupId);
-        if (Objects.isNull(vipGroup)) {
-            throw new BizException("指定的vip课程不存在");
-        }
-        if (Objects.isNull(classGroup)) {
-            throw new BizException("未找到关联班级");
-        }
-        if (classGroup.getStudentNum() + num < 0) {
-            classGroup.setStudentNum(0);
-        } else {
-            classGroup.setStudentNum(classGroup.getStudentNum() + num);
-        }
-
-        Integer studentPaymentNum = studentPaymentOrderDao.countStudentPaymentNum(vipGroupId.toString());
-
-        if (studentPaymentNum.equals(classGroup.getExpectStudentNum()) && updateVipStatus) {
-            classGroup.setStudentNum(studentPaymentNum);
-            classGroup.setDelFlag(0);
-            classGroupDao.update(classGroup);
-            createVipGroupCourseScheInfo(vipGroupId, classGroup);
-        }
-        if (num != 0 || updateVipStatus) {
-            int i = courseScheduleDao.countVipGroupCourses(vipGroupId.intValue(), "VIP");
-            classGroup.setTotalClassTimes(i);
-            classGroupDao.update(classGroup);
-        }
-    }
-
-    @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public void createVipGroupCourseScheInfo(Long vipGroupId, ClassGroup classGroup) {
         VipGroup vipGroup = vipGroupDao.get(vipGroupId);
         List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(), CourseSchedule.class);
@@ -3673,6 +3642,36 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         return result;
     }
 
+    @Override
+    public Map<String, BigDecimal> getStudentSurplusCourseFee1(SurplusCourseFeeDto feeDto) {
+        //获取当前课程组关联的活动
+        Set<String> ignoreGroupId = new HashSet<>();
+        Set<Integer> ignoreActivityIds = new HashSet<>();
+        this.studentSurplusCourseFeeTree(feeDto,ignoreGroupId,ignoreActivityIds);
+        //再通过活动编号获取锁关联的课程组、会员
+        //计算出需要退的金额
+        return null;
+    }
+
+    public void studentSurplusCourseFeeTree(SurplusCourseFeeDto feeDto,Set<String> ignoreGroupId,Set<Integer> ignoreActivityIds){
+        String join = StringUtils.join(ignoreGroupId, ",");
+        feeDto.setIgnoreGroupId(join);
+        //获取课程组关联的活动
+        List<SurplusCourseFeeDto> surplusCourseFeeDtos = courseScheduleStudentPaymentDao.queryActivityUserMapperId(feeDto);
+        if (!CollectionUtils.isEmpty(surplusCourseFeeDtos)){
+            ignoreActivityIds.addAll(surplusCourseFeeDtos.stream().map(e -> e.getActivityUserMapperId()).collect(Collectors.toSet()));
+            for (SurplusCourseFeeDto surplusCourseFeeDto : surplusCourseFeeDtos) {
+                surplusCourseFeeDto.setIgnoreGroupId(join);
+                //获取活动关联的课程组
+                List<SurplusCourseFeeDto> feeDtos = courseScheduleStudentPaymentDao.queryGroupIdByActivity(surplusCourseFeeDto);
+                if(!CollectionUtils.isEmpty(feeDtos)){
+                    ignoreGroupId.addAll(feeDtos.stream().map(e -> e.getGroupId()).collect(Collectors.toSet()));
+                    feeDtos.forEach(e->this.studentSurplusCourseFeeTree(e,ignoreGroupId,ignoreActivityIds));
+                }
+            }
+        }
+    }
+
     @Transactional(rollbackFor = Exception.class)
     @Override
     public HttpResponseResult applyRefundAudit(Long id, StudentApplyRefundsStatus status, String remark, BigDecimal amount, boolean confirmReturnActivityGive) {
@@ -3980,68 +3979,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     }
 
     @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public boolean awardedMonthlyRewards() {
-        //获取上个月的时间
-        Date months = DateUtil.addMonths(new Date(), -1);
-        String firstDayOfMonth = DateUtil.format(DateUtil.getFirstDayOfMonth(months), DateUtil.ISO_EXPANDED_DATE_FORMAT);
-        String lastDayOfMonth = DateUtil.format(DateUtil.getLastDayOfMonth(months), DateUtil.ISO_EXPANDED_DATE_FORMAT);
-
-        List<TaskRewardsRulesDto> rewardsRulesDtos = courseScheduleRewardsRulesService.queryVipGroupTeacherClassTimesByMonth(firstDayOfMonth, lastDayOfMonth);
-        if (rewardsRulesDtos != null && rewardsRulesDtos.size() > 0) {
-            List<Integer> activeIds = rewardsRulesDtos.stream().map(e -> e.getActiveId()).collect(Collectors.toList());
-            List<CourseScheduleRewardsRules> rewardsRules = courseScheduleRewardsRulesService.findByIds(activeIds);
-            Map<Integer, List<CourseScheduleRewardsRules>> integerListMap = rewardsRules.stream().collect(Collectors.groupingBy(CourseScheduleRewardsRules::getId));
-            String currentMonth = DateUtil.format(new Date(), DateUtil.ISO_YEAR_MONTH_FORMAT);
-            rewardsRulesDtos.forEach(e -> {
-                //当前用户是否已经发放过上月奖励
-                Integer num = sysUserCashAccountDetailDao.countByTypeAndTime(currentMonth, e.getTeacherId(), e.getActiveId());
-                if (num == null || num == 0) {
-                    CourseScheduleRewardsRules rewardsRule = integerListMap.get(e.getActiveId()).get(0);
-                    List<RewardsRulesJsonDto> rulesJsonDtos = JSONObject.parseArray(rewardsRule.getRewardsRulesJson(), RewardsRulesJsonDto.class);
-                    BigDecimal money = BigDecimal.ZERO;
-                    //STAIR 阶梯, PER 累计, TOTAL
-                    RewardsRulesJsonDto dto;
-                    int times = e.getTimes();
-                    switch (rewardsRule.getRewardMode()) {
-                        case STAIR:
-                            for (int i = 0; i < rulesJsonDtos.size(); i++) {
-                                dto = rulesJsonDtos.get(i);
-                                if (e.getTimes() >= dto.getMin()) {
-                                    //最后一个梯度
-                                    if (rulesJsonDtos.size() - 1 == i) {
-                                        money = money.add(dto.getMoney().multiply(new BigDecimal(times)));
-                                    } else if (e.getTimes() >= dto.getMax()) {
-                                        times = Math.abs(dto.getMax() - times);
-                                        money = money.add(dto.getMoney().multiply(new BigDecimal(dto.getMax() - dto.getMin() + 1)));
-                                    } else {
-                                        money = money.add(dto.getMoney().multiply(new BigDecimal(times)));
-                                    }
-                                }
-                            }
-                            break;
-                        case PER:
-                            for (int i = 0; i < rulesJsonDtos.size(); i++) {
-                                dto = rulesJsonDtos.get(i);
-                                if (e.getTimes() >= dto.getMin()) {
-                                    money = dto.getMoney().multiply(new BigDecimal(times));
-                                }
-                            }
-                            break;
-                        case TOTAL:
-                            break;
-                    }
-                    if (money.doubleValue() > 0) {
-                        sysUserCashAccountDetailService.addCashAccountDetail(e.getTeacherId(), money, "", SysUserCashAccountDetailService.ORGAN,
-                                PlatformCashAccountDetailTypeEnum.REWARDS, null, DealStatusEnum.SUCCESS, "分部奖励", e.getActiveId().toString());
-                    }
-                }
-            });
-        }
-        return true;
-    }
-
-    @Override
     public List<School> querySchoolByUserId(Integer userId) {
         return vipGroupDao.querySchoolByUserId(userId);
     }

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

@@ -416,12 +416,13 @@
 	<resultMap id="ActivityUserDto" type="com.ym.mec.biz.dal.dto.ActivityUserDto">
 		<result property="userId" column="user_id_"/>
 		<result property="username" column="username_"/>
+		<result property="phone" column="phone_"/>
 		<result property="subjectName" column="subject_name_"/>
 		<result property="subjectId" column="subject_id_"/>
 		<result property="subCourseNum" column="sub_course_num_"/>
 	</resultMap>
 	<select id="queryActivityStudentList" resultMap="ActivityUserDto">
-		SELECT aum.user_id_,su.avatar_,sj.id_ subject_id_,su.username_,sj.name_ subject_name_,SUM(aum.sub_course_num_) sub_course_num_
+		SELECT aum.user_id_,su.avatar_,sj.id_ subject_id_,su.username_,su.phone_,sj.name_ subject_name_,SUM(aum.sub_course_num_) sub_course_num_
 		FROM (SELECT aum.id_,aum.user_id_,aum.sub_course_num_,aum.single_course_time_ from activity_user_mapper aum
 		WHERE aum.sub_course_num_ > 0
 		<if test="queryInfo.categoryId != null">
@@ -463,6 +464,7 @@
 			</if>
 		</where>
 		GROUP BY aum.user_id_
+		ORDER BY sj.id_ DESC,sub_course_num_ DESC
 	</select>
 	<select id="queryActivityCourseTimeList" resultType="java.lang.Integer">
 		select distinct aum.single_course_time_ from activity_user_mapper aum

+ 25 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -1083,4 +1083,29 @@
         </foreach>
         group by cssp.user_id_ , u.organ_id_
 	</select>
+	<resultMap id="SurplusCourseFeeDto" type="com.ym.mec.biz.dal.dto.SurplusCourseFeeDto">
+		<result property="studentId" column="user_id_"/>
+		<result property="groupType" column="group_type_"/>
+		<result property="groupId" column="group_id_"/>
+		<result property="activityUserMapperId" column="activity_user_mapper_id_"/>
+	</resultMap>
+	<select id="queryActivityUserMapperId" resultMap="SurplusCourseFeeDto">
+		SELECT cssp.activity_user_mapper_id_,cssp.group_type_
+		FROM course_schedule_student_payment cssp
+		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+		WHERE cs.status_ = 'NOT_START' AND cssp.user_id_ = #{feeDto.studentId}
+		AND cssp.music_group_id_ = #{feeDto.groupId} AND cssp.group_type_ = #{feeDto.groupType} AND cssp.activity_user_mapper_id_ IS NOT NULL
+		<if test="feeDto.ignoreGroupId != null and feeDto.ignoreGroupId != ''">
+			AND NOT FIND_IN_SET(cssp.music_group_id_,#{feeDto.ignoreGroupId})
+		</if>
+		GROUP BY cssp.activity_user_mapper_id_
+	</select>
+	<select id="queryGroupIdByActivity" resultMap="SurplusCourseFeeDto">
+		SELECT DISTINCT cssp.music_group_id_ group_id_,cssp.group_type_,cssp.user_id_ FROM course_schedule_student_payment cssp
+		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+		WHERE cs.status_ = 'NOT_START' AND cssp.group_type_ = #{feeDto.groupType} AND cssp.activity_user_mapper_id_ = #{feeDto.activityUserMapperId}
+		<if test="feeDto.ignoreGroupId != null and feeDto.ignoreGroupId != ''">
+			AND NOT FIND_IN_SET(cssp.music_group_id_,#{feeDto.ignoreGroupId})
+		</if>
+	</select>
 </mapper>

+ 8 - 4
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -3,10 +3,7 @@ package com.ym.mec.web.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.ClassDateAdjustDto;
-import com.ym.mec.biz.dal.dto.ReturnFeeDto;
-import com.ym.mec.biz.dal.dto.VipGroupApplyBaseInfoDto;
-import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.StudentApplyRefunds.StudentApplyRefundsStatus;
 import com.ym.mec.biz.dal.enums.AuditStatusEnum;
@@ -417,4 +414,11 @@ public class VipGroupManageController extends BaseController {
     public Object getStudentSurplusCourseFee(Long vipGroupId, Integer studentId){
         return succeed(vipGroupService.getStudentSurplusCourseFee(vipGroupId,studentId));
     }
+
+
+//    @ApiOperation(value = "获取学生指定vip课的剩余课时费用")
+//    @PostMapping(value = "/getStudentSurplusCourseFee")
+//    public Object getStudentSurplusCourseFee(@RequestBody SurplusCourseFeeDto feeDto){
+//        return succeed(vipGroupService.getStudentSurplusCourseFee1(feeDto));
+//    }
 }