add
wangpengfei
2023-07-21 58b19364744f6f61c64978dda97b01eec37823b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package model
 
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
)
 
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"`
        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"`
        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"`
        SatisfactionId       int                  `json:"satisfactionId" gorm:"column:satisfaction_id;type:int;comment:满意度id"`
        TimelyRateId         int                  `json:"timelyRateId" gorm:"column:timely_rate_id;type:int;comment:及时率id"`
        SolveRateId          int                  `json:"solveRateId" gorm:"column:solve_rate_id;type:int;comment:解决率id"`
        IsVisitId            int                  `json:"isVisitId" gorm:"column:is_visit_id;type:int;comment:服务人员是否来过id"`
        OldMemberId          int                  `json:"oldMemberId" gorm:"column:old_member_id;type:int;comment:原服务人员"`
        Remark               string               `json:"remark" gorm:"column:remark;type:text;comment:备注"`
        File                 string               `json:"file" gorm:"column:file;type:varchar(255);comment:附件"`
 
        gorm.Model `json:"-"`
    }
 
    ServiceFollowupSearch struct {
        ServiceFollowup
        Orm *gorm.DB
    }
)
 
func (ServiceFollowup) TableName() string {
    return "service_followup"
}
 
func NewServiceFollowupSearch() *ServiceFollowupSearch {
    return &ServiceFollowupSearch{
        Orm: mysqlx.GetDB(),
    }
}
 
func (slf *ServiceFollowupSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&ServiceFollowup{})
    if slf.Id != 0 {
        db = db.Where("id = ?", slf.Id)
    }
 
    return db
}
 
func (slf *ServiceFollowupSearch) Create(record *ServiceFollowup) error {
    var db = slf.build()
    return db.Create(record).Error
}
 
func (slf *ServiceFollowupSearch) Update(record *ServiceFollowup) error {
    var db = slf.build()
    return db.Updates(record).Error
}
 
func (slf *ServiceFollowupSearch) Delete() error {
    var db = slf.build()
    return db.Delete(&ServiceFollowup{}).Error
}
 
func (slf *ServiceFollowupSearch) Find() (*ServiceFollowup, error) {
    var db = slf.build()
    var record = &ServiceFollowup{}
    err := db.First(record).Error
    return record, err
}
 
func (slf *ServiceFollowupSearch) FindAll() ([]*ServiceFollowup, error) {
    var db = slf.build()
    var records = make([]*ServiceFollowup, 0)
    err := db.Preload("CustomerServiceSheet").Find(&records).Error
    return records, err
}
 
func (slf *ServiceFollowupSearch) SetId(id int) *ServiceFollowupSearch {
    slf.Id = id
    return slf
}
 
// 合同类型 合同状态(服务合同)
// 付款方式 是否开票 账户(销售退款单)
// 退入仓库 状态(销售退货单)
// 报价单状态 (报价单)
// 可能性 币种 当前状态(销售机会)