| 
					
				 | 
			
			
				@@ -27,9 +27,11 @@ import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type TreeService interface { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//ValidManager(code string, account string, password string) error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	ValidRule(ctx iris.Context) (viewmodels.Tree, error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ValidRuleBidsectionType(ctx iris.Context) (viewmodels.Permission, error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Create(data viewmodels.Tree) error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	GetAllProject(projectId int) *viewmodels.Tree 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	GetAllContract(projectId int, projectAccountId int) *viewmodels.FolderContract 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	GetAllContract(projectId int, account *models.CmProjectAccount, bidsectionType int) *viewmodels.FolderContract 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	Rename(treevm viewmodels.Tree, projectId int) error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	GetFolderAndBid(id int, projectId int) ([]models.CmTree, error) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	DeleteFolderAndBid(id int, projectId int) error 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -38,13 +40,15 @@ type TreeService interface { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //返回service操作类 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type treeService struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	dao *dao.TreeDao 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	dao                  *dao.TreeDao 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	permissionAccountDao *dao.PermissionAccountDao 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //创建项目service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func NewTreeService() TreeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return &treeService{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		dao: dao.NewTreeDao(datasource.InstanceDbMaster()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		dao:                  dao.NewTreeDao(datasource.InstanceDbMaster()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		permissionAccountDao: dao.NewPermissionAccountDao(datasource.InstanceDbMaster()), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,6 +70,24 @@ func (s *treeService) ValidRule(ctx iris.Context) (viewmodels.Tree, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return folderVaild, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 文件夹规则验证 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *treeService) ValidRuleBidsectionType(ctx iris.Context) (viewmodels.Permission, error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	folderVaild := viewmodels.Permission{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	err := ctx.ReadForm(&folderVaild) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		log.Println("folder-ValidRule-ReadForm转换异常, error=", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return folderVaild, err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	err = folderVaild.ValidateType() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		log.Println("请求标段类型验证, error=", err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return folderVaild, err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return folderVaild, nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 获得项目下 相关文件夹-整个树结构 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (s *treeService) GetAllProject(projectId int) *viewmodels.Tree { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	datalist := s.dao.GetAllTree(projectId) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -122,10 +144,13 @@ func (s *treeService) GetAllProject(projectId int) *viewmodels.Tree { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 获得合同管理的目录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-func (s *treeService) GetAllContract(projectId int, projectAccountId int) *viewmodels.FolderContract { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (s *treeService) GetAllContract(projectId int, account *models.CmProjectAccount, bidsectionType int) *viewmodels.FolderContract { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	datalist := s.dao.GetAllTree(projectId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	folderlist := make([]viewmodels.FolderContract, 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// 2.获得该账号的权限 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	permissionData := s.permissionAccountDao.GetProjectIdAccountId(projectId, account.Id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	// 生成根 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	folder := viewmodels.FolderContract{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	id, _ := comm.AesEncrypt(strconv.Itoa(0), conf.SignSecret) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -137,54 +162,85 @@ func (s *treeService) GetAllContract(projectId int, projectAccountId int) *viewm 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	folderlist = append(folderlist, folder) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	// 加入数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	for _, data := range datalist { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder := viewmodels.FolderContract{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		id, _ := comm.AesEncrypt(strconv.Itoa(data.Id), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		parentId, _ := comm.AesEncrypt(strconv.Itoa(data.ParentId), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.Id = id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.Name = data.Name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.ParentId = parentId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.ProjectId = projectId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.BidsectionId = bidsectionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 合同数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.Contracts = data.Contracts 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.ContractsIncome = data.ContractsIncome 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.ContractsReturned = data.ContractsReturned 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 汇款进度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ContractsIncome, err := strconv.ParseFloat(data.ContractsIncome, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			ContractsIncome = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ContractsReturned, err := strconv.ParseFloat(data.ContractsReturned, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil || ContractsReturned == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			ContractsReturned = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			folder.ContractsIncomeProgress = "0%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			folder.ContractsIncomeProgress = fmt.Sprintf("%.0f", (ContractsReturned/ContractsIncome)*100) + "%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.ContractsPay = data.ContractsPay 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.ContractsPaid = data.ContractsPaid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 支付进度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ContractsPay, err := strconv.ParseFloat(data.ContractsPay, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			ContractsPay = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		flag := true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if data.BidsectionId != 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			flag = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		ContractsPaid, err := strconv.ParseFloat(data.ContractsPaid, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil || ContractsPaid == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			ContractsPaid = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			folder.ContractsPayProgress = "0%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			folder.ContractsPayProgress = fmt.Sprintf("%.0f", (ContractsPaid/ContractsPay)*100) + "%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 过滤没有权限访问的标段-管理员不需要过滤 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if data.BidsectionId != 0 && account.IsAdmin != 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			permission := map[string]int{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for _, item := range permissionData { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if data.BidsectionId == item.BidsectionId { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					// 区别合同,安全,质量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if bidsectionType == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						json.Unmarshal([]byte(item.SafePermission), &permission) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} else if bidsectionType == 2 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						json.Unmarshal([]byte(item.QualityPermission), &permission) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} else if bidsectionType == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						json.Unmarshal([]byte(item.ContractPermission), &permission) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if permission["access"] == 1 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						flag = true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.Isfolder = data.Isfolder 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.IsEnd = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if flag { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder := viewmodels.FolderContract{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			id, _ := comm.AesEncrypt(strconv.Itoa(data.Id), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			parentId, _ := comm.AesEncrypt(strconv.Itoa(data.ParentId), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.Id = id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.Name = data.Name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.ParentId = parentId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.ProjectId = projectId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.BidsectionId = bidsectionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 合同数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.Contracts = data.Contracts 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.ContractsIncome = data.ContractsIncome 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.ContractsReturned = data.ContractsReturned 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 汇款进度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ContractsIncome, err := strconv.ParseFloat(data.ContractsIncome, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				ContractsIncome = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ContractsReturned, err := strconv.ParseFloat(data.ContractsReturned, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if err != nil || ContractsReturned == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				ContractsReturned = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				folder.ContractsIncomeProgress = "0%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				folder.ContractsIncomeProgress = fmt.Sprintf("%.0f", (ContractsReturned/ContractsIncome)*100) + "%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.ContractsPay = data.ContractsPay 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.ContractsPaid = data.ContractsPaid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 支付进度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ContractsPay, err := strconv.ParseFloat(data.ContractsPay, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				ContractsPay = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			ContractsPaid, err := strconv.ParseFloat(data.ContractsPaid, 64) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if err != nil || ContractsPaid == 0 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				ContractsPaid = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				folder.ContractsPayProgress = "0%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				folder.ContractsPayProgress = fmt.Sprintf("%.0f", (ContractsPaid/ContractsPay)*100) + "%" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.Isfolder = data.Isfolder 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.IsEnd = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.HasFolder = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folder.IsBid = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			folderlist = append(folderlist, folder) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.HasFolder = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folder.IsBid = false 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		folderlist = append(folderlist, folder) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	//fmt.Println(folderlist) 
			 |