| | |
| | | package model
|
| | |
|
| | | import (
|
| | | "aps_crm/constvar"
|
| | | "aps_crm/pkg/mysqlx"
|
| | | "gorm.io/gorm"
|
| | | )
|
| | |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:合同编号"`
|
| | | ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:联系人id"`
|
| | | ServiceId int `json:"serviceId" gorm:"column:service_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"`
|
| | | PlanId int `json:"planId" gorm:"column:plan_id;type:int;comment:服务计划id"`
|
| | |
| | |
|
| | | ServiceFollowupSearch struct {
|
| | | ServiceFollowup
|
| | |
|
| | | Orm *gorm.DB
|
| | | Keyword string
|
| | | OrderBy string
|
| | | PageNum int
|
| | | PageSize int
|
| | |
|
| | | Orm *gorm.DB
|
| | | 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
|
| | |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
|
| | | }
|
| | |
|
| | | err := db.Preload("CustomerServiceSheet").Find(&records).Error
|
| | | err := db.Preload("CustomerServiceSheet").Preload("ServiceOrder").Find(&records).Error
|
| | | return records, total, err
|
| | | }
|
| | |
|
| | |
| | | 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
|