company_contract.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. package controllers
  2. import (
  3. companyContractResp "hongze/hongze_mobile_admin/models/response/company_contract"
  4. "hongze/hongze_mobile_admin/models/tables/company_contract"
  5. "hongze/hongze_mobile_admin/models/tables/company_report_permission"
  6. "hongze/hongze_mobile_admin/services"
  7. "hongze/hongze_mobile_admin/services/contract"
  8. "hongze/hongze_mobile_admin/utils"
  9. )
  10. //客户合同模块
  11. type CompanyContractCommon struct {
  12. BaseAuth
  13. }
  14. // @Title 合同详情详情
  15. // @Description 合同详情接口
  16. // @Param CompanyId query int true "客户ID"
  17. // @Param CompanyContractId query int true "合同id"
  18. // @Success 200 {object} company_contract.CompanyContractDetailResp
  19. // @router /detail [get]
  20. func (c *CompanyContractCommon) ApplyContractDetail() {
  21. sysUser := c.AdminWx
  22. companyId, _ := c.GetInt("CompanyId")
  23. if companyId <= 0 {
  24. c.FailWithMessage("参数错误", "参数错误,客户id小于等于0")
  25. return
  26. }
  27. companyContractId, _ := c.GetInt("CompanyContractId")
  28. roleTypeCode := sysUser.RoleTypeCode
  29. productId := services.GetProductId(roleTypeCode)
  30. //if productId == 0 {
  31. // c.FailWithMessage("当前账户类型异常", "客户类型为:"+roleTypeCode)
  32. // return
  33. //}
  34. detail, err := company_contract.GetCompanyContractDetail(companyId, productId, companyContractId)
  35. if err != nil {
  36. c.FailWithMessage("获取信息失败", "获取信息失败,Err:"+err.Error())
  37. return
  38. }
  39. productId = detail.ProductId
  40. if productId == 1 {
  41. for _, v := range utils.PermissionFiccClassifyArr {
  42. checkList := make([]int, 0)
  43. plist := new(company_report_permission.PermissionLookList)
  44. items, err := company_report_permission.GetPermissionLookItems(productId, v)
  45. if err != nil {
  46. c.FailWithMessage("获取失败", "获取权限信息失败,Err:"+err.Error())
  47. return
  48. }
  49. for _, n := range items {
  50. count, err := company_contract.GetCompanyContractPermissionCheckByContractId(companyId, detail.CompanyContractId, n.ChartPermissionId)
  51. if err != nil {
  52. c.FailWithMessage("获取失败", "获取权限信息失败,Err:"+err.Error())
  53. return
  54. }
  55. if count > 0 {
  56. checkList = append(checkList, n.ChartPermissionId)
  57. }
  58. }
  59. plist.Items = items
  60. plist.ClassifyName = v
  61. plist.CheckList = checkList
  62. detail.PermissionList = append(detail.PermissionList, plist)
  63. }
  64. } else {
  65. classifyName := "权益"
  66. checkList := make([]int, 0)
  67. plist := new(company_report_permission.PermissionLookList)
  68. items, err := company_report_permission.GetPermissionLookItems(productId, classifyName)
  69. if err != nil {
  70. c.FailWithMessage("获取失败", "获取权限信息失败,Err:"+err.Error())
  71. return
  72. }
  73. for _, n := range items {
  74. count, err := company_contract.GetCompanyContractPermissionCheckByContractId(companyId, detail.CompanyContractId, n.ChartPermissionId)
  75. if err != nil {
  76. c.FailWithMessage("获取失败", "获取权限信息失败,Err:"+err.Error())
  77. return
  78. }
  79. if count > 0 {
  80. checkList = append(checkList, n.ChartPermissionId)
  81. }
  82. //n.PermissionName = n.Remark
  83. }
  84. plist.Items = items
  85. plist.ClassifyName = classifyName
  86. plist.CheckList = checkList
  87. detail.PermissionList = append(detail.PermissionList, plist)
  88. // CRM8.8-权限主客观合并
  89. newPermissionLookList := contract.HandleEquityPermissionLookList(detail.PermissionList)
  90. detail.PermissionList = newPermissionLookList
  91. }
  92. resp := companyContractResp.CompanyContractDetailResp{
  93. detail,
  94. }
  95. c.OkDetailed(resp, "获取成功")
  96. }