zhangqian
2023-10-13 250cbfa1ddcb3cf38e0d0505c1c7e282b940d25b
model/salesLeads.go
@@ -9,19 +9,21 @@
type (
   SalesLeads struct {
      Id              int                  `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
      Name            string               `json:"name" gorm:"column:name;unique;type:varchar(255);comment:公司名称"`
      Name            string               `json:"name" gorm:"column:name;uniqueIndex:name_isDeleted_idx;;type:varchar(255);comment:公司名称"`
      IsDeleted       bool                 `json:"-" gorm:"column:is_deleted;uniqueIndex:name_isDeleted_idx;type:tinyint(1);comment:是否删除"`
      Number          string               `json:"number" gorm:"column:number;type:varchar(255);comment:销售线索编号"`
      ContactName     string               `json:"contact_name" gorm:"column:contact_name;type:varchar(255);comment:联系人姓名"`
      ContactPhone    string               `json:"contact_phone" gorm:"column:contact_phone;type:varchar(255);comment:联系人电话"`
      ContactPosition string               `json:"contact_position" gorm:"column:contact_position;type:varchar(255);comment:联系人职位"`
      SalesSourcesId  int                  `json:"sales_sources_id" gorm:"column:sales_sources_id;type:int(11);comment:商机来源ID"`
      SalesSources    SalesSources         `json:"-" gorm:"foreignKey:SalesSourcesId"`
      SalesSources    SalesSources         `json:"sales_sources" gorm:"foreignKey:SalesSourcesId"`
      MemberId        int                  `json:"member_id" gorm:"column:member_id;type:int(11);comment:销售负责人ID"`
      Member          User                 `json:"-" gorm:"foreignKey:MemberId"`
      Member          User                 `json:"member" gorm:"foreignKey:MemberId"`
      SalesStatus     constvar.SalesStatus `json:"sales_status" gorm:"column:sales_status;type:int(11);comment:销售状态"`
      Desc            string               `json:"desc" gorm:"column:desc;type:varchar(255);comment:备注"`
      Reason          string               `json:"reason" gorm:"column:reason;type:text;comment:失败原因"`
      FollowRecord    []FollowRecord       `gorm:"foreignKey:SalesLeadsId"`
      DetailAddress   string               `json:"detail_address" gorm:"column:detail_address;type:varchar(255);comment:详细地址"`
      Address
      gorm.Model `json:"-"`
   }
@@ -107,6 +109,7 @@
func (slf *SalesLeadsSearch) Delete() error {
   var db = slf.build()
   db.Update("is_deleted", 1)
   return db.Delete(&SalesLeads{}).Error
}
@@ -133,7 +136,7 @@
      db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
   }
   err := db.Preload("FollowRecord").Find(&records).Error
   err := db.Preload("SalesSources").Preload("Member").Preload("Province").Preload("City").Preload("FollowRecord").Order("id desc").Find(&records).Error
   return records, total, err
}