package fms import ( "hongze/fms_api/global" "time" ) type ContractIncomeHistory struct { IncomeId int `json:"income_id" gorm:"primaryKey;column:income_id"` // Amount float64 `json:"amount" gorm:"column:amount"` // 开票金额 InvoiceTime time.Time `json:"invoice_time" gorm:"column:invoice_time"` // 开票日期/到款月 SellerId int `json:"seller_id" gorm:"column:seller_id"` // 销售ID SellerName string `json:"seller_name" gorm:"column:seller_name"` // 销售名称 NewCompany int `json:"new_company" gorm:"column:new_company"` // 是否为新客户:0-否;1-是 CompanyName string `json:"company_name" gorm:"column:company_name"` // 客户名称 } func (c *ContractIncomeHistory) List(condition string, pars []interface{}) (list []*ContractIncomeHistory, err error) { list = make([]*ContractIncomeHistory, 0) err = global.DEFAULT_MYSQL.Model(c). Where(condition, pars...). Find(&list).Error return } func (c *ContractIncomeHistory) TableName() string { return "contract_income_history" } // GetIncomeHistory func GetIncomeHistory(condition string, pars []interface{}) (results []*IncomeSummaryItem, err error) { sql := `SELECT amount,seller_name,new_company AS contract_type,company_name,invoice_time AS invoice_date FROM contract_income_history WHERE ` sql += condition sql += ` ORDER BY invoice_date ` err = global.DEFAULT_MYSQL.Raw(sql, pars...).Find(&results).Error return } // GetIncomeHistoryList func GetIncomeHistoryList() (results []*ContractIncomeHistory, err error) { sql := `SELECT * FROM contract_income_history WHERE seller_id=0 ` err = global.DEFAULT_MYSQL.Raw(sql).Find(&results).Error return } func (c *ContractIncomeHistory) Update(updateCols []string) (err error) { err = global.DEFAULT_MYSQL.Model(c).Select(updateCols).Updates(c).Error return } func GetLatestHistoryIncome(condition string, pars []interface{}) (result *ContractInvoice, err error) { sql := `SELECT * FROM contract_income_history WHERE 1=1 ` sql += condition sql += ` ORDER BY invoice_time DESC ` err = global.DEFAULT_MYSQL.Raw(sql, pars...).First(&result).Error return }