|
@@ -7,7 +7,9 @@ import (
|
|
|
"hongze/fms_api/global"
|
|
|
"hongze/fms_api/models/base"
|
|
|
"hongze/fms_api/models/crm"
|
|
|
+ "hongze/fms_api/models/system"
|
|
|
"hongze/fms_api/utils"
|
|
|
+ "strings"
|
|
|
)
|
|
|
|
|
|
// ContractController CRM系统合同
|
|
@@ -100,3 +102,101 @@ func (rg *ContractController) SearchList(c *gin.Context) {
|
|
|
baseData.SetList(respList)
|
|
|
resp.OkData("获取成功", baseData, c)
|
|
|
}
|
|
|
+
|
|
|
+// PermissionList
|
|
|
+// @Title 合同品种列表
|
|
|
+// @Description 合同品种列表
|
|
|
+// @Param ProductId query int false "品种类型: 1-FICC(默认); 2-权益"
|
|
|
+// @Success 200 {object} crm.PermissionSetResp
|
|
|
+// @router /crm/contract/permission_list [get]
|
|
|
+func (rg *ContractController) PermissionList(c *gin.Context) {
|
|
|
+ var req crm.ContractPermissionListReq
|
|
|
+ if e := c.BindQuery(&req); e != nil {
|
|
|
+ err, ok := e.(validator.ValidationErrors)
|
|
|
+ if !ok {
|
|
|
+ resp.FailData("参数解析失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp.FailData("参数解析失败", err.Translate(global.Trans), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ productId := 0
|
|
|
+ if req.ProductId == 0 {
|
|
|
+ productId = 1
|
|
|
+ }
|
|
|
+ respList := new(crm.PermissionSetResp)
|
|
|
+
|
|
|
+ // FICC
|
|
|
+ if productId == 1 {
|
|
|
+ // 获取品种分类配置
|
|
|
+ sysConf := new(system.SysConfig)
|
|
|
+ confCond := `config_code = ?`
|
|
|
+ confPars := make([]interface{}, 0)
|
|
|
+ confPars = append(confPars, system.ConfigKeyCrmPermissionFiccClassify)
|
|
|
+ confItem, e := sysConf.FetchByCondition(confCond, confPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取失败", "Err:"+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if confItem.ConfigValue == "" {
|
|
|
+ resp.FailData("获取失败", "FICC品种分类配置为空", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ classifyArr := strings.Split(confItem.ConfigValue, ",")
|
|
|
+ if len(classifyArr) == 0 {
|
|
|
+ resp.FailData("获取失败", "FICC品种分类配置为空", c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取FICC权限
|
|
|
+ ficcCond := `enabled = 1 AND permission_type = 0 AND product_id = ? AND classify_name IN ?`
|
|
|
+ ficcPars := make([]interface{}, 0)
|
|
|
+ ficcPars = append(ficcPars, productId, classifyArr)
|
|
|
+ items, e := crm.GetPermissionSetItemsByCondition(ficcCond, ficcPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取失败", "获取FICC权限信息失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ficcItemMap := make(map[string][]*crm.PermissionSetItem, 0)
|
|
|
+ for i := range items {
|
|
|
+ if ficcItemMap[items[i].ClassifyName] == nil {
|
|
|
+ ficcItemMap[items[i].ClassifyName] = make([]*crm.PermissionSetItem, 0)
|
|
|
+ }
|
|
|
+ ficcItemMap[items[i].ClassifyName] = append(ficcItemMap[items[i].ClassifyName], items[i])
|
|
|
+ }
|
|
|
+
|
|
|
+ for i := range classifyArr {
|
|
|
+ if classifyArr[i] == "市场策略" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ checkList := make([]int, 0)
|
|
|
+ if classifyArr[i] == "宏观经济" {
|
|
|
+ checkList = append(checkList, 1)
|
|
|
+ }
|
|
|
+ p := new(crm.PermissionSetList)
|
|
|
+ p.ClassifyName = classifyArr[i]
|
|
|
+ p.Items = ficcItemMap[classifyArr[i]]
|
|
|
+ p.CheckList = make([]int, 0)
|
|
|
+ respList.List = append(respList.List, p)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 权益
|
|
|
+ if productId == 2 {
|
|
|
+ raiCond := `enabled = 1 AND permission_type = 0 AND product_id = ? AND classify_name = ?`
|
|
|
+ raiPars := make([]interface{}, 0)
|
|
|
+ raiPars = append(raiPars, productId, crm.CompanyProductRaiName)
|
|
|
+ items, e := crm.GetPermissionSetItemsByCondition(raiCond, raiPars)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取失败", "获取权益权限信息失败, Err: "+e.Error(), c)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ p := new(crm.PermissionSetList)
|
|
|
+ p.ClassifyName = crm.CompanyProductRaiName
|
|
|
+ p.Items = items
|
|
|
+ p.CheckList = make([]int, 0)
|
|
|
+ respList.List = append(respList.List, p)
|
|
|
+ }
|
|
|
+ resp.OkData("获取成功", respList, c)
|
|
|
+}
|