12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CompanyReportRecord struct {
- CompanyReportRecordId int `orm:"column(company_report_record_id);pk"`
- CompanyId int
- ProductId int
- CompanyProductId int
- CompanyName string
- Status string
- StartDate string
- EndDate string
- SellerId int
- SellerName string
- CreditCode string
- CreateDate string
- CreateTime time.Time
- ModifyTime time.Time
- }
- func AddCompanyReportRecord(item *CompanyReportRecord) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- func GetExistCompanyReportRecord(endDate string, productId int) (list []*CompanyReportRecord, err error) {
- sql := ` SELECT * FROM company_report_record WHERE create_date>=? AND product_id = ? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, endDate, productId).QueryRows(&list)
- return
- }
- func GetCompanyList(productId int) (list []*CompanyReportRecord, err error) {
- sql := ` SELECT a.company_id,a.company_name,a.credit_code,b.status,b.start_date,b.end_date,b.seller_id,b.seller_name,b.company_product_id,b.product_id
- FROM company AS a
- INNER JOIN company_product AS b ON a.company_id=b.company_id
- WHERE b.product_id = ? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, productId).QueryRows(&list)
- return
- }
- // 更新客户报告记录信息
- func UpdateCompanyReportRecord(where, updateParams map[string]interface{}) error {
- o := orm.NewOrm()
- ptrStructOrTableName := "company_report_record"
- qs := o.QueryTable(ptrStructOrTableName)
- for expr, exprV := range where {
- qs = qs.Filter(expr, exprV)
- }
- _, err := qs.Update(updateParams)
- return err
- }
|