Parcourir la source

活动排课查询学员列表支持分页

zouxuan il y a 3 ans
Parent
commit
e752c1e491

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupActivityDao.java

@@ -62,9 +62,9 @@ public interface VipGroupActivityDao extends BaseDAO<Integer, VipGroupActivity>
 	 * @author zx
 	 * @date 2021/10/11 15:02
 	 */
-	List<ActivityWaitCourseStudentNumDto> getActivityStudentCanCourseNum(@Param("userId") Integer userId,
-																		 @Param("activityId") Integer activityId,
-																		 @Param("search") String search);
+	List<ActivityWaitCourseStudentNumDto> getActivityStudentCanCourseNum(Map<String, Object> params);
+
+	int countActivityStudentCanCourseNum(Map<String, Object> params);
 
 	/**
 	* @description: 双十一活动统计

+ 41 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ActivityStudentQueryInfo.java

@@ -0,0 +1,41 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+* @author zx
+* @date 2021/9/26 15:52
+*/
+public class ActivityStudentQueryInfo extends QueryInfo {
+
+    private Integer activityId;
+
+    private Integer userId;
+
+    private Boolean giveFlag;
+
+    public Boolean getGiveFlag() {
+        return giveFlag;
+    }
+
+    public void setGiveFlag(Boolean giveFlag) {
+        this.giveFlag = giveFlag;
+    }
+
+    public Integer getActivityId() {
+        return activityId;
+    }
+
+    public void setActivityId(Integer activityId) {
+        this.activityId = activityId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+}

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

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.VipGroupActivity;
+import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
 import com.ym.mec.biz.dal.page.DoubleEleven2021QueryInfo;
 import com.ym.mec.biz.dal.page.VipGroupActivityQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -67,7 +68,7 @@ public interface VipGroupActivityService extends BaseService<Integer, VipGroupAc
     * @author zx
     * @date 2021/10/11 15:00
     */
-    List<ActivityWaitCourseStudentNumDto> getActivityStudentCanCourseNum(Integer userId, Integer activityId,String search);
+    PageInfo<ActivityWaitCourseStudentNumDto> getActivityStudentCanCourseNum(ActivityStudentQueryInfo queryInfo);
 
     /**
     * @description: 分部双11活动统计

+ 18 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupActivityServiceImpl.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.entity.ActivityApplyStudentType;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.entity.VipGroupActivity;
 import com.ym.mec.biz.dal.entity.VipGroupCategory;
+import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
 import com.ym.mec.biz.dal.page.DoubleEleven2021QueryInfo;
 import com.ym.mec.biz.dal.page.VipGroupActivityQueryInfo;
 import com.ym.mec.biz.service.VipGroupActivityService;
@@ -190,8 +191,23 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
     }
 
 	@Override
-	public List<ActivityWaitCourseStudentNumDto> getActivityStudentCanCourseNum(Integer userId, Integer activityId,String search) {
-		return vipGroupActivityDao.getActivityStudentCanCourseNum(userId,activityId,search);
+	public PageInfo<ActivityWaitCourseStudentNumDto> getActivityStudentCanCourseNum(ActivityStudentQueryInfo queryInfo) {
+		PageInfo<ActivityWaitCourseStudentNumDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<ActivityWaitCourseStudentNumDto> dataList = null;
+		int count = vipGroupActivityDao.countActivityStudentCanCourseNum(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = vipGroupActivityDao.getActivityStudentCanCourseNum(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
 	}
 
     @Override

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

@@ -318,6 +318,7 @@
 		GROUP BY aum.user_id_)c
 	</select>
 	<select id="getActivityStudentCanCourseNum" resultMap="ActivityWaitCourseStudentNumDto">
+		SELECT * FROM (
 		SELECT COUNT(CASE WHEN aum.vip_flag_ = 1 THEN 1 ELSE NULL END) vip_num_,
 			   COUNT(CASE WHEN aum.practice_flag_ = 1 THEN 1 ELSE NULL END) practice_num_,
 			   COUNT(CASE WHEN aum.give_vip_flag_ = 1 THEN 1 ELSE NULL END) give_vip_num_,
@@ -332,7 +333,41 @@
 		<if test="search != null and search != ''">
 			AND (aum.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
 		</if>
-		GROUP BY aum.user_id_
+		GROUP BY aum.user_id_) c
+		<where>
+			<if test="giveFlag != null and giveFlag == 1">
+				AND c.give_vip_num_ > 0 OR c.give_practice_num_ > 0
+			</if>
+			<if test="giveFlag != null and giveFlag == 0">
+				AND c.vip_num_ > 0 OR c.practice_num_ > 0
+			</if>
+		</where>
+		<include refid="global.limit"/>
+	</select>
+	<select id="countActivityStudentCanCourseNum" resultType="int">
+		SELECT COUNT(c.user_id_) FROM (
+		SELECT COUNT(CASE WHEN aum.vip_flag_ = 1 THEN 1 ELSE NULL END) vip_num_,
+		COUNT(CASE WHEN aum.practice_flag_ = 1 THEN 1 ELSE NULL END) practice_num_,
+		COUNT(CASE WHEN aum.give_vip_flag_ = 1 THEN 1 ELSE NULL END) give_vip_num_,
+		COUNT(CASE WHEN aum.give_practice_flag_ = 1 THEN 1 ELSE NULL END) give_practice_num_,aum.user_id_
+		FROM activity_user_mapper aum
+		LEFT JOIN sys_user su ON su.id_ = aum.user_id_
+		WHERE aum.return_fee_ = 0 AND aum.activity_id_ = #{activityId}
+		<if test="userId != null">
+			AND aum.teacher_id_ = #{userId}
+		</if>
+		<if test="search != null and search != ''">
+			AND (aum.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
+		</if>
+		GROUP BY aum.user_id_) c
+		<where>
+			<if test="giveFlag != null and giveFlag == 1">
+				AND c.give_vip_num_ > 0 OR c.give_practice_num_ > 0
+			</if>
+			<if test="giveFlag != null and giveFlag == 0">
+				AND c.vip_num_ > 0 OR c.practice_num_ > 0
+			</if>
+		</where>
 	</select>
 	<resultMap id="DoubleEleven2021ActivityDto" type="com.ym.mec.biz.dal.dto.DoubleEleven2021ActivityDto">
 		<result property="buyNum" column="buy_num_"/>

+ 4 - 2
mec-teacher/src/main/java/com/ym/mec/teacher/controller/VipGroupActivityController.java

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.dto.VipGroupActivityAddDto;
 import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.entity.SysConfig;
 import com.ym.mec.biz.dal.entity.VipGroupActivity;
+import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
 import com.ym.mec.biz.dal.page.VipGroupActivityQueryInfo;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.VipGroupActivityService;
@@ -65,12 +66,13 @@ public class VipGroupActivityController extends BaseController {
 
     @ApiOperation(value = "获取活动学员课排课次数")
     @RequestMapping("/getActivityStudentCanCourseNum")
-    public Object getActivityStudentCanCourseNum(Integer activityId,String search){
+    public Object getActivityStudentCanCourseNum(ActivityStudentQueryInfo queryInfo){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser == null){
             return failed("用户信息获取失败");
         }
-        return succeed(vipGroupActivityService.getActivityStudentCanCourseNum(sysUser.getId(),activityId,search));
+        queryInfo.setUserId(sysUser.getId());
+        return succeed(vipGroupActivityService.getActivityStudentCanCourseNum(queryInfo));
     }
 
     @ApiOperation(value = "新增vip课活动方案")

+ 3 - 2
mec-web/src/main/java/com/ym/mec/web/controller/education/ActivityController.java

@@ -6,6 +6,7 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
 import com.ym.mec.biz.dal.page.CloudTeacherActiveQueryInfo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
@@ -96,12 +97,12 @@ public class ActivityController extends BaseController {
 
     @ApiOperation(value = "获取活动学员课排课次数")
     @RequestMapping("/getActivityStudentCanCourseNum")
-    public Object getActivityStudentCanCourseNum(Integer activityId,String search){
+    public Object getActivityStudentCanCourseNum(ActivityStudentQueryInfo queryInfo){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser == null){
             return failed("用户信息获取失败");
         }
-        return succeed(vipGroupActivityService.getActivityStudentCanCourseNum(null,activityId,search));
+        return succeed(vipGroupActivityService.getActivityStudentCanCourseNum(queryInfo));
     }