xingzai 1 vuosi sitten
vanhempi
commit
5306e0f88b
2 muutettua tiedostoa jossa 34 lisäystä ja 2 poistoa
  1. 33 2
      controllers/cygx/contract_allocation.go
  2. 1 0
      models/cygx/company_contract.go

+ 33 - 2
controllers/cygx/contract_allocation.go

@@ -105,6 +105,7 @@ func getQueryParams(condition string, pars []interface{}, sysUser *system.Admin,
 // @Param   ContractType   query   string  false       "合同类型,枚举值:“,`新签合同`,`续约合同`,`补充协议`"
 // @Param   FormalType   query   string  false     "转正类型,枚举值:“,`标准`,`非标`"
 // @Param   IsExport   query   bool  false       "是否导出excel,默认是false"
+// @Param   ResearcherRealName   query   string  false       "研究员姓名"
 // @Param   IsAllocation   query   int  false       "派点状态: -1-默认全部; 0-未派点; 1-已派点"
 // @Success 200 {object}  cygx.CompanyContractListResp
 // @router /allocation/company_contract_list [get]
@@ -131,6 +132,7 @@ func (this *ContractAllocationController) CompanyContractList() {
 	keyword := this.GetString("Keyword")
 	startDate := this.GetString("StartDate")
 	endDate := this.GetString("EndDate")
+	researcherRealName := this.GetString("ResearcherRealName")
 	isAllocation, _ := this.GetInt("IsAllocation", -1) // CRM 13.9
 	if startDate == "" {
 		startDate = "2015-01-01"
@@ -195,7 +197,35 @@ func (this *ContractAllocationController) CompanyContractList() {
 
 	//默认只查询权益 2023-06-01 之后的合同
 	condition += ` AND c.product_id = ?  AND a.start_date > ? `
-	pars = append(pars, 2, "2023-06-01")
+	pars = append(pars, 2, "2023-01-01")
+
+	mapMoneyPoint := make(map[int]float64)
+	//研究员姓名查询
+	if researcherRealName != "" {
+		var conditionAllocation string
+		var parsAllocation []interface{}
+
+		conditionAllocation = " AND  real_name = ? "
+		parsAllocation = append(parsAllocation, researcherRealName)
+		allocationCompanyContractList, err := cygx.GetCygxAllocationCompanyContractList(conditionAllocation, parsAllocation)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,GetCygxAllocationCompanyContractListErr:" + err.Error()
+			return
+		}
+		var companyContractIds []int
+		for _, v := range allocationCompanyContractList {
+			companyContractIds = append(companyContractIds, v.CompanyContractId)
+			mapMoneyPoint[v.CompanyContractId] = v.Money
+		}
+		lenCon := len(companyContractIds)
+		if lenCon == 0 {
+			condition += ` AND a.company_contract_id = 0 `
+		} else {
+			condition += ` AND a.company_contract_id IN   (` + utils.GetOrmInReplace(lenCon) + `)`
+			pars = append(pars, companyContractIds)
+		}
+	}
 
 	var list []*cygx.CompanyContractResp
 
@@ -248,6 +278,7 @@ func (this *ContractAllocationController) CompanyContractList() {
 			}
 			for _, v := range list {
 				v.ContractId = mapContractCode[v.ContractCode]
+				v.MoneyPoint = mapMoneyPoint[v.CompanyContractId]
 			}
 		}
 
@@ -697,7 +728,7 @@ func (this *ContractAllocationController) CompanyContractStatistics() {
 		item.GroupProportion += "%"
 
 		// 部门占比
-		item.DepartmentProportion = fmt.Sprint(mapPermissionMoney[k] / totalMoney * 100)
+		item.DepartmentProportion = fmt.Sprint(mapPermissionMoney[k] / totalMoney * 100 / float64(len(mapPermissionUser[k])))
 		if item.DepartmentProportion == "" {
 			item.DepartmentProportion = "0"
 		}

+ 1 - 0
models/cygx/company_contract.go

@@ -24,6 +24,7 @@ type CompanyContractResp struct {
 	FormalType        string  `description:"转正类型,枚举值: 标准、非标"`
 	IsGray            bool    `description:"是否置灰"`
 	ContractId        int     `description:"合同唯一id"`
+	MoneyPoint        float64 `description:"派点金额"`
 }
 
 // 增量客户统计报表返回类