Przeglądaj źródła

feat(system): 添加课程价格规则查询功能并优化详情页面数据展示- 在 AppCoursesPriceRulesMapper 中添加 selectRuleIdsByCourseId 方法
- 在 DetailServiceImpl 中实现 getPlaceSales 方法,统计指定课程的总订单数
- 更新 getPlaceInfo 方法,增加价格信息展示

SheepHy 2 tygodni temu
rodzic
commit
1633a5c42b

+ 24 - 21
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/DetailServiceImpl.java

@@ -1,14 +1,15 @@
 package org.jeecg.modules.app.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.jeecg.modules.app.service.IDetailService;
 import org.jeecg.modules.app.vo.PlaceInfoVO;
+import org.jeecg.modules.system.app.entity.AppOrderProduct;
 import org.jeecg.modules.system.app.entity.AppSite;
-import org.jeecg.modules.system.app.mapper.AppCoursesMapper;
-import org.jeecg.modules.system.app.mapper.AppCoursesPriceRulesMapper;
-import org.jeecg.modules.system.app.mapper.AppOrderProductMapper;
-import org.jeecg.modules.system.app.mapper.AppSiteMapper;
+import org.jeecg.modules.system.app.entity.AppSitePriceRules;
+import org.jeecg.modules.system.app.mapper.*;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 public class DetailServiceImpl implements IDetailService {
     @Resource
@@ -19,14 +20,22 @@ public class DetailServiceImpl implements IDetailService {
     private AppCoursesPriceRulesMapper appCoursesPriceRulesMapper;
     @Resource
     private AppOrderProductMapper appOrderProductMapper;
+    @Resource
+    private AppSitePriceRulesMapper appSitePriceRulesMapper;
 
     @Override
     public PlaceInfoVO getPlaceInfo(String id) {
         AppSite appSite = appSiteMapper.selectById(id);
         PlaceInfoVO placeInfo = appSiteMapper.getPlaceInfo(id);
+        AppSitePriceRules appSitePriceRules = appSitePriceRulesMapper.selectOne(Wrappers.<AppSitePriceRules>lambdaQuery()
+                .eq(AppSitePriceRules::getSiteId, id)
+                .eq(AppSitePriceRules::getStatus, 0)
+                .last("limit 1"));
         PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
-//        placeInfoMsgVO.setName(appSite.getName())
-//                .setSales(appSite.getSales())
+        placeInfoMsgVO.setName(appSite.getName())
+                .setSales(getPlaceSales(id))
+                .setOriginalPrice(appSitePriceRules.getOriginalPrice())
+                .setSellingPrice(appSitePriceRules.getSellingPrice());
         return placeInfo;
     }
 
@@ -38,20 +47,14 @@ public class DetailServiceImpl implements IDetailService {
      * @Param
      **/
     public int getPlaceSales(String id) {
-//        List<String> ids = appCoursesPriceRulesMapper.selectObjs(
-//                        Wrappers.<AppCoursesPriceRules>lambdaQuery()
-//                                .eq(AppCoursesPriceRules::getCoursesId, id)
-//                                .select(AppCoursesPriceRules::getId)
-//                ).stream()
-//                .map(obj -> (String) obj)
-//                .collect(Collectors.toList());
-//        if (!ids.isEmpty()) {
-//            int totalOrders = appOrderProductMapper.selectCount(
-//                    Wrappers.<AppOrderProduct>lambdaQuery()
-//                            .in(AppOrderProduct::getProductId, ids)
-//            );
-//        }
-//
-        return 0;
+        List<String> ids = appCoursesPriceRulesMapper.selectRuleIdsByCourseId(id);
+        int totalOrders = 0;
+        if (!ids.isEmpty()) {
+            totalOrders = Math.toIntExact(appOrderProductMapper.selectCount(
+                    Wrappers.<AppOrderProduct>lambdaQuery()
+                            .in(AppOrderProduct::getProductId, ids)
+            ));
+        }
+        return totalOrders;
     }
 }

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

@@ -1,10 +1,10 @@
 package org.jeecg.modules.system.app.mapper;
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.system.app.entity.AppCoursesPriceRules;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import java.util.List;
 
 /**
  * @Description: 课程价格规则表
@@ -13,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @Version: V1.0
  */
 public interface AppCoursesPriceRulesMapper extends BaseMapper<AppCoursesPriceRules> {
-
+    List<String> selectRuleIdsByCourseId(@Param("coursesId") String coursesId);
 }

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

@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.system.app.mapper.AppCoursesPriceRulesMapper">
-
+    <select id="selectRuleIdsByCourseId" resultType="string">
+        SELECT id FROM app_courses_price_rules WHERE courses_id = #{coursesId}
+    </select>
 </mapper>