Browse Source

学员活动购买

zouxuan 2 years ago
parent
commit
deacd6e02f

+ 62 - 38
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ActivityUserMapperDetailDto.java

@@ -1,73 +1,97 @@
 package com.ym.mec.biz.dal.dto;
 
-import com.ym.mec.biz.dal.entity.ActivityUserMapper;
 import io.swagger.annotations.ApiModelProperty;
 
-public class ActivityUserMapperDetailDto extends ActivityUserMapper {
+import java.math.BigDecimal;
+import java.util.Date;
 
-    @ApiModelProperty(value = "付费课类型")
-    private String categoryName;
+public class ActivityUserMapperDetailDto{
 
-    @ApiModelProperty(value = "赠送课类型")
-    private String giveCategoryName;
+    @ApiModelProperty(value = "活动编号")
+    private Integer activityId;
 
-    @ApiModelProperty(value = "学员姓名")
-    private String username;
+    @ApiModelProperty(value = "来源")
+    private String addMemo;
 
-    @ApiModelProperty(value = "指导老师姓名")
-    private String teacherName;
+    @ApiModelProperty(value = "购买时间")
+    private Date createTime;
 
-    @ApiModelProperty(value = "分部")
-    private String organName;
+    @ApiModelProperty(value = "是否免费")
+    private Boolean freeFlag;
 
-    @ApiModelProperty(value = "分部")
-    private Integer organId;
+    @ApiModelProperty(value = "剩余课程次数")
+    private Integer subCourseNum;
 
-    public Integer getOrganId() {
-        return organId;
+    @ApiModelProperty(value = "总课次")
+    private Integer totalCourseNum;
+
+    @ApiModelProperty(value = "剩余未排课价值")
+    private BigDecimal subCoursePrice;
+
+    @ApiModelProperty(value = "课类型")
+    private String categoryName = "网管课";
+
+    public Integer getActivityId() {
+        return activityId;
     }
 
-    public void setOrganId(Integer organId) {
-        this.organId = organId;
+    public void setActivityId(Integer activityId) {
+        this.activityId = activityId;
     }
 
-    public String getCategoryName() {
-        return categoryName;
+    public String getAddMemo() {
+        return addMemo;
     }
 
-    public void setCategoryName(String categoryName) {
-        this.categoryName = categoryName;
+    public void setAddMemo(String addMemo) {
+        this.addMemo = addMemo;
     }
 
-    public String getGiveCategoryName() {
-        return giveCategoryName;
+    public Date getCreateTime() {
+        return createTime;
     }
 
-    public void setGiveCategoryName(String giveCategoryName) {
-        this.giveCategoryName = giveCategoryName;
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
     }
 
-    public String getUsername() {
-        return username;
+    public Boolean getFreeFlag() {
+        return freeFlag;
     }
 
-    public void setUsername(String username) {
-        this.username = username;
+    public void setFreeFlag(Boolean freeFlag) {
+        this.freeFlag = freeFlag;
     }
 
-    public String getTeacherName() {
-        return teacherName;
+    public Integer getSubCourseNum() {
+        return subCourseNum;
     }
 
-    public void setTeacherName(String teacherName) {
-        this.teacherName = teacherName;
+    public void setSubCourseNum(Integer subCourseNum) {
+        this.subCourseNum = subCourseNum;
     }
 
-    public String getOrganName() {
-        return organName;
+    public Integer getTotalCourseNum() {
+        return totalCourseNum;
     }
 
-    public void setOrganName(String organName) {
-        this.organName = organName;
+    public void setTotalCourseNum(Integer totalCourseNum) {
+        this.totalCourseNum = totalCourseNum;
+    }
+
+    public BigDecimal getSubCoursePrice() {
+        return subCoursePrice;
+    }
+
+    public void setSubCoursePrice(BigDecimal subCoursePrice) {
+        this.subCoursePrice = subCoursePrice;
+    }
+
+    public String getCategoryName() {
+        return categoryName;
+    }
+
+    public void setCategoryName(String categoryName) {
+        this.categoryName = categoryName;
     }
 }

+ 0 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ActivityUserMapperServiceImpl.java

@@ -1173,27 +1173,6 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 			pageInfo.setTotal(count);
 			params.put("offset", pageInfo.getOffset());
 			dataList = activityUserMapperDao.queryDetailPage(params);
-			List<Integer> userIds = dataList.stream().map(e -> e.getUserId()).distinct().collect(Collectors.toList());
-			List<Integer> teacherIds = dataList.stream().filter(e -> e.getTeacherId() != null).map(e -> e.getTeacherId()).distinct().collect(Collectors.toList());
-			Map<Integer,String> teacherName = new HashMap<>();
-			if (CollectionUtils.isNotEmpty(teacherIds)){
-				teacherName = MapUtil.convertMybatisMap(teacherDao.queryNameByIdList(teacherIds));
-			}
-			Map<Integer,String> studentName = new HashMap<>();
-			if (CollectionUtils.isNotEmpty(userIds)){
-				studentName = MapUtil.convertMybatisMap(teacherDao.queryUserNameByIdList(userIds));
-			}
-			List<Integer> organIds = dataList.stream().map(e -> e.getOrganId()).distinct().collect(Collectors.toList());
-			Map<Integer, String> organNameMap = this.getMap("organization", "id_", "name_", organIds, queryInfo.getTenantId(), Integer.class, String.class);
-			List<ConditionDto> categorys = vipGroupCategoryService.findConditionCategorys();
-			Map<Integer, String> categoryName = categorys.stream().collect(Collectors.toMap(e->e.getId().intValue(), ConditionDto::getName, (key1, key2) -> key2));
-			for (ActivityUserMapperDetailDto row : dataList) {
-				row.setCategoryName(categoryName.get(row.getCategoryId()));
-				row.setGiveCategoryName(categoryName.get(row.getGiveCategoryId()));
-				row.setTeacherName(teacherName.get(row.getTeacherId()));
-				row.setUsername(studentName.get(row.getUserId()));
-				row.setOrganName(organNameMap.get(row.getOrganId()));
-			}
 		}
 		if (count == 0) {
 			dataList = new ArrayList<>();

+ 62 - 44
mec-biz/src/main/resources/config/mybatis/ActivityUserMapperMapper.xml

@@ -590,46 +590,49 @@
 	<select id="findByIds" resultMap="ActivityUserMapper">
 		SELECT * FROM activity_user_mapper aum WHERE FIND_IN_SET(aum.id_,#{activityUserMapperIds})
 	</select>
-	<resultMap id="ActivityUserMapperDetailDto" type="com.ym.mec.biz.dal.dto.ActivityUserMapperDetailDto" extends="ActivityUserMapper">
-		<result property="organId" column="organ_id_"/>
+	<resultMap id="ActivityUserMapperDetailDto" type="com.ym.mec.biz.dal.dto.ActivityUserMapperDetailDto">
+		<result property="activityId" column="activity_id_"/>
+		<result property="addMemo" column="add_memo_"/>
+		<result property="subCourseNum" column="sub_course_num_"/>
+		<result property="totalCourseNum" column="total_course_num_"/>
+		<result property="createTime" column="create_time_"/>
+		<result property="freeFlag" column="free_flag_"/>
+		<result property="subCoursePrice" column="sub_no_course_price_"/>
+		<result property="categoryName" column="name_"/>
 	</resultMap>
     <select id="queryDetailPage" resultMap="ActivityUserMapperDetailDto">
-		select aum.*,su.organ_id_ from activity_user_mapper aum
-		left join sys_user su ON su.id_ = aum.user_id_
-		<include refid="queryDetailPageSql"/>
-		ORDER BY aum.id_ DESC
+		select aum.id_,aum.activity_id_,aum.add_memo_,vga.name_,aum.sub_course_num_,aum.total_course_num_,
+		aum.create_time_,false free_flag_,aum.sub_no_course_price_ from activity_user_mapper aum
+		left join vip_group_category vga ON vga.id_ = aum.category_id_
+		where (aum.vip_flag_ > 0 OR aum.practice_flag_ > 0) AND aum.return_fee_ = 0
+		<include refid="countDetailPageSql"/>
+		UNION ALL
+		select aum.id_,aum.activity_id_,aum.add_memo_,vga.name_,aum.sub_give_course_num_ sub_course_num_,
+		aum.total_give_course_num_ total_course_num_,aum.create_time_,true free_flag_,0 sub_no_course_price_ from activity_user_mapper aum
+		left join vip_group_category vga ON vga.id_ = aum.give_category_id_
+		where (aum.give_vip_flag_ > 0 OR aum.give_practice_flag_ > 0) AND aum.return_fee_ = 0
+		<include refid="countDetailPageSql"/>
+		order by id_ DESC
 		<include refid="global.limit"/>
 	</select>
-	<sql id="queryDetailPageSql">
-		<where>
-			<if test="search != null and search != ''">
-				AND (aum.activity_id_ = #{search} OR aum.add_memo_ LIKE CONCAT('%',#{search},'%'))
-			</if>
-			<if test="userId != null">
-				AND aum.user_id_ = #{userId}
-			</if>
-			<if test="organId != null and organId != ''">
-				AND FIND_IN_SET(su.organ_id_,#{organId})
-			</if>
-			<if test="returnFee != null">
-				AND aum.return_fee_ = #{returnFee}
-			</if>
-			<if test="returnFee != null">
-				AND aum.return_fee_ = #{returnFee}
-			</if>
-			<if test="hasSubCourse != null and hasSubCourse == true">
-				and (aum.sub_course_num_ > 0 or aum.sub_give_course_num_ > 0)
-			</if>
-			<if test="hasSubCourse != null and hasSubCourse == false">
-				and aum.sub_course_num_ &lt;= 0 and aum.sub_give_course_num_ &lt;= 0
-			</if>
-		</where>
-	</sql>
 	<select id="countDetailPage" resultType="java.lang.Integer">
-		select COUNT(aum.id_) from activity_user_mapper aum
-		left join sys_user su ON su.id_ = aum.user_id_
-		<include refid="queryDetailPageSql"/>
+		select COUNT(aum.id_) from (select aum.id_ from activity_user_mapper aum
+		where (aum.vip_flag_ > 0 OR aum.practice_flag_ > 0) AND aum.return_fee_ = 0
+		<include refid="countDetailPageSql"/>
+		UNION ALL
+		select aum.id_ from activity_user_mapper aum
+		where (aum.give_vip_flag_ > 0 OR aum.give_practice_flag_ > 0) AND aum.return_fee_ = 0
+		<include refid="countDetailPageSql"/>
+		) aum
 	</select>
+	<sql id="countDetailPageSql">
+		<if test="search != null and search != ''">
+			AND (aum.activity_id_ = #{search} OR aum.add_memo_ LIKE CONCAT('%',#{search},'%'))
+		</if>
+		<if test="userId != null">
+			AND aum.user_id_ = #{userId}
+		</if>
+	</sql>
 	<resultMap id="ActivityUserMapperSumDto" type="com.ym.mec.biz.dal.dto.ActivityUserMapperSumDto">
 		<result property="organId" column="organ_id_"/>
 		<result property="userId" column="user_id_"/>
@@ -647,7 +650,6 @@
 	</resultMap>
 	<sql id="querySumPageSql">
 		<where>
-			aum.return_fee_ = 0 and aum.total_course_num_ > 0
 			<if test="organId != null and organId != ''">
 				AND FIND_IN_SET(su.organ_id_,#{organId})
 			</if>
@@ -658,23 +660,39 @@
 	</sql>
 	<select id="countSumPage" resultType="java.lang.Integer">
 		select COUNT(DISTINCT aum.user_id_)
+		from (select aum.user_id_,aum.category_id_,aum.sub_course_num_,aum.total_course_num_
 		from activity_user_mapper aum
+		left join vip_group_category vgc ON vgc.id_ = aum.category_id_
+		where aum.return_fee_ = 0 and aum.total_course_num_ > 0
+		UNION ALL
+		select aum.user_id_,aum.give_category_id_ category_id_,aum.sub_give_course_num_,aum.total_give_course_num_
+		from activity_user_mapper aum
+		left join vip_group_category vgc ON vgc.id_ = aum.category_id_
+		where aum.return_fee_ = 0 and aum.total_give_course_num_ > 0) aum
 		left join sys_user su ON su.id_ = aum.user_id_
 		<include refid="querySumPageSql"/>
 	</select>
 	<select id="querySumPage" resultType="com.ym.mec.biz.dal.dto.ActivityUserMapperSumDto">
 		select aum.user_id_,su.organ_id_,su.username_,su.phone_,
-			   CONCAT(SUM(CASE WHEN vgc.name_ = '1v1' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v1' THEN aum.total_course_num_ ELSE 0 END)) 'one',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '1v2' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v2' THEN aum.total_course_num_ ELSE 0 END)) 'two',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '1v3' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v3' THEN aum.total_course_num_ ELSE 0 END)) 'three',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '1v4' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v4' THEN aum.total_course_num_ ELSE 0 END)) 'four',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '1v5' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v5' THEN aum.total_course_num_ ELSE 0 END)) 'five',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '1v6' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v6' THEN aum.total_course_num_ ELSE 0 END)) 'six',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '1v7' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v7' THEN aum.total_course_num_ ELSE 0 END)) 'seven',
-				CONCAT(SUM(CASE WHEN vgc.name_ = '乐理课' THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '乐理课' THEN aum.total_course_num_ ELSE 0 END)) 'theory',
-				CONCAT(SUM(CASE WHEN vgc.name_ IS NULL THEN aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ IS NULL THEN aum.total_course_num_ ELSE 0 END)) 'practice'
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v1' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v1' THEN aum.total_course_num_ ELSE 0 END)) 'one',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v2' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v2' THEN aum.total_course_num_ ELSE 0 END)) 'two',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v3' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v3' THEN aum.total_course_num_ ELSE 0 END)) 'three',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v4' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v4' THEN aum.total_course_num_ ELSE 0 END)) 'four',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v5' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v5' THEN aum.total_course_num_ ELSE 0 END)) 'five',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v6' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v6' THEN aum.total_course_num_ ELSE 0 END)) 'six',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '1v7' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '1v7' THEN aum.total_course_num_ ELSE 0 END)) 'seven',
+		CONCAT(SUM(CASE WHEN vgc.name_ = '乐理课' THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ = '乐理课' THEN aum.total_course_num_ ELSE 0 END)) 'theory',
+		CONCAT(SUM(CASE WHEN vgc.name_ IS NULL THEN aum.total_course_num_ - aum.sub_course_num_ ELSE 0 END) ,'/',SUM(CASE WHEN vgc.name_ IS NULL THEN aum.total_course_num_ ELSE 0 END)) 'practice'
+		from (select aum.user_id_,aum.category_id_,aum.sub_course_num_,aum.total_course_num_
 		from activity_user_mapper aum
 		left join vip_group_category vgc ON vgc.id_ = aum.category_id_
+		where aum.return_fee_ = 0 and aum.total_course_num_ > 0
+		UNION ALL
+		select aum.user_id_,aum.give_category_id_ category_id_,aum.sub_give_course_num_,aum.total_give_course_num_
+		from activity_user_mapper aum
+		left join vip_group_category vgc ON vgc.id_ = aum.category_id_
+		where aum.return_fee_ = 0 and aum.total_give_course_num_ > 0) aum
+		left join vip_group_category vgc ON vgc.id_ = aum.category_id_
 		left join sys_user su ON su.id_ = aum.user_id_
 		<include refid="querySumPageSql"/>
 		group by aum.user_id_

