liujiandao
2023-10-17 07e0edb712b81e8d3b38465f71d66206e81361db
Merge branch 'master' of http://192.168.5.5:10010/r/aps/crm
3个文件已修改
74 ■■■■■ 已修改文件
model/index.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/quotationStatus.go 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/saleStage.go 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/index.go
@@ -122,6 +122,8 @@
        NewTimelyRateSearch(),
        NewFaultTypeSearch(),
        NewRepositorySearch(),
        NewSaleStageSearch(),
        NewQuotationStatusSearch(),
    }
    for _, model := range models {
model/quotationStatus.go
@@ -3,6 +3,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
    "sync"
)
type (
@@ -11,7 +12,7 @@
        Id   int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Name string `json:"name" gorm:"column:name;type:varchar(255);comment:商机阶段名称"`
    }
    QuotationStatusSearch struct {
        QuotationStatus
        Orm *gorm.DB
@@ -83,3 +84,37 @@
    var db = slf.build()
    return db.Updates(data).Error
}
func (slf *QuotationStatusSearch) CreateBatch(records []*QuotationStatus) error {
    var db = slf.build()
    return db.Create(records).Error
}
// InitDefaultData 初始化数据
func (slf *QuotationStatusSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) {
    var (
        db          = slf.Orm.Table(slf.TableName())
        total int64 = 0
    )
    defer wg.Done()
    if err := db.Count(&total).Error; err != nil {
        errCh <- err
        return
    }
    if total != 0 {
        return
    }
    records := []*QuotationStatus{
        {1, "已创建"},
        {2, "已发送"},
        {3, "已审批"},
        {4, "已拒绝"},
        {5, "已接受"},
    }
    err := slf.CreateBatch(records)
    if err != nil {
        errCh <- err
        return
    }
}
model/saleStage.go
@@ -3,6 +3,7 @@
import (
    "aps_crm/pkg/mysqlx"
    "gorm.io/gorm"
    "sync"
)
type (
@@ -84,3 +85,37 @@
    var db = slf.build()
    return db.Updates(data).Error
}
func (slf *SaleStageSearch) CreateBatch(records []*SaleStage) error {
    var db = slf.build()
    return db.Create(records).Error
}
// InitDefaultData 初始化数据
func (slf *SaleStageSearch) InitDefaultData(errCh chan<- error, wg *sync.WaitGroup) {
    var (
        db          = slf.Orm.Table(slf.TableName())
        total int64 = 0
    )
    defer wg.Done()
    if err := db.Count(&total).Error; err != nil {
        errCh <- err
        return
    }
    if total != 0 {
        return
    }
    records := []*SaleStage{
        {1, "初期沟通"},
        {2, "需求分析"},
        {3, "商务谈判"},
        {4, "成功关闭"},
        {4, "成功结案"},
    }
    err := slf.CreateBatch(records)
    if err != nil {
        errCh <- err
        return
    }
}