package com.ssj.dao.sys.teacher.dao.impl;

import com.ssj.dao.sys.teacher.dao.ITzybQueryDao;
import com.ssj.framework.core.persistence.PagingHibernateJdbcDao;
import com.ssj.service.conch.parents.request.OrderReq;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Repository
public class TzybQueryDaoImpl implements ITzybQueryDao {

	@Autowired
    private PagingHibernateJdbcDao dao;

	@Override
	public Map<String, Object> findChildInfo(String libId, String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.img_url,t.child_name,t.id,t.school,t.grade,t.banben,t.user_id, \n");
		selSQL.append("case when t.tags_character ='' and t.tags_habit='' then null when LENGTH(trim(t.tags_character))>0 and LENGTH(trim(t.tags_habit))=0 then t.tags_character\n");
		selSQL.append("when LENGTH(trim(t.tags_character))=0 and LENGTH(trim(t.tags_habit))>0 then t.tags_habit\n");
		selSQL.append("else concat(t.tags_character,';',t.tags_habit) end thabit,case when LENGTH(ifnull(t.derver,'1'))=0 then '1' else ifnull(t.derver,'1') end  as derver \n");
		selSQL.append("from tb_lib_vip t\n");
		//selSQL.append("left join tb_lib_vip_service t13 on t.id = t13.vip_id\n");
		selSQL.append("where t.id = ?  \n");
		queryParams.add(vipId);
		//queryParams.add(libId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null?null:list.get(0);
	}

