This commit is contained in:
Lx 2025-06-06 17:32:16 +08:00
parent 69044eabb4
commit 412897e5ac
16 changed files with 252 additions and 21 deletions

View File

@ -166,6 +166,15 @@ public class DlDriveSchoolCoachController {
return success(dlDriveSchoolCoachService.getCoachByIdAndTime(id,timeType,startTime,endTime));
}
@GetMapping("/getBusinessByIdAndTime")
@Operation(summary = "获得驾校业务经理")
public CommonResult<?> getBusinessByIdAndTime(@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.getBusinessByIdAndTime(id,timeType,startTime,endTime));
}
/**
*
* @author vinjor-M

View File

@ -105,6 +105,7 @@ public interface DlDriveSchoolCoachService extends IService<DlDriveSchoolCoach>
**/
CoachInfoVO getCoachById(String id);
CoachInfoVO getCoachByIdAndTime(String id, String timeType, String startTime, String endTime);
CoachInfoVO getBusinessByIdAndTime(String id, String timeType, String startTime, String endTime);
/**
* 根据邀请码查询教练信息

View File

@ -211,11 +211,16 @@ public class DataViewServiceImpl implements DataViewService {
double coachAmount = 0;
int schoolNum = 0;
double schoolAmount = 0;
int businessNum = 0;
double businessAmount = 0;
for (DlDriveSchoolStudentVO item : studentList) {
if ("02".equals(item.getSource())) {
//教练自招
coachNum++;
coachAmount = coachAmount + item.getPriceAmount();
} else if ("04".equals(item.getSource())) {
businessNum++;
businessAmount = businessAmount + item.getPriceAmount();
} else {
//驾校统招
schoolNum++;
@ -225,6 +230,7 @@ public class DataViewServiceImpl implements DataViewService {
int allNum = coachNum + schoolNum;
double coachRate = 0;
double schoolRate = 0;
double businessRate = 0;
if (allNum > 0) {
if (coachNum > 0) {
coachRate = (double) coachNum / allNum;
@ -232,6 +238,9 @@ public class DataViewServiceImpl implements DataViewService {
if (schoolNum > 0) {
schoolRate = (double) schoolNum / allNum;
}
if (businessNum > 0) {
businessRate = (double) businessNum / allNum;
}
}
studentInfoMap.put("coachNum", new BigDecimal(coachNum).setScale(2, RoundingMode.HALF_UP));
studentInfoMap.put("coachAmount", new BigDecimal(coachAmount).setScale(2, RoundingMode.HALF_UP));
@ -239,6 +248,9 @@ public class DataViewServiceImpl implements DataViewService {
studentInfoMap.put("schoolNum", schoolNum);
studentInfoMap.put("schoolAmount", schoolAmount);
studentInfoMap.put("schoolRate", 0 != schoolRate ? (Double.parseDouble(df.format(schoolRate)) * 100) : 0);
studentInfoMap.put("businessNum", businessNum);
studentInfoMap.put("businessAmount", businessAmount);
studentInfoMap.put("businessRate", 0 != businessRate ? (Double.parseDouble(df.format(businessRate)) * 100) : 0);
rtnObj.setStudentInfo(studentInfoMap);
/*4.财务情况--*/
//应收

View File

@ -643,6 +643,58 @@ public class DlDriveSchoolCoachServiceImpl extends ServiceImpl<DlDriveSchoolCoac
return result;
}
@Override
public CoachInfoVO getBusinessByIdAndTime(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);
/*3.统计教练的学生基本信息*/
//毕业情况
List<DlDriveSchoolStudentVO> studentVOList = studentMapper.selectStudentListBusiness(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<DlDriveSchoolStudentVO> studentList = studentMapper.selectStudentList(coach.getUserId(), startTimeStr, endTimeStr);
int coachNum=0;
double coachAmount=0;
for (DlDriveSchoolStudentVO item:studentList){
if("04".equals(item.getSource())){
//教练自招
coachNum++;
coachAmount = coachAmount+item.getPriceAmount();
}
}
studentInfoMap.put("coachNum",coachNum);
studentInfoMap.put("coachAmount",coachAmount);
result.setStudentInfoMap(studentInfoMap);
return result;
}
/**
* 根据邀请码查询教练信息
*/

View File

@ -456,6 +456,9 @@ public class DlDriveSchoolStudentServiceImpl extends ServiceImpl<DlDriveSchoolSt
if ("03".equals(type)) {
//自来的学生
return dlDriveSchoolStudentMapper.indexCusStudentList(startTime, endTime);
} else if ("04".equals(type)) {
//自来的学生
return dlDriveSchoolStudentMapper.indexGetTrainList(type, coachId, startTime, endTime);
} else {
return dlDriveSchoolStudentMapper.indexGetTrainList(type, coachId, startTime, endTime);
}

