Jelajahi Sumber

feat(app): 实现分班管理与课程验证功能增强

- 添加事务注解支持与参数校验
- 优化分班删除逻辑与教练权限控制- 更新数据库查询条件与关联关系- 增强临时约课功能并校验教练身份
- 完善课程验证用户查询逻辑与权限判断
- 调整实体类字段类型与表单验证规则
wzq 2 hari lalu
induk
melakukan
43d3c21378
13 mengubah file dengan 104 tambahan dan 33 penghapusan
  1. 9 11
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/commercial/CommercialController.java
  2. 7 3
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppClassGroupingController.java
  3. 7 0
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/ClassGroupingCasePageForm.java
  4. 1 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/ClassGroupingForm.java
  5. 5 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/AppCoursesVerificationRecordMapper.java
  6. 6 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppClassGroupingMapper.xml
  7. 1 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppCoursesMapper.xml
  8. 32 2
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppCoursesVerificationRecordMapper.xml
  9. 4 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppCoursesVerificationRecordService.java
  10. 1 4
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppClassGroupingServiceImpl.java
  11. 20 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoureseServiceImpl.java
  12. 10 3
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoursesVerificationRecordServiceImpl.java
  13. 1 1
      national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/vo/ClassGroupingCaseVO.java

+ 9 - 11
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/commercial/CommercialController.java

@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.app.form.ClassPostponeForm;
 import org.jeecg.modules.app.form.CourseQueryUsersForm;
