company.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type Company struct {
  7. CompanyId int64 `orm:"column(company_id);pk"`
  8. CompanyName string `description:"客户名称"`
  9. CreditCode string `description:"社会统一信用码"`
  10. CompanyCode string `description:"客户编码"`
  11. Sort int `description:"优先级"`
  12. IsFeeCustomer int `description:"是否付费用户"`
  13. Country string `description:"国家编码"`
  14. ProvinceId int `description:"省id"`
  15. CityId int `description:"市id"`
  16. Address string `description:"详细地址"`
  17. CompanyType int `orm:"column(type)" description:"客户标签,1:付费客户,2:试用客户,3:流失客户,4:潜在客户"`
  18. Enabled int `description:"用户状态"`
  19. CreatedTime time.Time `description:"创建时间"`
  20. LastUpdatedTime time.Time `description:"最后一次阅读时间"`
  21. Seller string `description:"销售员"`
  22. SellsId int `description:"销售员id"`
  23. CompanyBelong string `description:"客户所属,ficc:ficc客户,public_offering:公募客户,partner:合作伙伴"`
  24. StartDate string `description:"合同开始日期"`
  25. EndDate string `description:"合同结束日期"`
  26. LoseReason string `description:"流失原因"`
  27. LastType int `description:"原客户标签"`
  28. IsVip int `description:"0:普通用户,1:大客户"`
  29. LossTime time.Time `description:"流失时间"`
  30. FirstStartDate string `description:"首次设置为试用客户开始时间"`
  31. FirstEndDate string `description:"首次设置为试用客户结束时间"`
  32. DateType int `description:"设置流失类型,1:1个月,2:2个月,3:3个月"`
  33. Status string `description:"'试用','永续','冻结','流失','正式','潜在'"`
  34. }
  35. //获取企业信息详情
  36. func GetCompanyInfoById(companyId int) (item *Company, err error) {
  37. o := orm.NewOrm()
  38. sql := ` SELECT * FROM company
  39. WHERE company_id = ? `
  40. err = o.Raw(sql, companyId).QueryRow(&item)
  41. return
  42. }
  43. func GetCompanyById(companyId int) (item []*CompanyProduct, err error) {
  44. o := orm.NewOrm()
  45. sql := ` SELECT a.*,b.status,b.is_suspend,b.product_id, b.seller_name FROM company AS a
  46. INNER JOIN company_product AS b ON a.company_id=b.company_id
  47. WHERE a.company_id=? `
  48. _, err = o.Raw(sql, companyId).QueryRows(&item)
  49. return
  50. }
  51. func GetCompanyProductById(companyId, productId int) (item *CompanyProduct, err error) {
  52. o := orm.NewOrm()
  53. sql := ` SELECT a.*,b.status,b.is_suspend,b.seller_id FROM company AS a
  54. INNER JOIN company_product AS b ON a.company_id=b.company_id
  55. WHERE a.company_id=? AND b.product_id=? `
  56. err = o.Raw(sql, companyId, productId).QueryRow(&item)
  57. return
  58. }