12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package contract
- import (
- "github.com/gin-gonic/gin"
- "github.com/go-playground/validator/v10"
- "hongze/fms_api/controller/resp"
- "hongze/fms_api/global"
- "hongze/fms_api/models/fms"
- )
- // ServiceController 合同套餐
- type ServiceController struct{}
- // ServiceList
- // @Title 合同套餐列表
- // @Description 合同套餐列表
- // @Param ProductId query int false "品种类型: 1-FICC(默认); 2-权益"
- // @Success 200 {object} crm.ContractSearchListResp
- // @router /contract/service/list [get]
- func (sr *ServiceController) List(c *gin.Context) {
- var req fms.ContractServiceListReq
- 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
- }
- list, e := fms.GetContractServiceTemplateMapByProductId(productId)
- if e != nil {
- resp.FailData("获取失败", "获取产品套餐失败, Err: "+e.Error(), c)
- return
- }
- for i := 0; i < len(list); i++ {
- secList, e := fms.GetContractServiceTemplateMapByParentId(list[i].ServiceTemplateId)
- if e != nil {
- resp.FailData("获取失败", "Err:"+e.Error(), c)
- return
- }
- secondLen := len(secList)
- for j := 0; j < secondLen; j++ {
- detail, e := fms.GetContractServiceDetailByTemplateId(secList[j].ServiceTemplateId)
- if e != nil {
- resp.FailData("获取失败", "获取详情模板失败, Err:"+e.Error(), c)
- return
- }
- secList[j].Detail = detail
- // 权益存在第三级主客观套餐
- thirdList, e := fms.GetContractServiceTemplateMapByParentId(secList[j].ServiceTemplateId)
- if e != nil {
- resp.FailData("获取失败", "获取三级套餐失败, Err:"+e.Error(), c)
- return
- }
- secList[j].Children = thirdList
- }
- detail, e := fms.GetContractServiceDetailByTemplateId(list[i].ServiceTemplateId)
- if e != nil {
- resp.FailData("获取失败", "获取详情模板失败, Err:"+e.Error(), c)
- return
- }
- list[i].Detail = detail
- list[i].Children = secList
- }
- resp.OkData("获取成功", list, c)
- }
|