lanjianrong hace 4 años
padre
commit
f84efaf6aa

+ 1 - 1
bootstrap/bootstrap.go

@@ -181,7 +181,7 @@ func (b *Bootstrapper) Bootstrap() *Bootstrapper {
 	// 设置csrf
 	// b.SetupCsrfHandlers(CsrfKey)
 	// 设置jwt
-	b.SetupJwtHandlers(JwtKey)
+	// b.SetupJwtHandlers(JwtKey)
 	// 设置rpc
 	//b.SetupRpcClient()
 	//设置异常信息

+ 12 - 12
comm/functions.go

@@ -175,9 +175,9 @@ func MakeSectionContract(Data []*viewmodels.TreeSectionContract, node *viewmodel
 
 		// 项目节父项使用
 		// 1.合同总金额 回款总金额 已支付总金额
-		contractPriceTotal := 0.00
-		returnPriceTotal := 0.00
-		paidPriceTotal := 0.00
+		// contractPriceTotal := 0.00
+		// returnPriceTotal := 0.00
+		// paidPriceTotal := 0.00
 
 		node.Children = append(node.Children, childs[0:]...) //添加子节点
 		for _, v := range childs {                           //查询子节点的子节点,并添加到子节点
@@ -188,18 +188,18 @@ func MakeSectionContract(Data []*viewmodels.TreeSectionContract, node *viewmodel
 			}
 
 			// 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
+			// 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)
-		node.ContractsPaid = fmt.Sprintf("%.2f", paidPriceTotal)
+		// node.ContractPrice = fmt.Sprintf("%.2f", contractPriceTotal)
+		// node.ContractReturned = fmt.Sprintf("%.2f", returnPriceTotal)
+		// node.ContractsPaid = fmt.Sprintf("%.2f", paidPriceTotal)
 	}
 }
 

+ 1 - 1
conf/db.go

@@ -38,4 +38,4 @@ var DbMasterList = []DbConfig{
 	},
 }
 
-var DbMaster = DbMasterList[1]
+var DbMaster = DbMasterList[0]

+ 4 - 8
dao/contract_dao.go

@@ -316,7 +316,7 @@ func (d *ContractDao) Close(projectId int, bidsectionId int, treeId int, id int)
 	contractsCm := models.CmContracts{}
 	contractsCm.Status = 2
 	contractsCm.Locking = 1
