ziwen 2 years ago
parent
commit
b9e4b71c88
2 changed files with 8 additions and 5 deletions
  1. 1 0
      controller/crm/contract.go
  2. 7 5
      services/crm/contract.go

+ 1 - 0
controller/crm/contract.go

@@ -235,6 +235,7 @@ func (rg *ContractController) ServiceDetail(c *gin.Context) {
 
 	contractDetail, e := crmService.GetContractDetail(req.ContractId)
 	if e != nil {
+		global.LOG.Error(e.Error())
 		resp.FailMsg("获取失败", "获取合同套餐及品种信息失败, Err: "+e.Error(), c)
 		return
 	}

+ 7 - 5
services/crm/contract.go

@@ -97,8 +97,8 @@ func getContractServiceAndDetailList(contractId int) (serviceList []*crm.Contrac
 		return
 	}
 
-	templateMap := make(map[string]*fms.ContractServiceTemplate)
-	templateIdMap := make(map[int]string)
+	templateMap := make(map[string]*fms.ContractServiceTemplate,0)
+	templateIdMap := make(map[int]string,0)
 	for _, v := range serviceTempList {
 		templateIdMap[v.ServiceTemplateId] = v.Title
 	}
@@ -111,7 +111,7 @@ func getContractServiceAndDetailList(contractId int) (serviceList []*crm.Contrac
 		}
 	}
 
-	fmsTemplateIdMap := make(map[int]string)
+	fmsTemplateIdMap := make(map[int]string,0)
 
 	newLen := len(serviceList)
 	for i := 0; newLen > i; i++ {
@@ -136,9 +136,11 @@ func getContractServiceAndDetailList(contractId int) (serviceList []*crm.Contrac
 			v.FMSServiceTemplatePId =templateMap[pTitle+v.Title].Pid
 			v.FMSPTitle = templateIdMap[v.Pid]
 		}else{
-			v.FMSServiceTemplateId = templateMap[v.Title].ServiceTemplateId
+			if templateMap[v.Title] != nil {
+				v.FMSServiceTemplateId = templateMap[v.Title].ServiceTemplateId
+				v.FMSServiceTemplatePId =templateMap[v.Title].Pid
+			}
 			v.FMSTitle = templateIdMap[v.FMSServiceTemplateId]
-			v.FMSServiceTemplatePId =templateMap[v.Title].Pid
 			v.FMSPTitle = templateIdMap[v.Pid]
 		}
 	}