This commit is contained in:
Lx 2025-06-03 16:22:52 +08:00
parent d5053744ee
commit bb1bfee430
17 changed files with 749 additions and 111 deletions

View File

@ -56,6 +56,28 @@ public class DataViewController {
return success(dataViewService.selectIndexInfo(type,timeType,coachId,startTime,endTime));
}
/**
* 业务经理首页数据统计查询接口 --
* @author vinjor-M
* @date 14:12 2025/2/14
* @param type 查询类型coach-教练查询|admin-管理员查询
* @param timeType 时间查询类型all-全部|day-当日|month-当月|more-自定义
* @param coachId 教练id
* @param startTime 查询时间范围--开始
* @param endTime 查询时间范围--结束
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/indexDataByBusiness")
@Operation(summary = "首页数据统计查询接口")
public CommonResult<?> selectIndexInfoByBusiness(@RequestParam(value = "type") String type,
@RequestParam(value = "timeType") String timeType,
@RequestParam(value = "coachId",required = false) Long coachId,
@RequestParam(value = "startTime",required = false) String startTime,
@RequestParam(value = "endTime",required = false) String endTime,
@RequestParam(value = "isSign",required = false) Integer isSign) {
return success(dataViewService.selectIndexInfoByBusiness(type,timeType,coachId,startTime,endTime, isSign));
}
/**
* 查询学生总数
* @author vinjor-M
@ -66,4 +88,4 @@ public class DataViewController {
public CommonResult<?> getStudentCount() {
return success(dataViewService.getStudentCount());
}
}
}

View File

@ -157,6 +157,15 @@ public class DlDriveSchoolCoachController {
return success(dlDriveSchoolCoachService.getCoachById(id));
}
@GetMapping("/getCoachByIdAndTime")
@Operation(summary = "获得驾校教练")
public CommonResult<?> appGetCoachByIdAndTime(@RequestParam("id") String id,
@RequestParam(value = "timeType") String timeType,
@RequestParam(value = "startTime",required = false) String startTime,
@RequestParam(value = "endTime",required = false) String endTime) {
return success(dlDriveSchoolCoachService.getCoachByIdAndTime(id,timeType,startTime,endTime));
}
/**
*
* @author vinjor-M

View File

@ -1,10 +1,7 @@
package cn.iocoder.yudao.module.base.mapper;
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStaffVO;
import cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO;
import cn.iocoder.yudao.module.base.vo.DriveSchoolStudentExportVo;
import cn.iocoder.yudao.module.base.vo.StudentCountVO;
import cn.iocoder.yudao.module.base.vo.*;
import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
import cn.iocoder.yudao.module.inspection.vo.InspectionStaffExportVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -103,6 +100,7 @@ public interface DlDriveSchoolStudentMapper extends BaseMapper<DlDriveSchoolStud
**/
List<DlDriveSchoolStudentVO> selectStudentListCoach(@Param("coachId") Long coachId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<DlDriveSchoolStudentVO> selectStudentListBusiness(@Param("coachId") Long coachId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<DlDriveSchoolStudentByBusinessVO> selectStudentListByBusiness(@Param("coachId") Long coachId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("isSign") Integer isSign);
/**
* app首页查询训练学员---指定条件下

View File

@ -30,6 +30,7 @@ public interface DataViewService {
* @param endTime 查询时间范围--结束
**/
IndexDataVO selectIndexInfo(String type, String timeType, Long coachId, String startTime, String endTime);
IndexDataVO selectIndexInfoByBusiness(String type, String timeType, Long coachId, String startTime, String endTime, Integer isSign);
/**
* 查询学生总数
@ -38,4 +39,4 @@ public interface DataViewService {
* @return java.util.Map<java.lang.String,java.lang.Object>
**/
Map<String,Object> getStudentCount();
}
}

View File