-	successNum, err := session.Where("id = ? and project_id = ? and bidsection_id = ? ", id, projectId, bidsectionId).Update(contractsCm)
+	successNum, err := session.Where("id = ?", id).Update(contractsCm)
 	if err != nil {
 		session.Rollback()
 		return errors.New("关闭合同出错")
@@ -328,9 +328,7 @@ func (d *ContractDao) Close(projectId int, bidsectionId int, treeId int, id int)
 
 	// 2.更新项目节合同状态,锁定合同
 	treeContractsCm := models.CmTreeContracts{}
-	treeContractsCm.ContractStatus = 2
-	treeContractsCm.ContractLocking = 1
-	successNum, err = session.Where("tree_id = ? and project_id = ? and bidsection_id = ? ", treeId, projectId, bidsectionId).Update(treeContractsCm)
+	successNum, err = session.Where("tree_id = ? ", treeId).Update(treeContractsCm)
 	if err != nil {
 		session.Rollback()
 		return errors.New("关闭合同出错-项目节")
@@ -361,7 +359,7 @@ func (d *ContractDao) Unlock(projectId int, bidsectionId int, treeId int, id int
 	contractsCm := models.CmContracts{}
 	contractsCm.Locking = 0
 	contractsCm.Status = 1
-	_, err = session.Where("id = ? and project_id = ? and bidsection_id = ? ", id, projectId, bidsectionId).Cols("locking,Status").Update(contractsCm)
+	_, err = session.Where("id = ?", id).Cols("locking,Status").Update(contractsCm)
 	if err != nil {
 		session.Rollback()
 		return errors.New("解锁合同出错")
@@ -369,9 +367,7 @@ func (d *ContractDao) Unlock(projectId int, bidsectionId int, treeId int, id int
 
 	// 2.更新项目节上合同锁状态
 	treeContractsCm := models.CmTreeContracts{}
-	treeContractsCm.ContractLocking = 0
-	treeContractsCm.ContractStatus = 1
-	_, err = session.Where("tree_id = ? and project_id = ? and bidsection_id = ? ", treeId, projectId, bidsectionId).Cols("contract_locking,contract_status").Update(treeContractsCm)
+	_, err = session.Where("tree_id = ?", treeId).Cols("contract_locking,contract_status").Update(treeContractsCm)
 	if err != nil {
 		session.Rollback()
 		return errors.New("解锁合同出错-项目节")

+ 33 - 36
dao/tree_contract_dao.go

@@ -29,11 +29,11 @@ func NewTreeContractDao(engine *xorm.Engine) *TreeContractDao {
 }
 
 // 获得本项目的合同项目节
-func (d *TreeContractDao) Get(treeId int, bidsectionId int, projectId int, treeType int) *models.CmTreeContracts {
+func (d *TreeContractDao) Get(treeId int) *models.CmTreeContracts {
 
 	data := &models.CmTreeContracts{}
 	_, err := d.engine.
-		Where("tree_id=? and bidsection_id =? and project_id=? and  tree_type=?", treeId, bidsectionId, projectId, treeType).
+		Where("tree_id=? ", treeId).
 		Get(data)
 
 	if err != nil {
@@ -44,12 +44,11 @@ func (d *TreeContractDao) Get(treeId int, bidsectionId int, projectId int, treeT
 }
 
 // 获得项目下的项目节
-func (d *TreeContractDao) GetAll(bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
+func (d *TreeContractDao) GetAll() []models.CmTreeContracts {
 
 	datalist := make([]models.CmTreeContracts, 0)
 	err := d.engine.
 		Asc("id").
-		Where("bidsection_id =? and project_id=? and tree_type=?", bidsectionId, projectId, treeType).
 		Limit(5000, 0).
 		Find(&datalist)
 	if err != nil {
@@ -117,11 +116,11 @@ func (d *TreeContractDao) GetContract(bidsectionId int, projectId int, treeType
 }
 
 // 获得节点的孩子
-func (d *TreeContractDao) GetChildren(parentId int, bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
+func (d *TreeContractDao) GetChildren(parentId int) []models.CmTreeContracts {
 	datalist := make([]models.CmTreeContracts, 0)
 	err := d.engine.
 		Asc("serial").
-		Where("parent_id=?  and bidsection_id=? and project_id=? and tree_type=?", parentId, bidsectionId, projectId, treeType).
+		Where("parent_id=?", parentId).
 		Find(&datalist)
 	if err != nil {
 		return datalist
@@ -131,11 +130,11 @@ func (d *TreeContractDao) GetChildren(parentId int, bidsectionId int, projectId
 }
 
 //根据序号和深度获得前一个兄弟节点
-func (d *TreeContractDao) GetElderBrother(serial int, depth int, parentId int, bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
+func (d *TreeContractDao) GetElderBrother(serial int, depth int, parentId int) []models.CmTreeContracts {
 	datalist := make([]models.CmTreeContracts, 0)
 	err := d.engine.
 		Desc("serial").
-		Where("serial < ? and depth = ? and  parent_id =? and bidsection_id=?  and project_id=? and tree_type=?", serial, depth, parentId, bidsectionId, projectId, treeType).
+		Where("serial < ? and depth = ? and  parent_id =? ", serial, depth, parentId).
 		Find(&datalist)
 	if err != nil {
 		return datalist
@@ -145,11 +144,11 @@ func (d *TreeContractDao) GetElderBrother(serial int, depth int, parentId int, b
 }
 
 //根据序号和深度获得后一个兄弟节点
-func (d *TreeContractDao) GetYoungerBrother(serial int, depth int, parentId int, bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
+func (d *TreeContractDao) GetYoungerBrother(serial int, depth int, parentId int) []models.CmTreeContracts {
 	datalist := make([]models.CmTreeContracts, 0)
 	err := d.engine.
 		Asc("serial").
-		Where("serial > ? and depth = ? and  parent_id =? and bidsection_id=?   and project_id=? and tree_type=?", serial, depth, parentId, bidsectionId, projectId, treeType).
+		Where("serial > ? and depth = ? and  parent_id =? ", serial, depth, parentId).
 		Find(&datalist)
 	if err != nil {
 		return datalist
@@ -173,11 +172,11 @@ func (d *TreeContractDao) GetLast(projectId int, treeType int) *models.CmTreeCon
 }
 
 // 获得谋归属下的项目节
-func (d *TreeContractDao) GetAttribution(attribution string, projectId int, bidsectionId int, treeType int) []models.CmTreeContracts {
+func (d *TreeContractDao) GetAttribution(attribution string) []models.CmTreeContracts {
 	datalist := make([]models.CmTreeContracts, 0)
 	err := d.engine.
 		Asc("serial").
-		Where("attribution like ? and project_id=? and bidsection_id=? and tree_type=?", attribution+"%", projectId, bidsectionId, treeType).
+		Where("attribution like ? ", attribution+"%").
 		Find(&datalist)
 	if err != nil {
 		return datalist
@@ -187,17 +186,15 @@ func (d *TreeContractDao) GetAttribution(attribution string, projectId int, bids
 }
 
 // 获得谋归属下的项目节-合同
-func (d *TreeContractDao) GetAttributionContract(section *models.CmTreeContracts, treeType int) []models.CmTreeContracts {
+func (d *TreeContractDao) GetAttributionContract(section *models.CmTreeContracts) []models.CmTreeContracts {
 
 	// attribution := section.Attribution
 	attribution := fmt.Sprintf("%s-", section.Code)
-	projectId := section.ProjectId
-	bidsectionId := section.BidsectionId
 
 	datalist := make([]models.CmTreeContracts, 0)
 	err := d.engine.
 		Asc("serial").
-		Where("(attribution like ? or id =? ) and project_id=? and bidsection_id=? and tree_type=? and contract_id!=0", attribution+"%", section.Id, projectId, bidsectionId, treeType).
+		Where("(attribution like ? or id =? ) and project_id=? contract_id!=0", attribution+"%", section.Id).
 		Find(&datalist)
 	if err != nil {
 		return datalist
@@ -207,7 +204,7 @@ func (d *TreeContractDao) GetAttributionContract(section *models.CmTreeContracts
 }
 
 // 项目节升降级
-func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrother *models.CmTreeContracts, operation string, bidsectionId int, projectId int, treeType int) error {
+func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrother *models.CmTreeContracts, operation string) error {
 
 	session := d.engine.NewSession()
 	defer session.Close()
@@ -226,7 +223,7 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 		attribution := fmt.Sprintf("%s%d-", elderBrother.Attribution, elderBrother.Serial)
 		// 2-4 序号 没有孩子序号为1,有孩子 最大孩子序号+1
 		// 2-4-1 获得上一位哥的孩子们
-		elderBrotherChildren := d.GetChildren(elderBrother.TreeId, bidsectionId, projectId, treeType)
+		elderBrotherChildren := d.GetChildren(elderBrother.TreeId)
 		serial := 1
 		if len(elderBrotherChildren) != 0 {
 			serial = elderBrotherChildren[len(elderBrotherChildren)-1].Serial + 1
@@ -237,7 +234,7 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 		// 移动后编号
 		moveCode := fmt.Sprintf("%s%d", attribution, serial)
 		_, err = session.Exec("UPDATE  cm_tree_contracts SET `parent_id` = ?,attribution= ? , serial = ? ,`code` = replace(`code`, '"+section.Code+"', '"+moveCode+"')"+
-			",`depth` =`depth` + ? where id = ? and tree_type=? ", elderBrother.TreeId, attribution, serial, 1, section.Id, treeType)
+			",`depth` =`depth` + ? where id = ?", elderBrother.TreeId, attribution, serial, 1, section.Id)
 		if err != nil {
 			session.Rollback()
 			return errors.New("降级失败")
@@ -250,14 +247,14 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 		moveAttributionChildren := fmt.Sprintf("%s%d-", attribution, serial)
 		// 3-2 降级 深度+1
 		_, err = session.Exec("UPDATE  cm_tree_contracts SET  "+
-			"`depth` =`depth` + ? where attribution like ? and project_id=? and bidsection_id=? and tree_type=? ", 1, attributionChildren+"%", projectId, bidsectionId, treeType)
+			"`depth` =`depth` + ? where attribution like ? ", 1, attributionChildren+"%")
 		if err != nil {
 			session.Rollback()
 			return errors.New("降级失败")
 		}
 		// 3-3--替换 归属和编号
 		// "`attribution` = replace(`attribution`, '"+attributionChildren+"', '"+moveAttributionChildren+"') ,`code` = replace(`code`, '"+section.Code+"', '"+moveCode+"'),"
-		err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, section.Code, moveCode, projectId, bidsectionId, treeType)
+		err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, section.Code, moveCode)
 		if err != nil {
 			session.Rollback()
 			return errors.New("降级失败")
@@ -265,7 +262,7 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 	} else if operation == "upDepth" {
 		// 升级
 		// 1.父亲节点
-		sectionFather := d.Get(section.ParentId, bidsectionId, projectId, treeType)
+		sectionFather := d.Get(section.ParentId)
 		if sectionFather.Id == 0 {
 			session.Rollback()
 			return errors.New("升级-未找到上级项目节")
@@ -273,7 +270,7 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 		// 2.原节点的父亲ID字段升级为爷爷ID
 		// 2-1 升级 深度-1
 		// 2-2 序号 爷爷的孩子们的 序号+1
-		grandpaChildren := d.GetChildren(sectionFather.ParentId, bidsectionId, projectId, treeType)
+		grandpaChildren := d.GetChildren(sectionFather.ParentId)
 		serial := 1
 		if len(grandpaChildren) != 0 {
 			serial = grandpaChildren[len(grandpaChildren)-1].Serial + 1
@@ -283,7 +280,7 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 		moveCode := fmt.Sprintf("%s%d", sectionFather.Attribution, serial)
 		// 升级的项目节
 		_, err = session.Exec("UPDATE  cm_tree_contracts SET `parent_id` = ?,attribution= ? , serial = ? ,`code` = replace(`code`, '"+section.Code+"', '"+moveCode+"')"+
-			",`depth` =`depth` - ? where id = ? and tree_type=? ", sectionFather.ParentId, sectionFather.Attribution, serial, 1, section.Id, treeType)
+			",`depth` =`depth` - ? where id = ? ", sectionFather.ParentId, sectionFather.Attribution, serial, 1, section.Id)
 		if err != nil {
 			session.Rollback()
 			return errors.New("升级失败")
@@ -295,13 +292,13 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 		moveAttributionChildren := fmt.Sprintf("%s%d-", sectionFather.Attribution, serial)
 		// 深度 -1
 		_, err = session.Exec("UPDATE  cm_tree_contracts SET `attribution` = replace(`attribution`, '"+attributionChildren+"', '"+moveAttributionChildren+"') "+
-			",`depth` =`depth` - ? where attribution like ? and project_id=? and bidsection_id=? and tree_type=? ", 1, attributionChildren+"%", projectId, bidsectionId, treeType)
+			",`depth` =`depth` - ? where attribution like ? ", 1, attributionChildren+"%")
 		if err != nil {
 			session.Rollback()
 			return errors.New("升级失败")
 		}
 		// 3-1
-		err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, section.Code, moveCode, projectId, bidsectionId, treeType)
+		err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, section.Code, moveCode)
 		if err != nil {
 			session.Rollback()
 			return errors.New("升级失败")
@@ -320,7 +317,7 @@ func (d *TreeContractDao) MoveDepth(section *models.CmTreeContracts, elderBrothe
 }
 
 // 合同项目节上下移动
-func (d *TreeContractDao) MoveSerial(section *models.CmTreeContracts, brother *models.CmTreeContracts, operation string, bidsectionId int, projectId int, treeType int) error {
+func (d *TreeContractDao) MoveSerial(section *models.CmTreeContracts, brother *models.CmTreeContracts, operation string) error {
 	session := d.engine.NewSession()
 	defer session.Close()
 	err := session.Begin()
@@ -330,13 +327,13 @@ func (d *TreeContractDao) MoveSerial(section *models.CmTreeContracts, brother *m
 
 	//1.上下移
 	// 1.项目节序号替换为兄弟序号
-	_, err = session.Exec("UPDATE  cm_tree_contracts SET  serial = ? , `code` = replace(`code`, '"+section.Code+"', '"+brother.Code+"')  where id = ? and tree_type=? ", brother.Serial, section.Id, treeType)
+	_, err = session.Exec("UPDATE  cm_tree_contracts SET  serial = ? , `code` = replace(`code`, '"+section.Code+"', '"+brother.Code+"')  where id = ?", brother.Serial, section.Id)
 	if err != nil {
 		session.Rollback()
 		return errors.New("移动失败")
 	}
 	// 兄弟序号替换为项目节序号
-	_, err = session.Exec("UPDATE  cm_tree_contracts SET  serial = ? , `code` = replace(`code`, '"+brother.Code+"', '"+section.Code+"')  where id = ? and tree_type=? ", section.Serial, brother.Id, treeType)
+	_, err = session.Exec("UPDATE  cm_tree_contracts SET  serial = ? , `code` = replace(`code`, '"+brother.Code+"', '"+section.Code+"')  where id = ?", section.Serial, brother.Id)
 	if err != nil {
 		session.Rollback()
 		return errors.New("移动失败")
@@ -347,7 +344,7 @@ func (d *TreeContractDao) MoveSerial(section *models.CmTreeContracts, brother *m
 	// 移动后的 孩子归属和编号
 	moveAttributionChildren := fmt.Sprintf("%s%d-", brother.Attribution, brother.Serial)
 
-	err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, section.Code, brother.Code, projectId, bidsectionId, treeType)
+	err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, section.Code, brother.Code)
 	if err != nil {
 		session.Rollback()
 		return errors.New("移动失败")
@@ -365,7 +362,7 @@ func (d *TreeContractDao) MoveSerial(section *models.CmTreeContracts, brother *m
 	attributionChildren = fmt.Sprintf("%s%d-", brother.Attribution, brother.Serial)
 	// 移动后的 孩子归属
 	moveAttributionChildren = fmt.Sprintf("%s%d-", section.Attribution, section.Serial)
-	err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, brother.Code, section.Code, projectId, bidsectionId, treeType)
+	err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, brother.Code, section.Code)
 	if err != nil {
 		session.Rollback()
 		return errors.New("移动失败")
@@ -380,7 +377,7 @@ func (d *TreeContractDao) MoveSerial(section *models.CmTreeContracts, brother *m
 }
 
 // 修改项目节序号
-func (d *TreeContractDao) UpdateSerial(section *models.CmTreeContracts, serial int, treeType int) error {
+func (d *TreeContractDao) UpdateSerial(section *models.CmTreeContracts, serial int) error {
 	session := d.engine.NewSession()
 	defer session.Close()
 	err := session.Begin()
@@ -390,7 +387,7 @@ func (d *TreeContractDao) UpdateSerial(section *models.CmTreeContracts, serial i
 
 	// 1.更新项目节序号和项目节编号
 	moveCode := fmt.Sprintf("%s%d", section.Attribution, serial)
-	_, err = session.Exec("UPDATE  cm_tree_contracts SET  serial = ? , `code` = ?  where id = ? and tree_type=? ", serial, moveCode, section.Id, treeType)
+	_, err = session.Exec("UPDATE  cm_tree_contracts SET  serial = ? , `code` = ?  where id = ? ", serial, moveCode, section.Id)
 	if err != nil {
 		session.Rollback()
 		log.Println("合同项目节序号更新 error=", err)
@@ -403,7 +400,7 @@ func (d *TreeContractDao) UpdateSerial(section *models.CmTreeContracts, serial i
 	moveAttributionChildren := fmt.Sprintf("%s%d-", section.Attribution, serial)
 	// 2-3 项目节 孩子的编号
 	code := fmt.Sprintf("%s%d", section.Attribution, section.Serial)
-	err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, code, moveCode, section.ProjectId, section.BidsectionId, treeType)
+	err = d.replaceContractAttribution(session, attributionChildren, moveAttributionChildren, code, moveCode)
 	if err != nil {
 		session.Rollback()
 		log.Println("合同项目节序号更新 error=", err)
@@ -521,9 +518,9 @@ func (d *TreeContractDao) Delete(section *models.CmTreeContracts) error {
 }
 
 //替换项目节归属
-func (d *TreeContractDao) replaceContractAttribution(session *xorm.Session, attributionChildren string, moveAttributionChildren string, code string, moveCode string, projectId int, bidsectionId int, treeType int) error {
+func (d *TreeContractDao) replaceContractAttribution(session *xorm.Session, attributionChildren string, moveAttributionChildren string, code string, moveCode string) error {
 	// 1.获得需要替换的数据
-	sectionData := d.GetAttribution(attributionChildren, projectId, bidsectionId, treeType)
+	sectionData := d.GetAttribution(attributionChildren)
 	if len(sectionData) == 0 {
 		return nil
 	}

+ 62 - 54
lib/section_template1.json

@@ -1,7 +1,7 @@
 [
     {
         "id": 1,
-        "name": "第一部分 建筑安装工程费",
+        "name": "工程可行性研究阶段",
         "depth": 0,
         "serial": 1,
         "attribution": "",
@@ -9,98 +9,106 @@
     },
     {
         "id": 2,
-        "name": "第二部分 土地使用及拆迁补偿费",
-        "depth": 0,
-        "serial": 2,
-        "attribution": "",
-        "parentId": 0
+        "name": "第一篇 总体设计",
+        "depth": 1,
+        "serial": 1,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 3,
-        "name": "第三部分 工程建设其他费",
-        "depth": 0,
-        "serial": 3,
-        "attribution": "",
-        "parentId": 0
+        "name": "第二篇 路线",
+        "depth": 1,
+        "serial": 2,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 4,
-        "name": "建设项目管理费",
+        "name": "第三篇 路基路面",
         "depth": 1,
-        "serial": 1,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 3,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 5,
-        "name": "研究试验费",
+        "name": "第四篇 桥梁",
         "depth": 1,
-        "serial": 2,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 4,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 6,
-        "name": "建设项目前期工作费",
+        "name": "第五篇 隧道",
         "depth": 1,
-        "serial": 3,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 5,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 7,
-        "name": "专项评价(估)费",
+        "name": "第六篇 路线交叉",
         "depth": 1,
-        "serial": 4,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 6,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 8,
-        "name": "联合诗运转费",
+        "name": "第七篇 交通工程及沿线设施",
         "depth": 1,
-        "serial": 5,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 7,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 9,
-        "name": "工程保通管理费",
+        "name": "第八篇 安全工程",
         "depth": 1,
-        "serial": 6,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 8,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 10,
-        "name": "工程保险费",
+        "name": "第九篇 环境保护及景观设计",
         "depth": 1,
-        "serial": 7,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 9,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 11,
-        "name": "其他相关费用",
+        "name": "第十篇 综合排水",
         "depth": 1,
-        "serial": 8,
-        "attribution": "3-",
-        "parentId": 3
+        "serial": 10,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 12,
-        "name": "第四部分 预备费",
-        "depth": 0,
-        "serial": 4,
-        "attribution": "",
-        "parentId": 0
+        "name": "第十一篇 其他",
+        "depth": 1,
+        "serial": 11,
+        "attribution": "1-",
+        "parentId": 1
     },
     {
         "id": 13,
-        "name": "第五部分 建设期贷款利息",
-        "depth": 0,
-        "serial": 5,
-        "attribution": "",
-        "parentId": 0
+        "name": "第十二篇 筑路材料",
+        "depth": 1,
+        "serial": 12,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 14,
+        "name": "第十三篇 施工方案",
+        "depth": 1,
+        "serial": 13,
+        "attribution": "1-",
+        "parentId": 1
     }
-]
+]

+ 0 - 13
models/cm_approver.go

@@ -1,13 +0,0 @@
-package models
-
-type CmApprover struct {
-	Id           int `xorm:"not null pk autoincr comment('自增ID') INT(11)"`
-	ProjectId    int `xorm:"comment('项目ID') INT(11)"`
-	BidsectionId int `xorm:"comment('标段id') INT(11)"`
-	DataType     int `xorm:"not null default 1 comment('数据类型(1安全2质量)') TINYINT(1)"`
-	DataId       int `xorm:"comment('数据ID') INT(11)"`
-	Status       int `xorm:"comment('状态(0未上报1待审批2完成3关闭)') TINYINT(1)"`
-	Progress     int `xorm:"not null default 0 comment('审批进度(0审批1整改2复查)') TINYINT(1)"`
-	AuditOrder   int `xorm:"comment('审批顺序') INT(11)"`
-	AuditId      int `xorm:"comment('审核人id') INT(11)"`
-}

+ 0 - 21
models/cm_quality.go

@@ -1,21 +0,0 @@
-package models
-
-import (
-	"time"
-)
-
-type CmQuality struct {
-	Id               int       `xorm:"not null pk autoincr comment('自增id') INT(11)"`
-	BidsectionId     int       `xorm:"not null default 0 comment('标段id') INT(11)"`
-	ProjectId        int       `xorm:"not null default 0 comment('项目ID') INT(11)"`
-	Code             string    `xorm:"comment('编号') VARCHAR(128)"`
-	CreateTime       time.Time `xorm:"comment('检查时间') DATETIME"`
-	EndTime          time.Time `xorm:"comment('结束时间') DATETIME"`
-	Position         string    `xorm:"comment('检查部位') VARCHAR(1024)"`
-	Inspection       string    `xorm:"comment('检查项目') VARCHAR(3072)"`
-	InspectionDetail string    `xorm:"comment('现场检查情况') TEXT"`
-	Demand           string    `xorm:"comment('处理要求') VARCHAR(128)"`
-	Status           int       `xorm:"not null default 0 comment('状态(0未上报1审批中2待整改3待复查4完成5关闭)') INT(11)"`
-	Uid              int       `xorm:"not null default 0 comment('创建者id') INT(11)"`
-	Times            int       `xorm:"not null default 1 comment('审批次数') INT(11)"`
-}

+ 0 - 18
models/cm_quality_audit.go

@@ -1,18 +0,0 @@
-package models
-
-import (
-	"time"
-)
-
-type CmQualityAudit struct {
-	Id            int       `xorm:"not null pk autoincr comment('自增id') INT(11)"`
-	QualityId     int       `xorm:"not null default 0 comment('质量巡检id') INT(11)"`
-	BidsectionId  int       `xorm:"not null default 0 comment('标段id') INT(11)"`
-	Times         int       `xorm:"not null default 1 comment('审核次数') INT(11)"`
-	AuditId       int       `xorm:"not null default 0 comment('审核人id') INT(11)"`
-	Status        int       `xorm:"default 0 comment('状态(0通过1退回2关闭)') INT(11)"`
-	Progress      int       `xorm:"not null default 0 comment('审批进度(0上报人1审批2整改3复查)') TINYINT(1)"`
-	CreateTime    time.Time `xorm:"comment('开始时间') DATETIME"`
-	Opinion       string    `xorm:"comment('审批意见') VARCHAR(1024)"`
-	Rectifiedinfo string    `xorm:"comment('整改情况') VARCHAR(1024)"`
-}

+ 0 - 11
models/cm_rule.go

@@ -1,11 +0,0 @@
-package models
-
-type CmRule struct {
-	Id                 int    `xorm:"not null pk autoincr comment('自增id') INT(11)"`
-	ProjectId          int    `xorm:"not null default 0 comment('项目ID') INT(11)"`
-	BidsectionId       int    `xorm:"not null default 0 comment('标段ID') INT(11)"`
-	SafeRule           string `xorm:"comment('安全巡检编号规则') VARCHAR(255)"`
-	QualityRule        string `xorm:"comment('质量巡检编号规则') VARCHAR(255)"`
-	ContractReturnRule string `xorm:"comment('合同收入编号规则') VARCHAR(255)"`
-	ContractPaidRule   string `xorm:"comment('合同支出编号规则') VARCHAR(255)"`
-}

+ 0 - 21
models/cm_safe.go

@@ -1,21 +0,0 @@
-package models
-
-import (
-	"time"
-)
-
-type CmSafe struct {
-	Id               int       `xorm:"not null pk autoincr comment('自增id') INT(11)"`
-	BidsectionId     int       `xorm:"not null default 0 comment('标段id') INT(11)"`
-	ProjectId        int       `xorm:"not null default 0 comment('项目ID') INT(11)"`
-	Code             string    `xorm:"comment('编号') VARCHAR(128)"`
-	CreateTime       time.Time `xorm:"comment('检查时间') DATETIME"`
-	EndTime          time.Time `xorm:"comment('结束时间') DATETIME"`
-	Position         string    `xorm:"comment('检查部位') VARCHAR(1024)"`
-	Inspection       string    `xorm:"comment('检查项目') VARCHAR(3072)"`
-	InspectionDetail string    `xorm:"comment('现场检查情况') TEXT"`
-	Demand           string    `xorm:"comment('处理要求') VARCHAR(128)"`
-	Status           int       `xorm:"not null default 0 comment('状态(0未上报1审批中2待整改3待复查4完成5关闭)') INT(11)"`
-	Uid              int       `xorm:"not null default 0 comment('创建者id') INT(11)"`
-	Times            int       `xorm:"not null default 1 comment('审批次数') INT(11)"`
-}

+ 0 - 18
models/cm_safe_audit.go

@@ -1,18 +0,0 @@
-package models
-
-import (
-	"time"
-)
-
-type CmSafeAudit struct {
-	Id            int       `xorm:"not null pk autoincr comment('自增id') INT(11)"`
-	SafeId        int       `xorm:"not null default 0 comment('安全巡检id') INT(11)"`
-	BidsectionId  int       `xorm:"not null default 0 comment('标段id') INT(11)"`
-	Times         int       `xorm:"not null default 1 comment('审核次数') INT(11)"`
-	AuditId       int       `xorm:"not null default 0 comment('审核人id') INT(11)"`
-	Status        int       `xorm:"default 0 comment('状态(0通过1退回2关闭)') INT(11)"`
-	Progress      int       `xorm:"not null default 0 comment('审批进度(0上报人1审批2整改3复查)') TINYINT(1)"`
-	CreateTime    time.Time `xorm:"comment('开始时间') DATETIME"`
-	Opinion       string    `xorm:"comment('审批意见') VARCHAR(1024)"`
-	Rectifiedinfo string    `xorm:"comment('整改情况') VARCHAR(1024)"`
-}

+ 0 - 15
models/cm_safe_file.go

@@ -1,15 +0,0 @@
-package models
-
-import (
-	"time"
-)
-
-type CmSafeFile struct {
-	Id           int       `xorm:"not null pk autoincr comment('自增id') INT(11)"`
-	BidsectionId int       `xorm:"not null default 0 comment('标段id') INT(11)"`
-	SafeId       int       `xorm:"not null default 0 comment('安全巡检id') INT(11)"`
-	Uid          int       `xorm:"not null default 0 comment('上传者') INT(11)"`
-	CreatedTime  time.Time `xorm:"comment('上传时间') DATETIME"`
-	FileName     string    `xorm:"not null comment('附件名称') VARCHAR(255)"`
-	FilePath     string    `xorm:"not null comment('附件路径') VARCHAR(32)"`
-}

+ 21 - 21
models/cm_tree_contracts.go

@@ -5,25 +5,25 @@ import (
 )
 
 type CmTreeContracts struct {
-	Id               int       `xorm:"not null pk autoincr comment('自增ID') INT(11)"`
-	TreeType         int       `xorm:"not null default 0 comment('项目节类型(0收入,1支出)') TINYINT(1)"`
-	TreeId           int       `xorm:"not null comment('树ID') INT(11)"`
-	ParentId         int       `xorm:"not null default 0 comment('父级ID') INT(11)"`
-	Name             string    `xorm:"not null comment('名称') VARCHAR(64)"`
-	Code             string    `xorm:"comment('项目节编号') VARCHAR(32)"`
-	Depth            int       `xorm:"not null default 0 comment('深度') TINYINT(4)"`
-	Serial           int       `xorm:"not null default 0 comment('序号') INT(11)"`
-	Attribution      string    `xorm:"comment('归属') VARCHAR(32)"`
-	Sort             int       `xorm:"not null default 0 comment('排序') TINYINT(4)"`
-	ProjectId        int       `xorm:"not null default 0 comment('项目ID') INT(11)"`
-	BidsectionId     int       `xorm:"comment('标段ID') INT(11)"`
-	ContractId       int       `xorm:"not null default 0 comment('合同ID') INT(11)"`
-	ContractName     string    `xorm:"comment('合同名称') VARCHAR(64)"`
-	ContractCode     string    `xorm:"comment('合同编号') VARCHAR(32)"`
-	ContractPrice    string    `xorm:"not null default 0.00 comment('合同金额') DECIMAL(12,2)"`
-	ContractReturned string    `xorm:"not null default 0.00 comment('回款金额') DECIMAL(12,2)"`
-	ContractsPaid    string    `xorm:"not null default 0.00 comment('合同已支付金额') DECIMAL(12,2)"`
-	ContractStatus   int       `xorm:"not null default 0 comment('合同状态(0履行中1待关闭2正常关闭)') TINYINT(1)"`
-	ContractLocking  int       `xorm:"not null default 0 comment('合同锁定(0未锁定1锁定)') TINYINT(1)"`
-	CreateTime       time.Time `xorm:"comment('创建时间') DATETIME"`
+	Id           int    `xorm:"not null pk autoincr comment('自增ID') INT(11)"`
+	TreeType     int    `xorm:"not null default 0 comment('项目节类型(0收入,1支出)') TINYINT(1)"`
+	TreeId       int    `xorm:"not null comment('树ID') INT(11)"`
+	ParentId     int    `xorm:"not null default 0 comment('父级ID') INT(11)"`
+	Name         string `xorm:"not null comment('名称') VARCHAR(64)"`
+	Code         string `xorm:"comment('项目节编号') VARCHAR(32)"`
+	Depth        int    `xorm:"not null default 0 comment('深度') TINYINT(4)"`
+	Serial       int    `xorm:"not null default 0 comment('序号') INT(11)"`
+	Attribution  string `xorm:"comment('归属') VARCHAR(32)"`
+	Sort         int    `xorm:"not null default 0 comment('排序') TINYINT(4)"`
+	ProjectId    int    `xorm:"not null default 0 comment('项目ID') INT(11)"`
+	BidsectionId int    `xorm:"comment('标段ID') INT(11)"`
+	ContractId   int    `xorm:"not null default 0 comment('合同ID') INT(11)"`
+	ContractName string `xorm:"comment('合同名称') VARCHAR(64)"`
+	// ContractCode     string    `xorm:"comment('合同编号') VARCHAR(32)"`
+	// ContractPrice    string    `xorm:"not null default 0.00 comment('合同金额') DECIMAL(12,2)"`
+	// ContractReturned string    `xorm:"not null default 0.00 comment('回款金额') DECIMAL(12,2)"`
+	// ContractsPaid    string    `xorm:"not null default 0.00 comment('合同已支付金额') DECIMAL(12,2)"`
+	// ContractStatus   int       `xorm:"not null default 0 comment('合同状态(0履行中1待关闭2正常关闭)') TINYINT(1)"`
+	// ContractLocking  int       `xorm:"not null default 0 comment('合同锁定(0未锁定1锁定)') TINYINT(1)"`
+	CreateTime time.Time `xorm:"comment('创建时间') DATETIME"`
 }

+ 0 - 156
services/contract_expenditure_service.go

@@ -1,156 +0,0 @@
-/*
- * @description: 合同支出业务相关
- * @Author: CP
- * @Date: 2020-12-21 15:35:03
- * @FilePath: \construction_management\services\contract_expenditure_service.go
- */
-
-package services
-
-import (
-	"errors"
-	"time"
-
-	"go.mod/conf"
-	"go.mod/models"
-	"go.mod/web/viewmodels"
-)
-
-// 新增支出合同
-func (s *contractService) AddExpenditure(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error {
-	// 1. 项目节存在
-	contracts := s.treeContractDao.Get(treeId, bidsectionId, projectId, 1)
-	if contracts.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// k := int32(projectId)
-	// 2.项目节是没有合同
-	if contracts.ContractId != 0 {
-		return errors.New("该项目节上已经存在合同")
-	}
-
-	// 2-1.查找合同编号是否存在
-	codeData := s.contractDao.GetByCode(projectId, bidsectionId, contractData.Code, 2)
-	if len(codeData) != 0 {
-		return errors.New("该合同编号已经存在")
-	}
-
-	// 3.新增合同 --合计标段上的金额
-	contractsCm := &models.CmContracts{}
-	contractsCm.Code = contractData.Code
-	contractsCm.Name = contractData.Name
-	contractsCm.ContractsType = 2
-	contractsCm.Price = contractData.Price
-	contractsCm.Returned = "0"
-	contractsCm.Paid = "0"
-	contractsCm.TreeId = treeId
-	contractsCm.ProjectId = projectId
-	contractsCm.BidsectionId = bidsectionId
-	contractsCm.Status = 0
-	contractsCm.CreateTime = time.Now()
-	contractsCm.UpdateTime = time.Now()
-
-	err := s.contractDao.Add(contractsCm)
-	if err != nil {
-		return err
-	}
-
-	// 3.获得该标段下合同总数 - 总收入金额
-	contractTotal, priceTotal := s.getContractTotalAndPrice(bidsectionId, projectId, 1)
-	// 更新标段目录上合同金额和总数
-	err = s.treeDao.UpdateContractsAndPayPrice(projectId, bidsectionId, contractTotal, priceTotal)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// 更新支出合同
-func (s *contractService) UpdateExpenditure(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error {
-	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 1)
-	if contractsTree.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// 2.项目节是没有合同
-	if contractsTree.ContractId == 0 {
-		return errors.New("该项目节上没有找到合同")
-	}
-
-	// 3.合同锁定 不能删除
-	if contractsTree.ContractLocking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	contractsCm := &models.CmContracts{}
-	contractsCm.Id = contractsTree.ContractId
-	contractsCm.Content = contractData.Content
-	contractsCm.Name = contractData.Name
-	contractsCm.Price = contractData.Price
-	contractsCm.PartyA = contractData.PartyA
-	contractsCm.PartyASigner = contractData.PartyASigner
-	contractsCm.PartyB = contractData.PartyB
-	contractsCm.PartyBSigner = contractData.PartyBSigner
-
-	loc, _ := time.LoadLocation("Local")
-	SignerTime, err := time.ParseInLocation(conf.SysTimeform, contractData.SignerTime, loc)
-	if err != nil {
-		return errors.New("签约时间填写异常")
-	}
-	contractsCm.SignerTime = SignerTime
-	contractsCm.Remarks = contractData.Remarks
-
-	columns := []string{"Content", "Name", "Price", "PartyA", "PartyASigner", "PartyB", "PartyBSigner"}
-	err = s.contractDao.Update(contractsCm, columns, projectId, bidsectionId, treeId)
-	if err != nil {
-		return err
-	}
-	// 3.获得该标段下合同总数 - 总收入金额
-	contractTotal, priceTotal := s.getContractTotalAndPrice(bidsectionId, projectId, 1)
-	// 更新标段目录上合同金额和总数
-	err = s.treeDao.UpdateContractsAndPayPrice(projectId, bidsectionId, contractTotal, priceTotal)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-// 删除支出合同
-func (s *contractService) DeleteExpenditure(projectId int, bidsectionId int, treeId int, id int) error {
-	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 1)
-	if contractsTree.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// 2.项目节是没有合同
-	if contractsTree.ContractId == 0 {
-		return errors.New("该项目节上没有找到合同")
-	}
-
-	// 3.合同锁定 不能删除
-	if contractsTree.ContractLocking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	// 删除支出合同
-	err := s.contractDao.DeleteExpenditure(projectId, bidsectionId, treeId, id)
-	if err != nil {
-		return err
-	}
-	// 3.获得该标段下合同总数 - 总收入金额
-	contractTotal, priceTotal := s.getContractTotalAndPrice(bidsectionId, projectId, 1)
-	// 更新标段目录上合同金额和总数
-	err = s.treeDao.UpdateContractsAndPayPrice(projectId, bidsectionId, contractTotal, priceTotal)
-	if err != nil {
-		return err
-	}
-
-	// 4.更新回款总金额
-	err = s.contractPaidDao.UpdatePaidTotalPrice(projectId, bidsectionId, id)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}

+ 0 - 267
services/contract_paid_service.go

@@ -1,267 +0,0 @@
-/*
- * @description: 合同已支付 相关业务操作
- * @Author: CP
- * @Date: 2020-12-22 14:33:43
- * @FilePath: \construction_management\services\contract_paid_service.go
- */
-
-package services
-
-import (
-	"errors"
-	"log"
-	"strconv"
-	"time"
-
-	"github.com/kataras/iris/v12"
-	"go.mod/comm"
-	"go.mod/conf"
-	"go.mod/models"
-	"go.mod/web/viewmodels"
-)
-
-// 获得合同下已支付列表
-func (s *contractService) PaidAll(projectId int, bidsectionId int, contractsId int, page int) []*viewmodels.ContractsPaid {
-	// 1.获得合同回款列表
-	// data := s.contractReturnDao.GetPage(projectId, bidsectionId, contractsId, page)
-	data := s.contractPaidDao.GetAll(projectId, bidsectionId, contractsId)
-
-	contractsReturnVM := make([]*viewmodels.ContractsPaid, 0)
-	for _, item := range data {
-		cr := s.makeContractPaidVM(&item)
-		contractsReturnVM = append(contractsReturnVM, cr)
-	}
-
-	return contractsReturnVM
-}
-
-// 创建已支付信息
-func (s *contractService) PaidCreate(returnData *viewmodels.ContractsPaid, projectId int, bidsectionId int, contractsId int, projectAccountId int) error {
-	// 1.合同存在
-	contract := s.contractDao.GetInProjectAndBidsection(contractsId, projectId, bidsectionId)
-	if contract.Id == 0 {
-		return errors.New("未找到合同")
-	}
-	// 1-2 合同关闭 不能操作
-	if contract.Status == 2 {
-		return errors.New("合同已关闭")
-	}
-	// 1-3已支付的中金额不能超过 合同金额
-	price, err := strconv.ParseFloat(returnData.Price, 64)
-	if err != nil {
-		return errors.New("金额填写有误")
-	}
-	paidPrice, _ := strconv.ParseFloat(contract.Paid, 64)
-	contractPrice, _ := strconv.ParseFloat(contract.Price, 64)
-	resultPrice := contractPrice - paidPrice
-	if price > resultPrice {
-		return errors.New("支付金额不能超过合同金额")
-	}
-
-	// 2.已支付信息
-	contractsReturnCm := &models.CmContractsPaid{}
-	contractsReturnCm.ContractsId = contractsId
-	contractsReturnCm.ProjectId = projectId
-	contractsReturnCm.BidsectionId = bidsectionId
-	contractsReturnCm.Way = returnData.Way
-	contractsReturnCm.Remarks = returnData.Remarks
-	contractsReturnCm.CreateTime = time.Now()
-	contractsReturnCm.UpdateTime = time.Now()
-
-	loc, _ := time.LoadLocation("Local")
-	time, err := time.ParseInLocation(conf.SysTimeform, returnData.Time, loc)
-	if err != nil {
-		return errors.New("签约时间填写异常")
-	}
-	contractsReturnCm.Time = time
-	contractsReturnCm.CreateUser = returnData.CreateUser
-	contractsReturnCm.AccountId = projectAccountId
-
-	contractsReturnCm.Price = returnData.Price
-
-	// 3.新增回款
-	err = s.contractPaidDao.Add(contractsReturnCm)
-	if err != nil {
-		return err
-	}
-
-	// 4. 更新已支付总金额 -项目节树 标段树 合同表
-	err = s.contractPaidDao.UpdatePaidTotalPrice(projectId, bidsectionId, contractsId)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-// 编辑已支付信息
-func (s *contractService) PaidUpdate(returnData *viewmodels.ContractsPaid, projectId int, bidsectionId int, contractsId int, id int) error {
-
-	// 1.合同存在
-	contract := s.contractDao.GetInProjectAndBidsection(contractsId, projectId, bidsectionId)
-	if contract.Id == 0 {
-		return errors.New("未找到合同")
-	}
-	// 1-1 已支付是否存在
-	contractPaid := s.contractPaidDao.Get(id, contractsId, bidsectionId)
-	if contractPaid.Id == 0 {
-		return errors.New("未找到已支付")
-	}
-	// 1-2 合同关闭 不能操作
-	if contract.Status == 2 {
-		return errors.New("合同已关闭")
-	}
-
-	// 2.已支付信息
-	contractsReturnCm := &models.CmContractsPaid{}
-	contractsReturnCm.Id = id
-	contractsReturnCm.Way = returnData.Way
-	contractsReturnCm.Remarks = returnData.Remarks
-
-	loc, _ := time.LoadLocation("Local")
-	time, err := time.ParseInLocation("2006-01-02", returnData.Time, loc)
-	if err != nil {
-		return errors.New("已支付时间填写异常")
-	}
-	contractsReturnCm.Time = time
-
-	_, err = strconv.ParseFloat(returnData.Price, 64)
-	if err != nil {
-		return errors.New("金额填写有误")
-	}
-	contractsReturnCm.Price = returnData.Price
-
-	// 3.更新已支付信息
-	err = s.contractPaidDao.Update(contractsReturnCm, contractsId, bidsectionId)
-	if err != nil {
-		return err
-	}
-
-	// 4. 更新已支付总金额 -项目节树 标段树 合同表
-	err = s.contractPaidDao.UpdatePaidTotalPrice(projectId, bidsectionId, contractsId)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// 删除已支付
-func (s *contractService) PaidDelete(projectId int, bidsectionId int, contractsId int, id int) error {
-	// 1.合同存在
-	contract := s.contractDao.GetInProjectAndBidsection(contractsId, projectId, bidsectionId)
-	if contract.Id == 0 {
-		return errors.New("未找到合同")
-	}
-	// 1-1 已支付是否存在
-	contractPaid := s.contractPaidDao.Get(id, contractsId, bidsectionId)
-	if contractPaid.Id == 0 {
-		return errors.New("未找到已支付")
-	}
-	// 1-2 合同关闭 不能操作
-	if contract.Status == 2 {
-		return errors.New("合同已关闭")
-	}
-	// 3.合同锁定 不能删除
-	if contract.Locking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	// 1-2. 删除已支付
-	err := s.contractPaidDao.Delete(id, contractsId, bidsectionId, projectId)
-	if err != nil {
-		return err
-	}
-
-	// 2. 更新回款总金额 -项目节树 标段树 合同表
-	err = s.contractPaidDao.UpdatePaidTotalPrice(projectId, bidsectionId, contractsId)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func (s *contractService) makeContractPaidVM(data *models.CmContractsPaid) *viewmodels.ContractsPaid {
-	viewContractsReturn := &viewmodels.ContractsPaid{}
-	id, _ := comm.AesEncrypt(strconv.Itoa(data.Id), conf.SignSecret)
-	contractsId, _ := comm.AesEncrypt(strconv.Itoa(data.ContractsId), conf.SignSecret)
-	projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret)
-	bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret)
-
-	viewContractsReturn.Id = id
-	viewContractsReturn.ContractsId = contractsId
-	viewContractsReturn.ProjectId = projectId
-	viewContractsReturn.BidsectionId = bidsectionId
-	viewContractsReturn.Time = data.Time.Format(conf.SysTimeform)
-	viewContractsReturn.Price = data.Price
-
-	viewContractsReturn.Way = data.Way
-	viewContractsReturn.CreateUser = data.CreateUser
-	viewContractsReturn.Remarks = data.Remarks
-	viewContractsReturn.CreateTime = data.CreateTime.Format(conf.SysTimeform)
-
-	counts, _ := s.annexDao.GetCount(1, data.Id)
-	viewContractsReturn.FileCounts = counts
-
-	return viewContractsReturn
-}
-
-// 校验回款参数
-func (s *contractService) ValidRuleContractPaidAdd(ctx iris.Context) (*viewmodels.ContractsPaid, error) {
-
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.ContractsPaid{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadJSON(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateAdd()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-func (s *contractService) ValidRuleContractPaid(ctx iris.Context) (*viewmodels.ContractsPaid, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.ContractsPaid{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadForm(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.Validate()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-//
-func (s *contractService) ValidRuleContractPaidDel(ctx iris.Context) (*viewmodels.ContractsPaid, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.ContractsPaid{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadForm(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateDel()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}

+ 0 - 273
services/contract_return_service.go

@@ -1,273 +0,0 @@
-/*
- * @description: 合同回款 相关业务操作
- * @Author: CP
- * @Date: 2020-12-01 10:21:30
- * @FilePath: \construction_management\services\contract_return_service.go
- */
-
-package services
-
-import (
-	"errors"
-	"log"
-	"strconv"
-	"time"
-
-	"github.com/kataras/iris/v12"
-	"go.mod/comm"
-	"go.mod/conf"
-	"go.mod/models"
-	"go.mod/web/viewmodels"
-)
-
-func (s *contractService) makeContractRetrunVM(data *models.CmContractsReturn) *viewmodels.ContractsReturn {
-	viewContractsReturn := &viewmodels.ContractsReturn{}
-	id, _ := comm.AesEncrypt(strconv.Itoa(data.Id), conf.SignSecret)
-	contractsId, _ := comm.AesEncrypt(strconv.Itoa(data.ContractsId), conf.SignSecret)
-	projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret)
-	bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret)
-
-	viewContractsReturn.Id = id
-	viewContractsReturn.ContractsId = contractsId
-	viewContractsReturn.ProjectId = projectId
-	viewContractsReturn.BidsectionId = bidsectionId
-	viewContractsReturn.Time = data.Time.Format(conf.SysTimeform)
-	viewContractsReturn.Price = data.Price
-
-	viewContractsReturn.Way = data.Way
-	viewContractsReturn.CreateUser = data.CreateUser
-	viewContractsReturn.Remarks = data.Remarks
-	viewContractsReturn.CreateTime = data.CreateTime.Format(conf.SysTimeform)
-
-	counts, _ := s.annexDao.GetCount(1, data.Id)
-	viewContractsReturn.FileCounts = counts
-
-	return viewContractsReturn
-}
-
-// 校验回款参数
-func (s *contractService) ValidRuleContractRetrunAdd(ctx iris.Context) (*viewmodels.ContractsReturn, error) {
-
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.ContractsReturn{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadJSON(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateAdd()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-func (s *contractService) ValidRuleContractRetrun(ctx iris.Context) (*viewmodels.ContractsReturn, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.ContractsReturn{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadForm(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.Validate()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-//
-func (s *contractService) ValidRuleContractRetrunDel(ctx iris.Context) (*viewmodels.ContractsReturn, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.ContractsReturn{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadForm(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateDel()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-// 获得合同下回款列表
-func (s *contractService) ReturnAll(projectId int, bidsectionId int, contractsId int, page int) []*viewmodels.ContractsReturn {
-	// 1.获得合同回款列表
-	// data := s.contractReturnDao.GetPage(projectId, bidsectionId, contractsId, page)
-	data := s.contractReturnDao.GetAll(projectId, bidsectionId, contractsId)
-
-	contractsReturnVM := make([]*viewmodels.ContractsReturn, 0)
-	for _, item := range data {
-		cr := s.makeContractRetrunVM(&item)
-		contractsReturnVM = append(contractsReturnVM, cr)
-	}
-
-	return contractsReturnVM
-}
-
-// 创建回款信息
-func (s *contractService) ReturnCreate(returnData *viewmodels.ContractsReturn, projectId int, bidsectionId int, contractsId int, projectAccountId int) error {
-	// 1.合同存在
-	contract := s.contractDao.GetInProjectAndBidsection(contractsId, projectId, bidsectionId)
-	if contract.Id == 0 {
-		return errors.New("未找到合同")
-	}
-	// 1-2 合同关闭 不能操作回款
-	if contract.Status == 2 {
-		return errors.New("合同已关闭")
-	}
-
-	// 1-3已支付的中金额不能超过 合同金额
-	price, err := strconv.ParseFloat(returnData.Price, 64)
-	if err != nil {
-		return errors.New("金额填写有误")
-	}
-	returnedPrice, _ := strconv.ParseFloat(contract.Returned, 64)
-	contractPrice, _ := strconv.ParseFloat(contract.Price, 64)
-	resultPrice := contractPrice - returnedPrice
-
-	if price > resultPrice {
-		return errors.New("回款金额不能超过合同金额")
-	}
-
-	// 2.回款信息
-	contractsReturnCm := &models.CmContractsReturn{}
-	contractsReturnCm.ContractsId = contractsId
-	contractsReturnCm.ProjectId = projectId
-	contractsReturnCm.BidsectionId = bidsectionId
-	contractsReturnCm.Way = returnData.Way
-	contractsReturnCm.Remarks = returnData.Remarks
-	contractsReturnCm.CreateTime = time.Now()
-	contractsReturnCm.UpdateTime = time.Now()
-
-	loc, _ := time.LoadLocation("Local")
-	time, err := time.ParseInLocation(conf.SysTimeform, returnData.Time, loc)
-	if err != nil {
-		return errors.New("签约时间填写异常")
-	}
-	contractsReturnCm.Time = time
-	contractsReturnCm.CreateUser = returnData.CreateUser
-	contractsReturnCm.AccountId = projectAccountId
-
-	contractsReturnCm.Price = returnData.Price
-
-	// 3.新增回款
-	err = s.contractReturnDao.Add(contractsReturnCm)
-	if err != nil {
-		return err
-	}
-
-	// 4. 更新回款总金额 -项目节树 标段树 合同表
-	err = s.contractReturnDao.UpdateTotalPrice(projectId, bidsectionId, contractsId)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-// 编辑回款信息
-func (s *contractService) ReturnUpdate(returnData *viewmodels.ContractsReturn, projectId int, bidsectionId int, contractsId int, id int) error {
-
-	// 1.合同存在
-	contract := s.contractDao.GetInProjectAndBidsection(contractsId, projectId, bidsectionId)
-	if contract.Id == 0 {
-		return errors.New("未找到合同")
-	}
-	// 1-1 回款是否存在
-	contractReturn := s.contractReturnDao.Get(id, contractsId, bidsectionId)
-	if contractReturn.Id == 0 {
-		return errors.New("未找到回款")
-	}
-	// 1-2 合同关闭 不能操作回款
-	if contract.Status == 2 {
-		return errors.New("合同已关闭")
-	}
-
-	// 2.回款信息
-	contractsReturnCm := &models.CmContractsReturn{}
-	contractsReturnCm.Id = id
-	contractsReturnCm.Way = returnData.Way
-	contractsReturnCm.Remarks = returnData.Remarks
-
-	loc, _ := time.LoadLocation("Local")
-	time, err := time.ParseInLocation("2006-01-02", returnData.Time, loc)
-	if err != nil {
-		return errors.New("回款时间填写异常")
-	}
-	contractsReturnCm.Time = time
-
-	_, err = strconv.ParseFloat(returnData.Price, 64)
-	if err != nil {
-		return errors.New("金额填写有误")
-	}
-	contractsReturnCm.Price = returnData.Price
-
-	columns := []string{"Way", "Remarks", "Time", "Price"}
-
-	// 3.更新回款信息
-	err = s.contractReturnDao.Update(contractsReturnCm, contractsId, bidsectionId, columns)
-	if err != nil {
-		return err
-	}
-
-	// 4. 更新回款总金额 -项目节树 标段树 合同表
-	err = s.contractReturnDao.UpdateTotalPrice(projectId, bidsectionId, contractsId)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// 删除回款
-func (s *contractService) ReturnDelete(projectId int, bidsectionId int, contractsId int, id int) error {
-	// 1.合同存在
-	contract := s.contractDao.GetInProjectAndBidsection(contractsId, projectId, bidsectionId)
-	if contract.Id == 0 {
-		return errors.New("未找到合同")
-	}
-	// 1-2 合同关闭 不能操作
-	if contract.Status == 2 {
-		return errors.New("合同已关闭")
-	}
-
-	// 1-1 回款是否存在
-	contractReturn := s.contractReturnDao.Get(id, contractsId, bidsectionId)
-	if contractReturn.Id == 0 {
-		return errors.New("未找到回款")
-	}
-
-	// 3.合同锁定 不能删除
-	if contract.Locking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	// 1-2. 删除回款
-	err := s.contractReturnDao.Delete(id, contractsId, bidsectionId, projectId)
-	if err != nil {
-		return err
-	}
-
-	// 2. 更新回款总金额 -项目节树 标段树 合同表
-	err = s.contractReturnDao.UpdateTotalPrice(projectId, bidsectionId, contractsId)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}

+ 39 - 73
services/contract_section_tree_service.go

@@ -16,8 +16,8 @@ import (
 )
 
 // 获得合同项目节
-func (s *contractService) GetSecionTree(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract {
-	dataList := s.treeContractDao.GetAll(bidsectionId, projectId, treeType)
+func (s *contractService) GetSecionTree() *viewmodels.TreeSectionContract {
+	dataList := s.treeContractDao.GetAll()
 	sectionList := s.makeSectionTreeView(dataList)
 
 	// Node := sectionRoot //父节点
@@ -38,14 +38,14 @@ func (s *contractService) GetSecionTreeNotContract(bidsectionId int, projectId i
 }
 
 // 获得项目节树和孩子们下的合同数据-未使用
-func (s *contractService) GetSectionTreeContract(attribution string, bidsectionId int, projectId int, treeType int) []*viewmodels.Contracts {
-	s.treeContractDao.GetAttribution(attribution, bidsectionId, projectId, treeType)
+func (s *contractService) GetSectionTreeContract(attribution string) []*viewmodels.Contracts {
+	s.treeContractDao.GetAttribution(attribution)
 
 	return nil
 }
 
 // 设置合同项目节初始数据-根据模板导入
-func (s *contractService) SetSection(templateNumber int, bidsectionId int, projectId int, treeType int) error {
+func (s *contractService) SetSection(templateNumber int) error {
 	// 获得模板数据
 	templateTree := make([]*lib.ItemSectionTemplateTree, 0)
 	if templateNumber == 1 {
@@ -61,10 +61,9 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
 	for _, item := range templateTree {
 		section := &models.CmTreeContracts{}
 		section.TreeId = item.Id
-		section.TreeType = treeType
 		section.ParentId = item.ParentId
-		section.ProjectId = projectId
-		section.BidsectionId = bidsectionId
+		section.ProjectId = 1
+		section.BidsectionId = 1
 		section.Name = item.Name
 		section.Depth = item.Depth
 		section.Serial = item.Serial
@@ -72,10 +71,6 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
 		section.Code = fmt.Sprintf("%s%d", item.Attribution, item.Serial)
 		section.CreateTime = time.Now()
 
-		section.ContractPrice = "0"
-		section.ContractReturned = "0"
-		section.ContractsPaid = "0"
-
 		// err := s.treeContractDao.Create(section)
 		// if err != nil {
 		// 	log.Println("设置合同项目节模板错误 err=", err)
@@ -93,13 +88,13 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
 }
 
 // 新增项目节
-func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error) {
+func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSectionContract) (*models.CmTreeContracts, error) {
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
 		return nil, err
 	}
-	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	sectionFather := s.treeContractDao.Get(treeId)
 
 	if sectionFather.Id == 0 {
 		return nil, errors.New("未找到项目节")
@@ -116,7 +111,7 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 
 	// 2 获得最大序号
 	// 2-1 孩子节点
-	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, treeType)
+	childrenList := s.treeContractDao.GetChildren(treeId)
 
 	// 2-2.检查是否可以添加项目节
 	// 新建合同,项目层级必须在第二层以下,当第一层没有孩子可以添加合同
@@ -140,7 +135,6 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 	sectionCM := &models.CmTreeContracts{}
 	sectionCM.Id = lastId.Id + 1
 	sectionCM.TreeId = lastId.Id + 1
-	sectionCM.TreeType = treeType
 	sectionCM.ParentId = sectionFather.TreeId
 	sectionCM.Name = sectionData.Name
 	sectionCM.Depth = sectionFather.Depth + 1
@@ -148,12 +142,6 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 	sectionCM.Attribution = attribution
 	sectionCM.Code = code
 
-	sectionCM.ProjectId = projectId
-	sectionCM.BidsectionId = bidsectionId
-	sectionCM.ContractPrice = "0"
-	sectionCM.ContractReturned = "0"
-	sectionCM.ContractsPaid = "0"
-
 	data, err := s.treeContractDao.Create(sectionCM)
 	if err != nil {
 		return nil, err
@@ -162,13 +150,13 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 }
 
 // 新增项目节
-func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error) {
+func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract) (*models.CmTreeContracts, error) {
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
 		return nil, err
 	}
-	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	sectionFather := s.treeContractDao.Get(treeId)
 	if sectionFather.Id == 0 {
 		return nil, errors.New("未找到合同项目节")
 	}
@@ -183,7 +171,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 
 	// 2 获得最大序号
 	// 2-1 孩子节点
-	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, treeType)
+	childrenList := s.treeContractDao.GetChildren(treeId)
 	// 2-1 最大序号
 	serial := 1
 	if len(childrenList) != 0 {
@@ -198,7 +186,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 	sectionCM := &models.CmTreeContracts{}
 	sectionCM.Id = lastId.Id + 1
 	sectionCM.TreeId = lastId.Id + 1
-	sectionCM.TreeType = treeType
+
 	sectionCM.ParentId = sectionFather.TreeId
 	sectionCM.Name = sectionData.Name
 	sectionCM.Depth = sectionFather.Depth + 1
@@ -206,12 +194,6 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 	sectionCM.Attribution = attribution
 	sectionCM.Code = code
 
-	sectionCM.ProjectId = projectId
-	sectionCM.BidsectionId = bidsectionId
-	sectionCM.ContractPrice = "0"
-	sectionCM.ContractReturned = "0"
-	sectionCM.ContractsPaid = "0"
-
 	data, err := s.treeContractDao.Create(sectionCM)
 	if err != nil {
 		return nil, err
@@ -220,13 +202,13 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 }
 
 // 保存名称
-func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
+func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContract) error {
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	section := s.treeContractDao.Get(treeId)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -253,13 +235,13 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 }
 
 // 更新序号
-func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
+func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContract) error {
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	section := s.treeContractDao.Get(treeId)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -273,7 +255,7 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 	// 	return errors.New("请在项目节第三层开始编辑")
 	// }
 
-	err = s.treeContractDao.UpdateSerial(section, sectionData.Serial, treeType)
+	err = s.treeContractDao.UpdateSerial(section, sectionData.Serial)
 	if err != nil {
 		return errors.New("更新失败")
 	}
@@ -281,9 +263,9 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 }
 
 // 项目节删除
-func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId int, treeType int) error {
+func (s *contractService) SectionDelete(treeId int) error {
 	// 1.验证项目节ID
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	section := s.treeContractDao.Get(treeId)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -293,7 +275,7 @@ func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId
 		return errors.New("请在项目节第三层开始编辑")
 	}
 	// 1-2 有合同的不能编辑(包含孩子节点)
-	contractList := s.treeContractDao.GetAttributionContract(section, treeType)
+	contractList := s.treeContractDao.GetAttributionContract(section)
 	if len(contractList) != 0 {
 		return errors.New("该项目节存在合同")
 	}
@@ -306,13 +288,13 @@ func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId
 }
 
 // 项目节的层级移动
-func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
+func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract) error {
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	section := s.treeContractDao.Get(treeId)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -321,16 +303,16 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 	// 	return errors.New("请在项目节第三层开始编辑")
 	// }
 	// 1-2 有合同的不能编辑(包含孩子节点)
-	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId, treeType)
-	if len(contractList) != 0 {
-		return errors.New("该项目节已存在合同")
-	}
+	// contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId)
+	// if len(contractList) != 0 {
+	// 	return errors.New("该项目节已存在合同")
+	// }
 
 	// 2.层级降级-同级有前一个兄弟节点
 	elderBrother := &models.CmTreeContracts{}
 	if sectionData.Operation == "downDepth" {
 		// 获得前一个兄弟节点
-		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
+		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId)
 		if len(elderBrotherList) == 0 {
 			return errors.New("项目节不能降级")
 		}
@@ -354,7 +336,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 	}
 
 	// 4.执行升降级
-	err = s.treeContractDao.MoveDepth(section, elderBrother, sectionData.Operation, bidsectionId, projectId, treeType)
+	err = s.treeContractDao.MoveDepth(section, elderBrother, sectionData.Operation)
 	if err != nil {
 		return err
 	}
@@ -363,13 +345,13 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 }
 
 // 项目节的排序移动
-func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
+func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract) error {
 	// 1.验证项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
 		return err
 	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
+	section := s.treeContractDao.Get(treeId)
 	if section.Id == 0 {
 		return errors.New("未找到合同项目节")
 	}
@@ -378,23 +360,23 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 	// 	return errors.New("请在项目节第三层开始编辑")
 	// }
 	// 1-2 有合同的不能编辑(包含孩子节点)
-	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId, treeType)
-	if len(contractList) != 0 {
-		return errors.New("该项目节已存在合同")
-	}
+	// contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId, treeType)
+	// if len(contractList) != 0 {
+	// 	return errors.New("该项目节已存在合同")
+	// }
 
 	// 2.下移
 	brother := &models.CmTreeContracts{}
 	if sectionData.Operation == "downSerial" {
 		// 获得下一个兄弟
-		youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
+		youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId)
 		if len(youngerBrotherList) == 0 {
 			return errors.New("项目节不能下移")
 		}
 		brother = &youngerBrotherList[0]
 	} else if sectionData.Operation == "upSerial" {
 		// 获得上一个兄弟
-		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
+		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId)
 		if len(elderBrotherList) == 0 {
 			return errors.New("项目节不能上移")
 		}
@@ -404,7 +386,7 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 	}
 
 	// 4.执行升降级
-	err = s.treeContractDao.MoveSerial(section, brother, sectionData.Operation, bidsectionId, projectId, treeType)
+	err = s.treeContractDao.MoveSerial(section, brother, sectionData.Operation)
 	if err != nil {
 		return err
 	}
@@ -435,9 +417,7 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
 	section := &viewmodels.TreeSectionContract{}
 	id, _ := comm.AesEncrypt(strconv.Itoa(data.TreeId), conf.SignSecret)
 	parentId, _ := comm.AesEncrypt(strconv.Itoa(data.ParentId), conf.SignSecret)
-	projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret)
 	contractId, _ := comm.AesEncrypt(strconv.Itoa(data.ContractId), conf.SignSecret)
-	bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret)
 	section.Id = id
 	section.Name = data.Name
 	section.ParentId = parentId
@@ -445,27 +425,13 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
 	section.Serial = data.Serial
 	section.Attribution = data.Attribution
 	section.Code = data.Code
-	section.ProjectId = projectId
-	section.BidsectionId = bidsectionId
 	section.ContractId = contractId
 	// section.Children = make([]*viewmodels.TreeSectionContract, 0)
 	section.ElderBrother = true
 	section.IsEnd = false
 
 	section.Name = data.Name
-	section.ContractName = data.ContractName
-	section.ContractCode = data.ContractCode
-	section.ContractPrice = data.ContractPrice
-	section.ContractReturned = data.ContractReturned
-	section.ContractsPaid = data.ContractsPaid
-	section.ContractStatus = data.ContractStatus
-	section.ContractLocking = data.ContractLocking
 
 	section.CreateTime = data.CreateTime.Format(conf.SysTimeform)
-
-	//
-	section.Title = fmt.Sprintf("%s%d ", data.Attribution, data.Serial) + data.Name
-	section.Key = id
-	section.Value = id
 	return section
 }

+ 10 - 443
services/contract_service.go

@@ -8,15 +8,11 @@ package services
 
 import (
 	"errors"
-	"fmt"
 	"html"
 	"log"
-	"strconv"
 	"time"
 
 	"github.com/kataras/iris/v12"
-	"go.mod/comm"
-	"go.mod/conf"
 	"go.mod/dao"
 	"go.mod/datasource"
 	"go.mod/models"
@@ -32,56 +28,16 @@ type ContractService interface {
 	ValidRuleSectionNot(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 	ValidRuleGet(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 	ValidRuleSerial(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
-	ValidRuleContractAdd(ctx iris.Context) (*viewmodels.Contracts, error)
-	ValidRuleContractEdi(ctx iris.Context) (*viewmodels.Contracts, error)
-	ValidRuleContractDel(ctx iris.Context) (*viewmodels.Contracts, error)
-	ValidRuleContractClose(ctx iris.Context) (*viewmodels.Contracts, error)
-
-	ValidRuleContractRetrunAdd(ctx iris.Context) (*viewmodels.ContractsReturn, error)
-	ValidRuleContractRetrun(ctx iris.Context) (*viewmodels.ContractsReturn, error)
-	ValidRuleContractRetrunDel(ctx iris.Context) (*viewmodels.ContractsReturn, error)
-
-	ValidRuleContractPaidAdd(ctx iris.Context) (*viewmodels.ContractsPaid, error)
-	ValidRuleContractPaid(ctx iris.Context) (*viewmodels.ContractsPaid, error)
-	ValidRuleContractPaidDel(ctx iris.Context) (*viewmodels.ContractsPaid, error)
 
 	// 项目节
-	Get(treeId int, bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
-	GetSectionTreeContract(attribution string, bidsectionId int, projectId int, treeType int) []*viewmodels.Contracts
-	GetSecionTree(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
-	SetSection(templateNumber int, bidsectionId int, projectIdInt int, treeType int) error
-	SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error)
-	ContractSectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error)
-	SectionSave(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
-	UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
-	SectionDelete(treeId int, bidsectionId int, projectId int, treeType int) error
-	MoveDepth(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
-	MoveSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error
-	GetSecionTreeNotContract(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
-
-	GetContract(contractId int) *viewmodels.Contracts
-	Add(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error
-	Update(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error
-	Delete(projectId int, bidsectionId int, treeId int, id int) error
-	Close(projectId int, bidsectionId int, treeId int, id int, treeType int) error
-	Unlock(projectId int, bidsectionId int, treeId int, id int, treeType int) error
-	GetSurvey(bidsectionId int, projectId int, contractsType int) map[string]interface{}
-
-	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
-	ReturnAll(projectId int, bidsectionId int, contractsId int, page int) []*viewmodels.ContractsReturn
-	ReturnDelete(projectId int, bidsectionId int, contractsId int, id int) error
-
-	//支出合同
-	AddExpenditure(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error
-	UpdateExpenditure(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error
-	DeleteExpenditure(projectId int, bidsectionId int, treeId int, id int) error
-
-	// 已支付
-	PaidAll(projectId int, bidsectionId int, contractsId int, page int) []*viewmodels.ContractsPaid
-	PaidCreate(returnData *viewmodels.ContractsPaid, projectId int, bidsectionId int, contractsId int, projectAccountId int) error
-	PaidUpdate(returnData *viewmodels.ContractsPaid, projectId int, bidsectionId int, contractsId int, id int) error
-	PaidDelete(projectId int, bidsectionId int, contractsId int, id int) error
+	GetSecionTree() *viewmodels.TreeSectionContract
+	SetSection(templateNumber int) error
+	SectionAdd(sectionData *viewmodels.TreeSectionContract) (*models.CmTreeContracts, error)
+	SectionSave(sectionData *viewmodels.TreeSectionContract) error
+	UpdateSerial(sectionData *viewmodels.TreeSectionContract) error
+	SectionDelete(treeId int) error
+	MoveDepth(sectionData *viewmodels.TreeSectionContract) error
+	MoveSerial(sectionData *viewmodels.TreeSectionContract) error
 }
 
 //返回service操作类
@@ -253,107 +209,10 @@ func (s *contractService) ValidRuleContractAdd(ctx iris.Context) (*viewmodels.Co
 	return contractsVaild, nil
 }
 
-// 校验编辑接口
-func (s *contractService) ValidRuleContractEdi(ctx iris.Context) (*viewmodels.Contracts, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.Contracts{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadJSON(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateEdi()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	contractsVaild.Content = html.EscapeString(contractsVaild.Content)
-	contractsVaild.Name = html.EscapeString(contractsVaild.Name)
-	contractsVaild.Price = html.EscapeString(contractsVaild.Price)
-
-	contractsVaild.PartyA = html.EscapeString(contractsVaild.PartyA)
-	contractsVaild.PartyASigner = html.EscapeString(contractsVaild.PartyASigner)
-	contractsVaild.PartyB = html.EscapeString(contractsVaild.PartyB)
-	contractsVaild.PartyBSigner = html.EscapeString(contractsVaild.PartyBSigner)
-
-	return contractsVaild, nil
-}
-
-// 校验删除合同参数
-func (s *contractService) ValidRuleContractDel(ctx iris.Context) (*viewmodels.Contracts, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.Contracts{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadForm(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateDel()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-// 校验关闭合同参数
-func (s *contractService) ValidRuleContractClose(ctx iris.Context) (*viewmodels.Contracts, error) {
-	// 创建一个存放前端传过来参数
-	contractsVaild := &viewmodels.Contracts{}
-	// 存放raw的值,放入到contractsVaild
-	err := ctx.ReadJSON(contractsVaild)
-	if err != nil {
-		log.Println("folder-ValidRule-ReadForm转换异常, error=", err)
-		return contractsVaild, err
-	}
-	// 验证合同传参
-	err = contractsVaild.ValidateDel()
-	if err != nil {
-		log.Println("参数验证错误, error=", err)
-		return contractsVaild, err
-	}
-
-	return contractsVaild, nil
-}
-
-//------------------------------------------------------------
-// 获得项目节
-func (s *contractService) Get(treeId int, bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract {
-	// 1.获得项目节
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
-	// 2.构造数据
-	sectionVM := s.makeSectionView(section)
-	// 3.更新 上移和下一的限制
-	youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
-	if len(youngerBrotherList) == 0 {
-		sectionVM.IsEnd = true
-	}
-	sectionVM.ElderBrother = true
-	elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
-	if len(elderBrotherList) == 0 {
-		sectionVM.ElderBrother = false
-	}
-	return sectionVM
-}
-
-// 获得合同详情
-func (s *contractService) GetContract(contractId int) *viewmodels.Contracts {
-	contract := s.contractDao.Get(contractId)
-
-	contractsVM := s.makeContractVM(contract)
-	return &contractsVM
-}
-
 // 新增合同
-func (s *contractService) Add(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error {
+func (s *contractService) Add(contractData *viewmodels.Contracts, treeId int) error {
 	// 1. 项目节存在
-	contracts := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
+	contracts := s.treeContractDao.Get(treeId)
 	if contracts.Id == 0 {
 		return errors.New("未找到项目节")
 	}
@@ -363,12 +222,6 @@ func (s *contractService) Add(contractData *viewmodels.Contracts, projectId int,
 		return errors.New("该项目节上已经存在合同")
 	}
 
-	// 2-1.查找合同编号是否存在
-	codeData := s.contractDao.GetByCode(projectId, bidsectionId, contractData.Code, 1)
-	if len(codeData) != 0 {
-		return errors.New("该合同编号已经存在")
-	}
-
 	// 3.新增合同 --合计标段上的金额
 	contractsCm := &models.CmContracts{}
 	contractsCm.Code = contractData.Code
@@ -378,8 +231,6 @@ func (s *contractService) Add(contractData *viewmodels.Contracts, projectId int,
 	contractsCm.Returned = "0"
 	contractsCm.Paid = "0"
 	contractsCm.TreeId = treeId
-	contractsCm.ProjectId = projectId
-	contractsCm.BidsectionId = bidsectionId
 	contractsCm.Status = 0
 	contractsCm.CreateTime = time.Now()
 	contractsCm.UpdateTime = time.Now()
@@ -389,289 +240,5 @@ func (s *contractService) Add(contractData *viewmodels.Contracts, projectId int,
 		return err
 	}
 
-	// 3.获得该标段下合同总数 - 总收入金额
-	contractTotal, priceTotal := s.getContractTotalAndPrice(bidsectionId, projectId, 0)
-	// 更新标段目录上合同金额和总数
-	err = s.treeDao.UpdateContractsAndIncomePrice(projectId, bidsectionId, contractTotal, priceTotal)
-	if err != nil {
-		return err
-	}
-
 	return nil
 }
-
-// 更新合同
-func (s *contractService) Update(contractData *viewmodels.Contracts, projectId int, bidsectionId int, treeId int) error {
-	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
-	if contractsTree.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// 2.项目节是没有合同
-	if contractsTree.ContractId == 0 {
-		return errors.New("该项目节上没有找到合同")
-	}
-
-	// 3.合同锁定 不能删除
-	if contractsTree.ContractLocking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	contractsCm := &models.CmContracts{}
-	contractsCm.Id = contractsTree.ContractId
-	contractsCm.Content = contractData.Content
-	contractsCm.Name = contractData.Name
-	contractsCm.Price = contractData.Price
-	contractsCm.PartyA = contractData.PartyA
-	contractsCm.PartyASigner = contractData.PartyASigner
-	contractsCm.PartyB = contractData.PartyB
-	contractsCm.PartyBSigner = contractData.PartyBSigner
-
-	loc, _ := time.LoadLocation("Local")
-	SignerTime, err := time.ParseInLocation(conf.SysTimeform, contractData.SignerTime, loc)
-	if err != nil {
-		return errors.New("签约时间填写异常")
-	}
-	contractsCm.SignerTime = SignerTime
-	contractsCm.Remarks = contractData.Remarks
-
-	columns := []string{"Content", "Name", "Price", "PartyA", "PartyASigner", "PartyB", "PartyBSigner"}
-	err = s.contractDao.Update(contractsCm, columns, projectId, bidsectionId, treeId)
-	if err != nil {
-		return err
-	}
-	// 3.获得该标段下合同总数 - 总收入金额
-	contractTotal, priceTotal := s.getContractTotalAndPrice(bidsectionId, projectId, 0)
-	// 更新标段目录上合同金额和总数
-	err = s.treeDao.UpdateContractsAndIncomePrice(projectId, bidsectionId, contractTotal, priceTotal)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-// 删除合同
-func (s *contractService) Delete(projectId int, bidsectionId int, treeId int, id int) error {
-	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
-	if contractsTree.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// 2.项目节是没有合同
-	if contractsTree.ContractId == 0 {
-		return errors.New("该项目节上没有找到合同")
-	}
-
-	// 3.合同锁定 不能删除
-	if contractsTree.ContractLocking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	// 删除合同
-	err := s.contractDao.Delete(projectId, bidsectionId, treeId, id)
-	if err != nil {
-		return err
-	}
-	// 3.获得该标段下合同总数 - 总收入金额
-	contractTotal, priceTotal := s.getContractTotalAndPrice(bidsectionId, projectId, 0)
-	// 更新标段目录上合同金额和总数
-	err = s.treeDao.UpdateContractsAndIncomePrice(projectId, bidsectionId, contractTotal, priceTotal)
-	if err != nil {
-		return err
-	}
-
-	// 4.更新回款总金额
-	err = s.contractReturnDao.UpdateTotalPrice(projectId, bidsectionId, id)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// 关闭合同
-func (s *contractService) Close(projectId int, bidsectionId int, treeId int, id int, treeType int) error {
-	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
-	if contractsTree.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// 2.项目节是没有合同
-	if contractsTree.ContractId == 0 {
-		return errors.New("该项目节上没有找到合同")
-	}
-
-	// 3.合同锁定 不能删除
-	if contractsTree.ContractLocking == 1 {
-		return errors.New("该合同已锁定")
-	}
-
-	// 关闭合同
-	err := s.contractDao.Close(projectId, bidsectionId, treeId, id)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-// 解锁合同
-func (s *contractService) Unlock(projectId int, bidsectionId int, treeId int, id int, treeType int) error {
-	// 1. 项目节存在
-	contractsTree := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
-	if contractsTree.Id == 0 {
-		return errors.New("未找到项目节")
-	}
-	// 2.项目节是没有合同
-	if contractsTree.ContractId == 0 {
-		return errors.New("该项目节上没有找到合同")
-	}
-
-	// 解锁合同
-	err := s.contractDao.Unlock(projectId, bidsectionId, treeId, id)
-	if err != nil {
-		return err
-	}
-
-	return nil
-}
-
-//获得合同收入概况
-func (s *contractService) GetSurvey(bidsectionId int, projectId int, contractsType int) map[string]interface{} {
-	// 1.获得收入合同
-	year := time.Now().Year()
-	incomeList := s.contractDao.GetTypeYear(bidsectionId, projectId, contractsType, year)
-
-	// 2.初始化
-	totalContractPrice := 0.00
-	totalTypePrice := 0.00
-	performNumber := 0
-	closeNumber := 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 {
-		contractPrice, _ := strconv.ParseFloat(item.Price, 64)
-		totalContractPrice = totalContractPrice + contractPrice
-		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 {
-			performNumber = performNumber + 1
-		} else if item.Status == 1 {
-			uncloseNumber = uncloseNumber + 1
-		} else if item.Status == 2 {
-			closeNumber = closeNumber + 1
-		}
-
-		returnDate[item.CreateTime.Format(conf.SysTimeformMonth)] = returnDate[item.CreateTime.Format(conf.SysTimeformMonth)] + typePrice
-	}
-	totalContractPrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalContractPrice), 64)
-	totalTypePrice, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", totalTypePrice), 64)
-
-	// ac := accounting.Accounting{Symbol: "", Precision: 2}
-
-	surveryData := map[string]interface{}{
-		"totalContractPrice":     totalContractPrice,
-		"totalContractPriceShow": totalContractPrice,
-		// "totalReturnPrice":   ac.FormatMoney(totalReturnPrice),
-		"performNumber": performNumber,
-		"closeNumber":   closeNumber,
-		"uncloseNumber": uncloseNumber,
-		"returnDate":    returnDate,
-	}
-
-	if contractsType == 1 {
-		surveryData["totalReturnPriceShow"] = totalTypePrice
-	} else {
-		surveryData["totalPaidPriceShow"] = totalTypePrice
-	}
-
-	return surveryData
-}
-
-// 获得合同总数量和总金额
-func (s *contractService) getContractTotalAndPrice(bidsectionId int, projectId int, treeType int) (contractTotal int, priceTotal float64) {
-
-	contractListAll := s.treeContractDao.GetContractAll(bidsectionId, projectId)
-
-	// 获得收入合同
-	contractList := s.treeContractDao.GetContract(bidsectionId, projectId, treeType)
-	priceTotal = 0.00
-	for _, item := range contractList {
-		contractPrice, _ := strconv.ParseFloat(item.ContractPrice, 64)
-		priceTotal = priceTotal + contractPrice
-	}
-	// 合同总数
-	// contractTotal = len(contractList) + 1
-	contractTotal = len(contractListAll)
-	// 合同收入总金额
-	// price, _ := strconv.ParseFloat(priceString, 64)
-	// priceTotal = priceTotal + price
-	// 保留2位小数
-	priceTotal, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", priceTotal), 64)
-
-	return contractTotal, priceTotal
-}
-
-// 构建合同详情视图
-func (s *contractService) makeContractVM(contract *models.CmContracts) viewmodels.Contracts {
-	contractsVM := viewmodels.Contracts{}
-	if contract.Id == 0 {
-		return contractsVM
-	}
-
-	id, _ := comm.AesEncrypt(strconv.Itoa(contract.Id), conf.SignSecret)
-	treeId, _ := comm.AesEncrypt(strconv.Itoa(contract.TreeId), conf.SignSecret)
-	bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(contract.BidsectionId), conf.SignSecret)
-
-	contractsVM.Id = id
-	contractsVM.TreeId = treeId
-	contractsVM.ContractsType = contract.ContractsType
-	contractsVM.BidsectionId = bidsectionId
-
-	contractsVM.Name = contract.Name
-	contractsVM.Content = contract.Content
-	contractsVM.Code = contract.Code
-	contractsVM.PartyA = contract.PartyA
-	contractsVM.PartyASigner = contract.PartyASigner
-	contractsVM.PartyB = contract.PartyB
-	contractsVM.PartyBSigner = contract.PartyBSigner
-	contractsVM.Remarks = contract.Remarks
-	contractsVM.Price = contract.Price
-	contractsVM.Returned = contract.Returned
-	contractsVM.Paid = contract.Paid
-	contractsVM.Status = contract.Status
-	contractsVM.Locking = contract.Locking
-
-	contractsVM.CreateTime = contract.CreateTime.Format(conf.SysTimeform)
-	contractsVM.UpdateTime = contract.UpdateTime.Format(conf.SysTimeform)
-	// nilTime := time.Time{}
-	// contract.SignerTime != nilTime
-
-	if !contract.SignerTime.IsZero() {
-		contractsVM.SignerTime = contract.SignerTime.Format(conf.SysTimeform)
-	}
-
-	return contractsVM
-}

+ 20 - 523
web/api/contract_api.go

@@ -7,13 +7,8 @@
 package api
 
 import (
-	"fmt"
-
 	"github.com/kataras/iris/v12"
-	"go.mod/lib"
-	"go.mod/models"
 	"go.mod/services"
-	"go.mod/web/utils"
 	"go.mod/web/viewmodels"
 )
 
@@ -27,58 +22,14 @@ type ContractApi struct {
 	// ServiceProject        services.ProjectService
 }
 
-// @Summary 获得合同目录和标段
-// @Tags 合同管理
-// @Description 获得合同目录和标段
-// @Accept  json
-// @Produce  json
-// @Param   bidsectionType     path    string     true        "标段类型0合同1安全2质量"
-// @Success 200 {object} viewmodels.FolderContract "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
-// @Router /api/contract/folder [get]
-func (c *ContractApi) GetFolder() {
-
-	bidTypeData, err := c.ServiceTree.ValidRuleBidsectionType(c.Ctx)
-	if err != nil {
-		ErrMsg := utils.FormValidError(err)
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
-		return
-	}
-
-	// 获得项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-	// 获得项目账号ID
-	// projectAccountId, err := utils.GetProjectAccountId(c.Ctx)
-	// if err != nil {
-	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-	// 	return
-	// }
-
-	account := c.Ctx.Values().Get("account").(*models.CmProjectAccount)
-
-	// 获得层级文件夹
-	FolderData := c.ServiceTree.GetAllContract(projectId, account, bidTypeData.BidsectionType)
-
-	c.Ctx.JSON(iris.Map{
-		"code": 0,
-		"msg":  "",
-		"data": FolderData,
-	})
-}
-
-// @Summary 获得标段收入-项目节信息
-// @Tags 合同管理-收入合同
+// @Summary 获得项目节信息
+// @Tags 合同管理-项目节
 // @Description 未设置合同项目节 返回项目节模板信息
 // @Accept  json
 // @Produce  json
-// @Security ApiKeyAuth
-// @Param   bidsectionId     path    string     true        "标段ID"
 // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/income/section/all [get]
-func (c *ContractApi) GetIncomeSectionAll() {
+// @Router /api/section/all [get]
+func (c *ContractApi) GetSectionAll() {
 
 	sectionData := viewmodels.TreeSectionContract{}
 	err := c.Ctx.ReadForm(&sectionData)
@@ -86,483 +37,29 @@ func (c *ContractApi) GetIncomeSectionAll() {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
 		return
 	}
-	if sectionData.BidsectionId == "" {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
+	// if sectionData.BidsectionId == "" {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
+	// 	return
+	// }
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
+	// 	return
+	// }
 
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
 
 	//获得合同项目节
-	sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, 0)
-
-	// 1.未设置了项目节
-	if len(sectionTree.Children) == 0 {
-		// 返回项目节2个基础模板
-		templateTree1 := lib.NewItemSection().TemplateTree1
-		templateTree2 := lib.NewItemSection().TemplateTree2
-
-		c.Ctx.JSON(iris.Map{
-			"code":             0,
-			"msg":              "",
-			"isTemplate":       1,
-			"sectionTemplate1": templateTree1,
-			"sectionTemplate2": templateTree2,
-		})
-		return
-		//2.项目节已设置
-	} else {
-		// 2.已设置项目节
-		c.Ctx.JSON(iris.Map{
-			"code":        0,
-			"msg":         "",
-			"isTemplate":  0,
-			"sectionTree": sectionTree,
-		})
-		return
-		// 返回项目相关所有信息
-	}
-}
-
-// @Summary 单个合同和项目节
-// @Tags 合同管理-收入合同
-// @Description 获得合同详情和项目节详情
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,isContract:是否有合同(包含孩子们),section:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/income [get]
-func (c *ContractApi) GetIncome() {
-	// 1.规则验证
-	sectionData, err := c.ServiceContract.ValidRuleGet(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	// 2.项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-	// 3.标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-	// 4.树ID
-	treeId, err := utils.GetDecryptId(sectionData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	// 获得项目节详情
-	section := c.ServiceContract.Get(treeId, bidsectionId, projectId, 0)
-
-	// 该项目节 子树下是否有合同
-	isContract := true
-	contractList := c.ServiceContract.GetSectionTreeContract(section.Attribution, bidsectionId, projectId, 0)
-	if len(contractList) == 0 {
-		isContract = false
-	}
-	// 获得合同详情
-	contractId, _ := utils.GetDecryptId(section.ContractId)
-	contract := &viewmodels.Contracts{}
-	if contractId != 0 {
-		contract = c.ServiceContract.GetContract(contractId)
-	}
-	c.Ctx.JSON(iris.Map{
-		"code":       0,
-		"msg":        "",
-		"section":    section,
-		"isContract": isContract, //该项目节(包含子孙)下是否有合同
-		"contract":   contract,
-	})
-}
-
-// @Summary 新增合同
-// @Tags 合同管理-收入合同
-// @Description 新增合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   code     path    string     true        "合同编号"
-// @Param   name     path    string     true        "合同名称"
-// @Param   contractsType     path    int     true        "合同类型(1)"
-// @Param   price     path    string     true        "合同金额"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/income/create [post]
-func (c *ContractApi) PostIncomeCreate() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractAdd(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 可优化-事务问题
-	// 先添加项目节
-	// 1.新建合同,项目层级必须在第二层以下,当第一层没有孩子可以添加合同
-
-	sectionData := &viewmodels.TreeSectionContract{}
-	sectionData.Id = contractData.TreeId
-	sectionData.Name = " "
-	sectionResult, err := c.ServiceContract.ContractSectionAdd(sectionData, bidsectionId, projectIdInt, 0)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 在添加合同
-	err = c.ServiceContract.Add(contractData, projectIdInt, bidsectionId, sectionResult.Id)
-	if err != nil {
-		// 需要删除项目节-有问题
-		c.ServiceContract.SectionDelete(sectionResult.Id, bidsectionId, projectIdInt, 0)
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 获得项目节
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
-	// 合同ID
-	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
-	contractDetail := c.ServiceContract.GetContract(contractId)
+	sectionTree := c.ServiceContract.GetSecionTree()
 
 	c.Ctx.JSON(iris.Map{
-		"code":     0,
-		"msg":      "新增成功",
-		"contract": contractDetail,
-	})
-}
-
-// @Summary 编辑合同
-// @Tags 合同管理-收入合同
-// @Description 编辑合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "合同ID"
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   content     path    string     true        "合同内容"
-// @Param   name     path    string     true        "合同名称"
-// @Param   price     path    string     true        "合同金额"
-// @Param   partyA     path    string     true        "甲方"
-// @Param   partyASigner     path    string     true        "甲方签约人"
-// @Param   partyB     path    string     true        "已方"
-// @Param   partyBSigner     path    string     true        "已方签约人"
-// @Param   signerTime     path    string     true        "签约时间"
-// @Param   remarks     path    string     true        "备注"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/income/update [post]
-func (c *ContractApi) PostIncomeUpdate() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractEdi(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.Update(contractData, projectIdInt, bidsectionId, treeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	//2.请求当前项目信息
-	// 1.验证项目节ID
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
-	// 合同ID
-	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
-	contractDetail := c.ServiceContract.GetContract(contractId)
-
-	c.Ctx.JSON(iris.Map{
-		"code":     0,
-		"msg":      "编辑成功",
-		"section":  sectionDetail,
-		"contract": contractDetail,
-	})
-}
-
-// @Summary 删除合同
-// @Tags 合同管理-收入合同
-// @Description 删除合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "合同ID"
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract [delete]
-func (c *ContractApi) Delete() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractDel(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	id, err := utils.GetDecryptId(contractData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 删除合同
-	err = c.ServiceContract.Delete(projectIdInt, bidsectionId, treeId, id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	//2.请求当前项目信息--需求变更 删除合同要删除项目节,不需要返回项目节信息
-	// 1.验证项目节ID
-	// sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
-
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功", "section": ""})
-}
-
-// @Summary 关闭合同
-// @Tags 合同管理
-// @Description 关闭合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "合同ID"
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/close [post]
-func (c *ContractApi) PostClose() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractClose(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	id, err := utils.GetDecryptId(contractData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.Close(projectIdInt, bidsectionId, treeId, id, contractData.TreeType)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 1.项目节信息
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
-	contractDetail := c.ServiceContract.GetContract(id)
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "关闭成功", "section": sectionDetail, "contract": contractDetail})
-}
-
-// @Summary 解锁合同
-// @Tags 合同管理
-// @Description 解锁合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "合同ID"
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/unlock [post]
-func (c *ContractApi) PostUnlock() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractClose(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	id, err := utils.GetDecryptId(contractData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.Unlock(projectIdInt, bidsectionId, treeId, id, contractData.TreeType)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 1.项目节信息
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
-	contractDetail := c.ServiceContract.GetContract(id)
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "解锁成功", "section": sectionDetail, "contract": contractDetail})
-}
-
-// @Summary 合同概述
-// @Tags 合同管理
-// @Description 合同概述
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/survey [get]
-func (c *ContractApi) GetSurvey() {
-	sectionData := viewmodels.Contracts{}
-	err := c.Ctx.ReadForm(&sectionData)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-	err = sectionData.ValidateBidsectionId()
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	// 账号ID
-	accountId, err := utils.GetProjectAccountId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 缓存标段ID-用于权限
-	key := fmt.Sprintf("pm_%d_%d", projectId, accountId)
-	lib.NewRedis().SetBidsectionIdByCache(key, bidsectionId)
-
-	incomeData := c.ServiceContract.GetSurvey(bidsectionId, projectId, 1)
-	expenditureData := c.ServiceContract.GetSurvey(bidsectionId, projectId, 2)
-	data := map[string]interface{}{
-		"incomeData":      incomeData,
-		"expenditureData": expenditureData,
-	}
-	c.Ctx.JSON(iris.Map{
 		"code": 0,
 		"msg":  "",
-		"data": data,
+		"data": sectionTree,
 	})
-
 }

+ 0 - 343
web/api/contract_expenditure_api.go

@@ -1,343 +0,0 @@
-/*
- * @description: 合同支出相关控制
- * @Author: CP
- * @Date: 2020-12-18 16:44:13
- * @FilePath: \construction_management\web\api\contract_expenditure_api.go
- */
-package api
-
-import (
-	"fmt"
-
-	"github.com/kataras/iris/v12"
-	"go.mod/lib"
-	"go.mod/web/utils"
-	"go.mod/web/viewmodels"
-)
-
-// @Summary 获得标段支出-项目节信息
-// @Tags 合同管理-支出合同
-// @Description 未设置合同项目节 返回项目节模板信息
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/expenditure/section/all [get]
-func (c *ContractApi) GetExpenditureSectionAll() {
-
-	sectionData := viewmodels.TreeSectionContract{}
-	err := c.Ctx.ReadForm(&sectionData)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-	if sectionData.BidsectionId == "" {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	//获得合同项目节
-	sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, 1)
-
-	// 1.未设置了项目节
-	if len(sectionTree.Children) == 0 {
-		// 返回项目节2个基础模板
-		templateTree1 := lib.NewItemSection().TemplateTree1
-		templateTree2 := lib.NewItemSection().TemplateTree2
-
-		c.Ctx.JSON(iris.Map{
-			"code":             0,
-			"msg":              "",
-			"isTemplate":       1,
-			"sectionTemplate1": templateTree1,
-			"sectionTemplate2": templateTree2,
-		})
-		return
-		//2.项目节已设置
-	} else {
-		// 2.已设置项目节
-		c.Ctx.JSON(iris.Map{
-			"code":        0,
-			"msg":         "",
-			"isTemplate":  0,
-			"sectionTree": sectionTree,
-		})
-		return
-		// 返回项目相关所有信息
-	}
-}
-
-// @Summary 单个合同和项目节
-// @Tags 合同管理-支出合同
-// @Description 获得合同详情和项目节详情
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,isContract:是否有合同(包含孩子们),section:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/expenditure [get]
-func (c *ContractApi) GetExpenditure() {
-	// 1.规则验证
-	sectionData, err := c.ServiceContract.ValidRuleGet(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	// 2.项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-	// 3.标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-	// 4.树ID
-	treeId, err := utils.GetDecryptId(sectionData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	// 获得项目节详情
-	section := c.ServiceContract.Get(treeId, bidsectionId, projectId, 1)
-
-	// 该项目节 子树下是否有合同
-	isContract := true
-	contractList := c.ServiceContract.GetSectionTreeContract(section.Attribution, bidsectionId, projectId, 1)
-	if len(contractList) == 0 {
-		isContract = false
-	}
-	// 获得合同详情
-	contractId, _ := utils.GetDecryptId(section.ContractId)
-	contract := &viewmodels.Contracts{}
-	if contractId != 0 {
-		contract = c.ServiceContract.GetContract(contractId)
-	}
-	c.Ctx.JSON(iris.Map{
-		"code":       0,
-		"msg":        "",
-		"section":    section,
-		"isContract": isContract, //该项目节(包含子孙)下是否有合同
-		"contract":   contract,
-	})
-}
-
-// @Summary 新增合同
-// @Tags 合同管理-支出合同
-// @Description 新增合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   code     path    string     true        "合同编号"
-// @Param   name     path    string     true        "合同名称"
-// @Param   contractsType     path    int     true        "合同类型(1)"
-// @Param   price     path    string     true        "合同金额"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/expenditure/create [post]
-func (c *ContractApi) PostExpenditureCreate() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractAdd(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	if !(contractData.ContractsType == 0 || contractData.ContractsType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同类型只能是0或者1"})
-		return
-	}
-
-	sectionData := &viewmodels.TreeSectionContract{}
-	sectionData.Id = contractData.TreeId
-	sectionData.Name = " "
-	sectionResult, err := c.ServiceContract.SectionAdd(sectionData, bidsectionId, projectIdInt, 1)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.AddExpenditure(contractData, projectIdInt, bidsectionId, sectionResult.Id)
-	if err != nil {
-		// 需要删除项目节
-		c.ServiceContract.SectionDelete(sectionResult.Id, bidsectionId, projectIdInt, 1)
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 获得项目节
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 1)
-	// 合同ID
-	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
-	contractDetail := c.ServiceContract.GetContract(contractId)
-
-	c.Ctx.JSON(iris.Map{
-		"code":     0,
-		"msg":      "新增成功",
-		"contract": contractDetail,
-	})
-}
-
-// @Summary 编辑合同
-// @Tags 合同管理-支出合同
-// @Description 编辑合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "合同ID"
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   content     path    string     true        "合同内容"
-// @Param   name     path    string     true        "合同名称"
-// @Param   price     path    string     true        "合同金额"
-// @Param   partyA     path    string     true        "甲方"
-// @Param   partyASigner     path    string     true        "甲方签约人"
-// @Param   partyB     path    string     true        "已方"
-// @Param   partyBSigner     path    string     true        "已方签约人"
-// @Param   signerTime     path    string     true        "签约时间"
-// @Param   remarks     path    string     true        "备注"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/expenditure/update [post]
-func (c *ContractApi) PostExpenditureUpdate() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractEdi(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.UpdateExpenditure(contractData, projectIdInt, bidsectionId, treeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	//2.请求当前项目信息
-	// 1.验证项目节ID
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 1)
-	// 合同ID
-	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
-	contractDetail := c.ServiceContract.GetContract(contractId)
-
-	c.Ctx.JSON(iris.Map{
-		"code":     0,
-		"msg":      "编辑成功",
-		"section":  sectionDetail,
-		"contract": contractDetail,
-	})
-}
-
-// @Summary 删除合同
-// @Tags 合同管理-支出合同
-// @Description 删除合同
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "合同ID"
-// @Param   treeId     path    string     true        "项目节ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/expenditure [delete]
-func (c *ContractApi) DeleteExpenditure() {
-	// 验证参数
-	contractData, err := c.ServiceContract.ValidRuleContractDel(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(contractData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 项目节ID
-	treeId, err := utils.GetDecryptId(contractData.TreeId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	id, err := utils.GetDecryptId(contractData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.DeleteExpenditure(projectIdInt, bidsectionId, treeId, id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	//2.请求当前项目信息
-	// 1.验证项目节ID
-	// sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 1)
-
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功", "section": ""})
-}

+ 0 - 229
web/api/contract_paid_api.go

@@ -1,229 +0,0 @@
-/*
- * @description: 合同已支付相关
- * @Author: CP
- * @Date: 2020-12-22 11:45:22
- * @FilePath: \construction_management\web\api\contract_paid_api.go
- */
-package api
-
-import (
-	"fmt"
-
-	"github.com/kataras/iris/v12"
-	"go.mod/models"
-	"go.mod/web/utils"
-)
-
-// @Summary 获得已支付列表
-// @Tags 合同管理-支出合同
-// @Description 获得已支付列表
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/paid/list [get]
-func (c *ContractApi) GetPaidList() {
-	returnData, err := c.ServiceContract.ValidRuleContractPaid(c.Ctx)
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	returnList := c.ServiceContract.PaidAll(projectId, bidsectionId, contractsId, returnData.Page)
-
-	c.Ctx.JSON(iris.Map{
-		"code": 0,
-		"msg":  "",
-		"data": returnList,
-	})
-}
-
-// @Summary 新增已支付
-// @Tags 合同管理-支出合同
-// @Description 新增已支付
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   time     path    string     true        "已支付时间"
-// @Param   Price     path    string     true        "已支付金额"
-// @Param   Way     path    string     true        "已支付方式"
-// @Param   remarks     path    string     true        "备注"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/paid/create [post]
-func (c *ContractApi) PostPaidCreate() {
-	// 验证参数
-	returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 获得项目账号ID
-	projectAccountId, err := utils.GetProjectAccountId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	account := c.Ctx.Values().Get("account").(*models.CmProjectAccount)
-	returnData.CreateUser = account.Name
-
-	err = c.ServiceContract.PaidCreate(returnData, projectId, bidsectionId, contractsId, projectAccountId)
-	contractData := c.ServiceContract.GetContract(contractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功", "contract": contractData})
-}
-
-// @Summary 更新已支付
-// @Tags 合同管理-支出合同
-// @Description 更新已支付
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "已支付ID"
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   time     path    string     true        "已支付时间"
-// @Param   Price     path    string     true        "已支付金额"
-// @Param   Way     path    string     true        "已支付方式"
-// @Param   remarks     path    string     true        "备注"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/paid/update [post]
-func (c *ContractApi) PostPaidUpdate() {
-	// 验证参数
-	returnData, err := c.ServiceContract.ValidRuleContractPaidAdd(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	if returnData.Id == "" {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "已支付ID不能为空"})
-		return
-	}
-	// 已支付ID
-	id, err := utils.GetDecryptId(returnData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.PaidUpdate(returnData, projectId, bidsectionId, contractsId, id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
-}
-
-// @Summary 删除已支付
-// @Tags 合同管理-支出合同
-// @Description 删除已支付
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "已支付ID"
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/piad/delete [delete]
-func (c *ContractApi) DeletePaidDelete() {
-	// 验证参数
-	returnData, err := c.ServiceContract.ValidRuleContractPaidDel(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 回款ID
-	id, err := utils.GetDecryptId(returnData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.PaidDelete(projectId, bidsectionId, contractsId, id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
-}

+ 0 - 248
web/api/contract_return_api.go

@@ -1,248 +0,0 @@
-/*
- * @description:合同回款相关
- * @Author: CP
- * @Date: 2020-11-26 11:32:21
- * @FilePath: \construction_management\web\api\contract_return_api.go
- */
-package api
-
-import (
-	"fmt"
-
-	"github.com/kataras/iris/v12"
-	"go.mod/models"
-	"go.mod/web/utils"
-)
-
-// @Summary 获得回款类型
-// @Tags 合同管理
-// @Description 获得回款类型
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/return/way [get]
-func (c *ContractApi) GetReturnWay() {
-
-	way := [8]string{"支票", "现金", "网上转账", "电汇", "邮政汇款", "支付宝", "微信支付", "其他"}
-
-	c.Ctx.JSON(iris.Map{
-		"code": 0,
-		"msg":  "",
-		"data": way,
-	})
-}
-
-// @Summary 获得回款列表
-// @Tags 合同管理-收入合同
-// @Description 获得回款列表
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/return/list [get]
-func (c *ContractApi) GetReturnList() {
-	returnData, err := c.ServiceContract.ValidRuleContractRetrun(c.Ctx)
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	returnList := c.ServiceContract.ReturnAll(projectId, bidsectionId, contractsId, returnData.Page)
-	//returnCount:=c.ServiceContract.ReturnCount(projectId, bidsectionId, contractsId,)
-	c.Ctx.JSON(iris.Map{
-		"code": 0,
-		"msg":  "",
-		"data": returnList,
-	})
-}
-
-// @Summary 新增回款内容
-// @Tags 合同管理-收入合同
-// @Description 新增回款内容
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   time     path    string     true        "回款时间"
-// @Param   Price     path    string     true        "回款金额"
-// @Param   Way     path    string     true        "回款方式"
-// @Param   remarks     path    string     true        "备注"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/return/create [post]
-func (c *ContractApi) PostReturnCreate() {
-	// 验证参数
-	returnData, err := c.ServiceContract.ValidRuleContractRetrunAdd(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 获得项目账号ID
-	projectAccountId, err := utils.GetProjectAccountId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	account := c.Ctx.Values().Get("account").(*models.CmProjectAccount)
-	returnData.CreateUser = account.Name
-
-	err = c.ServiceContract.ReturnCreate(returnData, projectId, bidsectionId, contractsId, projectAccountId)
-	contractData := c.ServiceContract.GetContract(contractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功", "contract": contractData})
-}
-
-// @Summary 更新回款内容
-// @Tags 合同管理-收入合同
-// @Description 更新回款内容
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "回款ID"
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   time     path    string     true        "回款时间"
-// @Param   Price     path    string     true        "回款金额"
-// @Param   Way     path    string     true        "回款方式"
-// @Param   remarks     path    string     true        "备注"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/return/update [post]
-func (c *ContractApi) PostReturnUpdate() {
-	// 验证参数
-	returnData, err := c.ServiceContract.ValidRuleContractRetrunAdd(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	if returnData.Id == "" {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "回款ID不能为空"})
-		return
-	}
-	// 回款ID
-	id, err := utils.GetDecryptId(returnData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.ReturnUpdate(returnData, projectId, bidsectionId, contractsId, id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
-}
-
-// @Summary 删除回款
-// @Tags 合同管理-收入合同
-// @Description 删除回款
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   id     path    string     true        "回款ID"
-// @Param   contractsId     path    string     true        "合同ID"
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,msg:错误信息}"
-// @Router /api/contract/return/delete [delete]
-func (c *ContractApi) DeleteReturnDelete() {
-	// 验证参数
-	returnData, err := c.ServiceContract.ValidRuleContractRetrunDel(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 项目ID
-	projectId, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(returnData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 合同ID
-	contractsId, err := utils.GetDecryptId(returnData.ContractsId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 回款ID
-	id, err := utils.GetDecryptId(returnData.Id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	err = c.ServiceContract.ReturnDelete(projectId, bidsectionId, contractsId, id)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
-}

+ 152 - 201
web/api/contract_section_tree_api.go

@@ -34,37 +34,36 @@ func (c *ContractApi) PostSectionDepth() {
 		return
 	}
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
-
-	err = c.ServiceContract.MoveDepth(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
+
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
+
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
+
+	err = c.ServiceContract.MoveDepth(sectionData)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 	}
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+	// treeId, _ := utils.GetDecryptId(sectionData.Id)
+	// sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{
-		"code":    0,
-		"msg":     "操作成功",
-		"section": sectionDetail,
+		"code": 0,
+		"msg":  "操作成功",
 	})
 }
 
@@ -88,24 +87,24 @@ func (c *ContractApi) PostSectionSerial() {
 		return
 	}
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
-
-	err = c.ServiceContract.MoveSerial(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
+
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
+
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
+
+	err = c.ServiceContract.MoveSerial(sectionData)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -113,13 +112,13 @@ func (c *ContractApi) PostSectionSerial() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+	// treeId, _ := utils.GetDecryptId(sectionData.Id)
+	// sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{
-		"code":    0,
-		"msg":     "操作成功",
-		"section": sectionDetail,
+		"code": 0,
+		"msg":  "操作成功",
+		// "section": sectionDetail,
 	})
 }
 
@@ -143,24 +142,24 @@ func (c *ContractApi) PostSectionSerialUpdate() {
 		return
 	}
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-		return
-	}
-
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
-
-	err = c.ServiceContract.UpdateSerial(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
+
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
+	// 	return
+	// }
+
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
+
+	err = c.ServiceContract.UpdateSerial(sectionData)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -168,13 +167,13 @@ func (c *ContractApi) PostSectionSerialUpdate() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+	// treeId, _ := utils.GetDecryptId(sectionData.Id)
+	// sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{
-		"code":    0,
-		"msg":     "操作成功",
-		"section": sectionDetail,
+		"code": 0,
+		"msg":  "操作成功",
+		// "section": sectionDetail,
 	})
 }
 
@@ -185,8 +184,6 @@ func (c *ContractApi) PostSectionSerialUpdate() {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   templateNumber     body    int     true        "模板号" default(1)
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section/template [post]
 func (c *ContractApi) PostSectionTemplate() {
@@ -199,38 +196,43 @@ func (c *ContractApi) PostSectionTemplate() {
 	}
 
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
 	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
+
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
+
+	//获得合同项目节
+	// sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, sectionData.TreeType)
+
+	err = c.ServiceContract.SetSection(sectionData.TemplateNumber)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 	}
 
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
+	if err != nil {
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 	}
-
-	//获得合同项目节
-	sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, sectionData.TreeType)
-
+	c.Ctx.JSON(iris.Map{"code": 0, "msg": "设置成功"})
 	// 1.未设置了项目节
-	if len(sectionTree.Children) == 0 {
-		err = c.ServiceContract.SetSection(sectionData.TemplateNumber, bidsectionId, projectIdInt, sectionData.TreeType)
-		if err != nil {
-			c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-			return
-		}
-		c.Ctx.JSON(iris.Map{"code": 0, "msg": "设置成功"})
-	} else {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "项目节已经设置"})
-		return
-	}
+	// if len(sectionTree.Children) == 0 {
+
+	// } else {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "项目节已经设置"})
+	// 	return
+	// }
 }
 
 // @Summary 新增 合同项目节
@@ -240,8 +242,6 @@ func (c *ContractApi) PostSectionTemplate() {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "项目节ID"
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Param   name     body    string     true        "项目节名称"
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section/add [post]
@@ -254,24 +254,24 @@ func (c *ContractApi) PostSectionAdd() {
 	}
 
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
-
-	_, err = c.ServiceContract.SectionAdd(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
+	// // 标段ID
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
+
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
+
+	_, err = c.ServiceContract.SectionAdd(sectionData)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -286,8 +286,6 @@ func (c *ContractApi) PostSectionAdd() {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "项目节ID"
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Param   name     body    string     true        "项目节名称"
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section/save [post]
@@ -300,24 +298,24 @@ func (c *ContractApi) PostSectionSave() {
 	}
 
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
-
-	err = c.ServiceContract.SectionSave(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
+	// // 标段ID
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
+
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
+
+	err = c.ServiceContract.SectionSave(sectionData)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -325,10 +323,10 @@ func (c *ContractApi) PostSectionSave() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+	// treeId, _ := utils.GetDecryptId(sectionData.Id)
+	// sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功", "section": sectionDetail})
+	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功"})
 }
 
 // @Summary 删除 合同项目节
@@ -338,8 +336,6 @@ func (c *ContractApi) PostSectionSave() {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "项目节ID"
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section [delete]
 func (c *ContractApi) DeleteSection() {
@@ -351,17 +347,17 @@ func (c *ContractApi) DeleteSection() {
 	}
 
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
+	// // 标段ID
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
 	// 项目节ID
 	treeId, err := utils.GetDecryptId(sectionData.Id)
 	if err != nil {
@@ -369,60 +365,15 @@ func (c *ContractApi) DeleteSection() {
 		return
 	}
 
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
 
-	err = c.ServiceContract.SectionDelete(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+	err = c.ServiceContract.SectionDelete(treeId)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
 	}
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功"})
 }
-
-// @Summary 获得项目节(不含合同)
-// @Tags 合同管理-项目节
-// @Description 获得项目节(不含合同)
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   treeType     path    int     true        "项目节类型(0收入,1支出)"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/section/not [get]
-func (c *ContractApi) GetSectionNot() {
-
-	// 验证规则
-	sectionData, err := c.ServiceContract.ValidRuleSectionNot(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	// 解密
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
-		return
-	}
-
-	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
-
-	//获得合同项目节
-	sectionTree := c.ServiceContract.GetSecionTreeNotContract(bidsectionId, projectIdInt, sectionData.TreeType)
-
-	// 2.已设置项目节
-	c.Ctx.JSON(iris.Map{
-		"code":        0,
-		"msg":         "",
-		"sectionTree": sectionTree,
-	})
-
-}

+ 0 - 54
web/viewmodels/contracts_paid.go

@@ -1,54 +0,0 @@
-/*
- * @description:合同已支出-视图
- * @Author: CP
- * @Date: 2020-12-22 14:25:47
- * @FilePath: \construction_management\web\viewmodels\contracts_paid.go
- */
-package viewmodels
-
-import validation "github.com/go-ozzo/ozzo-validation/v3"
-
-type ContractsPaid struct {
-	Id           string `form:"id" json:"id" `
-	ContractsId  string `form:"contractsId" json:"contractsId" `
-	ProjectId    string `form:"projectId" json:"projectId" `
-	BidsectionId string `form:"bidsectionId" json:"bidsectionId" `
-	Time         string `form:"time" json:"time" `
-	Price        string `form:"price" json:"price" `
-	Way          string `form:"way" json:"way" `
-	CreateUser   string `form:"createUser" json:"createUser" `
-	AccountId    string `form:"accountId" json:"accountId" `
-	Remarks      string `form:"remarks" json:"remarks" `
-	CreateTime   string `form:"createTime" json:"createTime" `
-	FileCounts   int64  `from:"fileCounts" json:"fileCounts"`
-
-	Page int `form:"page" json:"page" `
-}
-
-// 验证方法
-func (l ContractsPaid) Validate() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-		validation.Field(&l.Page, validation.Required.Error("页数不能为空")),
-	)
-}
-
-// 验证方法
-func (l ContractsPaid) ValidateAdd() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-		validation.Field(&l.Time, validation.Required.Error("支付时间不能为空")),
-		validation.Field(&l.Price, validation.Required.Error("金额不能为空")),
-		validation.Field(&l.Way, validation.Required.Error("合同类型不能为空"), validation.In("支票", "现金", "网上转账", "电汇", "邮政汇款", "支付宝", "微信支付", "其他").Error("未找到相关回款类型")),
-	)
-}
-
-func (l ContractsPaid) ValidateDel() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.Id, validation.Required.Error("已支付ID不能为空")),
-		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-	)
-}

+ 0 - 55
web/viewmodels/contracts_return.go

@@ -1,55 +0,0 @@
-/*
- * @description: 合同回款-视图
- * @Author: CP
- * @Date: 2020-11-27 14:51:44
- * @FilePath: \construction_management\web\viewmodels\contracts_return.go
- */
-package viewmodels
-
-import validation "github.com/go-ozzo/ozzo-validation/v3"
-
-type ContractsReturn struct {
-	Id           string `form:"id" json:"id" `
-	ContractsId  string `form:"contractsId" json:"contractsId" `
-	ProjectId    string `form:"projectId" json:"projectId" `
-	BidsectionId string `form:"bidsectionId" json:"bidsectionId" `
-	// TreeId       string `form:"treeId" json:"treeId" `
-	Time       string `form:"time" json:"time" `
-	Price      string `form:"price" json:"price" `
-	Way        string `form:"way" json:"way" `
-	CreateUser string `form:"createUser" json:"createUser" `
-	AccountId  string `form:"accountId" json:"accountId" `
-	Remarks    string `form:"remarks" json:"remarks" `
-	CreateTime string `form:"createTime" json:"createTime" `
-	FileCounts int64  `from:"fileCounts" json:"fileCounts"`
-
-	Page int `form:"page" json:"page" `
-}
-
-// 验证方法
-func (l ContractsReturn) Validate() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-		validation.Field(&l.Page, validation.Required.Error("页数不能为空")),
-	)
-}
-
-// 验证方法
-func (l ContractsReturn) ValidateAdd() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-		validation.Field(&l.Time, validation.Required.Error("回款时间不能为空")),
-		validation.Field(&l.Price, validation.Required.Error("金额不能为空")),
-		validation.Field(&l.Way, validation.Required.Error("合同类型不能为空"), validation.In("支票", "现金", "网上转账", "电汇", "邮政汇款", "支付宝", "微信支付", "其他").Error("未找到相关回款类型")),
-	)
-}
-
-func (l ContractsReturn) ValidateDel() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.Id, validation.Required.Error("回款ID不能为空")),
-		validation.Field(&l.ContractsId, validation.Required.Error("合同ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-	)
-}

+ 27 - 33
web/viewmodels/tree_section_contract.go

@@ -14,25 +14,25 @@ import (
 // IsEnd 为true 不能下移
 
 type TreeSectionContract struct {
-	Id           string `form:"id" json:"id" `
-	TreeType     int    `form:"treeType" json:"treeType"`
-	ParentId     string `form:"parentId" json:"parentId"`
-	Name         string `form:"name" json:"name"`
-	Depth        int    `form:"depth" json:"depth"`
-	Serial       int    `form:"serial" json:"serial"`
-	Attribution  string `form:"attribution" json:"attribution"`
-	Code         string `form:"code" json:"code"`
-	ProjectId    string `form:"projectId" json:"projectId"`
-	BidsectionId string `form:"bidsectionId" json:"bidsectionId"`
-	ContractId   string `form:"contractId" json:"contractId"`
-
-	ContractName     string `form:"contractName" json:"contractName"`
-	ContractCode     string `form:"contractCode" json:"contractCode"`
-	ContractPrice    string `form:"contractPrice" json:"contractPrice"`
-	ContractReturned string `form:"contractReturned" json:"contractReturned"`
-	ContractsPaid    string `form:"contractsPaid" json:"contractsPaid"`
-	ContractStatus   int    `form:"contractStatus" json:"contractStatus"`
-	ContractLocking  int    `form:"contractLocking" json:"contractLocking"`
+	Id string `form:"id" json:"id" `
+	// TreeType     int    `form:"treeType" json:"treeType"`
+	ParentId    string `form:"parentId" json:"parentId"`
+	Name        string `form:"name" json:"name"`
+	Depth       int    `form:"depth" json:"depth"`
+	Serial      int    `form:"serial" json:"serial"`
+	Attribution string `form:"attribution" json:"attribution"`
+	Code        string `form:"code" json:"code"`
+	// ProjectId    string `form:"projectId" json:"projectId"`
+	// BidsectionId string `form:"bidsectionId" json:"bidsectionId"`
+	ContractId string `form:"contractId" json:"contractId"`
+
+	// ContractName     string `form:"contractName" json:"contractName"`
+	// ContractCode     string `form:"contractCode" json:"contractCode"`
+	// ContractPrice    string `form:"contractPrice" json:"contractPrice"`
+	// ContractReturned string `form:"contractReturned" json:"contractReturned"`
+	// ContractsPaid    string `form:"contractsPaid" json:"contractsPaid"`
+	// ContractStatus   int    `form:"contractStatus" json:"contractStatus"`
+	// ContractLocking  int    `form:"contractLocking" json:"contractLocking"`
 
 	CreateTime string                 `form:"createTime" json:"createTime"`
 	Children   []*TreeSectionContract `json:"children"`
@@ -41,39 +41,33 @@ type TreeSectionContract struct {
 	Operation      string `form:"operation" json:"operation"`
 	ElderBrother   bool   `form:"elderBrother" json:"elderBrother"`
 	IsEnd          bool   `form:"isEnd" json:"isEnd"`
-
-	// 前端需要
-	Key   string `form:"key" json:"key"`
-	Value string `form:"value" json:"value"`
-	Title string `form:"title" json:"title"`
 }
 
 func (l TreeSectionContract) ValidateDepth() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
 		validation.Field(&l.Operation, validation.Required.Error("操作名称不能为空"), validation.In("upDepth", "downDepth", "upSerial", "downSerial").Error("未找到相关操作")),
 	)
 }
 
 func (l TreeSectionContract) ValidateSectionNot() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.TreeType, validation.In(0, 1).Error("请输入数字0或1")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-	)
+	return validation.ValidateStruct(&l) // validation.Field(&l.TreeType, validation.In(0, 1).Error("请输入数字0或1")),
+	// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+
 }
 
 func (l TreeSectionContract) ValidateTemplate() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.TemplateNumber, validation.Required.Error("模板号不能为空"), validation.In(1, 2).Error("未找到相关模板")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
 	)
 }
 
 func (l TreeSectionContract) ValidateSectionAdd() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
 		// validation.Field(&l.Name, validation.Required.Error("项目节名称不能为空")),
 	)
 }
@@ -81,7 +75,7 @@ func (l TreeSectionContract) ValidateSectionAdd() error {
 func (l TreeSectionContract) ValidateSectionDelete() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
 	)
 }
 
@@ -89,7 +83,7 @@ func (l TreeSectionContract) ValidateSectionDelete() error {
 func (l TreeSectionContract) ValidateSectionSerial() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),
-		validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
 		validation.Field(&l.Serial, validation.Required.Error("序号不能为空")),
 	)
 }