company_report_record.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CompanyReportRecord struct {
  7. CompanyReportRecordId int `orm:"column(company_report_record_id);pk"`
  8. CompanyId int
  9. ProductId int
  10. CompanyProductId int
  11. CompanyName string
  12. Status string
  13. StartDate string
  14. EndDate string
  15. SellerId int
  16. SellerName string
  17. CreditCode string
  18. CreateDate string
  19. CreateTime time.Time
  20. ModifyTime time.Time
  21. }
  22. func AddCompanyReportRecord(item *CompanyReportRecord) (lastId int64, err error) {
  23. o := orm.NewOrm()
  24. lastId, err = o.Insert(item)
  25. return
  26. }
  27. func GetExistCompanyReportRecord(endDate string, productId int) (list []*CompanyReportRecord, err error) {
  28. sql := ` SELECT * FROM company_report_record WHERE create_date>=? AND product_id = ? `
  29. o := orm.NewOrm()
  30. _, err = o.Raw(sql, endDate, productId).QueryRows(&list)
  31. return
  32. }
  33. func GetCompanyList(productId int) (list []*CompanyReportRecord, err error) {
  34. 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
  35. FROM company AS a
  36. INNER JOIN company_product AS b ON a.company_id=b.company_id
  37. WHERE b.product_id = ? `
  38. o := orm.NewOrm()
  39. _, err = o.Raw(sql, productId).QueryRows(&list)
  40. return
  41. }
  42. // 更新客户报告记录信息
  43. func UpdateCompanyReportRecord(where, updateParams map[string]interface{}) error {
  44. o := orm.NewOrm()
  45. ptrStructOrTableName := "company_report_record"
  46. qs := o.QueryTable(ptrStructOrTableName)
  47. for expr, exprV := range where {
  48. qs = qs.Filter(expr, exprV)
  49. }
  50. _, err := qs.Update(updateParams)
  51. return err
  52. }