| | |
| | | SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"` |
| | | Creator int `json:"creator" gorm:"column:creator;type:int(11);comment:创建人"` |
| | | Modifier int `json:"modifier" gorm:"column:modifier;type:int(11);comment:修改人"` |
| | | EstimatedCollectionDate string `json:"estimated_collection_date" gorm:"column:estimated_collection_date;type:datetime;comment:预计收款日期"` |
| | | EstimatedCollectionDate *string `json:"estimated_collection_date" gorm:"column:estimated_collection_date;type:datetime;comment:预计收款日期"` |
| | | EstimatedCollectionAmount float64 `json:"estimated_collection_amount" gorm:"column:estimated_collection_amount;type:decimal(10,2);comment:预计收款金额"` |
| | | gorm.Model |
| | | gormModel |
| | | } |
| | | |
| | | CollectionProjectionSearch struct { |
| | | CollectionProjection |
| | | |
| | | Orm *gorm.DB |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | SearchMap map[string]interface{} |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | |
| | | var db = slf.Orm.Model(&CollectionProjection{}) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if len(slf.SearchMap) > 0 { |
| | | for key, value := range slf.SearchMap { |
| | | switch v := value.(type) { |
| | | case string: |
| | | if key == "estimated_collection_date" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | case int: |
| | | if key == "client_id" || key == "sale_chance_id" { |
| | | db = db.Where(key+" = ?", v) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return db |
| | |
| | | return |
| | | } |
| | | |
| | | func (slf *CollectionProjectionSearch) Find() (record CollectionProjection, err error) { |
| | | func (slf *CollectionProjectionSearch) Find() (int64, error, []*CollectionProjection) { |
| | | var db = slf.build() |
| | | err = db.First(&record).Error |
| | | return |
| | | var records = make([]*CollectionProjection, 0) |
| | | var total int64 |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return total, err, records |
| | | } |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) |
| | | } |
| | | |
| | | err := db.Find(&records).Error |
| | | return total, err, records |
| | | } |
| | | |
| | | func (slf *CollectionProjectionSearch) SetID(id int) *CollectionProjectionSearch { |
| | |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *CollectionProjectionSearch) SetSearchMap(data map[string]interface{}) *CollectionProjectionSearch { |
| | | slf.SearchMap = data |
| | | return slf |
| | | } |