| | |
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | ) |
| | |
| | | |
| | | ServiceFollowupSearch struct { |
| | | ServiceFollowup |
| | | |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | KeywordType constvar.ServiceFollowupKeywordType |
| | | Keyword interface{} |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | |
| | | } |
| | | ) |
| | | |
| | |
| | | |
| | | func (slf *ServiceFollowupSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&ServiceFollowup{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | switch slf.KeywordType { |
| | | case constvar.ServiceFollowupKeywordFollowupNo: |
| | | db = db.Where("number = ?", slf.Keyword) |
| | | case constvar.ServiceFollowupKeywordCustomerName: |
| | | db = db.Where("client_id = ?", slf.Keyword) |
| | | case constvar.ServiceFollowupKeywordContactName: |
| | | db = db.Where("contact_id = ?", slf.Keyword) |
| | | case constvar.ServiceFollowupKeywordCustomerServiceNo: |
| | | db = db.Where("service_id = ?", slf.Keyword) |
| | | case constvar.ServiceFollowupKeywordVisitor: |
| | | db = db.Where("member_id = ?", slf.Keyword) |
| | | case constvar.ServiceFollowupKeywordSatisfactionDegree: |
| | | db = db.Where("satisfaction_id = ?", slf.Keyword) |
| | | |
| | | } |
| | | |
| | | return db |
| | |
| | | return slf |
| | | } |
| | | |
| | | // 可能性 币种 当前状态(销售机会) |
| | | func (slf *ServiceFollowupSearch) SetKeywordType(keyword constvar.ServiceFollowupKeywordType) *ServiceFollowupSearch { |
| | | slf.KeywordType = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *ServiceFollowupSearch) SetKeyword(keyword string) *ServiceFollowupSearch { |
| | | slf.Keyword = keyword |