feat(work): 添加课程数量统计功能
- 在 ITpCoursesService接口中添加 queryCount 方法 - 在 TpCoursesController 中添加 count 接口 - 在 TpCoursesServiceImpl 中实现 queryCount 方法,统计课程数量和订单相关数据- 更新 README.md,将项目名称改为"室内设计业务系统"
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.dromara.work.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -45,6 +46,15 @@ public class TpCoursesController extends BaseController {
|
||||
return tpCoursesService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计课程列表
|
||||
*/
|
||||
@SaCheckPermission("work:courses:list")
|
||||
@GetMapping("/count")
|
||||
public R<Map<String, Object>> count(TpCoursesBo bo) {
|
||||
return R.ok(tpCoursesService.queryCount(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出课程列表
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 课程Service接口
|
||||
@@ -65,4 +66,12 @@ public interface ITpCoursesService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 查询课程数量
|
||||
*
|
||||
* @param bo 课程
|
||||
* @return 课程数量
|
||||
*/
|
||||
Map<String, Object> queryCount(TpCoursesBo bo);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.dromara.work.mapper.TpCoursesMapper;
|
||||
import org.dromara.work.service.ITpCoursesService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
@@ -79,6 +80,26 @@ public class TpCoursesServiceImpl implements ITpCoursesService {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询课程数量
|
||||
*
|
||||
* @param bo 课程
|
||||
* @return 课程数量
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> queryCount(TpCoursesBo bo) {
|
||||
LambdaQueryWrapper<TpCourses> lqw = buildQueryWrapper(bo);
|
||||
List<TpCoursesVo> list = baseMapper.selectVoList(lqw);
|
||||
List<TpOrder> orderList = orderMapper.selectList(new LambdaQueryWrapper<TpOrder>().in(TpOrder::getCourseId, list.stream().map(TpCoursesVo::getId).toList()).ne(TpOrder::getPayState, 1));
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("count", list.size());
|
||||
map.put("bmNum", orderList.stream().mapToInt(TpOrder::getBmNum).sum());
|
||||
map.put("dcNum", orderList.stream().mapToInt(TpOrder::getDcNum).sum());
|
||||
map.put("price", orderList.stream().map(f -> new BigDecimal(String.valueOf(f.getPrice()))).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
map.put("payPrice", orderList.stream().map(f -> new BigDecimal(String.valueOf(f.getPayPrice()))).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的课程列表
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user