caipin 4 年之前
父節點
當前提交
2083f16860
共有 5 個文件被更改,包括 87 次插入14 次删除
  1. 1 0
      conf/project.go
  2. 13 0
      dao/contract_dao.go
  3. 47 9
      services/contract_service.go
  4. 6 5
      web/api/contract_api.go
  5. 20 0
      web/api/project_account_api.go

+ 1 - 0
conf/project.go

@@ -10,6 +10,7 @@ import "time"
 
 
 const SysTimeform = "2006-01-02 15:04:05"
 const SysTimeform = "2006-01-02 15:04:05"
 const SysTimeformShort = "2006-01-02"
 const SysTimeformShort = "2006-01-02"
+const SysTimeformMonth = "2006-01"
 
 
 // 请填写您的AccessKeyId。
 // 请填写您的AccessKeyId。
 const AccessKeyId = "LTAI4GAEAwazcR8JvjZxMiJL"
 const AccessKeyId = "LTAI4GAEAwazcR8JvjZxMiJL"

+ 13 - 0
dao/contract_dao.go

@@ -48,7 +48,20 @@ func (d *ContractDao) GetType(bidsectionId int, projectId int, contractsType int
 	_ = d.engine.
 	_ = d.engine.
 		Where("project_id=? and bidsection_id=? and contracts_type=? ", projectId, bidsectionId, contractsType).
 		Where("project_id=? and bidsection_id=? and contracts_type=? ", projectId, bidsectionId, contractsType).
 		Find(&datalist)
 		Find(&datalist)
+	return datalist
+}
+
+// 获得本项目的合同项目节
+func (d *ContractDao) GetTypeYear(bidsectionId int, projectId int, contractsType int, year int) []models.CmContracts {
 
 
+	startYear := fmt.Sprintf("%d-01-01:00.00.00", year)
+	endYear := fmt.Sprintf("%d-12-31:23.59.59", year)
+
+	datalist := make([]models.CmContracts, 0)
+	_ = d.engine.
+		Where("project_id=? and bidsection_id=? and contracts_type=? and signer_time>='"+startYear+"' and signer_time<='"+endYear+"'",
+			projectId, bidsectionId, contractsType).
+		Find(&datalist)
 	return datalist
 	return datalist
 }
 }
 
 

+ 47 - 9
services/contract_service.go

@@ -60,7 +60,7 @@ type ContractService interface {
 	Delete(projectId int, bidsectionId int, treeId int, id int) error
 	Delete(projectId int, bidsectionId int, treeId int, id int) error
 	Close(projectId int, bidsectionId int, treeId int, id int) error
 	Close(projectId int, bidsectionId int, treeId int, id int) error
 	Unlock(projectId int, bidsectionId int, treeId int, id int) error
 	Unlock(projectId int, bidsectionId int, treeId int, id int) error
-	GetIncomeSurvey(bidsectionId int, projectId int) map[string]interface{}
+	GetSurvey(bidsectionId int, projectId int, contractsType int) map[string]interface{}
 
 
 	ReturnCreate(returnData *viewmodels.ContractsReturn, projectId int, bidsectionId int, contractsId int, projectAccountId int) error
 	ReturnCreate(returnData *viewmodels.ContractsReturn, projectId int, bidsectionId int, contractsId int, projectAccountId int) error
 	ReturnUpdate(returnData *viewmodels.ContractsReturn, projectId int, bidsectionId int, contractsId int, id int) error
 	ReturnUpdate(returnData *viewmodels.ContractsReturn, projectId int, bidsectionId int, contractsId int, id int) error
@@ -516,20 +516,44 @@ func (s *contractService) Unlock(projectId int, bidsectionId int, treeId int, id
 }
 }
 
 
 //获得合同收入概况
 //获得合同收入概况
