| | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | ) |
| | | |
| | |
| | | SaleChance SaleChance `json:"sale_chance" gorm:"foreignKey:SaleChanceId"` |
| | | Products []Product `json:"products" gorm:"many2many:quotation_product"` |
| | | CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:编码id"` |
| | | AmountTotal decimal.Decimal `gorm:"-" json:"amountTotal"` //价格合计 |
| | | gorm.Model `json:"-"` |
| | | } |
| | | |
| | |
| | | } |
| | | if slf.Number != "" { |
| | | db = db.Where("number = ?", slf.Number) |
| | | } |
| | | if slf.QuotationStatusId != 0 { |
| | | db = db.Where("quotation_status_id = ?", slf.QuotationStatusId) |
| | | } |
| | | |
| | | if len(slf.SearchMap) > 0 { |
| | |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Preload("Products").Preload("Member").Preload("QuotationStatus").Preload("Client").Preload("Contact").Order("id desc").Find(&records).Error |
| | | err := db.Preload("Products").Preload("Member").Preload("QuotationStatus").Preload("Client").Preload("Contact").Preload("SaleChance").Order("id desc").Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | |
| | | slf.Number = number |
| | | return slf |
| | | } |
| | | |
| | | func (slf *QuotationSearch) SetIds(ids []int) *QuotationSearch { |
| | | slf.Orm = slf.Orm.Where("id in (?)", ids) |
| | | return slf |
| | | } |
| | | |
| | | func (slf *QuotationSearch) SetQuotationStatusId(id int) *QuotationSearch { |
| | | slf.QuotationStatusId = id |
| | | return slf |
| | | } |