Exemple #1
0
func ContractList(childId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	countSql := "select count(1) from contract where child_id=?"
	lessgo.Log.Debug(countSql)
	countParams := []interface{}{childId}

	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql := `
		select contr.id id,contr.contract_no contractNo,cour.name courseName,contr.apply_time applyTime,contr.price,contr.left_lesson_num totalNum,e.really_name employeeName,contr.type contractType,contr.status contractStatus,usedNum.num usedNum,leaveNum.num leaveNum,truantNum.num truantNum
		from contract contr
		left join (select count(1) num,contract_id from sign_in where child_id=? and type=1 group by contract_id) usedNum on usedNum.contract_id=contr.id
		left join (select count(1) num,contract_id from sign_in where child_id=? and type=2 group by contract_id) leaveNum on leaveNum.contract_id=contr.id
		left join (select count(1) num,contract_id from sign_in where child_id=? and type=3 group by contract_id) truantNum on truantNum.contract_id=contr.id
		left join employee e on e.user_id=contr.employee_id
		left join course cour on cour.cid=contr.course_id
		where contr.child_id=? limit ?,?
	`
	lessgo.Log.Debug(dataSql)

	dataParams := []interface{}{}
	dataParams = append(dataParams, childId)
	dataParams = append(dataParams, childId)
	dataParams = append(dataParams, childId)
	dataParams = append(dataParams, childId)
	dataParams = append(dataParams, (currPageNo-1)*pageSize)
	dataParams = append(dataParams, pageSize)

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #2
0
func ChildInClassPage(scheduleId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	countSql := " select count(1) from schedule_detail_child where schedule_detail_id=? "
	lessgo.Log.Debug(countSql)
	countParams := []interface{}{scheduleId}

	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql := `
				select sdc.child_id id,ch.name childName,p.telephone phone,e.really_name tmkName,sdc.create_time inviteTime,si.sign_time signTime,sdc.wyclass_id classId,sdc.create_user inviteUser,ch.center_id centerId,sdc.sms_status smsStatus,d.remark remark,cons.level level,cons.id cosumerId,wc.code code ,ch.sex sex,ch.birthday birthday
				from schedule_detail_child sdc
				left join class_schedule_detail csd on csd.id=sdc.schedule_detail_id
				left join wyclass wc on wc.class_id=csd.class_id
	            left join child ch on ch.cid=sdc.child_id
	            left join parent p on p.pid=ch.pid
	            left join consumer_new cons on cons.parent_id=ch.pid
	            left join (select consumer_id,GROUP_CONCAT(concat(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i'),' ',note) ORDER BY id DESC SEPARATOR '<br/>') remark from consumer_contact_log group by consumer_id) d on d.consumer_id=cons.id
				left join employee e on e.user_id=sdc.create_user
				left join sign_in si on si.child_id=sdc.child_id and sdc.schedule_detail_id=si.schedule_detail_id
				where sdc.schedule_detail_id=? order by si.sid desc,sdc.id desc limit ?,?`
	lessgo.Log.Debug(dataSql)

	dataParams := []interface{}{}
	dataParams = append(dataParams, scheduleId)
	dataParams = append(dataParams, (currPageNo-1)*pageSize)
	dataParams = append(dataParams, pageSize)

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #3
0
func ChildInNormalSchedulePage(scheduleId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	countSql := " select count(1) from schedule_detail_child where schedule_detail_id=?"
	countParams := []interface{}{scheduleId}
	lessgo.Log.Debug(countSql)

	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql := `
				select sdc.child_id id,ch.name childName,p.telephone phone,si.type signType,si.sign_time signTime,cour.name courseName,contr.id as contractId,contr.contract_no contractNo,contr.apply_time applyTime,cons.id consumerId,cons.level level,d.remark,sdc.is_free isFree,contr.left_lesson_num totalNum,usedNum.num usedNum,csd.center_id centerId
	 		    from (select * from schedule_detail_child where schedule_detail_id=? order by id desc limit ?,?) sdc
	 			left join child ch on ch.cid=sdc.child_id
	 			left join parent p on p.pid=ch.pid
	 			left join consumer_new cons on cons.parent_id=ch.pid
	            left join (select consumer_id,GROUP_CONCAT(concat(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i'),' ',note) ORDER BY id DESC SEPARATOR '<br/>') remark from consumer_contact_log group by consumer_id) d on d.consumer_id=cons.id
	 			left join sign_in si on si.child_id=sdc.child_id and sdc.schedule_detail_id=si.schedule_detail_id
	 			left join class_schedule_detail csd on csd.id=sdc.schedule_detail_id
	 			left join contract contr on contr.id=sdc.contract_id
	 			left join course cour on cour.cid=contr.course_id
	 			left join (select count(1) num,contract_id from sign_in where type=1 or type=3 group by contract_id ) usedNum on usedNum.contract_id=contr.id
	 			order by si.sid desc,ch.cid desc
	 			`
	lessgo.Log.Debug(dataSql)

	dataParams := []interface{}{scheduleId, (currPageNo - 1) * pageSize, pageSize}

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #4
0
func ChildInParentPage(parentId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	params := []interface{}{}

	dataSql := `
				select ch.cid id,ch.name childName,ch.card_id cardId,ch.birthday,ch.sex,totalNum.num totalNum,usedNum.num usedNum
				from child ch
				left join (select sum(left_lesson_num) num,child_id from contract group by child_id) totalNum on totalNum.child_id=ch.cid
				left join (select count(1) num,child_id from sign_in where (type=1 or type=3) and contract_id!=0 and contract_id is not null group by child_id) usedNum on usedNum.child_id=ch.cid
				where 1=1 and ch.pid=?
	`

	params = append(params, parentId)

	countSql := "select count(1) from (" + dataSql + ") num"
	lessgo.Log.Debug(countSql)
	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, params)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql += " order by ch.cid desc limit ?,? "

	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	lessgo.Log.Debug(dataSql)
	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, params)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #5
0
//获取课件分页列表
func CoursewareList(centerId, kw string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	countSql := "select count(1) from courseware where center_id=? and (name like ? or intro like ?) "
	lessgo.Log.Debug(countSql)
	countParams := []interface{}{centerId, "%" + kw + "%", "%" + kw + "%"}

	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql := "select id,name,intro from courseware where center_id=? and (name like ? or intro like ?) order by id desc limit ?,?"
	lessgo.Log.Debug(dataSql)

	dataParams := []interface{}{}
	dataParams = append(dataParams, centerId)
	dataParams = append(dataParams, "%"+kw+"%")
	dataParams = append(dataParams, "%"+kw+"%")
	dataParams = append(dataParams, (currPageNo-1)*pageSize)
	dataParams = append(dataParams, pageSize)

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #6
0
func ChildInCenterPage(centerId, kw string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	countSql := " select count(1) from child ch left join parent p on p.pid=ch.pid where ch.center_id=? and (ch.name like ? or p.telephone like ?) "
	countParams := []interface{}{centerId, "%" + kw + "%", "%" + kw + "%"}
	lessgo.Log.Debug(countSql)

	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql := `
				select c.cid id,c.name as childName,c.telephone phone,cons.level level,d.remark remark,cons.id consumerId from
				(select ch.cid,ch.name,p.telephone,ch.pid from child ch left join parent p on p.pid=ch.pid where ch.center_id=? and (ch.name like ? or p.telephone like ?) order by ch.cid desc limit ?,?) c
				left join consumer_new cons on cons.parent_id=c.pid
	            left join (select consumer_id,GROUP_CONCAT(concat(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i'),' ',note) ORDER BY id DESC SEPARATOR '<br/>') remark from consumer_contact_log group by consumer_id) d on d.consumer_id=cons.id`
	lessgo.Log.Debug(dataSql)

	dataParams := []interface{}{centerId, "%" + kw + "%", "%" + kw + "%", (currPageNo - 1) * pageSize, pageSize}

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #7
0
func CoursePage(centerId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	countSql := " select count(1) from course where center_id=? "
	lessgo.Log.Debug(countSql)
	countParams := []interface{}{centerId}

	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql := `select cid as id,name,type from course where center_id=? order by cid desc limit ?,?`
	lessgo.Log.Debug(dataSql)

	dataParams := []interface{}{}
	dataParams = append(dataParams, centerId)
	dataParams = append(dataParams, (currPageNo-1)*pageSize)
	dataParams = append(dataParams, pageSize)

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
func ClassScheduleDetailPage(centerId, kw, dataType, employeeId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	params := []interface{}{}

	dataSql := `
				select csd.id,cour.name courseName,class.code,csd.start_time,class.name className,ce.name centerName,class.class_id,ce.cid centerId
				from class_schedule_detail csd
				left join wyclass class on csd.class_id=class.class_id
				left join course cour on cour.cid=csd.course_id
				left join center ce on ce.cid=csd.center_id
				where 1=1 `

	if dataType == "center" {
		userId, _ := strconv.Atoi(employeeId)
		_employee, err := FindEmployeeById(userId)
		if err != nil {
			lessgo.Log.Error(err.Error())
			return nil, err
		}

		params = append(params, _employee.CenterId)

		dataSql += " and csd.center_id=? "
	}

	if centerId != "" && dataType == "all" {
		params = append(params, centerId)
		dataSql += " and csd.center_id=? "
	}

	if kw != "" {
		dataSql += ` and csd.id in
		(select sdc.schedule_detail_id from child ch
		left join schedule_detail_child sdc on sdc.child_id=ch.cid
		left join parent p on p.pid=ch.pid
		where ch.name=? or p.telephone=?) `
		params = append(params, kw)
		params = append(params, kw)
	}

	countSql := "select count(1) from (" + dataSql + ") num"
	lessgo.Log.Debug(countSql)
	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, params)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql += " order by csd.id desc limit ?,? "

	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	lessgo.Log.Debug(dataSql)
	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, params)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #9
0
func PotentialChildPage(centerId, kw, dataType, employeeId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
	if centerId == "1" {
		centerId = "7"
	}

	params := []interface{}{}

	dataSql := `
				select ch.cid id,ce.name centerName,ch.name childName,p.telephone phone,ch.birthday,ch.sex
				from child ch
				left join parent p on p.pid=ch.pid
				left join center ce on ce.cid=ch.center_id
				left join (select child_id,count(1) num from contract where price >0 group by child_id) contract_num on contract_num.child_id=ch.cid where 1=1 and (contract_num.num=0 or contract_num.num is null)
	`

	if dataType == "center" {
		userId, _ := strconv.Atoi(employeeId)
		_employee, err := FindEmployeeById(userId)
		if err != nil {
			lessgo.Log.Error(err.Error())
			return nil, err
		}

		//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
		if _employee.CenterId == "1" {
			_employee.CenterId = "7"
		}

		params = append(params, _employee.CenterId)

		dataSql += " and ch.center_id=? "
	}

	if centerId != "" && dataType == "all" {
		params = append(params, centerId)
		dataSql += " and ch.center_id=? "
	}

	if kw != "" {
		dataSql += " and (ch.name like ? "
		dataSql += " or p.telephone like ?) "
		params = append(params, "%"+kw+"%")
		params = append(params, "%"+kw+"%")
	}

	countSql := "select count(1) from (" + dataSql + ") num"
	lessgo.Log.Debug(countSql)
	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, params)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql += " order by ch.cid desc limit ?,? "

	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	lessgo.Log.Debug(dataSql)
	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, params)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}
Exemple #10
0
func MemberPage(dataType, centerId, kw, employeeId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
	if centerId == "1" {
		centerId = "7"
	}

	params := []interface{}{}

	dataSql := `
				select p.pid id,ce.name centerName,p.telephone,p.father_name fatherName,p.father_phone fatherPhone,mother_name motherName,mother_phone motherPhone,b.childs
				from parent p
				left join consumer_new cons on cons.parent_id=p.pid
				left join center ce on cons.center_id=ce.cid
				left join (select pid,GROUP_CONCAT(name   ORDER BY cid DESC SEPARATOR ',') childs from child group by pid) b on b.pid=p.pid
				where p.is_member=1
	`

	if dataType == "center" {
		userId, _ := strconv.Atoi(employeeId)
		_employee, err := FindEmployeeById(userId)
		if err != nil {
			lessgo.Log.Error(err.Error())
			return nil, err
		}

		//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
		if _employee.CenterId == "1" {
			_employee.CenterId = "7"
		}

		params = append(params, _employee.CenterId)
		dataSql += " and cons.center_id=? "
	}

	if centerId != "" && dataType == "all" {
		params = append(params, centerId)
		dataSql += " and cons.center_id=? "
	}

	if kw != "" {
		dataSql += " and (b.childs like ? or p.telephone like ? or p.father_name like ? or p.father_phone like ? or p.mother_name like ? or p.mother_phone like ?)"
		params = append(params, "%"+kw+"%")
		params = append(params, "%"+kw+"%")
		params = append(params, "%"+kw+"%")
		params = append(params, "%"+kw+"%")
		params = append(params, "%"+kw+"%")
		params = append(params, "%"+kw+"%")
	}

	countSql := "select count(1) from (" + dataSql + ") num"
	lessgo.Log.Debug(countSql)
	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, params)
	if err != nil {
		lessgo.Log.Error(err.Error())
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataSql += " order by p.pid desc limit ?,? "
	lessgo.Log.Debug(dataSql)
	params = append(params, (currPageNo-1)*pageSize)
	params = append(params, pageSize)

	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, params)

	if err != nil {
		lessgo.Log.Error(err.Error())
		return nil, err
	}

	return pageData, nil
}
Exemple #11
0
func ConsumerPage(paramsMap map[string]string, dataType, employeeId string, pageNo, pageSize int) (*commonlib.TraditionPage, error) {

	db := lessgo.GetMySQL()
	defer db.Close()

	whereSql := ""

	countSql := `
		select count(1) from (
			select c.consumer_id from contacts c
			left join consumer_new b on b.id=c.consumer_id
			where (c.phone like ? or c.name like ? or b.child like ?) %v
			group by c.consumer_id
		) num
	`
	countParams := []interface{}{"%" + paramsMap["kw"] + "%", "%" + paramsMap["kw"] + "%", "%" + paramsMap["kw"] + "%"}

	dataSql := `
		select cons.id id,ce.name as centerName,e.really_name tmkName,cont.name contactName,cont.phone phone ,cons.home_phone homePhone,cons.child childName,cons.contact_status contactStatus,cons.parent_id parentId,b.remark remark,cons.pay_status payStatus,cons.pay_time payTime,cf.name comeFromName, cons.parttime_name partTimeName
		from (
			select c.consumer_id,min(c.id) contacts_id from contacts c
			left join consumer_new b on b.id=c.consumer_id
			where (c.phone like ? or c.name like ? or b.child like ?) %v
			group by c.consumer_id %v limit ?,?)a
		left join consumer_new cons on cons.id=a.consumer_id
		left join contacts cont on cont.id=a.contacts_id
		left join center ce on ce.cid=cons.center_id
		left join employee e on e.user_id=cons.current_tmk_id
		left join come_from cf on cf.id=cons.come_from_id
	`
	dataParams := []interface{}{"%" + paramsMap["kw"] + "%", "%" + paramsMap["kw"] + "%", "%" + paramsMap["kw"] + "%"}

	if paramsMap["status"] != "" {
		countParams = append(countParams, paramsMap["status"])
		dataParams = append(dataParams, paramsMap["status"])
		whereSql += " and b.contact_status=? "
	}

	if paramsMap["lastContractStartTime"] != "" && paramsMap["timeType"] == "1" {
		countParams = append(countParams, paramsMap["lastContractStartTime"])
		dataParams = append(dataParams, paramsMap["lastContractStartTime"])
		whereSql += " and b.sign_in_time>=? "
	}

	if paramsMap["lastContractStartTime"] != "" && paramsMap["timeType"] == "2" {
		countParams = append(countParams, paramsMap["lastContractStartTime"])
		dataParams = append(dataParams, paramsMap["lastContractStartTime"])
		whereSql += " and b.pay_time>=? "
	}

	if paramsMap["lastContractEndTime"] != "" && paramsMap["timeType"] == "1" {
		countParams = append(countParams, paramsMap["lastContractEndTime"])
		dataParams = append(dataParams, paramsMap["lastContractEndTime"])
		whereSql += " and b.sign_in_time<=? "
	}

	if paramsMap["lastContractEndTime"] != "" && paramsMap["timeType"] == "2" {
		countParams = append(countParams, paramsMap["lastContractEndTime"])
		dataParams = append(dataParams, paramsMap["lastContractEndTime"])
		whereSql += " and b.pay_time<=? "
	}

	if paramsMap["payStatus"] == "1" {
		whereSql += " and b.pay_time is not null and b.pay_time != '' and b.pay_status=1 "
	} else if paramsMap["payStatus"] == "2" {
		whereSql += " and b.pay_time is not null and b.pay_time != '' and b.pay_status=2 "
	} else if paramsMap["payStatus"] == "3" {
		whereSql += " and (b.pay_time is null or b.pay_time ='')"
	}

	if paramsMap["tmkId1"] != "" {
		countParams = append(countParams, paramsMap["tmkId1"])
		dataParams = append(dataParams, paramsMap["tmkId1"])
		whereSql += " and b.current_tmk_id=? "
	}

	if paramsMap["tmkId2"] != "" {
		countParams = append(countParams, paramsMap["tmkId2"])
		dataParams = append(dataParams, paramsMap["tmkId2"])
		whereSql += " and b.current_tmk_id=? "
	}

	if dataType == "center" {
		userId, _ := strconv.Atoi(employeeId)
		_employee, err := FindEmployeeById(userId)
		if err != nil {
			return nil, err
		}

		//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
		if _employee.CenterId == "1" {
			_employee.CenterId = "7"
		}

		countParams = append(countParams, _employee.CenterId)
		dataParams = append(dataParams, _employee.CenterId)

		whereSql += " and b.center_id=? "
	}

	if paramsMap["centerId1"] != "" && dataType == "all" {
		//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
		if paramsMap["centerId1"] == "1" {
			countParams = append(countParams, "7")
			dataParams = append(dataParams, "7")
		} else {
			countParams = append(countParams, paramsMap["centerId1"])
			dataParams = append(dataParams, paramsMap["centerId1"])
		}

		whereSql += " and b.center_id=? "
	}

	if paramsMap["centerId2"] != "" && dataType == "all" {
		//番茄田逻辑补丁,番茄田添加的用户都属于福州台江中心
		if paramsMap["centerId2"] == "1" {
			countParams = append(countParams, "7")
			dataParams = append(dataParams, "7")
		} else {
			countParams = append(countParams, paramsMap["centerId2"])
			dataParams = append(dataParams, paramsMap["centerId2"])
		}
		whereSql += " and b.center_id=? "
	}

	if paramsMap["parttimeName"] != "" {
		countParams = append(countParams, paramsMap["parttimeName"])
		dataParams = append(dataParams, paramsMap["parttimeName"])
		whereSql += " and b.parttime_name=? "
	}

	if paramsMap["comeFromId"] != "" {
		countParams = append(countParams, paramsMap["comeFromId"])
		dataParams = append(dataParams, paramsMap["comeFromId"])
		whereSql += " and b.come_from_id=? "
	}

	orderSql := ""

	if paramsMap["sort"] == "" || paramsMap["sort"] == "create_time" {
		orderSql += " order by b.id desc "
	} else if paramsMap["sort"] == "last_time" {
		orderSql += " order by b.last_contact_time desc "
	}

	countSql = fmt.Sprintf(countSql, whereSql)
	dataSql = fmt.Sprintf(dataSql, whereSql, orderSql)

	dataSql += ` left join (select consumer_id,GROUP_CONCAT(concat(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i'),' ',note)  ORDER BY id DESC SEPARATOR '<br/>') remark from consumer_contact_log group by consumer_id) b on b.consumer_id=cons.id `

	lessgo.Log.Debug(countSql)
	totalPage, totalNum, err := lessgo.GetTotalPage(pageSize, db, countSql, countParams)

	if err != nil {
		return nil, err
	}

	currPageNo := pageNo
	if currPageNo > totalPage {
		currPageNo = totalPage
	}

	dataParams = append(dataParams, (currPageNo-1)*pageSize, pageSize)

	lessgo.Log.Debug(dataSql)
	pageData, err := lessgo.GetFillObjectPage(db, dataSql, currPageNo, pageSize, totalNum, dataParams)

	if err != nil {
		return nil, err
	}

	return pageData, nil
}