Эх сурвалжийг харах

refactor(app):优化课程验证记录查询逻辑

- 将 verificationRecordList 查询方式从 lambdaQuery 改为自定义 mapper 方法- 在 AppCoursesVerificationRecordMapper 中新增 getRecordList 方法
- 修改 XML 中的查询条件,修复字段引用错误
- 新增 getRecordList 的 SQL 查询语句,关联订单表并过滤有效订单
-优化查询性能,确保获取正确的课程验证记录列表
wzq 1 долоо хоног өмнө
parent
commit
071e153b5c

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

@@ -20,4 +20,6 @@ public interface AppCoursesVerificationRecordMapper extends BaseMapper<AppCourse
                                                             @Param("coachUserId") String coachUserId);
 
     List<AppCoursesVerificationRecord> queryTemporaryCourseUser(String coursePriceRulesId, Integer orPostpone, Integer verifyStatus, String coachUserId);
+
+    List<AppCoursesVerificationRecord> getRecordList(@Param("priceRulesId") String priceRulesId);
 }

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

@@ -36,7 +36,7 @@
         <where>
             cu.del_flag = 0
             AND cg.del_flag = 0
-            AND ( or_temporary_course = 1 OR courses_type = 1 )
+            AND ( cvr.or_temporary_course = 1 OR cvr.courses_type = 1 )
             <if test="coursePriceRulesId != null and coursePriceRulesId != ''">
                 AND cvr.courses_price_rule_id = #{coursePriceRulesId}
             </if>
@@ -51,4 +51,12 @@
             </if>
         </where>
     </select>
+    <select id="getRecordList" resultType="org.jeecg.modules.system.app.entity.AppCoursesVerificationRecord">
+        SELECT *
+        FROM nm_courses_verification_record cvr
+                 LEFT JOIN nm_order o ON o.id = cvr.order_id
+        WHERE o.del_flag = 0
+          AND o.order_status BETWEEN 1 AND 3
+          AND cvr.courses_price_rule_id = #{priceRulesId}
+    </select>
 </mapper>

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

@@ -357,8 +357,7 @@ public class AppCoureseServiceImpl extends ServiceImpl<AppCoursesMapper, AppCour
             coursesPriceRulesVO.setEndTime(priceRules.getEndTime());
             coursesPriceRulesVO.setCoursesType(priceRules.getCoursesType());
 
-            List<AppCoursesVerificationRecord> verificationRecordList = appCoursesVerificationRecordMapper
-                    .selectList(Wrappers.<AppCoursesVerificationRecord>lambdaQuery().eq(AppCoursesVerificationRecord::getCoursesPriceRuleId, priceRules.getId()));
+            List<AppCoursesVerificationRecord> verificationRecordList = appCoursesVerificationRecordMapper.getRecordList(priceRules.getId());
             ArrayList<AppCoursesVerificationRecord> verificationRecords = verificationRecordList.stream()
                     .collect(Collectors.collectingAndThen(
                             Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(AppCoursesVerificationRecord::getUseUserId))),