Forráskód Böngészése

Merge branch 'crm5.1' into debug

hsun 3 éve
szülő
commit
f18ad0662c
1 módosított fájl, 25 hozzáadás és 0 törlés
  1. 25 0
      controllers/contract.go

+ 25 - 0
controllers/contract.go

@@ -7,6 +7,7 @@ import (
 	contractResp "hongze/hongze_mobile_admin/models/response/contract"
 	"hongze/hongze_mobile_admin/models/tables/contract"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval"
+	"hongze/hongze_mobile_admin/models/tables/contract_relation"
 	contractService "hongze/hongze_mobile_admin/services/contract"
 	"hongze/hongze_mobile_admin/services/seal"
 	"hongze/hongze_mobile_admin/utils"
@@ -431,6 +432,30 @@ func (c *ContractCommon) ListBySeal() {
 		c.FailWithMessage("获取合同列表失败", "获取合同列表失败,Err:"+err.Error())
 		return
 	}
+	if len(list) > 0 {
+		// 代付合同查询代付用户名称
+		contractIdSlice := make([]string, 0)
+		for i := 0; i < len(list); i ++ {
+			if list[i].ContractBusinessType == "代付合同" {
+				contractIdSlice = append(contractIdSlice, strconv.Itoa(list[i].ContractId))
+			}
+		}
+		contractIdStr := strings.Join(contractIdSlice, ",")
+		contractList, err := contract_relation.GetContractRelationListByPaymentOnBehalfContractIds(contractIdStr)
+		if err != nil {
+			c.FailWithMessage("获取失败", "获取代付合同对应的合同数据失败,Err:"+err.Error())
+			return
+		}
+		userCompanyNameMap := make(map[int]string, 0)
+		for i := 0; i < len(contractList); i ++ {
+			userCompanyNameMap[contractList[i].PaymentOnBehalfContractId] = contractList[i].CompanyName
+		}
+		for _, item := range list {
+			if item.ContractBusinessType == "代付合同" {
+				item.UseCompanyName = userCompanyNameMap[item.ContractId]
+			}
+		}
+	}
 
 	page := paging.GetPaging(currentIndex, pageSize, total)