Răsfoiți Sursa

feat(system): 增加场地信息销售数量并优化查询逻辑- 在 AppSitePlaceMapper.xml 中添加销售数量字段和相关查询逻辑
- 更新 DetailServiceImpl 中的场地信息查询方法,使用新的销售数量字段
- 优化 SQL 查询,提高性能

SheepHy 3 săptămâni în urmă
părinte
comite
4fe1a7f13a

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

@@ -168,11 +168,14 @@ public class DetailServiceImpl implements IDetailService {
                         .last("limit 1").orderByDesc(AppSitePriceRules::getSellingPrice));
                 PlaceInfoVO.PlaceInfoMsgVO placeInfoMsgVO = new PlaceInfoVO.PlaceInfoMsgVO();
                 placeInfoMsgVO.setName(appSitePlace.getName())
-                        .setSales(Math.toIntExact(appOrderMapper.selectCount(Wrappers.<AppOrder>lambdaQuery().eq(AppOrder::getOrderCode, appSitePlace.getOrgCode()))))
                         .setId(appSitePlace.getId())
                         .setCategory(getCategoryName(appSite.getCategoryId()))
                         .setCover(appSitePlace.getCover().split(",")[0])
                         .setReminder(appSitePlace.getReminder())
+                        .setSales(Math.toIntExact(appOrderMapper.selectCount(Wrappers.<AppOrder>lambdaQuery()
+                                .eq(AppOrder::getOrderCode, appSitePlace.getOrgCode())
+                                .eq(AppOrder::getType,0)
+                                .eq(AppOrder::getOrderType,0))))
                         .setRefundType(appSitePlace.getRefundType());
                 if(appSitePriceRules!=null){
                     placeInfoMsgVO.setOriginalPrice(appSitePriceRules.getOriginalPrice());
@@ -259,6 +262,7 @@ public class DetailServiceImpl implements IDetailService {
             courseInfoVO.setSalesYear(getCourseSales(appCourses.getId()));
             courseInfoVO.setPriceType(isFirstPurchase(user.getId()));
             courseInfoVO.setCover(list.get(0));
+            courseInfoVO.setPeriod(Math.toIntExact(appCoursesPriceRulesMapper.selectCount(Wrappers.<AppCoursesPriceRules>lambdaQuery().eq(AppCoursesPriceRules::getCoursesId, appCourses.getId()))));
             courseInfoVO.setHasDiscount(checkOrderOrFree(user.getId(), appCourses.getCategoryId()));
             AppSite appSite = appSiteMapper.selectById(appCourses.getAddressSiteId());
             if (appSite!=null){

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

@@ -14,6 +14,7 @@
     </resultMap>
 
     <select id="getPlaceInfoNoFixation" resultType="org.jeecg.modules.app.vo.PlaceInfoVO$PlaceInfoGymMsgVO">
+
         SELECT
             b.id,
             a.name,
@@ -22,19 +23,41 @@
             MAX(b.selling_price) AS selling_price,
             a.cover,
             a.reminder,
-            a.refund_type
+            a.refund_type,
+            COALESCE(o.sales, 0) AS sales
         FROM
             nm_site_place a
-                LEFT JOIN nm_site_price_rules b ON a.id = b.site_place_id
+                LEFT JOIN nm_site_price_rules b
+                          ON a.id = b.site_place_id
+                              AND b.day_of_week = DAYOFWEEK(NOW()) + 1
+                LEFT JOIN (
+                SELECT
+                    org_code,
+                    product_ids,
+                    COUNT(1) AS sales
+                FROM
+                    nm_order
+                WHERE
+                    type = 0
+                GROUP BY
+                    org_code, product_ids
+            ) o
+                          ON a.org_code = o.org_code
+                              AND b.id = o.product_ids
         WHERE
             a.site_id = #{id}
-          AND a.type = 2 AND b.day_of_week = DAYOFWEEK(NOW()) +1
+          AND a.type = 2
         GROUP BY
             b.id,
             a.name,
-            a.advance_time
+            a.advance_time,
+            a.cover,
+            a.reminder,
+            a.refund_type,
+            o.sales
         ORDER BY
             selling_price ASC;
+
     </select>
     <select id="findByConcerts" resultMap="ConcertsVOResult" >
      <![CDATA[   select b.site_place_id,a.name as site_place_name,