feat:完善后台经纪人审核信息
This commit is contained in:
@ -1,11 +1,52 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
import (
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/serve/orm"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ManageAgent struct {
|
||||
*model.ManageAgent
|
||||
}
|
||||
|
||||
type ManageAgentInfo struct {
|
||||
*model.ManageAgent
|
||||
Demand string `json:"-"`
|
||||
model.Area
|
||||
}
|
||||
|
||||
// Agents 经纪人信息
|
||||
func (m *ManageAgent) Agents(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*ManageAgentInfo, error) {
|
||||
db := orm.GetDB().Table(m.TableName()+" AS a").
|
||||
Select("a.id", "a.tenant_id", "a.name", "a.mobile", "a.industry", "a.credential_image",
|
||||
"a.examine_status", "a.examine_remark", "a.examine_at", "a.created_at", "t.province", "t.city", "d.demand").
|
||||
Joins(fmt.Sprintf("LEFT JOIN (SELECT a.agent_id, GROUP_CONCAT(a.`status`, ':', a.count SEPARATOR ';') AS demand FROM ("+
|
||||
"SELECT u_a.agent_id, d.status, COUNT(d.id) AS count FROM %s AS u_a "+
|
||||
"LEFT JOIN %s AS d ON u_a.uid = d.uid AND d.is_deleted = %d "+
|
||||
"WHERE u_a.is_deleted = %d AND u_a.invalid_status = %d GROUP BY u_a.agent_id, d.status) AS a GROUP BY a.agent_id) AS d ON a.id = d.agent_id",
|
||||
model.NewUserAgent().TableName(), model.NewTechnologyDemandService().TableName(), model.DeleteStatusForNot,
|
||||
model.DeleteStatusForNot, model.InvalidStatusForNot,
|
||||
)).
|
||||
Joins(fmt.Sprintf("LEFT JOIN %s AS t ON a.tenant_id = t.id", model.NewSysTenant().TableName())).
|
||||
Where("a.is_deleted = ?", model.DeleteStatusForNot)
|
||||
|
||||
if len(where) > 0 {
|
||||
for _, wo := range where {
|
||||
db = db.Where(wo.Condition, wo.Value)
|
||||
}
|
||||
}
|
||||
out := make([]*ManageAgentInfo, 0)
|
||||
|
||||
if err := db.Count(count).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := db.Order("a.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func NewManageAgent() *ManageAgent {
|
||||
return &ManageAgent{model.NewManageAgent()}
|
||||
}
|
||||
|
Reference in New Issue
Block a user