	@Override
	public Map<String, Object> isPush(String libId, String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT id,img from zyb_student_push  \n");
		selSQL.append("where TO_DAYS(push_time) = TO_DAYS(NOW()) and lib_id=? and vip_id=? ");
		queryParams.add(libId);
		queryParams.add(vipId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> courseCostList(String libId,String vipId,String pushId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.id as zyb_course_id,t.course_name,ifnull(t11.time_cost,'0') as time_cost,t11.type from zyb_course t     \n");
		selSQL.append(" inner join tb_lib_vip_service t12 on t12.lib_id = t.lib_id and t.course_hour = t12.course_hour and t12.vip_id=? ");
		selSQL.append(" and t12.species ='S003' and t12.stat =1 ");
		selSQL.append("	left join zyb_student_work t11 on t.id = t11.zyb_course_id and t.lib_id = t11.lib_id and t11.vip_id=t12.vip_id and TO_DAYS(NOW()) = TO_DAYS(t11.push_time) ");
		selSQL.append("where t.lib_id = ?  ");
		selSQL.append("and t.num <4  ");
		selSQL.append("ORDER BY t.num  ");
		queryParams.add(vipId);
		queryParams.add(libId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> courseLibList(String libId, String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.id ,t.course_name,t11.type,ifnull(t11.time_cost,'0') as time_cost,t.num,t.course_hour from zyb_course t   \n");
		selSQL.append("inner join tb_lib_vip_service t12 on t12.lib_id = t.lib_id and t.course_hour = t12.course_hour and t12.vip_id=? \n");
		selSQL.append(" and t12.species ='S003' and t12.stat =1 ");
		selSQL.append("left join zyb_student_work t11 on t.id = t11.zyb_course_id and t.lib_id = t11.lib_id and t11.vip_id=t12.vip_id and TO_DAYS(NOW()) = TO_DAYS(t11.push_time) \n");
		selSQL.append("where t.lib_id = ?  \n");
		selSQL.append("ORDER BY t.num  ");
		queryParams.add(vipId);
		queryParams.add(libId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> getSconCourseTime(String libId, String isDever,String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.id as zyb_course_id,t.course_name,'' as type,ifnull(t13.time_cost,'0') as time_cost,t.num from zyb_course t \n");
		selSQL.append("inner join tb_lib_vip_service t12 on t12.lib_id = t.lib_id and t.course_hour = t12.course_hour and t12.vip_id=? \n");
		selSQL.append(" and t12.species ='S003' and t12.stat =1 ");
		selSQL.append("left join (\n");
		selSQL.append("select t12.`subject`,CEILING(sum(t13.cost)) as time_cost  from (\n");
		selSQL.append("SELECT t.used_time,t11.`subject`,count(DISTINCT t11.homework_id),t.id from scon_homework t\n");
		selSQL.append("inner  join scon_homework_picture  t11 on t.id = t11.homework_id\n");
		selSQL.append("where t.derver=? and TO_DAYS(NOW())=TO_DAYS(t.create_time)\n");
		selSQL.append("group by t11.homework_id,t11.`subject`\n");
		selSQL.append(") t12\n");
		selSQL.append("left join (\n");
		selSQL.append("SELECT a.id,a.used_time/count(1) as cost from (\n");
		selSQL.append("SELECT t.used_time,t11.`subject`,count(DISTINCT t11.homework_id),t.id from scon_homework t\n");
		selSQL.append("inner  join scon_homework_picture  t11 on t.id = t11.homework_id\n");
		selSQL.append("where t.derver=? and TO_DAYS(NOW())=TO_DAYS(t.create_time)\n");
		selSQL.append("group by t11.homework_id,t11.`subject`\n");
		selSQL.append(")a GROUP BY a.id\n");
		selSQL.append(")t13 on t12.id = t13.id\n");
		selSQL.append("GROUP BY t12.`subject`\n");
		selSQL.append(") t13 on t.course_name=t13.`subject`\n");
		selSQL.append("where t.lib_id = ? and t.num<4\n");
		selSQL.append("ORDER BY t.num  \n");
		queryParams.add(vipId);
		queryParams.add(isDever);
		queryParams.add(isDever);
		queryParams.add(libId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> getDeverImgList(String vipId, String courseName) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.file_key,t.derver,t.is_feedback FROM `scon_homework_picture` t \n");
		selSQL.append("where t.vip_id=? and TO_DAYS(t.create_time)=TO_DAYS(NOW()) and t.subject=? \n");
		queryParams.add(vipId);
		queryParams.add(courseName);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findFeddBackInfo(String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.file_key FROM `scon_homework_picture` t \n");
		selSQL.append("where  TO_DAYS(t.create_time)=TO_DAYS(NOW()) and t.vip_id = ? and t.is_feedback=0 and t.is_delete = 0 and t.is_mark in (0, 2)\n");
		queryParams.add(vipId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findEditImgList(String pushId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT c.img from zyb_student_push a \n");
		selSQL.append("left join zyb_student_work b on a.id = b.student_push_id \n");
		selSQL.append("INNER  join zyb_student_work_img c on b.id = c.object_id \n");
		selSQL.append("where a.id=? \n");
		selSQL.append("order by b.num  \n");
		queryParams.add(pushId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findIsHasTeacher(String vipId,String serviceId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t14.type,t14.status,DATE_FORMAT(t12.activate_time,'%Y-%m-%d %H:%i:%s') as activate_time,DATE_FORMAT(t14.create_time,'%Y-%m-%d %H:%i:%s')  as teacher_time,ifnull(t17.name,a.wx_name) as mastername,t11.name,t.vip_id,case when t16.create_time is not null then DATE_FORMAT(t16.create_time,'%Y-%m-%d %H:%i:%s') else null end create_time,t15.league_name,t.id,t12.parent_name,t12.child_name,IFNULL(t14.course_name,'全科') as course_name,t14.grade,t14.teacher_lever,t11.sex,t11.school_age,t.plan_status,t.teacher_id,t11.personal_label,t.course_time,t.start_time,t.end_time,t.course_type,t.call_time,case when t16.create_time is not null then DATE_FORMAT(t16.feedback_time,'%Y-%m-%d %H:%i:%s') else null end feedback_time,t13.old_class_time,t.lesson_service_id,t.course_know_id,t.confirm_time,t14.course_count-t14.is_listen_test as course_count from kmt_course t   \n");
		selSQL.append("left join tb_lib_manager t11 on t.teacher_id = t11.user_id and t11.type=7 and t11.state=1 \n");
		selSQL.append("left join tb_lib_vip  t12 on t.vip_id = t12.id \n");
		selSQL.append("left join tb_lesson_service_apply t13 on t.id = t13.kmt_course_id and t13.type=1 and t13.is_delete=0 and t13.status = 1 \n");
		selSQL.append("left join tb_lesson_service t14 on t.lesson_service_id = t14.id \n");
		selSQL.append("left join tb_lib_manager t17 on t14.master_id = t17.user_id and t17.type=6 \n");
		selSQL.append("left join tb_user a on t17.user_id = a.id \n");
		selSQL.append("left join tb_lib_join t15 on t14.lib_id = t15.id \n");
		selSQL.append("left join kmt_course_know t16 on t.course_know_id = t16.id \n");
		selSQL.append("where t.vip_id = ? and t.is_finish=0 and t.plan_status<5  and t14.`status` BETWEEN 0 and 1 \n");
		if(serviceId != null){
			selSQL.append(" and t.lesson_service_id = ? \n");
		}
		selSQL.append("order by t.course_time ASC,t.start_time ASC  limit 1 \n");
		queryParams.add(vipId);
		
		if(serviceId != null){
			queryParams.add(serviceId);
		}
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public Map<String, Object> findIsHasPay(String vipId) {
		
		return null;
	}

	@Override
	public List<Map<String, Object>> findCourseList(String serviceId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("select t.course_time,t.start_time,t.end_time,t12.order_money,t11.order_no from kmt_course t   \n");
		selSQL.append("left join tb_lesson_service t11 on t.lesson_service_id = t11.id \n");
		selSQL.append("left join tb_orders t12 on t11.order_no = t12.order_no  \n");
		selSQL.append("where t.lesson_service_id = ? \n");
		selSQL.append("order by t.course_time ASC,t.start_time ASC  \n");
		queryParams.add(serviceId);

		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findStudyMap(String vipId, String serviceId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT count(if(plan_status=5,true,null)) as finish_total,count(if(plan_status=5,true,null))+1 as finish_total2,count(1) as total from kmt_course   \n");
		selSQL.append("where vip_id=? and course_type=1 and state=1 \n");
		if(serviceId != null){
			selSQL.append(" and lesson_service_id = ? \n");
		}
		queryParams.add(vipId);
		if(serviceId != null){
			queryParams.add(serviceId);
		}
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> findOrderList(OrderReq req, String userId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.*,count(1) as course_count from( \n");
		selSQL.append("SELECT DISTINCT t11.id,t11.is_group,c.id as course_id,f.child_name,DATE_FORMAT(ifnull(e.initiate_time,t.create_time),'%Y.%m.%d') as create_time,IFNULL(t11.course_name,'全科') as course_name,t11.teacher_lever,t11.grade,t11.start_time,t11.end_time,t11.vip_id,t11.status,d.name as teacher_name,t.order_no,t.order_money,t11.order_id,c.teacher_id,e.stat from tb_orders t \n");
		selSQL.append("INNER join tb_lesson_service t11 on t.order_no= t11.order_no \n");
		selSQL.append("left join tb_lib_vip f on t11.vip_id = f.id \n");
		selSQL.append("left join kmt_course c on t11.id = c.lesson_service_id \n");
		selSQL.append("left join tb_lib_manager d on c.teacher_id = d.user_id and d.type=7 \n");
		selSQL.append("left join tb_lib_order_refunds e on e.order_details_id = t11.id and e.stat_void=1 \n");
		selSQL.append("where t.user_id = ? and c.course_type=1 \n");
		if(req.getOrderType()==0){ //未支付
			selSQL.append(" and t.order_status in (0,2) \n");
		}else if(req.getOrderType()==1){
			selSQL.append(" and t.order_status = 1 and e.id is null \n");
		}else if(req.getOrderType()==2){ //退款
			selSQL.append(" and (t.order_status = 4 or (t.order_status = 1 and e.id is not null  ))\n");
		}
		selSQL.append(") t group by t.id \n");
		queryParams.add(userId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findOrderInfo(String orderNo) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("select a.course_name,a.grade,a.order_money-(a.finish_count*a.class_price) as refund_price,a.finish_count*a.class_price as cost_money,a.finish_count,a.right_count,a.order_money from (   \n");
		selSQL.append("SELECT IFNULL(t.course_name,'全科') as course_name,t.grade,count(if(t11.course_type=1,true,null)) AS right_count,count(if((t11.is_finish=1 or t11.plan_status>3) and t11.course_type=1,true,null)) AS finish_count,t13.order_money,IFNULL(t.price,0) as class_price from tb_lesson_service t  \n");
		selSQL.append("left join tb_orders t13 on t.order_no = t13.order_no \n");
		selSQL.append("left join kmt_course t11 on t.id = t11.lesson_service_id  \n");
		selSQL.append("where t.order_no = ?)a \n"); 
		queryParams.add(orderNo);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> findStudentListByTeacherId(String teacherId,int state,String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT DISTINCT t.vip_id,t.lesson_service_id,t.teacher_lever from kmt_course t where t.teacher_id = ? and t.state=1 and t.lesson_service_id is not null and is_group=0 \n");
		if(state ==0){ //未反馈
			selSQL.append("and   t.is_finish=0 and t.plan_status <5 \n");
		}else{ //已反馈
			selSQL.append("and  (t.is_finish=1 or t.plan_status=5) and TO_DAYS(t.course_time)=TO_DAYS(NOW())  \n");
		}
		queryParams.add(teacherId);
		
		if(vipId !=null && !"".equals(vipId)){
			selSQL.append("and   t.vip_id= ? \n");
			queryParams.add(vipId);
		}
		
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findTodayFinishTask(String vipId, String serviceId) {
		return findFinishTask(vipId,serviceId,null);
	}

	@Override
	public List<Map<String, Object>> findOneDayFinishTask(String vipId, String serviceId, String courseDate) {
		return findFinishTask(vipId,serviceId,courseDate);
	}

	public List<Map<String, Object>> findFinishTask(String vipId, String serviceId, String courseDate){
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("select a.* from ( ");
		selSQL.append("SELECT c.child_name,a.class_line as `master`,a.id,a.feedback_time,count(if(t14.type=2,true,null)) as ndaonum,  \n");
		selSQL.append("count(if(t14.type=3,true,null)) as khggnum,count(if(t14.type !=2 and t14.type !=3 and t14.type is not null,true,null)) as ztnum,a.teacher_lever,'' as teacher_say,'' as explain_content from  \n");
		selSQL.append("(select t.vip_id,t.course_know_id,t.id,t.class_line,t.feedback_time,t.teacher_lever from  kmt_course  t  \n");
		selSQL.append("where t.plan_status=5  and t.lesson_service_id=? and t.vip_id=?  and t.teacher_lever in ('注册老师','明星老师','资深老师','') \n");
		if(StringUtils.isNotBlank(courseDate)){
			selSQL.append(" and to_days(t.course_time) = to_days(date_format('"+courseDate+"','%Y-%m-%d'))");
		}
		selSQL.append("    ) a \n");
		selSQL.append("left JOIN kmt_course_know b on a.course_know_id = b.id \n");
		selSQL.append("left join tb_lib_vip c on a.vip_id = c.id \n");
		selSQL.append("LEFT JOIN kmt_img_face t11 on a.course_know_id = t11.course_know_id \n");
		selSQL.append("LEFT JOIN kmt_img_face_detail t12 on t11.id = t12.face_id  \n");
		selSQL.append("LEFT JOIN kmt_print_manage t13 on t11.course_know_id = t13.course_know_id \n");
		selSQL.append("left join kmt_course_question_detail t14 on t11.course_know_id=t14.course_know_id and t12.question_id = t14.question_id \n");
		selSQL.append(" group by a.id \n");
		selSQL.append("union all \n");
		selSQL.append("SELECT t13.child_name,0 as class_line,t.id,t.feedback_time,0 as ndaonum,0 as khggnum,0 as ztnum,t.teacher_lever,t11.teacher_say,t12.explain_content from kmt_course t   \n");
		selSQL.append("left join kmt_course_xb_feedback t11 on t.id = t11.kmt_course_id and t11.course_name='总体'  \n");
		selSQL.append("left join kmt_course_xb_feedback t12 on t.id = t12.kmt_course_id and t12.course_name='数学' \n");
		selSQL.append("INNER JOIN tb_lib_vip t13 on t.vip_id = t13.id \n");
		selSQL.append("where t.vip_id=? and t.lesson_service_id=?  and  t.teacher_lever='学霸老师' and t.plan_status=5 \n");
		if(StringUtils.isNotBlank(courseDate)){
			selSQL.append(" and to_days(t.course_time) = to_days(date_format('"+courseDate+"','%Y-%m-%d'))");
		}
		selSQL.append(")a  \n");
		selSQL.append(" ORDER BY a.feedback_time desc");
		queryParams.add(serviceId);
		queryParams.add(vipId);
		queryParams.add(vipId);
		queryParams.add(serviceId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findFeedbackDetail(String courseId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT c.user_id,c.child_name,d.`name`,d.t_photo,c.img_url,IFNULL(t.course_name,'全科') as course_name,t.grade,b.title,b.target,a.class_line,a.teacher_say,a.study_active,a.parent_view_time from kmt_course a   \n");
		selSQL.append("left join tb_lesson_service t on a.lesson_service_id = t.id  \n");
		selSQL.append("left join kmt_course_know b on a.course_know_id = b.id  \n");
		selSQL.append("left join tb_lib_vip c on a.vip_id = c.id  \n");
		selSQL.append(" left join tb_lib_manager d on a.teacher_id = d.user_id and d.type=7 and d.state=1 \n");
		selSQL.append("where a.id = ?  \n");
		queryParams.add(courseId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> findFeedbackList(String vipId, String date) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT a.id ,a.feedback_time,IFNULL(t11.course_name,'全科') as course_name from kmt_course a    \n");
		selSQL.append("left join tb_lesson_service t11 on a.lesson_service_id = t11.id   \n");
		selSQL.append("where TO_DAYS(a.course_time)=TO_DAYS(date_format(?,'%Y-%m-%d')) and a.is_finish =1 and a.vip_id = ?  \n");
		queryParams.add(date);
		queryParams.add(vipId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findCourseList(String vipId, String date) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT DISTINCT a.id,IFNULL(b.course_name,'全科') as course_name,b.grade,c.`name`,a.course_type,a.course_time,a.start_time from kmt_course a     \n");
		selSQL.append("left join tb_lesson_service b on a.lesson_service_id = b.id  \n");
		selSQL.append("left join tb_lib_manager c on a.teacher_id = c.user_id and c.type=7  \n");
		selSQL.append("where TO_DAYS(a.course_time)=TO_DAYS(date_format(?,'%Y-%m-%d')) and a.is_finish =0 and a.vip_id = ? \n");
		queryParams.add(date);
		queryParams.add(vipId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findSubjectList(String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT DISTINCT t.id,t.vip_id from tb_lesson_service t  left join tb_orders t11 on t.order_no=t11.order_no where t.vip_id = ? and t.`status` BETWEEN 0 and 2  order by t11.pay_time desc,t.create_time DESC \n");
		queryParams.add(vipId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findTimeCostBySubject(String derver, String courseName) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT ifnull(t13.time_cost,'0') as time_cost from  \n");
		selSQL.append(" (\n");
		selSQL.append("select t12.`subject`,FLOOR(sum(t13.cost)) as time_cost  from (\n");
		selSQL.append("SELECT t.used_time,t11.`subject`,count(DISTINCT t11.homework_id),t.id from scon_homework t\n");
		selSQL.append("inner  join scon_homework_picture  t11 on t.id = t11.homework_id\n");
		selSQL.append("where t.derver=? and TO_DAYS(NOW())=TO_DAYS(t.create_time) and t11.`subject`= ? \n");
		selSQL.append("group by t11.homework_id,t11.`subject`\n");
		selSQL.append(") t12\n");
		selSQL.append("left join (\n");
		selSQL.append("SELECT a.id,a.used_time/count(1) as cost from (\n");
		selSQL.append("SELECT t.used_time,t11.`subject`,count(DISTINCT t11.homework_id),t.id from scon_homework t\n");
		selSQL.append("inner  join scon_homework_picture  t11 on t.id = t11.homework_id\n");
		selSQL.append("where t.derver=? and TO_DAYS(NOW())=TO_DAYS(t.create_time) and t11.`subject`= ? \n");
		selSQL.append("group by t11.homework_id,t11.`subject`\n");
		selSQL.append(")a GROUP BY a.id\n");
		selSQL.append(")t13 on t12.id = t13.id\n");
		selSQL.append("GROUP BY t12.`subject`\n");
		selSQL.append(") t13 \n");
		queryParams.add(derver);
		queryParams.add(courseName);
		queryParams.add(derver);
		queryParams.add(courseName);
		List<Map<String, Object>> list =  dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public Map<String, Object> findMasterInfo(String courseId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT ifnull(t12.name,t13.wx_name) as master_name,t13.wx_account as master_account,t11.master_id,t15.league_name, \n");
		selSQL.append(" ifnull(t14.parent_name,t18.wx_name) as parent_name,t14.child_name,t11.grade,IFNULL(t11.course_name,'全科') as course_name,t.course_time,t.start_time,IFNULL(t16.`name`,t17.wx_name) as teacher_name  \n");
		selSQL.append("    from kmt_course t   \n");
		selSQL.append("left join tb_lesson_service t11 on t.lesson_service_id =t11.id \n");
		selSQL.append("left join tb_lib_manager t12 on t11.master_id=t12.user_id and t12.type=6 \n");
		selSQL.append("left join tb_user t13 on t12.user_id = t13.id \n");
		selSQL.append("left join tb_lib_vip t14 on t.vip_id = t14.id  \n");
		selSQL.append("left join tb_lib_join t15 on t11.lib_id = t15.id \n");
		selSQL.append("left join tb_lib_manager t16 on t.teacher_id=t16.user_id and t12.type=7 \n");
		selSQL.append("left join tb_user t17 on t16.user_id = t17.id \n");
		selSQL.append("left join tb_user t18 on t14.user_id = t18.id \n");
		selSQL.append("where t.id = ? limit 1\n");
		queryParams.add(courseId);
		List<Map<String, Object>> list =  dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> findRephotoList(String teacherUserId,int type,String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t11.child_name,t.id as photo_id,t.`subject`,t.file_key, t.is_mark, t.create_time,t.vip_id from scon_homework_picture t \n");
		selSQL.append("left join tb_lib_vip t11 on t.vip_id = t11.id \n");
		selSQL.append("left join zyb_student_push t12 on t.vip_id = t12.vip_id and TO_DAYS(t12.push_time)= TO_DAYS(NOW()) \n");
		selSQL.append("where t12.teacher_id = ? and t.is_mark = ?  and TO_DAYS(t.create_time)= TO_DAYS(NOW()) \n");
		queryParams.add(teacherUserId);
		queryParams.add(type);
		if(vipId !=null && !"".equals(vipId)){
			selSQL.append(" and t.vip_id = ? \n");
			queryParams.add(vipId);
		}
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findWorkPicList(String teacherUserId,String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.`subject`,t.vip_id,count(if(t.is_feedback=0,true,null)) AS feedbackcount,t.create_time,t11.child_name,t12.`name`, t12.t_photo,t.teacher_id \n");
		selSQL.append("from scon_homework_picture t  \n");
		selSQL.append("left join tb_lib_vip t11 on t.vip_id=t11.id \n");
		selSQL.append("left  join tb_lib_manager t12 on t.teacher_id=t12.user_id and t12.type=8 and t12.state=1 \n");
		selSQL.append("left join zyb_student_push t13 on t.vip_id = t13.vip_id and TO_DAYS(t13.push_time)=TO_DAYS(NOW())\n");
		selSQL.append("where t13.teacher_id=? and TO_DAYS(t.create_time)=TO_DAYS(NOW()) and t.teacher_id is not NULL  and t.is_delete = 0\n");
		queryParams.add(teacherUserId);
		if(vipId !=null && !"".equals(vipId)){
			selSQL.append(" and t.vip_id = ? \n");
			queryParams.add(vipId);
		}
		selSQL.append("GROUP BY t.`subject`,t.vip_id \n");
		
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> findTaskPicList(String teacherUserId, String subject,String vipId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT file_key,id as photo_id, if(is_feedback =1, 1, if(is_mark = 1, 4, if(is_mark > 0, is_mark, 0))) is_feedback from scon_homework_picture \n");
		selSQL.append("where teacher_id=? and vip_id=? and subject=? and TO_DAYS(create_time)=TO_DAYS(NOW()) and is_delete=0  \n");
		queryParams.add(teacherUserId);
		queryParams.add(vipId);
		queryParams.add(subject);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> correctImgList(String id) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("select distinct image file_key from scon_homework_wrong_question where homework_picture_id = ? ");
		queryParams.add(id);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findConfirmInfo(String courseId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT ifnull(t12.parent_name,t18.wx_name) as parent_name,ifnull(t11.`name`,t13.wx_name) as teacher_name,ifnull(t17.`name`,t15.wx_name) as master_name,t14.master_id,t17.lib_id"); 
		selSQL.append(",t14.grade,IFNULL(t14.course_name,'全科') as course_name,t12.child_name,t.start_time,t.course_time,t.end_time,t15.wx_account as master_account,t18.wx_account as parent_account,t12.user_id from kmt_course t   \n");
		selSQL.append("left join tb_lib_manager t11 on t.teacher_id = t11.user_id and t11.type=7 \n");
		selSQL.append("left join tb_user t13 on t11.user_id = t13.id \n");
		selSQL.append("left join tb_lib_vip  t12 on t.vip_id = t12.id \n");
		selSQL.append("left join tb_lesson_service t14 on t.lesson_service_id = t14.id \n");
		selSQL.append("left join tb_lib_manager t17 on  t14.master_id = t17.user_id and t17.type=6  \n");
		selSQL.append("left join tb_user t15 on t17.user_id = t15.id \n");
		selSQL.append("left join tb_user t18 on t12.user_id = t18.id \n");
		selSQL.append("where t.is_finish=0  and t14.`status` BETWEEN 0 and 1 \n");
		selSQL.append(" and t.id = ? \n");
		selSQL.append("order by t.course_time ASC,t.start_time ASC  limit 1 \n");
		queryParams.add(courseId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public Map<String, Object> findJudgePushInfo(String id) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT ifnull(t12.parent_name,t18.wx_name) as parent_name,t12.child_name,ifnull(t11.`name`,t13.wx_name) as teacher_name,ifnull(t17.`name`,t15.wx_name) as master_name,t14.master_id,t.teacher_id"); 
		selSQL.append(",t14.grade,IFNULL(t14.course_name,'全科') as course_name,t.start_time,t.course_time,t.end_time,t15.wx_account as master_account,t18.wx_account as parent_account,t12.user_id,t13.wx_account as teacher_account from kmt_course t   \n");
		selSQL.append("left join tb_lib_manager t11 on t.teacher_id = t11.user_id and t11.type=7 \n");
		selSQL.append("left join tb_user t13 on t11.user_id = t13.id \n");
		selSQL.append("left join tb_lib_vip  t12 on t.vip_id = t12.id \n");
		selSQL.append("left join tb_lesson_service t14 on t.lesson_service_id = t14.id \n");
		selSQL.append("left join tb_lib_manager t17 on  t14.master_id = t17.user_id and t17.type=6 \n");
		selSQL.append("left join tb_user t15 on t17.user_id = t15.id \n");
		selSQL.append("left join tb_user t18 on t12.user_id = t18.id \n");
		selSQL.append("where   t.id = ? \n");
		selSQL.append("order by t.course_time ASC,t.start_time ASC  limit 1 \n");
		queryParams.add(id);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null||list.size()==0?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> getDeverImgListByTime(String vipId, String courseName, Date scoringTime) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.file_key,t.derver,t.is_feedback FROM `scon_homework_picture` t \n");
		selSQL.append("where t.vip_id=? and TO_DAYS(t.create_time)=TO_DAYS(?) and t.subject=? \n");
		queryParams.add(vipId);
		queryParams.add(scoringTime);
		queryParams.add(courseName);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findTodayOneFinishTask(String vipId, String serviceId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT d.type,a.class_line,d.status,c.child_name,t13.`master`,a.start_time,a.call_time,a.id,a.feedback_time,a.parent_judge_lever,a.judge_lable,count(if(t14.type=2,true,null)) as ndaonum,  \n");
		selSQL.append("count(if(t14.type=3,true,null)) as khggnum,count(if(t14.type !=2 and t14.type !=3 and t14.type is not null,true,null)) as ztnum,d.teacher_lever from  \n");
		selSQL.append("(select t.vip_id,t.course_know_id,t.id,t.lesson_service_id,t.start_time,t.call_time,t.feedback_time,t.class_line,t.parent_judge_lever,t.judge_lable from  kmt_course  t  \n");
		selSQL.append("where t.plan_status=5  and t.lesson_service_id=? and t.vip_id=?  and TO_DAYS(t.course_time)=TO_DAYS(NOW()) \n");
		selSQL.append("   ORDER BY t.course_time desc,t.start_time DESC limit 1) a \n");
		selSQL.append("left join tb_lesson_service d on a.lesson_service_id = d.id \n");
		selSQL.append("left JOIN kmt_course_know b on a.course_know_id = b.id \n");
		selSQL.append("left join tb_lib_vip c on a.vip_id = c.id \n");
		selSQL.append("LEFT JOIN kmt_img_face t11 on a.course_know_id = t11.course_know_id \n");
		selSQL.append("LEFT JOIN kmt_img_face_detail t12 on t11.id = t12.face_id  \n");
		selSQL.append("LEFT JOIN kmt_print_manage t13 on t11.course_know_id = t13.course_know_id \n");
		selSQL.append("left join kmt_course_question_detail t14 on t11.course_know_id=t14.course_know_id and t12.question_id = t14.question_id \n");
		queryParams.add(serviceId);
		queryParams.add(vipId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null || list.size()==0 ?null:list.get(0);
	}

	@Override
	public Map<String, Object> findOnedayOneFinishTask(String vipId, String serviceId, String date) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<>();
		selSQL.append("SELECT d.type,b.class_line,d.status,c.child_name,t13.`master`,a.start_time,a.call_time,a.id,a.feedback_time,a.parent_judge_lever,a.judge_lable,count(if(t14.type=2,true,null)) as ndaonum,  \n");
		selSQL.append("count(if(t14.type=3,true,null)) as khggnum,count(if(t14.type !=2 and t14.type !=3 and t14.type is not null,true,null)) as ztnum from  \n");
		selSQL.append("(select t.vip_id,t.course_know_id,t.id,t.lesson_service_id,t.start_time,t.call_time,t.feedback_time,t.parent_judge_lever,t.judge_lable from  kmt_course  t  \n");
		selSQL.append("where t.plan_status=5  and t.lesson_service_id=? and t.vip_id=?  and TO_DAYS(t.course_time)=TO_DAYS(?) \n");
		selSQL.append("   ORDER BY t.course_time desc,t.start_time DESC limit 1) a \n");
		selSQL.append("left join tb_lesson_service d on a.lesson_service_id = d.id \n");
		selSQL.append("left JOIN kmt_course_know b on a.course_know_id = b.id \n");
		selSQL.append("left join tb_lib_vip c on a.vip_id = c.id \n");
		selSQL.append("LEFT JOIN kmt_img_face t11 on a.course_know_id = t11.course_know_id \n");
		selSQL.append("LEFT JOIN kmt_img_face_detail t12 on t11.id = t12.face_id  \n");
		selSQL.append("LEFT JOIN kmt_print_manage t13 on t11.course_know_id = t13.course_know_id \n");
		selSQL.append("left join kmt_course_question_detail t14 on t11.course_know_id=t14.course_know_id and t12.question_id = t14.question_id \n");
		queryParams.add(serviceId);
		queryParams.add(vipId);
		queryParams.add(date);
		System.out.println(selSQL.toString());
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null || list.size()==0 ?null:list.get(0);
	}

	@Override
	public Page<Map<String, Object>> findOnePage(Map<String, Object> params, Pageable pageable) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("select a.* from (  \n");
		selSQL.append("SELECT '' as child_name,0 as class_line,t.id, t.submit_time, 0 as ndaonum,0 as khggnum,0 as ztnum,t.subhtml,'1' as type,'' as teacher_say,'' as explain_content  from zyb_student_push t \n ");
		selSQL.append("where t.type=2 and t.vip_id=? \n");
		selSQL.append("union all ");
		selSQL.append("SELECT c.child_name,a.class_line,a.id,a.feedback_time,count(if(t14.type=2,true,null)) as ndaonum,  \n");
		selSQL.append("count(if(t14.type=3,true,null)) as khggnum,count(if(t14.type !=2 and t14.type !=3 and t14.type is not null,true,null)) as ztnum,'' as subhtml,'2' as type,'' as teacher_say,'' as explain_content from  \n");
		selSQL.append("(select t.vip_id,t.course_know_id,t.id,t.class_line,t.feedback_time from  kmt_course  t  \n");
		selSQL.append("where t.plan_status=5  and t.vip_id=? and t.teacher_lever in ('注册老师','明星老师','资深老师','')  \n");
		selSQL.append("   ORDER BY t.course_time desc,t.start_time DESC) a \n");
		selSQL.append("left join tb_lib_vip c on a.vip_id = c.id \n");
		selSQL.append("LEFT JOIN kmt_img_face t11 on a.course_know_id = t11.course_know_id \n");
		selSQL.append("LEFT JOIN kmt_img_face_detail t12 on t11.id = t12.face_id  \n");
		selSQL.append("LEFT JOIN kmt_print_manage t13 on t11.course_know_id = t13.course_know_id \n");
		selSQL.append("left join kmt_course_question_detail t14 on t11.course_know_id=t14.course_know_id and t12.question_id = t14.question_id \n");
		selSQL.append("group by a.id  \n");
		selSQL.append("union all \n");
		selSQL.append("SELECT t13.child_name,0 as class_line,t.id,t.feedback_time,0 as ndaonum,0 as khggnum,0 as ztnum,'' as subhtml,'3' as type,t11.teacher_say,t12.explain_content from kmt_course t   \n");
		selSQL.append("left join kmt_course_xb_feedback t11 on t.id = t11.kmt_course_id and t11.course_name='总体'  \n");
		selSQL.append("left join kmt_course_xb_feedback t12 on t.id = t12.kmt_course_id and t12.course_name='数学' \n");
		selSQL.append("INNER JOIN tb_lib_vip t13 on t.vip_id = t13.id \n");
		selSQL.append("where t.vip_id=? and  t.teacher_lever='学霸老师' and t.plan_status=5 \n");
		selSQL.append(") a where a.id is not null order by a.submit_time desc \n");
		queryParams.add(params.get("EQ_vipId"));
		queryParams.add(params.get("EQ_vipId"));
		queryParams.add(params.get("EQ_vipId"));
		return dao.findPage(selSQL.toString(), queryParams.toArray(), pageable);
	}

	@Override
	public Map<String, Object> findOrderIsOver(String lessonServiceId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT 1 from  \n");
		selSQL.append("(select * from tb_lesson_service where id=?) t  \n");
		selSQL.append("INNER JOIN tb_lesson_service t11 on t.vip_id = t11.vip_id and t.course_name=t11.course_name and t.id<>t11.id \n");
		selSQL.append("where  t11.`status`=1\n");
		queryParams.add(lessonServiceId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null || list.size()==0 ?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> findOverTimeList() {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT id from kmt_course where plan_status=5 and is_finish=0 and date_add(feedback_time, interval 12 hour) <= NOW()  \n");
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> BeginLessonTips() {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT DISTINCT t.course_time,t.start_time,t.end_time,t13.grade,IFNULL(t13.course_name,'全科') as course_name,t14.league_name,t12.wx_account,IFNULL(t11.`name`,t12.wx_name) as teacher_name  \n");
		selSQL.append("from kmt_course t   \n");
		selSQL.append("left join tb_lesson_service t13 on t.lesson_service_id = t13.id  \n");
		selSQL.append("left join tb_lib_join t14 on t13.lib_id = t14.id  \n");
		selSQL.append("left join tb_lib_manager t11 on t.teacher_id= t11.user_id and t11.type=7 and t11.state=1 \n");
		selSQL.append("left join tb_user t12 on t11.user_id = t12.id \n");
		selSQL.append("where t.plan_status BETWEEN 2 and 3 and TO_DAYS(t.course_time)=TO_DAYS(NOW()) and t12.wx_account is not null \n");
		selSQL.append("and date_format(now(),'%Y-%m-%d %H:%i:%s') BETWEEN date_add(date_format(CONCAT(t.course_time,' ',t.start_time),'%Y-%m-%d %H:%i'), interval -20 minute) and date_add(date_format(CONCAT(t.course_time,' ',t.start_time),'%Y-%m-%d %H:%i'), interval -16 minute)    \n");
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public List<Map<String, Object>> xbTodayFinishList(String vipId, String serviceId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.feedback_time,t13.child_name,t11.teacher_say,t12.explain_content,t.id from kmt_course t   \n");
		selSQL.append("left join kmt_course_xb_feedback t11 on t.id = t11.kmt_course_id and t11.course_name='总体'  \n");
		selSQL.append("left join kmt_course_xb_feedback t12 on t.id = t12.kmt_course_id and t12.course_name='数学' \n");
		selSQL.append("INNER JOIN tb_lib_vip t13 on t.vip_id = t13.id \n");
		selSQL.append("where t.vip_id=? and t.lesson_service_id=? and t.teacher_lever='学霸老师' and t.plan_status=5 \n");
		selSQL.append("and TO_DAYS(t.course_time)=TO_DAYS(NOW()) \n");
		queryParams.add(vipId);
		queryParams.add(serviceId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findchildInfoByCourseId(String courseId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT a.img_url,a.child_name,a.id,a.school,a.grade from tb_lib_vip a \n");
		selSQL.append("INNER JOIN kmt_course b on a.id = b.vip_id \n");
		selSQL.append("where b.id = ? \n");
		queryParams.add(courseId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null || list.size()==0 ?null:list.get(0);
	}

	@Override
	public List<Map<String, Object>> findXbFeedbackInfo(String courseId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT t.course_time,t13.child_name,t13.img_url,t11.course_name,t11.class_info_json,t11.explain_content,t.feedback_time, \n");
		selSQL.append("t11.feedback_index,t11.total_course,t11.next_plan,t11.other_help,t11.parents_label,t11.teacher_say,t11.error_know  as error_how , \n");
		selSQL.append("GROUP_CONCAT(t12.img_url) as file_key,t11.totality_info \n");
		selSQL.append("from kmt_course t \n");
		selSQL.append("INNER JOIN kmt_course_xb_feedback t11 on t.id = t11.kmt_course_id  \n");
		selSQL.append("left join kmt_course_xb_feedback_img t12 on t11.kmt_course_id=t12.kmt_course_id and t11.course_name=t12.course_name and t12.state=1 \n");
		selSQL.append("left join tb_lib_vip t13 on t.vip_id = t13.id \n");
		selSQL.append("where t.id = ? \n");
		selSQL.append("GROUP BY t11.id  order by t11.num \n");
		queryParams.add(courseId);
		return dao.findMap(selSQL.toString(), queryParams.toArray());
	}

	@Override
	public Map<String, Object> findRefundsInfo(String orderDetailsId) {
		StringBuilder selSQL = new StringBuilder();
		List<Object> queryParams = new ArrayList<Object>();
		selSQL.append("SELECT IFNULL(t12.`name`,t14.wx_name) as teacher_name,IFNULL(t13.`name`,t15.wx_name) as master_name, \n");
		selSQL.append("t.grade,IFNULL(t.course_name,'全科') as course_name,IFNULL(a.parent_name,t16.wx_name) as parent_name \n");
		selSQL.append("from tb_lesson_service  t  \n");
		selSQL.append("left join tb_lib_vip a on t.vip_id = a.id\n");
		selSQL.append("left join tb_user t16 on a.user_id = t16.id \n");
		selSQL.append("left join kmt_course t11 on t.id = t11.lesson_service_id \n");
		selSQL.append("left join tb_lib_manager t12 on t11.teacher_id = t12.user_id and t12.type=7  and t12.state=1 \n");
		selSQL.append("left join tb_lib_manager t13 on t.master_id = t13.user_id and t13.type=6 and t13.state=1 \n");
		selSQL.append("left join tb_user t14 on t12.user_id = t14.id \n");
		selSQL.append("left join tb_user t15 on t13.user_id = t15.id \n");
		selSQL.append("where t.id = ? \n");
		selSQL.append("group by t.id \n");
		queryParams.add(orderDetailsId);
		List<Map<String, Object>> list = dao.findMap(selSQL.toString(), queryParams.toArray());
		return list==null || list.size()==0 ?null:list.get(0);
	}

	
}
