Browse Source

会员调整

yuanliang 9 months ago
parent
commit
8b0e77bacc
18 changed files with 207 additions and 46 deletions
  1. 2 2
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/VipCardRecordController.java
  2. 12 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/TeacherBindingUserVo.java
  3. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/StudentDao.java
  4. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/OrderSearch.java
  5. 13 9
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentSearch.java
  6. 6 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/TeacherSearch.java
  7. 1 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/SourceTypeEnum.java
  8. 3 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/StudentService.java
  9. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java
  10. 14 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java
  11. 12 5
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserBindingTeacherServiceImpl.java
  12. 11 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MyFens.java
  13. 10 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/res/HomeTotalStudent.java
  14. 11 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/userBindingTeacher/UserBindingTeacherWrapper.java
  15. 12 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/StudentWrapper.java
  16. 16 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/HomeMapper.xml
  17. 49 14
      cooleshow-user/user-biz/src/main/resources/config/mybatis/StudentMapper.xml
  18. 26 11
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml

+ 2 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/VipCardRecordController.java

@@ -65,9 +65,9 @@ public class VipCardRecordController extends BaseController {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         addVipCardRecord.setCreateBy(sysUser.getId());
         if (addVipCardRecord.getStatus().equals(EVipRecordStatus.ADD)) {
-            addVipCardRecord.setSourceType(SourceTypeEnum.BACKEND_GIVE);
+            addVipCardRecord.setSourceType(SourceTypeEnum.PLATFORM);
         } else if (addVipCardRecord.getStatus().equals(EVipRecordStatus.DEDUCTION)) {
-            addVipCardRecord.setSourceType(SourceTypeEnum.BACKEND_DEDUCT);
+            addVipCardRecord.setSourceType(SourceTypeEnum.PLATFORM_DEDUCT);
         }
         vipCardRecordService.add(addVipCardRecord);
         return succeed();

+ 12 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/io/request/TeacherBindingUserVo.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.admin.io.request;
 
 import com.alibaba.fastjson.JSON;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import com.yonge.toolset.base.page.QueryInfo;
 import io.swagger.annotations.ApiModel;
@@ -100,6 +101,9 @@ public class TeacherBindingUserVo {
         @ApiModelProperty(value = "是否会员 0否 1是")
         private YesOrNoEnum isVip;
 
+        @ApiModelProperty("用户会员类型")
+        private EUserVipType vipType;
+
 
         @ApiModelProperty("课程数")
         private Long courseNum;
@@ -204,6 +208,14 @@ public class TeacherBindingUserVo {
         public void setBindingTime(Date bindingTime) {
             this.bindingTime = bindingTime;
         }
+
+        public EUserVipType getVipType() {
+            return vipType;
+        }
+
+        public void setVipType(EUserVipType vipType) {
+            this.vipType = vipType;
+        }
     }
 
     @ApiModel("BindingStudentCourseQuery-绑定学生课程列表查询")

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/StudentDao.java

@@ -82,4 +82,6 @@ public interface StudentDao extends BaseMapper<Student> {
     Integer queryStudentCounts(@Param("id") Long id);
 
     List<StudentWrapper.UserCount> countStudentByTenantGroupIds(@Param("tenantId") Long tenantId, @Param("groupIdList") List<Long> groupIdList);
+
+    List<StudentWrapper.StudentVipInfo> queryStudentVipInfo(@Param("studentIdList") List<Long> studentIdList);
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/OrderSearch.java

@@ -22,7 +22,7 @@ public class OrderSearch extends QueryInfo{
 	@ApiModelProperty("下单应用:STUDENT 学生端 TEACHER 老师端")
 	private String orderClient;
 
-	@ApiModelProperty("交易类型:  VIP、开通会员  PRACTICE、陪练课购买  LIVE、直播课购买 VIDEO、视频课购买 MUSIC、单曲点播 ACTI_REGIST、活动报名(多选用,分割)")
+	@ApiModelProperty("交易类型:  VIP、开通会员  SVIP、开通会员 PRACTICE、陪练课购买  LIVE、直播课购买 VIDEO、视频课购买 MUSIC、单曲点播 ACTI_REGIST、活动报名(多选用,分割)")
 	private String orderType;
 
 	@ApiModelProperty("订单状态 WAIT_PAY 待支付 PAYING 支付中  PAID 已付款 CLOSE 已关闭 FAIL 支付失败 (多选用,分割)")

+ 13 - 9
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentSearch.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.dto.search;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.biz.dal.enums.GenderEnum;
 import com.yonge.cooleshow.common.enums.UserLockFlag;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
@@ -31,8 +32,8 @@ public class StudentSearch extends QueryInfo{
     @ApiModelProperty(value = "0-正常, 1-锁定")
     private UserLockFlag lockFlag;
     private YesOrNoEnum delFlag;
-    @ApiModelProperty(value = "是否会员 0否 1是")
-    private YesOrNoEnum isVip;
+//    @ApiModelProperty(value = "是否会员 0否 1是")
+//    private YesOrNoEnum isVip;
 
     @ApiModelProperty(value = "是否练习 0否 1是")
     private YesOrNoEnum trainFlag;
@@ -80,6 +81,9 @@ public class StudentSearch extends QueryInfo{
     @ApiModelProperty("机构购买专辑的购买记录ID")
     private Long tenantAlbumPurchaseId;
 
+    @ApiModelProperty("用户会员类型")
+    private EUserVipType vipType;
+
     @ApiModelProperty(value = "手机号码列表", hidden = true)
     private List<String> phoneList = new ArrayList<>();
 
@@ -138,13 +142,13 @@ public class StudentSearch extends QueryInfo{
         this.lockFlag = lockFlag;
     }
 
-    public YesOrNoEnum getIsVip() {
-        return isVip;
-    }
-
-    public void setIsVip(Integer isVip) {
-        this.isVip = YesOrNoEnum.valueOf(isVip);
-    }
+//    public YesOrNoEnum getIsVip() {
+//        return isVip;
+//    }
+//
+//    public void setIsVip(Integer isVip) {
+//        this.isVip = YesOrNoEnum.valueOf(isVip);
+//    }
 
     public Date getStartTime() {
         return startTime;

+ 6 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/TeacherSearch.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.dto.search;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.common.enums.ESettlementFrom;
 import com.yonge.cooleshow.common.enums.UserLockFlag;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
@@ -32,8 +33,8 @@ public class TeacherSearch extends QueryInfo{
     
     private YesOrNoEnum delFlag;
     
-    @ApiModelProperty(value = "是否会员(0-否 1-是)")
-    private Integer isVip;
+//    @ApiModelProperty(value = "是否会员(0-否 1-是)")
+//    private Integer isVip;
     
     @ApiModelProperty("用户状态")
     private String userStatus;
@@ -78,6 +79,9 @@ public class TeacherSearch extends QueryInfo{
 	@ApiModelProperty("老师ID")
 	private Long userId;
 
+	@ApiModelProperty("用户会员类型")
+	private EUserVipType vipType;
+
 	@ApiModelProperty(value = "排序方式, 默认 create_time_ desc", hidden = true)
 	private String orderBy;
 	public YesOrNoEnum getTrainFlag() {

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/SourceTypeEnum.java

@@ -16,10 +16,10 @@ public enum SourceTypeEnum implements BaseEnum<String, AuditStatusEnum> {
     // 机构,机构自己上传曲目 , 暂时没有
     TENANT("机构"),
     PLATFORM("平台"),
+    PLATFORM_DEDUCT("后台扣减"),
     ACTIVITY("活动"),
     ORDER("订单"),
     BACKEND_GIVE("后台赠送"),
-    BACKEND_DEDUCT("后台扣减"),
     FREE_UPGRADE("免费升级"),
 
 

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/StudentService.java

@@ -15,6 +15,7 @@ import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
 import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -133,4 +134,6 @@ public interface StudentService extends IService<Student> {
     void sendStudentTenantChange(Student student, Long toTenantId);
 
     Map<Long,Student> getMapByIds(List<Long> userIds);
+
+    List<StudentWrapper.StudentVipInfo> queryStudentVipInfo( List<Long> studentIdList);
 }

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -46,6 +46,7 @@ import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
 import com.yonge.toolset.utils.string.ValueUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.BeanUtils;
@@ -665,6 +666,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 
     }
 
+    @Override
+    public List<StudentWrapper.StudentVipInfo> queryStudentVipInfo(List<Long> studentIdList) {
+        return baseMapper.queryStudentVipInfo(studentIdList);
+    }
+
     private Boolean updateStudent(StudentWrapper.Student studentInfo) {
         StudentVo student = detail(studentInfo.getId());
         if (student == null) {

+ 14 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -21,6 +21,7 @@ import com.yonge.cooleshow.biz.dal.dto.search.TeacherSearch;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType;
 import com.yonge.cooleshow.biz.dal.enums.ImGroupType;
 import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
@@ -58,6 +59,7 @@ import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
 import com.yonge.cooleshow.biz.dal.wordfilter.WordFilter;
 import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper;
@@ -926,6 +928,18 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     public IPage<MyFens> queryMyFans(IPage<MyFens> page, Long teacherId) {
         List<MyFens> teacherVos = baseMapper.queryMyFans(page,
                 TeacherQueryInfo.FansQuery.builder().teacherId(teacherId).build());
+        if (!teacherVos.isEmpty()) {
+            List<Long> studentIds = teacherVos.stream().map(n -> Long.valueOf(n.getUserId())).collect(Collectors.toList());
+            Map<Long, EUserVipType> vipMap = studentService.queryStudentVipInfo(studentIds).stream()
+                    .collect(Collectors.toMap(StudentWrapper.StudentVipInfo::getStudentId, StudentWrapper.StudentVipInfo::getCurrentVipType));
+
+            for (MyFens teacherVo : teacherVos) {
+                EUserVipType vipType = vipMap.getOrDefault(Long.valueOf(teacherVo.getUserId()), EUserVipType.NORMAL);
+                teacherVo.setIsVip(EUserVipType.NORMAL.equals(vipType) ? YesOrNoEnum.NO : YesOrNoEnum.YES);
+                teacherVo.setVipType(vipType);
+            }
+
+        }
         return page.setRecords(teacherVos);
     }
 
@@ -1047,7 +1061,6 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
 
             teacherInfo.setStudentNums(studentNumsMap.getOrDefault(teacherId, 0));
         }
-        teacherInfo.setUserVip(vipCardRecordService.UserVipInfo(teacherId, ClientEnum.TEACHER));
         return teacherInfo;
     }
 

+ 12 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserBindingTeacherServiceImpl.java

@@ -12,6 +12,7 @@ import com.yonge.cooleshow.biz.dal.entity.StudentAttendance;
 import com.yonge.cooleshow.biz.dal.entity.Subject;
 import com.yonge.cooleshow.biz.dal.entity.UserBindingTeacher;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum;
 import com.yonge.cooleshow.biz.dal.queryInfo.TeacherBindingUserQueryInfo;
 import com.yonge.cooleshow.biz.dal.service.StudentAttendanceService;
@@ -19,6 +20,7 @@ import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.biz.dal.service.UserBindingTeacherService;
 import com.yonge.cooleshow.biz.dal.vo.userBindingTeacher.UserBindingCourseWrapper;
 import com.yonge.cooleshow.biz.dal.vo.userBindingTeacher.UserBindingTeacherWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper;
 import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import com.yonge.toolset.base.exception.BizException;
@@ -105,10 +107,13 @@ public class UserBindingTeacherServiceImpl extends ServiceImpl<UserBindingTeache
         // vip
         List<Student> students = studentDao.selectBatchIds(studentIdList);
 
-        Map<Long, YesOrNoEnum> userIdVipMap = students.stream()
-                                                      .collect(Collectors.toMap(Student::getUserId,
-                                           student -> student.getMembershipEndTime() != null && student.getMembershipEndTime()
-                                           .compareTo(new Date()) > 0?YesOrNoEnum.YES:YesOrNoEnum.NO, (o, n) -> n));
+        List<StudentWrapper.StudentVipInfo> studentVipInfoList = studentDao.queryStudentVipInfo(studentIdList);
+        Map<Long, EUserVipType> vipMap = studentVipInfoList.stream().collect(Collectors.toMap(StudentWrapper.StudentVipInfo::getStudentId, StudentWrapper.StudentVipInfo::getCurrentVipType));
+
+//        Map<Long, YesOrNoEnum> userIdVipMap = students.stream()
+//                                                      .collect(Collectors.toMap(Student::getUserId,
+//                                           student -> student.getMembershipEndTime() != null && student.getMembershipEndTime()
+//                                           .compareTo(new Date()) > 0?YesOrNoEnum.YES:YesOrNoEnum.NO, (o, n) -> n));
 
         // 声部
         List<Long> subjectIdList = new ArrayList<>();
@@ -134,7 +139,9 @@ public class UserBindingTeacherServiceImpl extends ServiceImpl<UserBindingTeache
                                                                                             UserBindingTeacherWrapper.CourseNum::getStudentId));
 
         for (UserBindingTeacherWrapper record : records) {
-            record.setIsVip(userIdVipMap.get(record.getUserId()));
+            EUserVipType vipType = vipMap.getOrDefault(record.getUserId(), EUserVipType.NORMAL);
+            record.setIsVip(EUserVipType.NORMAL.equals(vipType)?YesOrNoEnum.NO:YesOrNoEnum.YES);
+            record.setVipType(vipType);
             record.setSubjectName(userIdSubjectMap.getOrDefault(record.getUserId(), ""));
 
             List<UserBindingTeacherWrapper.CourseNum> courseNums = userIdCourseStatusMap.get(record.getUserId());

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MyFens.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.vo;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.biz.dal.enums.GenderEnum;
 import com.yonge.cooleshow.biz.dal.enums.MK;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
@@ -36,6 +37,8 @@ public class MyFens implements Serializable {
     @ApiModelProperty(value = "是否会员 0否 1是")
     private YesOrNoEnum isVip;
 
+    private EUserVipType vipType;
+
     @ApiModelProperty("手机号")
     private String phone;
 
@@ -148,4 +151,12 @@ public class MyFens implements Serializable {
     public void setAge(Integer age) {
         this.age = age;
     }
+
+    public EUserVipType getVipType() {
+        return vipType;
+    }
+
+    public void setVipType(EUserVipType vipType) {
+        this.vipType = vipType;
+    }
 }

+ 10 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/res/HomeTotalStudent.java

@@ -15,6 +15,8 @@ public class HomeTotalStudent {
     private Integer registerNum;
     @ApiModelProperty("新增会员学员 ")
     private Integer vipNum;
+    @ApiModelProperty("新增会员学员 ")
+    private Integer svipNum;
     @ApiModelProperty("新增陪练课学员 ")
     private Integer practiceNum;
     @ApiModelProperty("新增视频课学员 ")
@@ -112,4 +114,12 @@ public class HomeTotalStudent {
     public void setInfoList(List<HomeTotalStudent> infoList) {
         this.infoList = infoList;
     }
+
+    public Integer getSvipNum() {
+        return svipNum;
+    }
+
+    public void setSvipNum(Integer svipNum) {
+        this.svipNum = svipNum;
+    }
 }

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/userBindingTeacher/UserBindingTeacherWrapper.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.vo.userBindingTeacher;
 
 import com.alibaba.fastjson.JSON;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -39,6 +40,8 @@ public class UserBindingTeacherWrapper {
     // 是否会员 0否 1是
     private YesOrNoEnum isVip;
 
+    private EUserVipType vipType;
+
 
     // 课程数
     private Integer courseNum;
@@ -151,6 +154,14 @@ public class UserBindingTeacherWrapper {
         this.bindingTime = bindingTime;
     }
 
+    public EUserVipType getVipType() {
+        return vipType;
+    }
+
+    public void setVipType(EUserVipType vipType) {
+        this.vipType = vipType;
+    }
+
     public static class CourseNum {
 
         // 学生id

+ 12 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/StudentWrapper.java

@@ -2,6 +2,8 @@ package com.yonge.cooleshow.biz.dal.wrapper;
 
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.yonge.cooleshow.biz.dal.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
+import com.yonge.cooleshow.biz.dal.enums.EVipType;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -230,4 +232,14 @@ public class StudentWrapper {
         private Long tenantGroupId;
         private Integer count;
     }
+
+
+    @Data
+    public static class StudentVipInfo {
+
+        private Long studentId;
+
+        private EUserVipType currentVipType;
+
+    }
 }

+ 16 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/HomeMapper.xml

@@ -120,6 +120,7 @@
 			</if>
 			sum(a.registerNum) as registerNum,
 			sum(b.vipNum) as vipNum,
+			sum(b2.svipNum) as svipNum,
 			sum(c.practiceNum) as practiceNum,
 			sum(d.videoNum) as videoNum,
 			sum(e.liveNum) as liveNum,
@@ -159,6 +160,21 @@
 		) b on t.sys_day_ymd_ = b.timeStr
 		left join (
 		select
+		DATE_FORMAT(t.first_svip_time_,'%Y-%m-%d') as timeStr,
+		count(1) as svipNum
+		from student_time t
+		<where>
+			<if test="param.startTime !=null">
+				<![CDATA[AND t.first_svip_time_ >= #{param.startTime} ]]>
+			</if>
+			<if test="param.endTime !=null">
+				<![CDATA[AND t.first_svip_time_ < #{param.endTime} ]]>
+			</if>
+		</where>
+		group by DATE_FORMAT(t.first_svip_time_,'%Y-%m-%d')
+		) b2 on t.sys_day_ymd_ = b2.timeStr
+		left join (
+		select
 			DATE_FORMAT(t.first_pay_time_,'%Y-%m-%d') as timeStr,
 			count(1) as payNum
 		from student_time t

+ 49 - 14
cooleshow-user/user-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -24,8 +24,8 @@
         , t.subject_id_ as `subjectId`
         , t.current_grade_num_ as `currentGradeNum`
         , t.member_rank_setting_id_ as `memberRankSettingId`
-        , t.membership_start_time_ as `membershipStartTime`
-        , t.membership_end_time_ as `membershipEndTime`
+<!--        , t.membership_start_time_ as `membershipStartTime`-->
+<!--        , t.membership_end_time_ as `membershipEndTime`-->
         , t.cloud_study_sequence_days_ as `cloudStudySequenceDays`
         , t.cloud_study_use_last_day_ as `cloudStudyUseLastDay`
         , t.train_time_ as trainTime
@@ -103,7 +103,11 @@
             u.phone_ as phone,
             !isnull(birthdate_) as isReal,
             u.real_name_ as realName,
-            (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
+            ifnull(vcr2.vip_type_,'NORMAL') as vipType,
+<!--            if(vcr.type_ = 'PERMANENT',null,vcr.end_time_) as membershipEndTime,-->
+            max(if(vcr.vip_type_ = 'VIP', vcr.end_time_, null)) vipEndTime,
+            max(if(vcr.type_='PERPETUAL', null , vcr.end_time_)) svipEndTime,
+<!--            (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,-->
             (
             SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
             ) as subjectName,
@@ -111,6 +115,8 @@
         FROM student t
         left join sys_user u on t.user_id_ = u.id_
         left join tenant_info ti on t.tenant_id_ = ti.id_
+        left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.efficient_flag_ = 1  and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP') and client_type_='STUDENT'
+        left join vip_card_record vcr2 on t.user_id_ = vcr2.user_id_ and vcr2.efficient_flag_ = 1 and vcr2.end_time_ > now() and now() >= vcr2.start_time_ and client_type_='STUDENT'
         <where>
             <if test="null != param.search and '' != param.search">
                 AND (
@@ -126,14 +132,22 @@
             <if test="null != param.subjectId and '' != param.subjectId">
                 AND FIND_IN_SET(t.subject_id_, #{param.subjectId})
             </if>
-            <if test="null != param.isVip">
-                <if test="1 == param.isVip.code">
-                    and t.membership_end_time_ &gt; now()
+            <if test="param.vipType != null">
+                <if test="param.vipType == 'NORMAL'">
+                    and vcr2.id_ is null
                 </if>
-                <if test="0 == param.isVip.code">
-                    and (t.membership_end_time_ is null or t.membership_end_time_ &lt;= now())
+                <if test="param.vipType != 'NORMAL'">
+                    and vcr2.vip_type_ = #{param.vipType}
                 </if>
             </if>
+<!--            <if test="null != param.isVip">-->
+<!--                <if test="1 == param.isVip.code">-->
+<!--                    and t.membership_end_time_ &gt; now()-->
+<!--                </if>-->
+<!--                <if test="0 == param.isVip.code">-->
+<!--                    and (t.membership_end_time_ is null or t.membership_end_time_ &lt;= now())-->
+<!--                </if>-->
+<!--            </if>-->
             <if test="param.startTime !=null">
                 <![CDATA[AND t.create_time_ >= #{param.startTime} ]]>
             </if>
@@ -146,12 +160,12 @@
             <if test="null != param.delFlag">
                 and u.del_flag_ = #{param.delFlag}
             </if>
-            <if test="null != param.vipEndTime">
-                and t.membership_end_time_ &lt;= #{param.vipEndTime}
-            </if>
-            <if test="null != param.vipStartTime">
-                and t.membership_end_time_ &gt;= #{param.vipStartTime}
-            </if>
+<!--            <if test="null != param.vipEndTime">-->
+<!--                and vcr.end_time_ &lt;= #{param.vipEndTime}-->
+<!--            </if>-->
+<!--            <if test="null != param.vipStartTime">-->
+<!--                and vcr.end_time_ &gt;= #{param.vipStartTime}-->
+<!--            </if>-->
             <if test="param.trainFlag != null">
                 AND t.train_time_ > 0
             </if>
@@ -183,6 +197,16 @@
                 AND FIND_IN_SET(t.tenant_group_id_, #{param.tenantGroupId})
             </if>
         </where>
+        group by t.user_id_
+        <if test="param.vipStartTime != null and param.vipEndTime != null">
+            having
+            <if test="param.vipType == 'VIP'">
+                and vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime
+            </if>
+            <if test="param.vipType == 'SVIP'">
+                and svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime
+            </if>
+        </if>
         <choose>
             <when test="param.orderBy != null and param.orderBy.trim() != ''">
                 order by ${param.orderBy}
@@ -373,4 +397,15 @@
         </where>
         group by tenant_group_id_
     </select>
+
+    <select id="queryStudentVipInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.StudentWrapper$StudentVipInfo">
+        select t.user_id_ studentId
+        ,ifnull(vcr.vip_type_,'NORMAL') currentVipType
+        from student t
+        left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.efficient_flag_ = 1 and vcr.end_time_>now() and now()>= vcr.start_time_ and vcr.client_type_= 'STUDENT'
+        where t.user_id_ in
+        <foreach collection="param.studentIdList" separator="," item="item" open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

+ 26 - 11
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -77,8 +77,8 @@
         , t.degree_flag_ as "degreeFlag"
         , t.teacher_flag_ as "teacherFlag"
         , t.member_rank_setting_id_ as "memberRankSettingId"
-        , t.membership_start_time_ as "membershipStartTime"
-        , t.membership_end_time_ as "membershipEndTime"
+<!--        , t.membership_start_time_ as "membershipStartTime"-->
+<!--        , t.membership_end_time_ as "membershipEndTime"-->
         , t.browse_ as "browse"
         , t.memo_ as "memo"
         , t.tag_ as "tag"
@@ -104,9 +104,11 @@
         u.avatar_ as avatar,
         u.birthdate_ as birthdate,
         u.gender_ as gender,
-        (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,
+<!--        (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,-->
         <!--            t.tag_ tag,-->
         u.del_flag_ as delFlag,
+        ifnull(vcr.vip_type_,'NORMAL') as vipType,
+        if(vcr.type_ = 'PERMANENT',null,vcr.end_time_) as membershipEndTime,
         (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
         (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
         (case when t.tenant_id_ = -1 then '平台' else ti.name_ end) as tenantName
@@ -116,6 +118,8 @@
         select distinct user_id_ from user_bank_card where del_flag_ = 0
         ) b on t.user_id_ = b.user_id_
         left join tenant_info ti on t.tenant_id_ = ti.id_
+        left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and cvr.client_type_ = 'TEACHER'
+        and vcr.efficient_flag_ = 1 and vcr.end_time_ >= now() and now() > vcr.start_time_ and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP')
         <where>
             <if test="null != param.search and '' != param.search">
                 AND (
@@ -139,14 +143,22 @@
                 </if>
                 )
             </if>
-            <if test="param.isVip != null">
-                <if test="param.isVip == 0">
-                    and (t.membership_end_time_ is null or t.membership_end_time_ &lt; now())
+            <if test="param.vipType != null">
+                <if test="param.vipType == 'NORMAL'">
+                    and vcr.id_ is null
                 </if>
-                <if test="param.isVip == 1">
-                    and t.membership_end_time_ &gt;= now()
+                <if test="param.vipType != 'NORMAL'">
+                    and vcr.vip_type_ = #{param.vipType}
                 </if>
             </if>
+<!--            <if test="param.isVip != null">-->
+<!--                <if test="param.isVip == 0">-->
+<!--                    and (t.membership_end_time_ is null or t.membership_end_time_ &lt; now())-->
+<!--                </if>-->
+<!--                <if test="param.isVip == 1">-->
+<!--                    and t.membership_end_time_ &gt;= now()-->
+<!--                </if>-->
+<!--            </if>-->
             <if test="param.tag != null">
                 and find_in_set(#{param.tag},t.tag_)
             </if>
@@ -166,10 +178,10 @@
                 and t.is_test_user_ = #{param.isTestUser}
             </if>
             <if test="null != param.vipEndTime">
-                and t.membership_end_time_ &lt;= #{param.vipEndTime}
+                and vcr.end_time_ &lt;= #{param.vipEndTime}
             </if>
             <if test="null != param.vipStartTime">
-                and t.membership_end_time_ &gt;= #{param.vipStartTime}
+                and vcr.end_time_ &gt;= #{param.vipStartTime}
             </if>
             <if test="param.trainFlag != null">
                 AND t.train_time_ > 0
@@ -239,6 +251,7 @@
         (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
         u.real_name_ as realName,
         u.id_card_no_ as idCardNo,
+        if(vcr.type_ = 'PERMANENT',null,vcr.end_time_) as membershipEndTime,
         (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
         (
         SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
@@ -249,6 +262,8 @@
         left join (
         select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
         ) b on t.user_id_ = b.user_id_
+        left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and cvr.client_type_ = 'TEACHER'
+        and vcr.efficient_flag_ = 1 and vcr.end_time_ >= now() and now() > vcr.start_time_ and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP')
         where u.del_flag_ = 0 and t.user_id_ = #{userId}
     </select>
 
@@ -322,7 +337,7 @@
         u.phone_ AS phone,
         u.birthdate_ AS birthdate,
         (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName,
-        if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip
+<!--        if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip-->
         FROM student_star s
         LEFT JOIN sys_user u ON s.student_id_ = u.id_
         LEFT JOIN student sr ON s.student_id_ = sr.user_id_