Quellcode durchsuchen

补充教练的订单数和授课人数

zhangxin vor 3 Tagen
Ursprung
Commit
e58dfce7ff

+ 2 - 2
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/controller/coach/CoachController.java

@@ -38,7 +38,7 @@ public class CoachController {
      * @Date 19:41 2025/7/11
      **/
     @GetMapping("/findCoachList")
-    @Operation(summary = "查询全部教练-缺少订单数和评价")
+    @Operation(summary = "查询全部教练")
     public Result<List<AppCoachVO>> findCoachList(){
         return iCoachService.findCoachList();
     }
@@ -48,7 +48,7 @@ public class CoachController {
      * @Date 19:41 2025/7/11
      **/
     @GetMapping("/findByCoachId")
-    @Operation(summary = "查询教练详情-缺少订单数和评价")
+    @Operation(summary = "查询教练详情")
     public Result<AppCoachDetailsVO> findByCoachId(AppCoachDetailsRequestVO appCoachDetailsRequestVO){
         if (StringUtils.isEmpty(appCoachDetailsRequestVO.getId())){
          return Result.error("查询失败,教练编号为空");

+ 22 - 14
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/CoachServiceImpl.java

@@ -14,7 +14,7 @@ import org.jeecg.modules.app.vo.course.CourseRequestVo;
 import org.jeecg.modules.app.vo.course.CourseResponseVo;
 import org.jeecg.modules.system.app.entity.AppCategory;
 import org.jeecg.modules.system.app.entity.AppOrder;
-import org.jeecg.modules.system.app.entity.AppOrderProduct;
+import org.jeecg.modules.system.app.entity.AppOrderProInfo;
 import org.jeecg.modules.system.app.mapper.*;
 import org.jeecg.modules.system.util.PositionUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,8 +41,9 @@ public class CoachServiceImpl implements ICoachService {
     AppCoursesMapper appCoursesMapper;
     @Autowired
     private AppOrderMapper appOrderMapper;
+
     @Autowired
-    private AppOrderProductMapper appOrderProductMapper;
+    private AppOrderProInfoMapper appOrderProInfoMapper;
 
     @Override
     public Result<List<AppCoachVO>> findCoachList() {
@@ -91,10 +92,17 @@ public class CoachServiceImpl implements ICoachService {
                 courseResponseVo.setKm(km);
             }
         }
+        Long  teachingCount=0L;
+        Long  orderNumCount=0L;
+        List<String> byInstructorId = appCoursesMapper.findByInstructorId(appCoachDetailsVO.getId());
         //缺少授课人数和订单数,评价
+        if (byInstructorId!=null&&!byInstructorId.isEmpty()){
+            teachingCount=   appOrderMapper.findByTeachingCount(byInstructorId);
+            orderNumCount=   appOrderMapper.findByOrderNumCount(byInstructorId);
+        }
 
-
-
+        appCoachDetailsVO.setClassesNumber(teachingCount);
+        appCoachDetailsVO.setOrderNumber(orderNumCount);
         return Result.ok(appCoachDetailsVO);
     }
 
@@ -112,13 +120,13 @@ public class CoachServiceImpl implements ICoachService {
         LocalDateTime startOfYear = now.withDayOfYear(1).atStartOfDay(); // 当前年份第一天
         LocalDateTime endOfYear = startOfYear.plusYears(1); // 下一年第一天
 
-        return Math.toIntExact(appOrderProductMapper.selectCount(
-                Wrappers.<AppOrderProduct>lambdaQuery()
-                        .eq(AppOrderProduct::getProductId, id)
-                        .eq(AppOrderProduct::getStatus,0)
-                        .eq(AppOrderProduct::getDelFlag,0)
-                        .ge(AppOrderProduct::getCreateTime, Date.from(startOfYear.atZone(ZoneId.systemDefault()).toInstant())) // >= 2025-01-01
-                        .lt(AppOrderProduct::getCreateTime, Date.from(endOfYear.atZone(ZoneId.systemDefault()).toInstant())) // < 2026-01-01
+        return Math.toIntExact(appOrderProInfoMapper.selectCount(
+                Wrappers.<AppOrderProInfo>lambdaQuery()
+                        .eq(AppOrderProInfo::getProductId, id)
+                        .eq(AppOrderProInfo::getStatus,0)
+                        .eq(AppOrderProInfo::getDelFlag,0)
+                        .ge(AppOrderProInfo::getCreateTime, Date.from(startOfYear.atZone(ZoneId.systemDefault()).toInstant())) // >= 2025-01-01
+                        .lt(AppOrderProInfo::getCreateTime, Date.from(endOfYear.atZone(ZoneId.systemDefault()).toInstant())) // < 2026-01-01
         ));
     }
 
@@ -130,9 +138,9 @@ public class CoachServiceImpl implements ICoachService {
      * @return int 课程年销售数
      **/
     private int getCourseSalesCount(String id) {
-        return Math.toIntExact(appOrderProductMapper.selectCount(
-                Wrappers.<AppOrderProduct>lambdaQuery()
-                        .eq(AppOrderProduct::getProductId, id)
+        return Math.toIntExact(appOrderProInfoMapper.selectCount(
+                Wrappers.<AppOrderProInfo>lambdaQuery()
+                        .eq(AppOrderProInfo::getProductId, id)
         ));
     }
 

+ 8 - 5
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/GameServiceImpl.java

@@ -98,11 +98,14 @@ public class GameServiceImpl  implements IGameService {
                 strings.add(gamePriceRulesVO.getId());
             }
         }
-
-        int orderNum = appOrderMapper.countTypeAndProductIds(strings, CommonConstant.ORDER_TYPE_1);
-        findByIdResponse.setOrderNum(orderNum);
-        List<GameOrderVo> gameOrderVoList = appOrderMapper.findByNewOrderInfo(strings,CommonConstant.ORDER_TYPE_1);
-        findByIdResponse.setGameOrderVoList(gameOrderVoList);
+        if (strings!=null&&!strings.isEmpty()){
+            int orderNum = appOrderMapper.countTypeAndProductIds(strings, CommonConstant.ORDER_TYPE_1);
+            findByIdResponse.setOrderNum(orderNum);
+        }
+        if (strings!=null&&!strings.isEmpty()){
+            List<GameOrderVo> gameOrderVoList = appOrderMapper.findByNewOrderInfo(strings,CommonConstant.ORDER_TYPE_1);
+            findByIdResponse.setGameOrderVoList(gameOrderVoList);
+        }
         return Result.OK(findByIdResponse);
     }
 

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

@@ -16,6 +16,8 @@ import java.util.List;
 public class AppCoachDetailsVO {
     @Schema(description = "教练主键id")
     private String id;
+    @Schema(description = "教练主键id")
+    private String userId;
     @Schema(description = "教练姓名")
     private String realname;
     @Schema(description = "教练头像")
@@ -31,7 +33,10 @@ public class AppCoachDetailsVO {
     private BigDecimal goodRate;
     /**授课人数*/
     @Schema(description = "授课人数")
-    private Integer classesNumber;
+    private Long classesNumber;
+    /**订单数*/
+    @Schema(description = "订单数")
+    private Long orderNumber;
     /**教学理念*/
     @Schema(description = "教学理念")
     private String teachingPhilosophy;

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

@@ -26,7 +26,11 @@ public interface AppOrderMapper extends BaseMapper<AppOrder> {
      * @param type
      * @return
      */
-    int countTypeAndProductIds(@Param("productId") List<String> productIds, @Param("type") int type);
+    int countTypeAndProductIds(@Param("productIds") List<String> productIds, @Param("type") int type);
 
     List<GameOrderVo> findByNewOrderInfo(@Param("productIds")  List<String> productIds,@Param("orderType")  Integer orderType);
+
+    Long findByTeachingCount(@Param("productIds") List<String> productIds);
+
+    Long findByOrderNumCount(@Param("productIds") List<String> productIds);
 }

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

@@ -99,7 +99,7 @@
             left join  sys_user b on a.user_id = b.id
     </select>
     <select id="findById" resultType="org.jeecg.modules.app.vo.coach.AppCoachDetailsVO">
-        select a.user_id as id,b.realname,a.training_programs,a.good_rate,a.teaching_philosophy,a.excel_msg,b.avatar,a.background_img,
+        select a.id,a.user_id,b.realname,a.training_programs,a.good_rate,a.teaching_philosophy,a.excel_msg,b.avatar,a.background_img,
                b.certificate_innocence,b.healthy,b.honor  from nm_instructor a left join  sys_user b on a.user_id = b.id where a.user_id = #{id}
 
     </select>

+ 14 - 0
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/system/app/mapper/xml/AppOrderMapper.xml

@@ -56,4 +56,18 @@
         order by pay_time desc
         limit 20
     </select>
+    <select id="findByTeachingCount" resultType="java.lang.Long">
+        select count(1)  from nm_order_pro_info
+        where product_id in
+        <foreach collection="productIds" item="productId" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+    </select>
+    <select id="findByOrderNumCount" resultType="java.lang.Long">
+        select count(DISTINCT  order_id)  from nm_order_pro_info
+        where product_id in
+        <foreach collection="productIds" item="productId" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+    </select>
 </mapper>