activity_signup.go 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package data_manage
  2. import "github.com/beego/beego/v2/client/orm"
  3. type CompanyDetail struct {
  4. CompanyId int `orm:"column(company_id);pk"`
  5. CompanyName string `description:"客户名称"`
  6. Status string `description:"客户状态"`
  7. SellerId int `description:"销售id"`
  8. SellerName string `description:"销售名称"`
  9. Mobile string `description:"销售手机号"`
  10. ProductId int `description:"1,FICC,2权益"`
  11. }
  12. func GetCompanyDetailByIdGroup(companyId int) (item *CompanyDetail, err error) {
  13. sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile
  14. FROM company AS a
  15. INNER JOIN company_product AS b ON a.company_id=b.company_id
  16. INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
  17. INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
  18. LEFT JOIN admin AS c ON b.seller_id=c.admin_id
  19. WHERE a.company_id=? AND b.product_id = 2
  20. OR (a.company_id = ? AND cp.permission_name = '策略' )
  21. ORDER BY b.product_id DESC LIMIT 0,1 `
  22. o := orm.NewOrm()
  23. err = o.Raw(sql, companyId, companyId).QueryRow(&item)
  24. return
  25. }
  26. func GetCountCompanyDetailByIdGroup(companyId int) (count int, err error) {
  27. sql := ` SELECT COUNT(1) AS count
  28. FROM company AS a
  29. INNER JOIN company_product AS b ON a.company_id=b.company_id
  30. INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
  31. INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
  32. LEFT JOIN admin AS c ON b.seller_id=c.admin_id
  33. WHERE a.company_id=? AND b.product_id = 2 OR (a.company_id = ? AND cp.permission_name = '策略' ) `
  34. o := orm.NewOrm()
  35. err = o.Raw(sql, companyId, companyId).QueryRow(&count)
  36. return
  37. }
  38. func GetCompanyPermission(companyId int) (permission string, err error) {
  39. sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',') AS permission
  40. FROM company_report_permission AS a
  41. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  42. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  43. WHERE a.company_id=?
  44. AND c.is_suspend=0
  45. AND b.cygx_auth=1
  46. AND c.status IN('正式','试用','永续')
  47. AND a.status IN('正式','试用','永续') `
  48. o := orm.NewOrm()
  49. err = o.Raw(sql, companyId).QueryRow(&permission)
  50. return
  51. }
  52. // 获取正式权限
  53. func GetCompanyPermissionByUserZhengShi(companyId int) (permission string, err error) {
  54. sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',') AS permission
  55. FROM company_report_permission AS a
  56. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  57. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  58. WHERE a.company_id=?
  59. AND c.is_suspend=0
  60. AND b.cygx_auth=1
  61. AND c.status IN('正式')
  62. AND a.status IN('正式') `
  63. o := orm.NewOrm()
  64. err = o.Raw(sql, companyId).QueryRow(&permission)
  65. return
  66. }