caipin 4 years ago
parent
commit
4162d9da8d
2 changed files with 20 additions and 1 deletions
  1. 19 0
      comm/functions.go
  2. 1 1
      conf/project.go

+ 19 - 0
comm/functions.go

@@ -172,6 +172,13 @@ func MakeSectionContract(Data []*viewmodels.TreeSectionContract, node *viewmodel
 			childs[0].ElderBrother = false
 			childs[len(childs)-1].IsEnd = true
 		}
+
+		// 项目节父项使用
+		// 1.合同总金额 回款总金额 已支付总金额
+		contractPriceTotal := 0.00
+		returnPriceTotal := 0.00
+		paidPriceTotal := 0.00
+
 		node.Children = append(node.Children, childs[0:]...) //添加子节点
 		for _, v := range childs {                           //查询子节点的子节点,并添加到子节点
 			_, has := haveChildSectionContract(Data, v)
@@ -179,7 +186,19 @@ func MakeSectionContract(Data []*viewmodels.TreeSectionContract, node *viewmodel
 				// 递归添加节点
 				MakeSectionContract(Data, v)
 			}
+
+			// 2.计算父项中金额
+			contractPrice, _ := strconv.ParseFloat(v.ContractPrice, 64)
+			contractPriceTotal += contractPrice
+			returnPrice, _ := strconv.ParseFloat(v.ContractReturned, 64)
+			returnPriceTotal += returnPrice
+			paidPrice, _ := strconv.ParseFloat(v.ContractsPaid, 64)
+			paidPriceTotal += paidPrice
 		}
+
+		// 3.赋值到父项中
+		node.ContractPrice = fmt.Sprintf("%.2f", contractPriceTotal)
+		node.ContractReturned = fmt.Sprintf("%.2f", returnPriceTotal)
 	}
 }
 

+ 1 - 1
conf/project.go

@@ -26,7 +26,7 @@ const CallbackUrl string = "http://88.88.88.88:8888"
 
 // 用户上传文件时指定的前缀。 --user-dir-prefix/
 const Upload_dir string = "xinxihua/"
-const Expire_time int64 = 600
+const Expire_time int64 = 60
 
 // 中国时区
 var SysTimeLocation, _ = time.LoadLocation("Asia/Chongqing")