| | |
| | | |
| | | type ( |
| | | ServiceFollowup struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"` |
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` |
| | | ServiceOrderId int `json:"serviceOrderId" gorm:"column:service_order_id;type:int;comment:客户服务单id"` |
| | | ServiceOrder ServiceOrder `gorm:"foreignKey:ServiceId"` |
| | | CustomerServiceSheet CustomerServiceSheet `json:"customerServiceSheet" gorm:"foreignKey:ServiceId"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:服务人员id"` |
| | | Member User `json:"Member" gorm:"foreignKey:MemberId"` |
| | | PlanId int `json:"planId" gorm:"column:plan_id;type:int;comment:服务计划id"` |
| | | SatisfactionId int `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:满意度id"` |
| | | Satisfaction Satisfaction `json:"satisfaction" gorm:"foreignKey:SatisfactionId"` |
| | | TimelyRateId int `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:及时率id"` |
| | | TimelyRate TimelyRate `json:"timelyRate" gorm:"foreignKey:TimelyRateId"` |
| | | SolveRateId int `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:解决率id"` |
| | | SolveRate SolveRate `json:"solveRate" gorm:"foreignKey:SolveRateId"` |
| | | IsVisitId int `json:"isVisitId" gorm:"column:is_visit_id;type:int;comment:服务人员是否来过id"` |
| | | IsVisit IsVisit `json:"isVisit" gorm:"foreignKey:IsVisitId"` |
| | | OldMemberId int `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:原服务人员"` |
| | | OldMember User `json:"oldMember" gorm:"foreignKey:OldMemberId"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | File string `json:"file" gorm:"column:file;type:varchar(255);comment:附件"` |
| | | |
| | | gorm.Model `json:"-"` |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:客户id"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"` |
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` |
| | | ServiceOrderId int `json:"serviceOrderId" gorm:"column:service_order_id;type:int;comment:客户服务单id"` |
| | | ServiceOrder ServiceOrder `gorm:"foreignKey:ServiceOrderId"` |
| | | MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:服务人员id"` |
| | | Member User `json:"Member" gorm:"foreignKey:MemberId"` |
| | | PlanId int `json:"planId" gorm:"column:plan_id;type:int;comment:服务计划id"` |
| | | SatisfactionId int `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:满意度id"` |
| | | Satisfaction Satisfaction `json:"satisfaction" gorm:"foreignKey:SatisfactionId"` |
| | | TimelyRateId int `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:及时率id"` |
| | | TimelyRate TimelyRate `json:"timelyRate" gorm:"foreignKey:TimelyRateId"` |
| | | SolveRateId int `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:解决率id"` |
| | | SolveRate SolveRate `json:"solveRate" gorm:"foreignKey:SolveRateId"` |
| | | IsVisitId int `json:"isVisitId" gorm:"column:is_visit_id;type:int;comment:服务人员是否来过id"` |
| | | IsVisit IsVisit `json:"isVisit" gorm:"foreignKey:IsVisitId"` |
| | | OldMemberId int `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:原服务人员"` |
| | | OldMember User `json:"oldMember" gorm:"foreignKey:OldMemberId"` |
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"` |
| | | File string `json:"file" gorm:"column:file;type:varchar(255);comment:附件"` |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | CrmModel |
| | | } |
| | | |
| | | ServiceFollowupSearch struct { |
| | | ServiceFollowup |
| | | Orm *gorm.DB |
| | | KeywordType constvar.ServiceFollowupKeywordType |
| | | Keyword interface{} |
| | | Keyword string |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | Preload bool |
| | | MemberIds []int |
| | | } |
| | | ) |
| | | |
| | | func (ServiceFollowup) TableName() string { |
| | | func (*ServiceFollowup) TableName() string { |
| | | return "service_followup" |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | if slf.ServiceOrderId > 0 { |
| | | db = db.Where("service_order_id = ?", slf.ServiceOrderId) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Preload("CustomerServiceSheet"). |
| | | Preload("ServiceOrder"). |
| | | Preload("Client"). |
| | | db = db.Preload("Client"). |
| | | Preload("Contact"). |
| | | Preload("ServiceOrder"). |
| | | Preload("Member"). |
| | | Preload("Satisfaction"). |
| | | Preload("TimelyRate"). |
| | | Preload("SolveRate"). |
| | | Preload("IsVisit"). |
| | | Preload("OldMember"). |
| | | Preload("Member") |
| | | Preload("OldMember") |
| | | } |
| | | |
| | | if len(slf.MemberIds) > 0 { |
| | | db = db.Where("service_followup.member_id in ?", slf.MemberIds) |
| | | } |
| | | if slf.Number != "" { |
| | | db = db.Where("number = ?", slf.Number) |
| | | } |
| | | |
| | | return db |
| | |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | err := db.Order("id desc").Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) Count() (int64, error) { |
| | | var db = slf.build() |
| | | var total int64 |
| | | err := db.Count(&total).Error |
| | | return total, err |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) MaxAutoIncr() (int, error) { |
| | | type Result struct { |
| | | Max int |
| | | } |
| | | |
| | | err := db.Find(&records).Error |
| | | return records, total, err |
| | | var ( |
| | | result Result |
| | | db = slf.build() |
| | | ) |
| | | |
| | | err := db.Select("MAX(id) as max").Scan(&result).Error |
| | | if err != nil { |
| | | return result.Max, fmt.Errorf("max err: %v", err) |
| | | } |
| | | return result.Max, nil |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) SetNumber(number string) *ServiceFollowupSearch { |
| | | slf.Number = number |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch { |
| | |
| | | slf.Orm = slf.Orm.Where("id in (?)", ids) |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) SetMemberIds(memberIds []int) *ServiceFollowupSearch { |
| | | slf.MemberIds = memberIds |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) UpdateByMap(data map[string]interface{}) error { |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |