company_product.go 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package company
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CompanyProduct struct {
  7. CompanyProductId int `orm:"column(company_product_id);pk" description:"客户产品id"`
  8. CompanyId int `description:"客户id"`
  9. ProductId int `description:"产品id"`
  10. ProductName string `description:"产品名称"`
  11. CompanyName string `description:"客户名称"`
  12. Source string `description:"来源"`
  13. Reasons string `description:"新增理由"`
  14. Status string `description:"客户状态"`
  15. IndustryId int `description:"行业id"`
  16. IndustryName string `description:"行业名称"`
  17. SellerId int `description:"销售id"`
  18. SellerName string `description:"销售名称"`
  19. GroupId int `description:"销售分组id"`
  20. DepartmentId int `description:"销售部门id"`
  21. IsSuspend int `description:"1:暂停,0:启用"`
  22. SuspendTime time.Time `description:"暂停启用时间"`
  23. TryOutTime time.Time `description:"正式转试用时间"`
  24. RenewalReason string `description:"正式转试用后的续约情况说明"`
  25. RenewalTodo string `description:"未续约说明中的待办事项说明"`
  26. LastDescriptionTime time.Time `description:"上次添加说明时间"`
  27. RenewalIntention int `description:"是否勾选无续约意向,1:确认,0:未确认"`
  28. ApproveStatus string `description:"审批状态:'审批中','通过','驳回'"`
  29. FreezeTime time.Time `description:"冻结时间"`
  30. FreezeReason time.Time `description:"冻结理由"`
  31. Remark string `description:"备注信息"`
  32. CreateTime time.Time `description:"创建时间"`
  33. ModifyTime time.Time `description:"修改时间"`
  34. StartDate string `description:"开始日期"`
  35. EndDate string `description:"结束日期"`
  36. ContractEndDate time.Time `description:"合同结束日期"`
  37. LoseReason string `description:"流失原因"`
  38. LossTime time.Time `description:"流失时间"`
  39. CompanyType string `description:"客户类型"`
  40. OpenCode string `description:"开放给第三方的编码,不让第三方定位我们的客户信息"`
  41. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。"`
  42. ViewTotal int `description:"总阅读次数"`
  43. RoadShowTotal int `description:"累计路演次数"`
  44. LastViewTime time.Time `description:"最后一次阅读时间"`
  45. PackageType int `description:"套餐类型"`
  46. IsFormal int `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
  47. TodoStatus string `description:"任务处理状态;枚举值:'无任务','未完成','已完成'"`
  48. TodoCreateTime time.Time `description:"任务创建时间"`
  49. TodoApproveTime time.Time `description:"任务审批时间"`
  50. TryStage int `description:"试用客户子标签:1未分类、2 推进、3 跟踪、4 预备"`
  51. TryOutDayTotal int `description:"客户总试用天数"`
  52. CloseReason string `description:"关闭原因"`
  53. CloseTime time.Time `description:"关闭时间"`
  54. OverseasLabel int `description:"海外客户试用子标签:1未分类、2 推进、3 跟踪、4 预备、"`
  55. IsOverseas int `description:"是否显示在海外客户0:显示,1:不显示"`
  56. ShareSellerId int `description:"共享销售员id"`
  57. }
  58. func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *CompanyProduct, err error) {
  59. o := orm.NewOrmUsingDB("weekly_report")
  60. sql := `SELECT b.* FROM company AS a
  61. INNER JOIN company_product AS b ON a.company_id=b.company_id
  62. WHERE a.company_id=? AND b.product_id=? LIMIT 1 `
  63. err = o.Raw(sql, companyId, productId).QueryRow(&item)
  64. return
  65. }
  66. func GetCompanyProductCount(companyId, productId int) (count int, err error) {
  67. sql := ` SELECT COUNT(1) AS count FROM company_product WHERE company_id = ? AND product_id = ? `
  68. o := orm.NewOrmUsingDB("weekly_report")
  69. err = o.Raw(sql, companyId, productId).QueryRow(&count)
  70. return
  71. }
  72. func GetCompanyProductDetailByCompanyId(companyId, productId int) (item *CompanyProduct, err error) {
  73. sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
  74. o := orm.NewOrmUsingDB("weekly_report")
  75. err = o.Raw(sql, companyId, productId).QueryRow(&item)
  76. return
  77. }
  78. type CompanyProductUser struct {
  79. CompanyId int `description:"客户id"`
  80. ProductId int `description:"产品id"`
  81. CompanyName string `description:"客户名称"`
  82. Status string `description:"客户状态"`
  83. SellerId int `description:"销售id"`
  84. SellerName string `description:"销售名称"`
  85. Mobile string `description:"手机号"`
  86. UserId int
  87. RealName string `description:"用户实际名称"`
  88. Email string `description:"邮箱"`
  89. }
  90. func GetCompanyProductListByUserId(userId int) (item *CompanyProductUser, err error) {
  91. o := orm.NewOrmUsingDB("weekly_report")
  92. sql := `SELECT
  93. u.mobile,
  94. u.user_id,
  95. u.email,
  96. u.real_name,
  97. u.company_id,
  98. p.seller_name,
  99. p.status,
  100. c.company_name
  101. FROM
  102. wx_user as u
  103. INNER JOIN company AS c ON c.company_id = u.company_id
  104. INNER JOIN company_product AS p ON p.company_id = u.company_id
  105. WHERE u.user_id = ? AND p.product_id = 2 `
  106. err = o.Raw(sql, userId).QueryRow(&item)
  107. return
  108. }