-func (s *contractService) GetIncomeSurvey(bidsectionId int, projectId int) map[string]interface{} {
+func (s *contractService) GetSurvey(bidsectionId int, projectId int, contractsType int) map[string]interface{} {
 	// 1.获得收入合同
 	// 1.获得收入合同
-	incomeList := s.contractDao.GetType(bidsectionId, projectId, 1)
+	year := time.Now().Year()
+	incomeList := s.contractDao.GetTypeYear(bidsectionId, projectId, contractsType, year)
+	// 2.初始化
 	totalContractPrice := 0.00
 	totalContractPrice := 0.00
-	totalReturnPrice := 0.00
+	totalTypePrice := 0.00
 	performNumber := 0
 	performNumber := 0
 	closeNumber := 0
 	closeNumber := 0
 	uncloseNumber := 0
 	uncloseNumber := 0
+	// 3.当年数据初始化
+	returnDate := map[string]float64{
+		fmt.Sprintf("%d-01", year): 0.00,
+		fmt.Sprintf("%d-02", year): 0.00,
+		fmt.Sprintf("%d-03", year): 0.00,
+		fmt.Sprintf("%d-04", year): 0.00,
+		fmt.Sprintf("%d-05", year): 0.00,
+		fmt.Sprintf("%d-06", year): 0.00,
+		fmt.Sprintf("%d-07", year): 0.00,
+		fmt.Sprintf("%d-08", year): 0.00,
+		fmt.Sprintf("%d-09", year): 0.00,
+		fmt.Sprintf("%d-10", year): 0.00,
+		fmt.Sprintf("%d-11", year): 0.00,
+		fmt.Sprintf("%d-12", year): 0.00,
+	}
 
 
 	for _, item := range incomeList {
 	for _, item := range incomeList {
 		contractPrice, _ := strconv.ParseFloat(item.Price, 64)
 		contractPrice, _ := strconv.ParseFloat(item.Price, 64)
 		totalContractPrice = totalContractPrice + contractPrice
 		totalContractPrice = totalContractPrice + contractPrice
-		returnPrice, _ := strconv.ParseFloat(item.Returned, 64)
-		totalReturnPrice = totalReturnPrice + returnPrice
+		typePrice := 0.00
+		if contractsType == 1 {
+			typePrice, _ = strconv.ParseFloat(item.Returned, 64)
+			totalTypePrice = totalTypePrice + typePrice
+		} else {
+			typePrice, _ = strconv.ParseFloat(item.Paid, 64)
+			totalTypePrice = totalTypePrice + typePrice
+		}
+
 		if item.Status == 0 {
 		if item.Status == 0 {
 			performNumber = performNumber + 1
 			performNumber = performNumber + 1
 		} else if item.Status == 1 {
 		} else if item.Status == 1 {
@@ -537,13 +561,27 @@ func (s *contractService) GetIncomeSurvey(bidsectionId int, projectId int) map[s
 		} else if item.Status == 2 {
 		} else if item.Status == 2 {
 			closeNumber = closeNumber + 1
 			closeNumber = closeNumber + 1
 		}
 		}
+		returnDate[item.SignerTime.Format(conf.SysTimeformMonth)] = returnDate[item.SignerTime.Format(conf.SysTimeformMonth)] + typePrice
 	}
 	}
 	totalContractPrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalContractPrice), 64)
 	totalContractPrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalContractPrice), 64)
-	fmt.Println(totalContractPrice)
-	// surveryData := make(map[string]interface{},0)
+	totalTypePrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalTypePrice), 64)
+
 	ac := accounting.Accounting{Symbol: "", Precision: 2}
 	ac := accounting.Accounting{Symbol: "", Precision: 2}
+
 	surveryData := map[string]interface{}{
 	surveryData := map[string]interface{}{
-		"totalContractPrice": ac.FormatMoney(totalContractPrice),
+		"totalContractPrice":     totalContractPrice,
+		"totalContractPriceShow": ac.FormatMoney(totalContractPrice),
+		// "totalReturnPrice":   ac.FormatMoney(totalReturnPrice),
+		"performNumber": performNumber,
+		"closeNumber":   closeNumber,
+		"uncloseNumber": uncloseNumber,
+		"returnDate":    returnDate,
+	}
+
+	if contractsType == 1 {
+		surveryData["totalReturnPriceShow"] = ac.FormatMoney(totalTypePrice)
+	} else {
+		surveryData["totalPaidPriceShow"] = ac.FormatMoney(totalTypePrice)
 	}
 	}
 
 
 	return surveryData
 	return surveryData

+ 6 - 5
web/api/contract_api.go

@@ -507,13 +507,14 @@ func (c *ContractApi) GetSurvey() {
 		return
 		return
 	}
 	}
 
 
-	incomeData := c.ServiceContract.GetIncomeSurvey(bidsectionId, projectId)
+	incomeData := c.ServiceContract.GetSurvey(bidsectionId, projectId, 1)
+	expenditureData := c.ServiceContract.GetSurvey(bidsectionId, projectId, 2)
 
 
 	c.Ctx.JSON(iris.Map{
 	c.Ctx.JSON(iris.Map{
-		"code":       0,
-		"msg":        "",
-		"incomeData": incomeData,
-		// "contract":   contractDetail,
+		"code":            0,
+		"msg":             "",
+		"incomeData":      incomeData,
+		"expenditureData": expenditureData,
 	})
 	})
 
 
 }
 }

+ 20 - 0
web/api/project_account_api.go

@@ -75,3 +75,23 @@ func (c *ProjectAccountApi) GetList() {
 		"data": AccountData,
 		"data": AccountData,
 	})
 	})
 }
 }
+
+// @Summary 获得项目账号角色列表
+// @Tags 项目账号相关
+// @Description 获得项目账号角色列表
+// @Security ApiKeyAuth
+// @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
+// @Router /api/projectAccount/role [get]
+func (c *ProjectAccountApi) GetRole() {
+	roleDate := map[int]string{
+		1: "建设单位",
+		2: "监理单位",
+		3: "施工单位",
+		4: "设计单位",
+	}
+	c.Ctx.JSON(iris.Map{
+		"code": 0,
+		"msg":  "",
+		"data": roleDate,
+	})
+}