View File

@ -84,7 +84,9 @@ public class SchoolCourseOrderServiceImpl extends ServiceImpl<SchoolCourseOrderM
public void updateSchoolCourseOrder(SchoolCourseOrderVO updateReqVO) {
// 更新
SchoolCourseOrder updateObj = BeanUtils.toBean(updateReqVO, SchoolCourseOrder.class);
this.sendMessage(updateReqVO);
if(updateReqVO.getIsSign() != null){
this.sendMessage(updateReqVO);
}
schoolCourseOrderMapper.updateById(updateObj);
}

View File

@ -46,5 +46,4 @@ public class ExamBatchController {
return success(examBatchService.selectOneById(id));
}
}
}

View File

@ -48,4 +48,15 @@ public class ExamBatchItemController {
return success(true);
}
}
/**
* 所有教练所有考试信息
*/
@GetMapping("/batchItemListByCoach")
public CommonResult<IPage<?>> batchItemListByCoach(ExamBatchVO examBatchVO,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<ExamBatchVO> page = new Page<>(pageNo,pageSize);
return success(examBatchItemService.batchItemListByCoach(examBatchVO, page));
}
}

View File

@ -64,4 +64,6 @@ public class AppExamBatchController {
examBatchItemService.updateObjNew(examBatchVO);
return success(true);
}
}

View File

@ -32,4 +32,5 @@ public interface ExamBatchItemMapper extends BaseMapper<ExamBatchItem> {
List<ExamVO> selectExamByUserIdAndCoachId(@Param("userId") Long userId, @Param("coachId") Long coachId);
List<ExamBatchItemVO> listJoinBatchByIds(@Param("examIds") List<String> examIds);
IPage<ExamBatchVO> batchItemListByCoach(@Param("entity") ExamBatchVO examBatchVO, Page<ExamBatchVO> page);
}

View File

@ -84,4 +84,6 @@ public interface ExamBatchItemService extends IService<ExamBatchItem> {
* @return
*/
List<ExamBatchItemVO> listJoinBatchByIds(List<String> examIds);
IPage<ExamBatchVO> batchItemListByCoach(ExamBatchVO examBatchVO, Page<ExamBatchVO> page);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.exam.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.constant.SchoolBaseConstants;
import cn.iocoder.yudao.module.base.service.DlDriveSchoolStudentService;
@ -365,4 +366,41 @@ public class ExamBatchItemServiceImpl extends ServiceImpl<ExamBatchItemMapper, E
if (CollUtil.isEmpty(examIds)) return null;
return baseMapper.listJoinBatchByIds(examIds);
}
/**
* 所有教练所有考试信息
*
* @param
* @return
*/
@Override
public IPage<ExamBatchVO> batchItemListByCoach(ExamBatchVO examBatchVO, Page<ExamBatchVO> page) {
if (examBatchVO == null) {
return null;
}
String startTimeStr = "";
String endTimeStr = "";
String startTime = examBatchVO.getStartTimeSearch();
String endTime = examBatchVO.getEndTimeSearch();
String timeType = examBatchVO.getTimeType();
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";
}
examBatchVO.setStartTimeSearch(startTimeStr);
examBatchVO.setEndTimeSearch(endTimeStr);
return baseMapper.batchItemListByCoach(examBatchVO, page);
}
}

View File

@ -28,4 +28,14 @@ public class ExamBatchVO extends ExamBatch {
* 查询时间区间-结束
*/
private String endTimeSearch;
/**
* 通过人数
*/
private Integer passCount;
/**
* 学生人数
*/
private Integer studentCount;
}

View File

