浏览代码

修改课程相关代码

zhangxin 2 天之前
父节点
当前提交
fbe9185200

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

@@ -60,8 +60,8 @@ public class AppDetailController {
      **/
     @GetMapping("/courseInfoVOList")
     @Operation(summary = "根据课程类型查询课程列表")
-    public Result<List<PlaceInfoVO.CourseInfoVO>> courseInfoVOList(@RequestParam @Schema(description="类目id")String categoryId, @RequestParam @Schema(description="店铺ID")String id){
-        return Result.ok(detailService.courseInfoVOList(categoryId,id));
+    public Result<List<PlaceInfoVO.CourseInfoVO>> courseInfoVOList(@RequestParam @Schema(description="类目id")String categoryId, @RequestParam @Schema(description="店铺ID")String id,@RequestParam @Schema(description="经度")double longitude,@RequestParam @Schema(description="纬度")double latitude){
+        return Result.ok(detailService.courseInfoVOList(categoryId,id,longitude,latitude));
     }
 
     /**

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

@@ -37,7 +37,7 @@ public interface IDetailService {
      * @Param type 课程类型
      * @return List<PlaceInfoVO.CourseInfoVO>
      **/
-    List<PlaceInfoVO.CourseInfoVO> courseInfoVOList(String categoryId,String id);
+    List<PlaceInfoVO.CourseInfoVO> courseInfoVOList(String categoryId,String id,double longitude,double latitude);
     
     /** 
      * @Author SheepHy

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.app.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.log4j.Log4j2;
@@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -48,6 +50,9 @@ public class DetailServiceImpl implements IDetailService {
     private AppCoursesMapper appCoursesMapper;
     @Resource
     private AppOrderProductMapper appOrderProductMapper;
+
+    @Autowired
+    private AppOrderProInfoMapper appOrderProInfoMapper;
     @Resource
     private AppSitePriceRulesMapper appSitePriceRulesMapper;
     @Resource
@@ -155,7 +160,7 @@ public class DetailServiceImpl implements IDetailService {
     }
 
     @Override
-    public List<PlaceInfoVO.CourseInfoVO> courseInfoVOList(String categoryId,String id) {
+    public List<PlaceInfoVO.CourseInfoVO> courseInfoVOList(String categoryId,String id,double longitude,double latitude) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         List<PlaceInfoVO.CourseInfoVO> courseInfoVOList = new ArrayList<>();
         appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery()
@@ -173,6 +178,8 @@ public class DetailServiceImpl implements IDetailService {
             AppSite appSite = appSiteMapper.selectById(appCourses.getSiteId());
             if (appSite!=null){
                 courseInfoVO.setAddress(appSite.getAddress());
+                double km = PositionUtil.calculateDistance(latitude, longitude, appSite.getLatitude().doubleValue(), appSite.getLongitude().doubleValue());
+                courseInfoVO.setKm(new BigDecimal(String.valueOf(km)));
             }
 
             courseInfoVOList.add(courseInfoVO);
@@ -229,9 +236,19 @@ public class DetailServiceImpl implements IDetailService {
     @Override
     public List<AppCategory> getAllCategory(String id) {
         AppSite appSite = appSiteMapper.selectById(id);
-        return appCategoryMapper.selectList(Wrappers.<AppCategory>lambdaQuery()
-                .eq(AppCategory::getStatus,0).eq(AppCategory::getOrgCode,appSite.getOrgCode())
-                .eq(AppCategory::getDelFlag,0));
+        List<AppCategory> appCategories = new ArrayList<>();
+        if (appSite!=null &&StringUtils.isNotBlank(appSite.getCategoryId())){
+            List<String> strings = new ArrayList<>();
+            if (appSite.getCategoryId().indexOf(",")>0){
+                strings = Arrays.asList(appSite.getCategoryId().split(","));
+            }else {
+                strings.add(appSite.getCategoryId());
+            }
+            appCategories = appCategoryMapper.selectList(Wrappers.<AppCategory>lambdaQuery()
+                    .eq(AppCategory::getStatus, 0).in(AppCategory::getId,strings)
+                    .eq(AppCategory::getDelFlag, 0));
+        }
+        return appCategories;
     }
 
     /**
@@ -292,13 +309,13 @@ public class DetailServiceImpl implements IDetailService {
         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
         ));
     }
 
@@ -310,9 +327,9 @@ public class DetailServiceImpl implements IDetailService {
      * @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)
         ));
     }
 

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

@@ -65,7 +65,7 @@ public class PlaceInfoVO {
         @Schema(description = "销售数量")
         private int sales;
         @Schema(description = "退款类型;0可退/到期自动退 1限时退 2不可退")
-        private int refundType;
+        private Integer refundType;
         @Schema(description = "类目")
         private List<String> category;
         @Schema(description = "原价")