caipin 4 年 前
コミット
f1e673a189

+ 3 - 5
dao/contract_dao.go

@@ -136,15 +136,13 @@ func (d *ContractDao) Update(contractsCm *models.CmContracts, columns []string,
 	}
 
 	// 1.更新合同表
-	successNum, err := session.Id(contractsCm.Id).MustCols(columns...).Update(contractsCm)
+	// successNum 是否有值更新的数量 为0,表示没有更新
+	// successNum, err := session.Id(contractsCm.Id).MustCols(columns...).Update(contractsCm)
+	_, err = session.Id(contractsCm.Id).MustCols(columns...).Update(contractsCm)
 	if err != nil {
 		session.Rollback()
 		return errors.New("更新失败")
 	}
-	if successNum == 0 {
-		session.Rollback()
-		return errors.New("合同数据异常,更新失败")
-	}
 
 	// 3.更新合同状态,合同金额和回款金额比对
 	// 3-1获得回款总金额

+ 1 - 0
dao/tree_contract_dao.go

@@ -35,6 +35,7 @@ func (d *TreeContractDao) Get(treeId int, bidsectionId int, projectId int, treeT
 	_, err := d.engine.
 		Where("tree_id=? and bidsection_id =? and project_id=? and  tree_type=?", treeId, bidsectionId, projectId, treeType).
 		Get(data)
+
 	if err != nil {
 		data.Id = 0
 		return data

+ 8 - 2
services/contract_section_tree_service.go

@@ -100,8 +100,9 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 		return nil, err
 	}
 	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+
 	if sectionFather.Id == 0 {
-		return nil, errors.New("未找到合同项目节")
+		return nil, errors.New("未找到项目节")
 	}
 
 	// 1-1 深度为>=2才能新增项目节
@@ -121,7 +122,7 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 	// 新建合同,项目层级必须在第二层以下,当第一层没有孩子可以添加合同
 	if sectionFather.Depth == 0 {
 		if len(childrenList) != 0 {
-			return nil, errors.New("该项目节不允许添加合同")
+			return nil, errors.New("该项目节不允许添加合同,请在下一层级新建合同")
 		}
 	}
 
@@ -326,6 +327,10 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 			return errors.New("项目节不能降级")
 		}
 		elderBrother = &elderBrotherList[0]
+		// 前一个兄弟节点 不能有合同
+		if elderBrother.ContractId != 0 {
+			return errors.New(elderBrother.Code + "已存在合同,不能降级")
+		}
 	} else if sectionData.Operation == "upDepth" { // 3.层级升级-只要有父亲都能升级
 		// 2-1 父节点深度为2不能升级
 		// if (section.Depth - 1) < 2 {
@@ -335,6 +340,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 		if section.ParentId == 0 {
 			return errors.New("项目节不能升级")
 		}
+
 	} else {
 		return errors.New("参数错误")
 	}

+ 1 - 1
web/api/contract_api.go

@@ -248,7 +248,7 @@ func (c *ContractApi) PostIncomeCreate() {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 	}
-
+	fmt.Println("dddd")
 	// 在添加合同
 	err = c.ServiceContract.Add(contractData, projectIdInt, bidsectionId, sectionResult.Id)
 	if err != nil {