|
@@ -6,7 +6,6 @@ import (
|
|
|
"hongze/fms_api/controller/resp"
|
|
|
"hongze/fms_api/global"
|
|
|
"hongze/fms_api/models/fms"
|
|
|
- "strconv"
|
|
|
)
|
|
|
|
|
|
// ServiceController 合同套餐
|
|
@@ -29,28 +28,22 @@ func (sr *ServiceController) List(c *gin.Context) {
|
|
|
resp.FailData("参数解析失败", err.Translate(global.Trans), c)
|
|
|
return
|
|
|
}
|
|
|
- productIdStr := req.ProductId
|
|
|
- var productId int
|
|
|
- var list []*fms.ContractServiceTemplateItem
|
|
|
- var err error
|
|
|
- if productIdStr == "" {
|
|
|
- list, err = fms.GetContractServiceTemplateSecond()
|
|
|
- }else{
|
|
|
- productId, _ = strconv.Atoi(productIdStr)
|
|
|
- list, err = fms.GetContractServiceTemplateMapByProductId(productId)
|
|
|
+
|
|
|
+ productId := req.ProductId
|
|
|
+ if productId == 0 {
|
|
|
+ productId = 1
|
|
|
}
|
|
|
|
|
|
- if err != nil {
|
|
|
- resp.FailData("获取失败", "获取产品套餐失败, Err: "+err.Error(), c)
|
|
|
+ list, e := fms.GetContractServiceTemplateMapByProductId(productId)
|
|
|
+ if e != nil {
|
|
|
+ resp.FailData("获取失败", "获取产品套餐失败, Err: "+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
- allMap := make(map[int][]*fms.ContractServiceTemplateMapItems)
|
|
|
- respList := make([]*fms.ContractServiceTemplateList, 0)
|
|
|
-
|
|
|
+ respList := make([]*fms.ContractServiceTemplateMapItems, 0)
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
- item := list[i]
|
|
|
v := new(fms.ContractServiceTemplateMapItems)
|
|
|
- v.ContractServiceTemplateItem = *item
|
|
|
+ v.ContractServiceTemplateItem = *list[i]
|
|
|
+
|
|
|
secFormatList := make([]*fms.ContractServiceTemplateMapItems, 0)
|
|
|
secList, e := fms.GetContractServiceTemplateMapByParentId(v.ServiceTemplateId)
|
|
|
if e != nil {
|
|
@@ -84,90 +77,14 @@ func (sr *ServiceController) List(c *gin.Context) {
|
|
|
secFormatList = append(secFormatList, sec)
|
|
|
}
|
|
|
|
|
|
- detail, e := fms.GetContractServiceDetailByTemplateId(item.ServiceTemplateId)
|
|
|
+ detail, e := fms.GetContractServiceDetailByTemplateId(list[i].ServiceTemplateId)
|
|
|
if e != nil {
|
|
|
resp.FailData("获取失败", "获取详情模板失败, Err:"+e.Error(), c)
|
|
|
return
|
|
|
}
|
|
|
v.Detail = detail
|
|
|
v.Children = secFormatList
|
|
|
- allMap[item.ProductId] = append(allMap[item.ProductId], v)
|
|
|
- }
|
|
|
- allTitleMap := map[int]string{
|
|
|
- 1:"FICC套餐",
|
|
|
- 2:"权益套餐",
|
|
|
- }
|
|
|
- if productId == 0 {
|
|
|
- tmp1 := &fms.ContractServiceTemplateList{
|
|
|
- Title: allTitleMap[1],
|
|
|
- Children: allMap[1],
|
|
|
- }
|
|
|
- tmp2 := &fms.ContractServiceTemplateList{
|
|
|
- Title: allTitleMap[2],
|
|
|
- Children: allMap[2],
|
|
|
- }
|
|
|
- respList = append(respList, tmp1)
|
|
|
- respList = append(respList, tmp2)
|
|
|
- }else{
|
|
|
- tmp := &fms.ContractServiceTemplateList{
|
|
|
- Title: allTitleMap[productId],
|
|
|
- Children: allMap[productId],
|
|
|
- }
|
|
|
- respList = append(respList, tmp)
|
|
|
- }
|
|
|
- resp.OkData("获取成功", respList, c)
|
|
|
-}
|
|
|
-
|
|
|
-// ServiceList
|
|
|
-// @Title 合同套餐列表
|
|
|
-// @Description 合同套餐列表
|
|
|
-// @Param ProductId query int false "套餐类型: 1-FICC(默认); 2-权益"
|
|
|
-// @Success 200 {object} crm.ContractSearchListResp
|
|
|
-// @router /contract/service/simple [get]
|
|
|
-func (sr *ServiceController) SimpleList(c *gin.Context) {
|
|
|
- list, err := fms.GetContractServiceTemplateSecond()
|
|
|
- if err != nil {
|
|
|
- resp.FailData("获取失败", "获取产品套餐失败, Err: "+err.Error(), c)
|
|
|
- return
|
|
|
+ respList = append(respList, v)
|
|
|
}
|
|
|
- allList := make([]*fms.ContractServiceTemplateItem, 0)
|
|
|
- allMap := make(map[int][]*fms.ContractServiceTemplateMapItems)
|
|
|
- respList := make([]*fms.ContractServiceTemplateList, 0)
|
|
|
- for i := 0; i < len(list); i++ {
|
|
|
- if list[i].Title == "行业套餐" {
|
|
|
- industryList, e := fms.GetContractServiceTemplateMapByParentId(list[i].ServiceTemplateId)
|
|
|
- if e != nil {
|
|
|
- resp.FailData("获取失败", "Err:"+e.Error(), c)
|
|
|
- return
|
|
|
- }
|
|
|
- for _, sv := range industryList {
|
|
|
- allList = append(allList, sv)
|
|
|
- }
|
|
|
- }else{
|
|
|
- allList = append(allList, list[i])
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for i := 0; i < len(allList); i++ {
|
|
|
- item := allList[i]
|
|
|
- v := new(fms.ContractServiceTemplateMapItems)
|
|
|
- v.ContractServiceTemplateItem = *item
|
|
|
- allMap[item.ProductId] = append(allMap[item.ProductId], v)
|
|
|
- }
|
|
|
- allTitleMap := map[int]string{
|
|
|
- 1:"FICC套餐",
|
|
|
- 2:"权益套餐",
|
|
|
- }
|
|
|
- tmp1 := &fms.ContractServiceTemplateList{
|
|
|
- Title: allTitleMap[1],
|
|
|
- Children: allMap[1],
|
|
|
- }
|
|
|
- tmp2 := &fms.ContractServiceTemplateList{
|
|
|
- Title: allTitleMap[2],
|
|
|
- Children: allMap[2],
|
|
|
- }
|
|
|
- respList = append(respList, tmp1)
|
|
|
- respList = append(respList, tmp2)
|
|
|
-
|
|
|
resp.OkData("获取成功", respList, c)
|
|
|
}
|