activity_signup.go 2.3 KB

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