@@ -109,19 +110,16 @@ public class CommercialController {
     @Operation(summary = "拍照验课人员查看")
     @PostMapping("/courseQueryUsers")
     public Result<List<AppCoursesVerificationRecord>> courseQueryUsers(@RequestBody CourseQueryUsersForm form) {
+        LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //如果不是教练
+        String roleCode = loginUser.getRoleCode();
+        if (!roleCode.contains("instructor")) {
+            loginUser.setId(null);
+        }
         List<AppCoursesVerificationRecord> verificationRecords =
-                appCoursesVerificationRecordService.courseQueryUsersList( form.getCoursePriceRulesId(),form.getOrPostpone(), form.getVerifyStatus());
+                appCoursesVerificationRecordService.courseQueryUsersList(form.getCoursePriceRulesId(),form.getOrPostpone(), form.getVerifyStatus(),loginUser.getId());
         List<AppCoursesVerificationRecord> temporaryCourseList =
-                appCoursesVerificationRecordService.list(Wrappers.lambdaQuery(AppCoursesVerificationRecord.class)
-                                .eq(AppCoursesVerificationRecord::getCoursesPriceRuleId, form.getCoursePriceRulesId())
-                                .eq(ObjectUtil.isNotEmpty(form.getOrPostpone()),AppCoursesVerificationRecord::getOrPostpone, form.getOrPostpone())
-                                .eq(ObjectUtil.isNotEmpty(form.getVerifyStatus()),AppCoursesVerificationRecord::getVerifyStatus, form.getVerifyStatus())
-                                .and(wrapper ->wrapper
-                                        .eq(AppCoursesVerificationRecord::getOrTemporaryCourse, CommonConstant.NUMBER_1)
-                                        .or()
-                                        .eq(AppCoursesVerificationRecord::getCoursesType, CommonConstant.NUMBER_1)
-                                )
-                        );
+                appCoursesVerificationRecordService.queryTemporaryCourseUser(form.getCoursePriceRulesId(),form.getOrPostpone(),form.getVerifyStatus(),loginUser.getId());
         verificationRecords.addAll(temporaryCourseList);
         List<AppCoursesVerificationRecord> list = verificationRecords.stream()
                 .collect(Collectors.collectingAndThen(

+ 7 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/controller/AppClassGroupingController.java

@@ -24,8 +24,10 @@ import org.jeecg.modules.system.app.vo.*;
 import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.simpleframework.xml.core.Validate;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.constraints.NotBlank;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -81,12 +83,12 @@ public class AppClassGroupingController {
      */
     @PostMapping(value = "/getStudentInfoList")
     public Result<List<StudentInfoVO>> getStudentInfoList(@RequestBody StudentInfoForm studentInfoForm) {
-        List<StudentInfoVO> studentInfoList = appClassGroupingService.getStudentInfoList(studentInfoForm);
+         List<StudentInfoVO> studentInfoList = appClassGroupingService.getStudentInfoList(studentInfoForm);
         return Result.OK(studentInfoList);
     }
 
     /**
-     * 根据所有门店地址
+     * 查询所有门店地址
      *
      * @param
      * @return
@@ -165,6 +167,7 @@ public class AppClassGroupingController {
     public Result<String> edit(@RequestBody @Validate ClassGroupingForm classGroupingCaseForm) {
 
         AppClassGrouping appClassGrouping = new AppClassGrouping();
+        appClassGrouping.setId(classGroupingCaseForm.getId());
         appClassGrouping.setClassName(classGroupingCaseForm.getClassName());
         appClassGrouping.setCourseId(classGroupingCaseForm.getCourseId());
         appClassGrouping.setCoachUserId(classGroupingCaseForm.getCoachUserId());
@@ -189,8 +192,9 @@ public class AppClassGroupingController {
      * @return
      */
     @AutoLog(value = "分班删除")
+    @Transactional(rollbackFor = Exception.class)
     @DeleteMapping(value = "/delete")
-    public Result<String> delete(@RequestParam(name = "classGroupingId", required = true) String classGroupingId) {
+    public Result<String> delete(@NotBlank(message = "分班ID不能为空") @RequestParam(name = "classGroupingId", required = true) String classGroupingId) {
         appClassGroupingService.removeById(classGroupingId);
         // 删除原来的
         appClassUserService.remove(Wrappers.<AppClassUser>lambdaQuery().eq(AppClassUser::getClassGroupingId, classGroupingId));

+ 7 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/ClassGroupingCasePageForm.java

@@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 import org.jeecg.modules.app.dto.PageDTO;
 
+import javax.validation.constraints.NotBlank;
 import java.io.Serial;
 import java.io.Serializable;
 
@@ -26,4 +27,10 @@ public class ClassGroupingCasePageForm extends PageDTO implements Serializable {
      */
     private String classGroupingName;
 
+    /**
+     * 课程Id
+     */
+    @NotBlank(message = "课程Id不能为空")
+    private String courseId;
+
 }

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/form/ClassGroupingForm.java

@@ -26,7 +26,7 @@ public class ClassGroupingForm implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
-     * id
+     * 分班id
      */
     private String id;
 

+ 5 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/AppCoursesVerificationRecordMapper.java

@@ -15,5 +15,9 @@ import java.util.List;
  */
 public interface AppCoursesVerificationRecordMapper extends BaseMapper<AppCoursesVerificationRecord> {
 
-    List<AppCoursesVerificationRecord> courseQueryUsersList(@Param("coursePriceRulesId") String coursePriceRulesId, @Param("orPostpone") Integer orPostpone, @Param("verifyStatus") Integer verifyStatus);
+    List<AppCoursesVerificationRecord> courseQueryUsersList(@Param("coursePriceRulesId") String coursePriceRulesId,
+                                                            @Param("orPostpone") Integer orPostpone, @Param("verifyStatus") Integer verifyStatus,
+                                                            @Param("coachUserId") String coachUserId);
+
+    List<AppCoursesVerificationRecord> queryTemporaryCourseUser(String coursePriceRulesId, Integer orPostpone, Integer verifyStatus, String coachUserId);
 }

+ 6 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppClassGroupingMapper.xml

@@ -18,6 +18,7 @@
         LEFT JOIN nm_order_pro_info op ON op.product_id = c.id
         <where>
             c.del_flag = 0
+            AND op.order_status BETWEEN 1 AND 3
             <if test="classGroupingPageForm.orgCode != null and classGroupingPageForm.orgCode != ''">
                 AND c.orgCode = #{classGroupingPageForm.orgCode}
             </if>
@@ -36,14 +37,15 @@
         SELECT
         cg.id,
         cg.class_name AS classGroupingName,
-        u.realname AS coachUserName,
-        COUNT( cu.id ) AS applyNum
+        u.realname AS coachName,
+        COUNT( cu.id ) AS applyNum,
+        cg.create_time
         FROM
         nm_class_grouping cg
         LEFT JOIN sys_user u ON u.id = cg.coach_user_id
         LEFT JOIN nm_class_user cu ON cu.class_grouping_id = cg.id
         <where>
-            cg.del_flag = 0
+            cg.del_flag = 0 AND cu.del_flag = 0 AND cg.course_id = #{classGroupingCasePageForm.courseId}
             <if test="classGroupingCasePageForm.classGroupingName != null and classGroupingCasePageForm.classGroupingName != ''">
                 AND cg.class_name = #{classGroupingCasePageForm.classGroupingName}
             </if>
@@ -64,7 +66,7 @@
                 LEFT JOIN nm_class_user cu ON cu.class_grouping_id = cg.id
                 LEFT JOIN sys_user u ON u.id = cg.coach_user_id
         WHERE
-            cg.del_flag = 0
+            cg.del_flag = 0 AND cu.del_flag = 0
             AND cu.family_member_id = #{userId}
 	        AND cu.course_id = #{classId}
     </select>

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppCoursesMapper.xml

@@ -225,7 +225,7 @@
                 and c.org_code = #{orgCode}
             </if>
             <if test="userId != null and userId != ''">
-                and c.user_id = #{userId}
+                and c.user_id like CONCAT('%',#{userId},'%')
             </if>
         </where>
         ORDER BY c.create_time DESC

+ 32 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppCoursesVerificationRecordMapper.xml

@@ -6,13 +6,43 @@
         SELECT
         cvr.*
         FROM
-        `nm_courses_verification_record` cvr
+        nm_class_user cu
+        LEFT JOIN nm_class_grouping cg ON cg.id = cu.class_grouping_id
+        LEFT JOIN `nm_courses_verification_record` cvr ON cu.family_member_id = cvr.use_user_id
         LEFT JOIN nm_order o ON o.id = cvr.order_id
         <where>
-            o.del_flag = 0 AND o.pay_status = 1
+            o.del_flag = 0 AND cu.del_flag = 0 AND o.pay_status = 1
             <if test="coursePriceRulesId != null and coursePriceRulesId != ''">
                 AND cvr.courses_price_rule_id = #{coursePriceRulesId}
             </if>
+            <if test="coachUserId != null and coachUserId != ''">
+                AND cg.coach_user_id = #{coachUserId}
+            </if>
+            <if test="orPostpone != null">
+                AND cvr.or_postpone = #{orPostpone}
+            </if>
+            <if test="verifyStatus != null">
+                AND cvr.verify_status = #{verifyStatus}
+            </if>
+        </where>
+    </select>
+    <select id="queryTemporaryCourseUser" resultType="org.jeecg.modules.system.app.entity.AppCoursesVerificationRecord">
+        SELECT
+            cvr.*
+        FROM
+            nm_class_user cu
+                LEFT JOIN nm_class_grouping cg ON cg.id = cu.class_grouping_id
+                LEFT JOIN `nm_courses_verification_record` cvr ON cu.family_member_id = cvr.use_user_id
+        <where>
+            cu.del_flag = 0
+            AND cg.del_flag = 0
+            AND ( or_temporary_course = 1 OR courses_type = 1 )
+            <if test="coursePriceRulesId != null and coursePriceRulesId != ''">
+                AND cvr.courses_price_rule_id = #{coursePriceRulesId}
+            </if>
+            <if test="coachUserId != null and coachUserId != ''">
+                AND cg.coach_user_id = #{coachUserId}
+            </if>
             <if test="orPostpone != null">
                 AND cvr.or_postpone = #{orPostpone}
             </if>

+ 4 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/IAppCoursesVerificationRecordService.java

@@ -18,5 +18,8 @@ public interface IAppCoursesVerificationRecordService extends IService<AppCourse
 
     Boolean courseUploadImage(VerifyForm verifyForm);
 
-    List<AppCoursesVerificationRecord> courseQueryUsersList(@NotBlank(message = "课时ID不能为空") String coursePriceRulesId, Integer orPostpone, Integer verifyStatus);
+    List<AppCoursesVerificationRecord> courseQueryUsersList(@NotBlank(message = "课时ID不能为空") String coursePriceRulesId, Integer orPostpone,
+                                                            Integer verifyStatus,String coachUserId);
+
+    List<AppCoursesVerificationRecord> queryTemporaryCourseUser(@NotBlank(message = "课时ID不能为空") String coursePriceRulesId, Integer orPostpone, Integer verifyStatus, String coachUserId);
 }

+ 1 - 4
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppClassGroupingServiceImpl.java

@@ -49,7 +49,7 @@ public class AppClassGroupingServiceImpl extends ServiceImpl<AppClassGroupingMap
         queryPage.getRecords().forEach(record -> {
 
             long AlreadyClassGroupingNum =
-                    appClassUserMapper.selectCount(Wrappers.lambdaQuery(AppClassUser.class).eq(AppClassUser::getClassGroupingId, record.getId()));
+                    appClassUserMapper.selectCount(Wrappers.lambdaQuery(AppClassUser.class).eq(AppClassUser::getCourseId, record.getId()));
 
             long UnClassGroupingNum = record.getApplyNum() - AlreadyClassGroupingNum;
 
@@ -78,9 +78,6 @@ public class AppClassGroupingServiceImpl extends ServiceImpl<AppClassGroupingMap
             List<AppClassUser> appClassUserList =
                     appClassUserMapper.selectList(Wrappers.lambdaQuery(AppClassUser.class).eq(AppClassUser::getCourseId, studentInfoForm.getCoursesId()));
 
-
-
-
             //根据当前课程查询订单
             List<AppOrderProInfo> orderProInfoList =
                     appOrderProInfoMapper.selectList(Wrappers.lambdaQuery(AppOrderProInfo.class).between(AppOrderProInfo::getOrderStatus, 1, 3).eq(AppOrderProInfo::getProductId, studentInfoForm.getCoursesId()));

+ 20 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoureseServiceImpl.java

@@ -80,6 +80,10 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
     private SysDepartMapper sysDepartMapper;
     @Resource
     private SeparateAccountsMapper separateAccountsMapper;
+    @Resource
+    private AppClassGroupingMapper appClassGroupingMapper;
+    @Resource
+    private AppClassUserMapper appClassUserMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -402,6 +406,13 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
     @Override
     public Boolean temporaryCourse(TemporaryCourseForm temporaryCourseForm) {
 
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //如果不是教练
+        String roleCode = user.getRoleCode();
+        if (!roleCode.contains("instructor")) {
+            throw new JeecgBootException("当前用户不是教练,请勿操作!");
+        }
+
         AppCoursesPriceRules appCoursesPriceRules = priceRulesMapper.selectById(temporaryCourseForm.getCoursePriceRulesId());
 
         for (String userId : temporaryCourseForm.getUserIds()) {
@@ -436,8 +447,16 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
 
             int insert = appCoursesVerificationRecordMapper.insert(appCoursesVerificationRecord);
             if (insert < 1) throw new JeecgBootException("临时约课创建失败", SC_INTERNAL_SERVER_ERROR_500);
+            //默认加入教练第一个班
+            List<AppClassGrouping> appClassGroupings = appClassGroupingMapper.selectList(Wrappers.<AppClassGrouping>lambdaQuery()
+                    .eq(AppClassGrouping::getCoachUserId, user.getId())
+                    .eq(AppClassGrouping::getCourseId, appCoursesPriceRules.getCoursesId()));
+            AppClassUser appClassUser = new AppClassUser();
+            appClassUser.setClassGroupingId(appClassGroupings.get(0).getId());
+            appClassUser.setCourseId(appCoursesPriceRules.getCoursesId());
+            appClassUser.setFamilyMemberId(userId);
+            appClassUserMapper.insert(appClassUser);
         }
-
         return Boolean.TRUE;
     }
 

+ 10 - 3
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/service/impl/AppCoursesVerificationRecordServiceImpl.java

@@ -65,7 +65,7 @@ public class AppCoursesVerificationRecordServiceImpl extends ServiceImpl<AppCour
                 throw new JeecgBootException("当前用户没有权限操作此课程");
             }
         } else {
-            if (!Objects.equals(appCourses.getUserId(), sysUser.getId())) {
+            if (!appCourses.getUserId().contains(sysUser.getId())) {
                 throw new JeecgBootException("当前用户没有权限操作此课程");
             }
         }
@@ -148,7 +148,14 @@ public class AppCoursesVerificationRecordServiceImpl extends ServiceImpl<AppCour
     }
 
     @Override
-    public List<AppCoursesVerificationRecord> courseQueryUsersList(String coursePriceRulesId, Integer orPostpone, Integer verifyStatus) {
-        return baseMapper.courseQueryUsersList(coursePriceRulesId,orPostpone, verifyStatus);
+    public List<AppCoursesVerificationRecord> courseQueryUsersList(String coursePriceRulesId, Integer orPostpone, Integer verifyStatus,
+                                                                   String coachUserId) {
+        return baseMapper.courseQueryUsersList(coursePriceRulesId,orPostpone, verifyStatus,coachUserId);
+    }
+
+    @Override
+    public List<AppCoursesVerificationRecord> queryTemporaryCourseUser(String coursePriceRulesId, Integer orPostpone, Integer verifyStatus,
+                                                                       String coachUserId) {
+        return baseMapper.queryTemporaryCourseUser(coursePriceRulesId,orPostpone, verifyStatus,coachUserId);
     }
 }

+ 1 - 1
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/vo/ClassGroupingCaseVO.java

@@ -36,7 +36,7 @@ public class ClassGroupingCaseVO implements Serializable {
     /**
      * 教练名称
      */
-    private Integer coachName;
+    private String coachName;
 
     /**
      * 报名人数