|
@@ -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)
|
|
|
));
|
|
|
}
|
|
|
|