@ -104,6 +104,7 @@ public interface DlDriveSchoolCoachService extends IService<DlDriveSchoolCoach>
* @return cn.iocoder.yudao.module.base.vo.CoachInfoVO
**/
CoachInfoVO getCoachById(String id);
CoachInfoVO getCoachByIdAndTime(String id, String timeType, String startTime, String endTime);
/**
* 根据邀请码查询教练信息

View File

@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.train.entity.Train;
import cn.iocoder.yudao.module.train.mapper.TrainMapper;
import cn.iocoder.yudao.module.train.service.TrainService;
import cn.iocoder.yudao.module.train.vo.TrainVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -67,7 +68,7 @@ public class DataViewServiceImpl implements DataViewService {
* @date 14:37 2025/2/8
**/
@Override
public StudentInfoVO selectStudentInfo(Long id,Long coachId) {
public StudentInfoVO selectStudentInfo(Long id, Long coachId) {
StudentInfoVO studentInfoVO = new StudentInfoVO();
// 学员主信息
@ -185,132 +186,132 @@ public class DataViewServiceImpl implements DataViewService {
//默认查全部数据
String startTimeStr = "";
String endTimeStr = "";
if("more".equals(timeType)){
if(StringUtils.isNotEmpty(startTime)){
startTimeStr = startTime+" 00:00:01";
if ("more".equals(timeType)) {
if (StringUtils.isNotEmpty(startTime)) {
startTimeStr = startTime + " 00:00:01";
}
if(StringUtils.isNotEmpty(endTime)) {
if (StringUtils.isNotEmpty(endTime)) {
endTimeStr = endTime + " 23:59:59";
}
}else if("month".equals(timeType)){
} else if ("month".equals(timeType)) {
//当月
startTimeStr = DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 00:00:01";
endTimeStr = DateUtil.format(DateUtil.endOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 23:59:59";
}else if("day".equals(timeType)){
startTimeStr = DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()), "yyyy-MM-dd") + " 00:00:01";
endTimeStr = DateUtil.format(DateUtil.endOfMonth(DateUtil.date()), "yyyy-MM-dd") + " 23:59:59";
} else if ("day".equals(timeType)) {
//当天
startTimeStr = DateUtil.formatDate(DateUtil.date())+" 00:00:01";
endTimeStr = DateUtil.formatDate(DateUtil.date())+" 23:59:59";
startTimeStr = DateUtil.formatDate(DateUtil.date()) + " 00:00:01";
endTimeStr = DateUtil.formatDate(DateUtil.date()) + " 23:59:59";
}
if("admin".equals(type)){
if ("admin".equals(type)) {
//管理员查询
/*1.招生情况*/
List<DlDriveSchoolStudentVO> studentList = studentMapper.selectStudentList(coachId, startTimeStr, endTimeStr);
Map<String,Object> studentInfoMap = new HashMap<>();
int coachNum=0;
double coachAmount=0;
int schoolNum=0;
double schoolAmount=0;
for (DlDriveSchoolStudentVO item:studentList){
if("02".equals(item.getSource())){
Map<String, Object> studentInfoMap = new HashMap<>();
int coachNum = 0;
double coachAmount = 0;
int schoolNum = 0;
double schoolAmount = 0;
for (DlDriveSchoolStudentVO item : studentList) {
if ("02".equals(item.getSource())) {
//教练自招
coachNum++;
coachAmount = coachAmount+item.getPriceAmount();
}else{
coachAmount = coachAmount + item.getPriceAmount();
} else {
//驾校统招
schoolNum++;
schoolAmount = schoolAmount+item.getPriceAmount();
schoolAmount = schoolAmount + item.getPriceAmount();
}
}
int allNum = coachNum+schoolNum;
double coachRate=0;
double schoolRate=0;
if(allNum>0){
if(coachNum>0){
coachRate = (double)coachNum / allNum;
int allNum = coachNum + schoolNum;
double coachRate = 0;
double schoolRate = 0;
if (allNum > 0) {
if (coachNum > 0) {
coachRate = (double) coachNum / allNum;
}
if(schoolNum>0){
schoolRate = (double)schoolNum / allNum;
if (schoolNum > 0) {
schoolRate = (double) schoolNum / allNum;
}
}
studentInfoMap.put("coachNum", new BigDecimal(coachNum).setScale(2, RoundingMode.HALF_UP));
studentInfoMap.put("coachAmount", new BigDecimal(coachAmount).setScale(2, RoundingMode.HALF_UP));
studentInfoMap.put("coachRate",0!=coachRate?(Double.parseDouble(df.format(coachRate))*100):0);
studentInfoMap.put("schoolNum",schoolNum);
studentInfoMap.put("schoolAmount",schoolAmount);
studentInfoMap.put("schoolRate",0!=schoolRate?(Double.parseDouble(df.format(schoolRate))*100):0);
studentInfoMap.put("coachRate", 0 != coachRate ? (Double.parseDouble(df.format(coachRate)) * 100) : 0);
studentInfoMap.put("schoolNum", schoolNum);
studentInfoMap.put("schoolAmount", schoolAmount);
studentInfoMap.put("schoolRate", 0 != schoolRate ? (Double.parseDouble(df.format(schoolRate)) * 100) : 0);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况--*/
//应收
Double showedReceive = courseOrderMapper.selectByCoachUserId(coachId,startTimeStr,endTimeStr);
Double showedReceive = courseOrderMapper.selectByCoachUserId(coachId, startTimeStr, endTimeStr);
//应付
List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId,startTimeStr,endTimeStr);
double showedPay =0.0;
for (SchoolCommission item:schoolCommissionList){
if(null!=item.getCommissionAmount()){
showedPay =showedPay+item.getCommissionAmount().doubleValue();
List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId, startTimeStr, endTimeStr);
double showedPay = 0.0;
for (SchoolCommission item : schoolCommissionList) {
if (null != item.getCommissionAmount()) {
showedPay = showedPay + item.getCommissionAmount().doubleValue();
}
}
Map<String,Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("inAmount",null==showedReceive?0:showedReceive);
moneyInfoMap.put("outAmount",showedPay);
Map<String, Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("inAmount", null == showedReceive ? 0 : showedReceive);
moneyInfoMap.put("outAmount", showedPay);
rtnObj.setMoneyInfo(moneyInfoMap);
}else if("coach".equals(type)){
} else if ("coach".equals(type)) {
//教练查询
/*1.学员情况*/
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListCoach(coachId,startTimeStr,endTimeStr);
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListCoach(coachId, startTimeStr, endTimeStr);
int overNum = (int) studentVOList.stream().filter(item -> null != item.getOrderGradTime()).count();
int noOverNum = studentVOList.size()-overNum;
int noOverNum = studentVOList.size() - overNum;
// courseTypeC1/C2统计
long c1Total = studentVOList.stream().filter(item -> "C1".equals(item.getCourseType())).count();
long c2Total = studentVOList.stream().filter(item -> "C2".equals(item.getCourseType())).count();
Map<String,Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("allNum",studentVOList.size());
studentInfoMap.put("overNum",overNum);
studentInfoMap.put("noOverNum",noOverNum);
Map<String, Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("allNum", studentVOList.size());
studentInfoMap.put("overNum", overNum);
studentInfoMap.put("noOverNum", noOverNum);
studentInfoMap.put("c1Total", c1Total);
studentInfoMap.put("c2Total", c2Total);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况-查教练自己应得的提成-*/
List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId,startTimeStr,endTimeStr);
double showedPay =0.0;
for (SchoolCommission item:schoolCommissionList){
if(null!=item.getCommissionAmount()){
showedPay =showedPay+item.getCommissionAmount().doubleValue();
List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId, startTimeStr, endTimeStr);
double showedPay = 0.0;
for (SchoolCommission item : schoolCommissionList) {
if (null != item.getCommissionAmount()) {
showedPay = showedPay + item.getCommissionAmount().doubleValue();
}
}
Map<String,Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("money",showedPay);
Map<String, Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("money", showedPay);
rtnObj.setMoneyInfo(moneyInfoMap);
}else if("business".equals(type)){
} else if ("business".equals(type)) {
//业务经理查询
/*1.招生情况*/
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListBusiness(coachId,startTimeStr,endTimeStr);
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListBusiness(coachId, startTimeStr, endTimeStr);
int overNum = (int) studentVOList.stream().filter(item -> null != item.getOrderGradTime()).count();
int noOverNum = studentVOList.size()-overNum;
int noOverNum = studentVOList.size() - overNum;
// courseTypeC1/C2统计
long c1Total = studentVOList.stream().filter(item -> "C1".equals(item.getCourseType())).count();
long c2Total = studentVOList.stream().filter(item -> "C2".equals(item.getCourseType())).count();
Map<String,Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("allNum",studentVOList.size());
studentInfoMap.put("overNum",overNum);
studentInfoMap.put("noOverNum",noOverNum);
Map<String, Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("allNum", studentVOList.size());
studentInfoMap.put("overNum", overNum);
studentInfoMap.put("noOverNum", noOverNum);
studentInfoMap.put("c1Total", c1Total);
studentInfoMap.put("c2Total", c2Total);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况-查教练自己应得的提成-*/
List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId,startTimeStr,endTimeStr);
double showedPay =0.0;
for (SchoolCommission item:schoolCommissionList){
if(null!=item.getCommissionAmount()){
showedPay =showedPay+item.getCommissionAmount().doubleValue();
List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId, startTimeStr, endTimeStr);
double showedPay = 0.0;
for (SchoolCommission item : schoolCommissionList) {
if (null != item.getCommissionAmount()) {
showedPay = showedPay + item.getCommissionAmount().doubleValue();
}
}
Map<String,Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("money",showedPay);
Map<String, Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("money", showedPay);
rtnObj.setMoneyInfo(moneyInfoMap);
}
/*2.训练情况*/
List<TrainVO> allTrainList = trainMapper.selectTrainByCondition(coachId,startTimeStr,endTimeStr);
List<TrainVO> allTrainList = trainMapper.selectTrainByCondition(coachId, startTimeStr, endTimeStr);
//所有车辆set目的是去重
Set<String> allCarSet = new HashSet<>();
Set<String> subject2CarSet = new HashSet<>();
@ -318,67 +319,120 @@ public class DataViewServiceImpl implements DataViewService {
Set<Long> allUserSet = new HashSet<>();
Set<Long> subject2UserSet = new HashSet<>();
Set<Long> subject3UserSet = new HashSet<>();
for (TrainVO trainVO:allTrainList){
if(2==trainVO.getSubject()){
for (TrainVO trainVO : allTrainList) {
if (2 == trainVO.getSubject()) {
subject2CarSet.add(trainVO.getCarNo());
allCarSet.add(trainVO.getCarNo());
subject2UserSet.add(trainVO.getUserId());
allUserSet.add(trainVO.getUserId());
}else if(3==trainVO.getSubject()){
} else if (3 == trainVO.getSubject()) {
subject3CarSet.add(trainVO.getCarNo());
allCarSet.add(trainVO.getCarNo());
subject3UserSet.add(trainVO.getUserId());
allUserSet.add(trainVO.getUserId());
}
}
Map<String,Object> trainInfoMap = new HashMap<>();
trainInfoMap.put("allCarNum",allCarSet.size());
trainInfoMap.put("subject2CarNum",subject2CarSet.size());
trainInfoMap.put("subject3CarNum",subject3CarSet.size());
trainInfoMap.put("allUserNum",allUserSet.size());
trainInfoMap.put("subject2UserNum",subject2UserSet.size());
trainInfoMap.put("subject3UserNum",subject3UserSet.size());
Map<String, Object> trainInfoMap = new HashMap<>();
trainInfoMap.put("allCarNum", allCarSet.size());
trainInfoMap.put("subject2CarNum", subject2CarSet.size());
trainInfoMap.put("subject3CarNum", subject3CarSet.size());
trainInfoMap.put("allUserNum", allUserSet.size());
trainInfoMap.put("subject2UserNum", subject2UserSet.size());
trainInfoMap.put("subject3UserNum", subject3UserSet.size());
rtnObj.setTrainInfo(trainInfoMap);
/*3.考试情况*/
List<ExamBatchItemVO> examBatchItemVOList = examBatchItemMapper.selectByCoachId(coachId,startTimeStr,endTimeStr);
List<ExamBatchItemVO> examBatchItemVOList = examBatchItemMapper.selectByCoachId(coachId, startTimeStr, endTimeStr);
Double subject2Num = 0.0;
Double subject3Num = 0.0;
Double subject2PassNum = 0.0;
Double subject3PassNum = 0.0;
for (ExamBatchItemVO exam:examBatchItemVOList){
if(2==exam.getSubject()){
for (ExamBatchItemVO exam : examBatchItemVOList) {
if (2 == exam.getSubject()) {
subject2Num++;
if(null!=exam.getIfPass() && exam.getIfPass()){
if (null != exam.getIfPass() && exam.getIfPass()) {
//考试通过
subject2PassNum++;
}
}else if(3==exam.getSubject()){
} else if (3 == exam.getSubject()) {
subject3Num++;
if(null!=exam.getIfPass() && exam.getIfPass()){
if (null != exam.getIfPass() && exam.getIfPass()) {
//考试通过
subject3PassNum++;
}
}
}
double subject2Rate=0;
double subject3Rate=0;
if(0!=subject2Num && 0!=subject2PassNum){
double subject2Rate = 0;
double subject3Rate = 0;
if (0 != subject2Num && 0 != subject2PassNum) {
subject2Rate = subject2PassNum / subject2Num;
}
if(0!=subject3Num && 0!=subject3PassNum){
if (0 != subject3Num && 0 != subject3PassNum) {
subject3Rate = subject3PassNum / subject3Num;
}
Map<String,Object> examInfoMap = new HashMap<>();
examInfoMap.put("subject2All",subject2Num);
examInfoMap.put("subject2Pass",subject2PassNum);
examInfoMap.put("subject2Rate",0!=subject2Rate?(Double.parseDouble(df.format(subject2Rate))*100):0);
examInfoMap.put("subject3All",subject3Num);
examInfoMap.put("subject3Pass",subject3PassNum);
examInfoMap.put("subject3Rate",0!=subject3Rate?(Double.parseDouble(df.format(subject3Rate))*100):0);
Map<String, Object> examInfoMap = new HashMap<>();
examInfoMap.put("subject2All", subject2Num);
examInfoMap.put("subject2Pass", subject2PassNum);
examInfoMap.put("subject2Rate", 0 != subject2Rate ? (Double.parseDouble(df.format(subject2Rate)) * 100) : 0);
examInfoMap.put("subject3All", subject3Num);
examInfoMap.put("subject3Pass", subject3PassNum);
examInfoMap.put("subject3Rate", 0 != subject3Rate ? (Double.parseDouble(df.format(subject3Rate)) * 100) : 0);
rtnObj.setExamInfo(examInfoMap);
return rtnObj;
}
@Override
public IndexDataVO selectIndexInfoByBusiness(String type, String timeType, Long coachId, String startTime, String endTime, Integer isSign) {
IndexDataVO rtnObj = new IndexDataVO();
DecimalFormat df = new DecimalFormat("#.00");
//默认查全部数据
String startTimeStr = "";
String endTimeStr = "";
if ("more".equals(timeType)) {
if (StringUtils.isNotEmpty(startTime)) {
startTimeStr = startTime + " 00:00:01";
}
if (StringUtils.isNotEmpty(endTime)) {
endTimeStr = endTime + " 23:59:59";
}
} else if ("month".equals(timeType)) {
//当月
startTimeStr = DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()), "yyyy-MM-dd") + " 00:00:01";
endTimeStr = DateUtil.format(DateUtil.endOfMonth(DateUtil.date()), "yyyy-MM-dd") + " 23:59:59";
} else if ("day".equals(timeType)) {
//当天
startTimeStr = DateUtil.formatDate(DateUtil.date()) + " 00:00:01";
endTimeStr = DateUtil.formatDate(DateUtil.date()) + " 23:59:59";
}
//业务经理查询
/*1.招生情况*/
List<DlDriveSchoolStudentByBusinessVO> studentVOList = studentMapper.selectStudentListByBusiness(coachId, startTimeStr, endTimeStr,isSign);
int overNum = (int) studentVOList.stream().filter(item -> null != item.getOrderGradTime()).count();
int noOverNum = studentVOList.size() - overNum;
// courseTypeC1/C2统计
long c1Total = studentVOList.stream().filter(item -> "C1".equals(item.getCourseType())).count();
long c2Total = studentVOList.stream().filter(item -> "C2".equals(item.getCourseType())).count();
Map<String, Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("allNum", studentVOList.size());
studentInfoMap.put("overNum", overNum);
studentInfoMap.put("noOverNum", noOverNum);
studentInfoMap.put("c1Total", c1Total);
studentInfoMap.put("c2Total", c2Total);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况-查教练自己应得的提成-*/
/*List<SchoolCommission> schoolCommissionList = commissionMapper.selectByCoachId(coachId, startTimeStr, endTimeStr);
double showedPay = 0.0;
for (SchoolCommission item : schoolCommissionList) {
if (null != item.getCommissionAmount()) {
showedPay = showedPay + item.getCommissionAmount().doubleValue();
}
}
Map<String, Object> moneyInfoMap = new HashMap<>();
moneyInfoMap.put("money", showedPay);
rtnObj.setMoneyInfo(moneyInfoMap);*/
return rtnObj;
}
/**
* 查询学生总数
*
@ -388,17 +442,38 @@ public class DataViewServiceImpl implements DataViewService {
**/
@Override
public Map<String, Object> getStudentCount() {
List<DlDriveSchoolStaffVO> list= studentMapper.selectStudentListCount();
List<DlDriveSchoolStaffVO> list = studentMapper.selectStudentListCount();
Map<String, Object> rtnMap = new HashMap<>();
rtnMap.put("all",list.size());
rtnMap.put("all", list.size());
//按courseType分组
Map<String, List<DlDriveSchoolStaffVO>> map = list.stream()
.filter(item -> item.getCourseType() != null) // 过滤掉 courseType null 的元素
.collect(Collectors.groupingBy(DlDriveSchoolStaffVO::getCourseType));
for (String key:map.keySet()){
rtnMap.put(key,map.get(key).size());
for (String key : map.keySet()) {
rtnMap.put(key, map.get(key).size());
}
// 已毕业人数gradTime 不为 null
Long graduatedCount = courseOrderMapper.selectCount(
new LambdaQueryWrapper<SchoolCourseOrder>()
.eq(SchoolCourseOrder::getIfEnd, false)
.in(SchoolCourseOrder::getPaymentStatus, Arrays.asList(2, 3, 4, 5))
.eq(SchoolCourseOrder::getIsSign, 1)
.isNotNull(SchoolCourseOrder::getGradTime)
);
// 未毕业人数gradTime null
Long notGraduatedCount = courseOrderMapper.selectCount(
new LambdaQueryWrapper<SchoolCourseOrder>()
.eq(SchoolCourseOrder::getIfEnd, false)
.in(SchoolCourseOrder::getPaymentStatus, Arrays.asList(2, 3, 4, 5))
.eq(SchoolCourseOrder::getIsSign, 1)
.isNull(SchoolCourseOrder::getGradTime)
);
rtnMap.put("graduated", graduatedCount);
rtnMap.put("notGraduated", notGraduatedCount);
return rtnMap;
}
}

View File

@ -483,6 +483,166 @@ public class DlDriveSchoolCoachServiceImpl extends ServiceImpl<DlDriveSchoolCoac
return result;
}
@Override
public CoachInfoVO getCoachByIdAndTime(String id, String timeType, String startTime, String endTime) {
DecimalFormat df = new DecimalFormat("#.00");
CoachInfoVO result = new CoachInfoVO();
//默认查全部数据
String startTimeStr = "";
String endTimeStr = "";
if("more".equals(timeType)){
if(org.apache.commons.lang3.StringUtils.isNotEmpty(startTime)){
startTimeStr = startTime+" 00:00:01";
}
if(org.apache.commons.lang3.StringUtils.isNotEmpty(endTime)) {
endTimeStr = endTime + " 23:59:59";
}
}else if("month".equals(timeType)){
//当月
startTimeStr = DateUtil.format(DateUtil.beginOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 00:00:01";
endTimeStr = DateUtil.format(DateUtil.endOfMonth(DateUtil.date()),"yyyy-MM-dd")+" 23:59:59";
}else if("day".equals(timeType)){
//当天
startTimeStr = DateUtil.formatDate(DateUtil.date())+" 00:00:01";
endTimeStr = DateUtil.formatDate(DateUtil.date())+" 23:59:59";
}
/*1.教练信息*/
DlDriveSchoolCoach coach = getById(id);
result.setCoachInfo(coach);
/*2.车辆信息*/
DriveSchoolCar schoolCar = null;
if (coach.getUserId() != null) {
schoolCar = schoolCarService.selectByCoachId(coach.getUserId());
if (schoolCar != null && schoolCar.getCarRegisterDate() != null) {
Long carOld = DateUtil.betweenYear(schoolCar.getCarRegisterDate(), new Date(), true);
schoolCar.setCarOld(carOld);
}
}
result.setCar(schoolCar);
/*3.统计教练的学生基本信息*/
//毕业情况
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListCoach(coach.getUserId(),startTimeStr,endTimeStr);
int overNum = (int) studentVOList.stream().filter(item -> null != item.getGradTime()).count();
int noOverNum = studentVOList.size()-overNum;
Map<String,Object> studentInfoMap = new HashMap<>();
studentInfoMap.put("overNum",overNum);
studentInfoMap.put("noOverNum",noOverNum);
//考试情况
List<ExamBatchItemVO> examBatchItemVOList = examBatchItemMapper.selectByCoachId(coach.getUserId(),startTimeStr,endTimeStr);
Double subject2Num = 0.0;
Double subject3Num = 0.0;
Double subject2PassNum = 0.0;
Double subject3PassNum = 0.0;
for (ExamBatchItemVO exam:examBatchItemVOList){
if(2==exam.getSubject()){
subject2Num++;
if(null!=exam.getIfPass() && exam.getIfPass()){
//考试通过
subject2PassNum++;
}
}else if(3==exam.getSubject()){
subject3Num++;
if(null!=exam.getIfPass() && exam.getIfPass()){
//考试通过
subject3PassNum++;
}
}
}
double subject2Rate=0;
double subject3Rate=0;
if(0!=subject2Num && 0!=subject2PassNum){
subject2Rate = subject2PassNum / subject2Num;
}
if(0!=subject3Num && 0!=subject3PassNum){
subject3Rate = subject3PassNum / subject3Num;
}
studentInfoMap.put("subject2All",subject2Num);
studentInfoMap.put("subject2Pass",subject2PassNum);
studentInfoMap.put("subject2Rate",0!=subject2Rate?(Double.parseDouble(df.format(subject2Rate))*100):0);
studentInfoMap.put("subject3All",subject3Num);
studentInfoMap.put("subject3Pass",subject3PassNum);
studentInfoMap.put("subject3Rate",0!=subject3Rate?(Double.parseDouble(df.format(subject3Rate))*100):0);
//招生情况
List<DlDriveSchoolStudentVO> studentList = studentMapper.selectStudentList(coach.getUserId(), startTimeStr, endTimeStr);
int coachNum=0;
double coachAmount=0;
for (DlDriveSchoolStudentVO item:studentList){
if("02".equals(item.getSource())){
//教练自招
coachNum++;
coachAmount = coachAmount+item.getPriceAmount();
}
}
studentInfoMap.put("coachNum",coachNum);
studentInfoMap.put("coachAmount",coachAmount);
//训练情况
List<TrainVO> trainList = trainMapper.selectTrainByCondition(coach.getUserId(),startTimeStr,endTimeStr);
Set<Long> allUserSet = new HashSet<>();
Double trainTime = 0.0;
for (TrainVO item:trainList){
allUserSet.add(item.getUserId());
if(null!=item.getTrainTime()){
trainTime =trainTime+item.getTrainTime();
}
}
studentInfoMap.put("trainUserNum",allUserSet.size());
studentInfoMap.put("trainTime",trainTime);
result.setStudentInfoMap(studentInfoMap);
/*4.财务情况*/
List<SchoolCommission> commissionList = commissionMapper.selectByCoachId(coach.getUserId(),startTimeStr,endTimeStr);
//科目2当月应付
Double subject2MonthShowed = 0.0;
//科目2累计已付
Double subject2Payed = 0.0;
//科目2累计应付
Double subject2Showed = 0.0;
//科目3当月应付
Double subject3MonthShowed = 0.0;
//科目3累计已付
Double subject3Payed = 0.0;
//科目3累计应付
Double subject3Showed = 0.0;
//当月时间范围
// 获取当前月份的开始时间和结束时间
DateTime startOfMonth = DateUtil.beginOfMonth(DateUtil.date());
DateTime endOfMonth = DateUtil.endOfMonth(DateUtil.date());
for (SchoolCommission item:commissionList){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String localDateTimeNowStr = item.getCreateTime().format(formatter);
DateTime createTime = DateUtil.parse(localDateTimeNowStr);
if("2".equals(item.getSubject())){
//科目二
subject2Showed=subject2Showed+item.getCommissionAmount().doubleValue();
if(null!=item.getIfPay() && item.getIfPay()){
subject2Payed=subject2Payed+item.getCommissionAmount().doubleValue();
}
if(createTime.isAfterOrEquals(startOfMonth) && createTime.isBeforeOrEquals(endOfMonth)){
//在当月内
subject2MonthShowed = subject2MonthShowed+item.getCommissionAmount().doubleValue();
}
}else if("3".equals(item.getSubject())){
//科目三
subject3Showed=subject3Showed+item.getCommissionAmount().doubleValue();
if(null!=item.getIfPay() && item.getIfPay()){
subject3Payed=subject3Payed+item.getCommissionAmount().doubleValue();
}
if(createTime.isAfterOrEquals(startOfMonth) && createTime.isBeforeOrEquals(endOfMonth)){
//在当月内
subject3MonthShowed = subject3MonthShowed+item.getCommissionAmount().doubleValue();
}
}
}
Map<String,Object> financeMap = new HashMap<>();
financeMap.put("subject2MonthShowed",subject2MonthShowed);
financeMap.put("subject2Showed",subject2Showed);
financeMap.put("subject2Payed",subject2Payed);
financeMap.put("subject3MonthShowed",subject3MonthShowed);
financeMap.put("subject3Showed",subject3Showed);
financeMap.put("subject3Payed",subject3Payed);
result.setFinanceMap(financeMap);
return result;
}
/**
* 根据邀请码查询教练信息
*/

View File

@ -0,0 +1,60 @@
package cn.iocoder.yudao.module.base.vo;
import cn.iocoder.yudao.module.base.entity.DlDriveSchoolStudent;
import cn.iocoder.yudao.module.course.entity.Process;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 驾校学员 Response VO")
@Data
@ExcelIgnoreUnannotated
public class DlDriveSchoolStudentByBusinessVO extends DlDriveSchoolStudent {
/**教练ID*/
private Long coachId;
/**教练姓名*/
private String coachName;
/**教练ID*/
private String courseId;
/**学习进度*/
private Process process;
/**总金额*/
private Double priceAmount;
/**课程类型*/
private String courseType;
/**科目*/
private Integer subject;
/**是否支付*/
private String paymentStatus;
/**是否终止*/
private String ifEnd;
/**终止原因*/
private String endReason;
/**订单金额*/
private BigDecimal reserveMoney;
/**尾款金额*/
private BigDecimal restMoney;
/**支付类型*/
private String payType;
/**时间查询类型all-全部|day-当日|month-当月|more-自定义)*/
private String timeType;
/**查询时间范围--开始*/
private String startTime;
/**查询时间范围--结束*/
private String endTime;
/**是否毕业*/
private String isGrad;
/**订单表中的毕业时间*/
private String orderGradTime;
/**课程名称*/
private String courseName;
/**订单ID*/
private String orderId;
/**排序方式asc desc*/
private String sort;
/**是否面签*/
private Integer isSign;
}

View File

@ -6,6 +6,8 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 驾校学员 Response VO")
@Data
@ExcelIgnoreUnannotated
@ -41,4 +43,6 @@ public class DlDriveSchoolStudentVO extends DlDriveSchoolStudent {
private String orderId;
/**排序方式asc desc*/
private String sort;
/**是否面签*/
private Integer isSign;
}

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.course.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.course.entity.SchoolStudentCommissionRecord;
import cn.iocoder.yudao.module.course.service.SchoolStudentCommissionRecordService;
import cn.iocoder.yudao.module.course.vo.SchoolStudentCommissionRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@RestController
@RequestMapping("/commissionRecord")
@Validated
public class SchoolStudentCommissionRecordController {
@Autowired
private SchoolStudentCommissionRecordService commissionRecordService;
@PostMapping("/create")
public CommonResult<?> createRecord(@RequestBody SchoolStudentCommissionRecord record) {
return success(commissionRecordService.createRecord(record));
}
@PutMapping("/update")
public CommonResult<Boolean> updateRecord(@RequestBody SchoolStudentCommissionRecord record) {
return success(commissionRecordService.updateRecord(record));
}
@DeleteMapping("/delete")
public CommonResult<Boolean> deleteRecord(@RequestParam("id") Long id) {
return success(commissionRecordService.deleteRecord(id));
}
@GetMapping("/get")
public CommonResult<?> getRecord(@RequestParam("id") Long id) {
SchoolStudentCommissionRecord record = commissionRecordService.getRecordById(id);
return success(record);
}
@GetMapping("/list-by-student")
public CommonResult<List<SchoolStudentCommissionRecord>> getRecordsByStudentId(@RequestParam("studentId") Long studentId) {
List<SchoolStudentCommissionRecord> list = commissionRecordService.getRecordsByStudentId(studentId);
return success(list);
}
@GetMapping("/list-by-coach")
public CommonResult<List<SchoolStudentCommissionRecord>> getRecordsByCoachId(@RequestParam("coachId") Long coachId) {
List<SchoolStudentCommissionRecord> list = commissionRecordService.getRecordsByCoachId(coachId);
return success(list);
}
@PutMapping("/update-grant-status")
public CommonResult<Boolean> updateGrantStatus(@RequestBody SchoolStudentCommissionRecord reqVO) {
return success(commissionRecordService.updateGrantStatus(reqVO.getId(), reqVO.getIsGrant()));
}
}

View File

@ -0,0 +1,72 @@
package cn.iocoder.yudao.module.course.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* 学员各科目提成记录表
*/
@TableName("drive_school_commission_record")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SchoolStudentCommissionRecord extends TenantBaseDO {
/**
* 主键id
*/
@TableId(type = IdType.ASSIGN_UUID)
private Long id;
/**
* 课程id
*/
private String courseId;
/**
* 课程名称
*/
private String courseName;
/**
* 科目
*/
private String courseSubject;
/**
* 学员id
*/
private Long studentId;
/**
* 学员姓名
*/
private String studentName;
/**
* 教练id
*/
private Long coachId;
/**
* 教练姓名
*/
private String coachName;
/**
* 科目提成金额
*/
private BigDecimal subjectCommission;
/**
* 是否发放
*/
private Integer isGrant;
}

View File

@ -0,0 +1,10 @@
package cn.iocoder.yudao.module.course.mapper;
import cn.iocoder.yudao.module.course.entity.SchoolStudentCommissionRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SchoolStudentCommissionRecordMapper extends BaseMapper<SchoolStudentCommissionRecord> {
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.course.service;
import cn.iocoder.yudao.module.course.entity.SchoolStudentCommissionRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
public interface SchoolStudentCommissionRecordService extends IService<SchoolStudentCommissionRecord> {
/**
* 创建学员提成记录
*/
boolean createRecord(SchoolStudentCommissionRecord record);
/**
* 更新学员提成记录
*/
boolean updateRecord(SchoolStudentCommissionRecord record);
/**
* 删除学员提成记录
*/
boolean deleteRecord(Long id);
/**
* 根据ID获取学员提成记录
*/
SchoolStudentCommissionRecord getRecordById(Long id);
/**
* 获取学员的所有提成记录
*/
List<SchoolStudentCommissionRecord> getRecordsByStudentId(Long studentId);
/**
* 获取教练的所有提成记录
*/
List<SchoolStudentCommissionRecord> getRecordsByCoachId(Long coachId);
/**
* 更新提成发放状态
*/
boolean updateGrantStatus(Long id, Integer isGrant);
}

View File

@ -0,0 +1,53 @@
package cn.iocoder.yudao.module.course.service.impl;
import cn.iocoder.yudao.module.course.entity.SchoolStudentCommissionRecord;
import cn.iocoder.yudao.module.course.mapper.SchoolStudentCommissionRecordMapper;
import cn.iocoder.yudao.module.course.service.SchoolStudentCommissionRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class SchoolStudentCommissionRecordServiceImpl extends ServiceImpl<SchoolStudentCommissionRecordMapper, SchoolStudentCommissionRecord> implements SchoolStudentCommissionRecordService {
@Override
public boolean createRecord(SchoolStudentCommissionRecord record) {
return save(record);
}
@Override
public boolean updateRecord(SchoolStudentCommissionRecord record) {
return updateById(record);
}
@Override
public boolean deleteRecord(Long id) {
return removeById(id);
}
@Override
public SchoolStudentCommissionRecord getRecordById(Long id) {
return getById(id);
}
@Override
public List<SchoolStudentCommissionRecord> getRecordsByStudentId(Long studentId) {
return lambdaQuery().eq(SchoolStudentCommissionRecord::getStudentId, studentId).list();
}
@Override
public List<SchoolStudentCommissionRecord> getRecordsByCoachId(Long coachId) {
return lambdaQuery().eq(SchoolStudentCommissionRecord::getCoachId, coachId).list();
}
@Override
public boolean updateGrantStatus(Long id, Integer isGrant) {
SchoolStudentCommissionRecord record = new SchoolStudentCommissionRecord();
record.setId(id);
record.setIsGrant(isGrant);
return updateById(record);
}
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.course.vo;
import java.math.BigDecimal;
public class SchoolStudentCommissionRecordVO {
private String courseId;
private String courseName;
private String courseSubject;
private Long studentId;
private String studentName;
private Long coachId;
private String coachName;
private BigDecimal subjectCommission;
private Integer isGrant;
}

View File

@ -160,8 +160,8 @@
dss.deleted = 0
AND dsco.if_end = 0
AND dsco.deleted = 0
AND dsco.payment_status in ( '2', '3', '4', '5' )
AND dsco.is_sign = 1
-- AND dsco.payment_status in ( '2', '3', '4', '5' )
-- AND dsco.is_sign = 1
AND dss.id IS NOT NULL
AND dss.source = '04'
AND dss.source_user_id = #{entity.coachId}
@ -177,6 +177,9 @@
<if test="entity.courseType!=null and entity.courseType!=''">
AND dsco.course_type = #{entity.courseType}
</if>
<if test="entity.isSign!=null">
AND dsco.is_sign = #{entity.isSign}
</if>
GROUP BY
dss.user_id
<choose>
@ -296,6 +299,43 @@
GROUP BY
dsco.id
</select>
<select id="selectStudentListByBusiness" resultType="cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentByBusinessVO">
SELECT
dss.*,
dsco.course_type AS courseType,
dsco.course_name,
dsco.payment_status,
dsco.is_sign,
dsco.reserve_money,
dsco.rest_money,
dsco.pay_type
FROM
drive_school_student dss
LEFT JOIN drive_school_course_order dsco ON dss.user_id = dsco.user_id
WHERE
dss.deleted = 0
AND dsco.deleted = 0
AND dsco.if_end = 0
AND dsco.deleted = 0
AND dss.id IS NOT NULL
AND dss.source = '04'
<if test="coachId != null and coachId != ''">
AND dss.source_user_id = #{coachId}
</if>
<if test="startTime!=null and startTime!=''">
AND dss.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
AND dss.create_time &lt;= #{endTime}
</if>
<if test="isSign!=null">
AND dsco.is_sign = #{isSign}
</if>
GROUP BY
dss.user_id
</select>
<select id="selectTrainStudent" resultType="cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO">
SELECT
dss.*,dsc.type AS courseType,dst.subject

View File

@ -0,0 +1,4 @@
<?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="cn.iocoder.yudao.module.course.mapper.SchoolStudentCommissionRecordMapper">
</mapper>