@ -160,6 +160,12 @@
AND (dss.phone LIKE CONCAT('%', #{entity.phone}, '%')
OR dsc.phone LIKE CONCAT('%', #{entity.phone}, '%'))
</if>
<if test="entity.isSign != null ">
AND dsco.is_sign = #{entity.isSign}
</if>
<if test="entity.paymentStatus != null and entity.paymentStatus != ''">
AND dsco.payment_status = #{entity.paymentStatus}
</if>
</where>
ORDER BY dsco.create_time DESC
</select>

View File

@ -317,37 +317,50 @@
<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
-- 使用 MAX/MIN 取任意一个订单信息(不累加)
MAX(dsco.course_type) AS courseType,
MAX(dsco.course_name) AS course_name,
MAX(dsco.payment_status) AS payment_status,
MAX(dsco.is_sign) AS is_sign,
MAX(dsco.reserve_money) AS reserve_money, -- 不累加,只取一个订单的金额
MAX(dsco.rest_money) AS rest_money, -- 不累加,只取一个订单的金额
MAX(dsco.pay_type) AS 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
LEFT JOIN drive_school_course_order dsco
ON dss.user_id = dsco.user_id
AND dsco.deleted = 0
AND dsco.if_end = 0
AND dsco.deleted = 0
WHERE
dss.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!=''">
<if test="startTime != null and startTime != ''">
AND dss.create_time &gt;= #{startTime}
</if>
<if test="endTime!=null and endTime!=''">
<if test="endTime != null and endTime != ''">
AND dss.create_time &lt;= #{endTime}
</if>
<if test="isSign!=null">
AND dsco.is_sign = #{isSign}
<if test="isSign == 1">
-- 有至少一条订单已面签
AND dss.user_id IN (
SELECT user_id FROM drive_school_course_order
WHERE is_sign = 1 AND deleted = 0 AND if_end = 0
GROUP BY user_id
)
</if>
GROUP BY
dss.user_id
<if test="isSign == 0">
-- 没有任何一条订单是已面签的用户
AND dss.user_id NOT IN (
SELECT user_id FROM drive_school_course_order
WHERE is_sign = 1 AND deleted = 0 AND if_end = 0
GROUP BY user_id
)
</if>
GROUP BY dss.user_id -- 按学生分组,确保每个学生只出现一次
</select>
<select id="selectTrainStudent" resultType="cn.iocoder.yudao.module.base.vo.DlDriveSchoolStudentVO">
@ -428,6 +441,9 @@
<when test="type=='02'">
AND c.type='jl'
</when>
<when test="type=='04'">
AND c.type='ywjl'
</when>
</choose>
</if>
GROUP BY

View File

@ -158,4 +158,71 @@
#{id}
</foreach>
</select>
<select id="batchItemListByCoach" resultType="cn.iocoder.yudao.module.exam.vo.ExamBatchVO">
SELECT
c.user_id AS coach_id,
c.name AS coach_name,
COUNT(i.id) AS student_count,
SUM(CASE WHEN i.if_pass = 1 THEN 1 ELSE 0 END) AS pass_count,
ROUND(
IFNULL(SUM(CASE WHEN i.if_pass = 1 THEN 1 ELSE 0 END) / NULLIF(COUNT(i.id), 0) * 100, 0),
2
) AS pass_rate
FROM
drive_school_coach c
LEFT JOIN drive_school_exam_batch b
ON b.coach_id = c.user_id AND b.deleted = 0
<if test="entity.subject != null and entity.subject != '' ">
AND b.subject = #{entity.subject}
</if>
LEFT JOIN drive_school_exam_batch_item i
ON i.batch_id = b.id AND i.deleted = 0
<if test="entity.startTimeSearch != null and entity.startTimeSearch != '' ">
AND i.create_time &gt;= #{entity.startTimeSearch}
</if>
<if test="entity.endTimeSearch != null and entity.endTimeSearch != '' ">
AND i.create_time &lt;= #{entity.endTimeSearch}
</if>
WHERE
c.deleted = 0
<if test="entity.coachId != null">
AND c.id = #{entity.coachId}
</if>
GROUP BY
c.id, c.name
ORDER BY
student_count DESC
<!--SELECT
b.coach_id,
b.coach_name,
COUNT(i.id) AS student_count,
SUM(CASE WHEN i.if_pass = 1 THEN 1 ELSE 0 END) AS pass_count,
ROUND(
SUM(CASE WHEN i.if_pass = 1 THEN 1 ELSE 0 END) / NULLIF(COUNT(i.id), 0) * 100,
2
) AS pass_rate
FROM
drive_school_exam_batch b
LEFT JOIN drive_school_exam_batch_item i
ON b.id = i.batch_id AND i.deleted = 0
WHERE
b.deleted = 0
<if test="entity.subject != null">
AND b.subject = #{entity.subject}
</if>
<if test="entity.startTimeSearch != null and entity.startTimeSearch != '' ">
AND i.create_time &gt;= #{entity.startTimeSearch}
</if>
<if test="entity.endTimeSearch != null and entity.endTimeSearch != '' ">
AND i.create_time &lt;= #{entity.endTimeSearch}
</if>
<if test="entity.coachId != null">
AND b.coach_id = #{entity.coachId}
</if>
GROUP BY
b.coach_id, b.coach_name
ORDER BY
student_count DESC-->
</select>
</mapper>