1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- package data_manage
- import "github.com/beego/beego/v2/client/orm"
- 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 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
- }
- func GetCompanyPermission(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
- }
- // 获取正式权限
- 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
- }
|