Browse Source

Merge branch 'feature/1022_vip' into feature/1105_ref

刘俊驰 7 months ago
parent
commit
c13f682d78

+ 46 - 3
mec-application/src/main/java/com/ym/mec/web/controller/MemberRankSettingController.java

@@ -1,7 +1,11 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.entity.MemberFeeSetting;
+import com.ym.mec.biz.dal.entity.MemberRankOrganizationFeeMapper;
 import com.ym.mec.biz.dal.entity.MemberRankSetting;
+import com.ym.mec.biz.dal.page.MemberRankFeeQueryInfo;
 import com.ym.mec.biz.dal.wrapper.MemberRankSettingWrapper;
+import com.ym.mec.biz.service.MemberRankOrganizationFeeMapperService;
 import com.ym.mec.biz.service.MemberRankSettingService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
@@ -9,13 +13,16 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.yonge.log.model.AuditLogAnnotation;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.web:}/memberRankSetting")
 @Api(tags = "会员等级服务")
@@ -27,6 +34,9 @@ public class MemberRankSettingController extends BaseController {
     @Autowired
     private SysUserService sysUserService;
 
+    @Autowired
+    private MemberRankOrganizationFeeMapperService memberRankOrganizationFeeMapperService;
+
     @ApiOperation(value = "新增")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('memberRankSetting/add')")
@@ -83,8 +93,41 @@ public class MemberRankSettingController extends BaseController {
     @ApiOperation(value = "获取所有会员列表")
     @PostMapping("/findByOrganIds")
     @PreAuthorize("@pcs.hasPermissions('memberRankSetting/findByOrganIds')")
-    public HttpResponseResult<List<MemberRankSetting>> findAll(@RequestBody List<Integer> organIds) {
-        return succeed(memberRankSettingService.findByOrganIds(organIds));
+    public HttpResponseResult<List<MemberRankSetting>> findAll(@RequestBody List<Integer> organIds,
+                                                               @RequestParam(required = false, defaultValue = "false") Boolean organFeeFlag) {
+
+        // 根据分部ID查询对应的会员等级
+        List<MemberRankSetting> memberRanks = memberRankSettingService.findByOrganIds(organIds);
+
+        // 根据分部ID查询对应价格
+        if (Boolean.TRUE.equals(organFeeFlag)) {
+            MemberRankFeeQueryInfo queryInfo = new MemberRankFeeQueryInfo();
+            queryInfo.setRows(1000);
+            queryInfo.setPage(1);
+            if (CollectionUtils.isNotEmpty(organIds)) {
+
+                queryInfo.setOrganId(StringUtils.join(organIds, ","));
+            }
+            List<MemberRankOrganizationFeeMapper> rows = memberRankOrganizationFeeMapperService.queryPage(queryInfo).getRows();
+            if (CollectionUtils.isNotEmpty(rows)) {
+                Map<Integer, MemberFeeSetting> collect = rows.stream()
+                    .collect(Collectors.toMap(MemberRankOrganizationFeeMapper::getMemberRankSettingId, MemberRankOrganizationFeeMapper::getMemberFeeSetting, (o, n) -> n));
+
+                // 已统一规定会员等级只有两级,暂不考虑多级
+                for (MemberRankSetting item : memberRanks) {
+                    if (CollectionUtils.isEmpty(item.getChildren())) {
+                        continue;
+                    }
+
+                    // 设置价格
+                    for (MemberRankSetting child : item.getChildren()) {
+                        child.setMemberFeeSetting(collect.get(child.getId()));
+                    }
+                }
+            }
+        }
+
+        return succeed(memberRanks);
     }
 
     @ApiOperation(value = "获取可用的会员树状列表")

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LessonCoursewareService.java

@@ -27,5 +27,7 @@ public interface LessonCoursewareService extends IService<LessonCourseware> {
     List<LessonCoursewareWrapper.RefLevelDetailInfo> refLevel(LessonCoursewareWrapper.RefLevelQuery query);
 
     LessonCourseware getByLessonCoursewareId(Long lessonCoursewareId);
+
+    List<LessonCourseware> getByLessonCoursewareIds(List<Integer> categoryIds);
 }
 

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -304,6 +304,16 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
         return list.get(0);
     }
 
+    @Override
+    public List<LessonCourseware> getByLessonCoursewareIds(List<Integer> categoryIds) {
+        if (CollectionUtils.isEmpty(categoryIds)) {
+            return new ArrayList<>();
+        }
+        return this.lambdaQuery()
+            .in(LessonCourseware::getId, categoryIds)
+            .list();
+    }
+
     private LessonCoursewareWrapper.RefLevelDetailInfo initRefLevelDetailInfo(CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail coursewareDetail,
                                                                               CbsLessonCoursewareWrapper.LessonCourseware lessonCourseware) {
         LessonCoursewareWrapper.RefLevelDetailInfo refLevelDetailInfo = new LessonCoursewareWrapper.RefLevelDetailInfo();

+ 9 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentLessonTrainingDetailServiceImpl.java

@@ -60,6 +60,9 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
     private MemberRankCategoryMapperService memberRankCategoryMapperService;
 
     @Autowired
+    private LessonCoursewareService lessonCoursewareService;
+
+    @Autowired
     private MemberRankCourseTypeMapperService memberRankCourseTypeMapperService;
     /**
      * 查询详情
@@ -310,7 +313,7 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
             }
         }
         // 判断课件
-        Map<Integer, List<Integer>> userVipMap = Maps.newConcurrentMap();
+        Map<Integer, List<Long>> userVipMap = Maps.newConcurrentMap();
         studentLessonTrainingDetails.parallelStream().forEach(o -> {
             if (o.getUserId() == null) {
                 return;
@@ -326,19 +329,21 @@ public class StudentLessonTrainingDetailServiceImpl extends ServiceImpl<StudentL
             }
             List<Integer> categoryIds = courseTypeMapperList.stream().map(MemberRankCourseTypeMapper::getCourseType)
                 .distinct().map(Integer::parseInt).collect(Collectors.toList());
+            // 本地的课件ID 换远程ID
+            List<Long> lessonIds =  lessonCoursewareService.getByLessonCoursewareIds(categoryIds).stream().map(LessonCourseware::getLessonCourseId).distinct().collect(Collectors.toList());
             // 设置用户VIP可查看曲目分类
-            userVipMap.put(o.getUserId().intValue(), categoryIds);
+            userVipMap.put(o.getUserId().intValue(), lessonIds);
         });
         for (StudentLessonTrainingDetailWrapper.StudentLessonTrainingDetail studentLessonTrainingDetail : studentLessonTrainingDetails) {
             if (studentLessonTrainingDetail.getUserId() == null) {
                 return;
             }
             if ("VIDEO".equals(studentLessonTrainingDetail.getHomeworkType()) && StringUtils.isNotBlank(studentLessonTrainingDetail.getLessonCoursewareId())) {
-                List<Integer> courseTypeIds = userVipMap.get(studentLessonTrainingDetail.getUserId().intValue());
+                List<Long> courseTypeIds = userVipMap.get(studentLessonTrainingDetail.getUserId().intValue());
                 if (CollectionUtils.isEmpty(courseTypeIds)) {
                     courseTypeIds = new ArrayList<>();
                 }
-                if (courseTypeIds.contains(Integer.parseInt(studentLessonTrainingDetail.getLessonCoursewareId()))) {
+                if (courseTypeIds.contains(Long.parseLong(studentLessonTrainingDetail.getLessonCoursewareId()))) {
                     studentLessonTrainingDetail.setUseStatus("UNLOCK");
                 } else {
                     studentLessonTrainingDetail.setUseStatus("LOCK");

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

@@ -651,6 +651,6 @@
     </select>
 
     <select id="getActivationVipIds" resultType="java.lang.Integer">
-        select distinct level_ from cloud_teacher_order where student_id_ = #{studentId}  and end_time_ &gt;=now() and status_ = 2
+        select distinct member_rank_id_ from student_member_time where student_id_ = #{studentId}  and end_time_ &gt;=now()
     </select>
 </mapper>

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

@@ -89,7 +89,9 @@
 		LEFT JOIN organization o ON o.id_ = mrofm.organ_id_
 		LEFT JOIN sys_user su ON su.id_ = mrofm.operator_id_
 		<where>
-			mrofm.tenant_id_ = #{tenantId}
+			<if test="tenantId != null">
+				AND mrofm.tenant_id_ = #{tenantId}
+			</if>
 			<if test="search != null and search != ''">
 				AND mrs.name_ LIKE CONCAT('%',#{search},'%')
 			</if>