package models

import "rdluck_tools/orm"

type FreeViewerDetails struct {
	RealName       string
	Mobile         string
	Note           string
	CreatedTime    string
	MaxCreatedTime string
}

func GetFreeViewerDetails(startTime,endTime string) (items []*FreeViewerDetails, err error) {
	sql := `select u.real_name,u.mobile,u.note,u.created_time,max(uvh.created_time) as max_created_time
	from wx_user u
	LEFT JOIN user_view_history uvh on u.user_id = uvh.user_id
	where u.company_id = 1
	and u.apply_method<>2
	and u.mobile is not null
	AND u.mobile<>''
	and u.created_time > ?
	and u.created_time <= ?
	group by u.user_id`
	_, err = orm.NewOrm().Raw(sql, startTime,endTime).QueryRows(&items)
	return
}
