| | |
| | | import (
|
| | | "aps_crm/constvar"
|
| | | "aps_crm/pkg/mysqlx"
|
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm"
|
| | | "time"
|
| | | )
|
| | |
| | | ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"`
|
| | | Terms string `json:"terms" gorm:"column:terms;type:text;comment:条款"`
|
| | | Remark string `json:"remark" gorm:"column:remark;type:text;comment:备注"`
|
| | | AmountReceivable decimal.Decimal `gorm:"amount_receivable" json:"amountReceivable"` // 应收金额 |
| | | AmountReceived decimal.Decimal `gorm:"amount_received" json:"amountReceived"` // 已收金额 |
| | | AmountInvoiced decimal.Decimal `gorm:"amount_invoiced" json:"amountInvoiced"` // 已开票金额 |
| | | Products []Product `json:"products" gorm:"many2many:serviceContract_product;"`
|
| | | gorm.Model `json:"-"`
|
| | | }
|
| | |
| | | slf.Orm = slf.Orm.Where("id in (?)", ids)
|
| | | return slf
|
| | | }
|
| | | |
| | | func (slf *ServiceContractSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Updates(upMap).Error; err != nil { |
| | | return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *ServiceContractSearch) First() (*ServiceContract, error) { |
| | | var ( |
| | | record = new(ServiceContract) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.First(record).Error; err != nil { |
| | | return record, err |
| | | } |
| | | |
| | | return record, nil |
| | | } |