12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package cygx
- import "github.com/beego/beego/v2/client/orm"
- func GetCountCompanyDetailByIdGroup(companyId int) (count int, err error) {
- sql := ` SELECT COUNT(1) AS count
- FROM company AS a
- INNER JOIN company_product AS b ON a.company_id=b.company_id
- INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
- INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
- LEFT JOIN admin AS c ON b.seller_id=c.admin_id
- WHERE a.company_id=? AND b.product_id = 2 OR (a.company_id = ? AND cp.permission_name = '策略' ) `
- o := orm.NewOrm()
- err = o.Raw(sql, companyId, companyId).QueryRow(&count)
- return
- }
- type CompanyDetail struct {
- CompanyId int `orm:"column(company_id);pk"`
- CompanyName string `description:"客户名称"`
- Status string `description:"客户状态"`
- SellerId int `description:"销售id"`
- SellerName string `description:"销售名称"`
- Mobile string `description:"销售手机号"`
- ProductId int `description:"1,FICC,2权益"`
- }
- func GetCompanyDetailByIdGroup(companyId int) (item *CompanyDetail, err error) {
- sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile
- FROM company AS a
- INNER JOIN company_product AS b ON a.company_id=b.company_id
- INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
- INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
- LEFT JOIN admin AS c ON b.seller_id=c.admin_id
- WHERE a.company_id=? AND b.product_id = 2
- OR (a.company_id = ? AND cp.permission_name = '策略' )
- ORDER BY b.product_id DESC LIMIT 0,1 `
- o := orm.NewOrm()
- err = o.Raw(sql, companyId, companyId).QueryRow(&item)
- return
- }
- // 获取正式权限
- func GetCompanyPermissionByUserZhengShi(companyId int) (permission string, err error) {
- sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',') AS permission
- FROM company_report_permission AS a
- INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
- INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
- WHERE a.company_id=?
- AND c.is_suspend=0
- AND b.cygx_auth=1
- AND c.status IN('正式')
- AND a.status IN('正式') `
- o := orm.NewOrm()
- err = o.Raw(sql, companyId).QueryRow(&permission)
- return
- }
|