+ 6 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/ActivityUserMapperController.java

@@ -75,6 +75,9 @@ public class ActivityUserMapperController extends BaseController {
     @PostMapping("/createVipGroup")
     public HttpResponseResult createVipGroup(@RequestBody VipGroupApplyDto vipGroupApplyDto){
         VipGroupApplyBaseInfoDto applyBaseInfo = vipGroupApplyDto.getVipGroupApplyBaseInfo();
+        if(Objects.isNull(applyBaseInfo.getEducationalTeacherId())){
+            throw new BizException("请选择乐团主管");
+        }
         applyBaseInfo.setUserId(sysUserService.getUserId());
         Teacher teacher = teacherDao.get(applyBaseInfo.getUserId());
         applyBaseInfo.setOrganId(teacher.getTeacherOrganId());
@@ -91,6 +94,9 @@ public class ActivityUserMapperController extends BaseController {
     @PostMapping("/createPracticeGroup")
     public HttpResponseResult createPracticeGroup(@RequestBody PracticeGroupApplyDto practiceGroupApplyDto){
         PracticeGroupApplyBaseInfoDto applyBaseInfo = practiceGroupApplyDto.getPracticeGroupApplyBaseInfoDto();
+        if(Objects.isNull(applyBaseInfo.getEducationalTeacherId())){
+            throw new BizException("请选择乐团主管");
+        }
         applyBaseInfo.setUserId(sysUserService.getUserId());
         Teacher teacher = teacherDao.get(applyBaseInfo.getUserId());
         applyBaseInfo.setOrganId(teacher.getTeacherOrganId());

+ 2 - 1
mec-web/src/main/java/com/ym/mec/web/controller/education/EduActivityUserMapperController.java

@@ -88,13 +88,14 @@ public class EduActivityUserMapperController extends BaseController {
         return activityUserMapperService.createActivityVipGroup(vipGroupApplyDto);
     }
 
-    @ApiOperation(value = "教师端网管课活动排课")
+    @ApiOperation(value = "管理端网管课活动排课")
     @PostMapping("/createPracticeGroup")
     public Object createPracticeGroup(@RequestBody PracticeGroupApplyDto practiceGroupApplyDto){
         PracticeGroupApplyBaseInfoDto applyBaseInfo = practiceGroupApplyDto.getPracticeGroupApplyBaseInfoDto();
         if(Objects.isNull(applyBaseInfo.getUserId())){
             throw new BizException("请选择指导老师");
         }
+        applyBaseInfo.setEducationalTeacherId(sysUserService.getUserId());
         for (CourseSchedule courseSchedule : practiceGroupApplyDto.getCourseSchedules()) {
             courseSchedule.setEndClassTime(DateUtil.addMinutes(courseSchedule.getStartClassTime(), applyBaseInfo.getSingleClassMinutes()));
         }