caipin 4 vuotta sitten
vanhempi
commit
2c82a36582
4 muutettua tiedostoa jossa 76 lisäystä ja 19 poistoa
  1. 21 0
      models/cm_contracts.go
  2. 27 0
      models/cm_tree_contracts.go
  3. 9 0
      services/contract_service.go
  4. 19 19
      web/api/contract_api.go

+ 21 - 0
models/cm_contracts.go

@@ -0,0 +1,21 @@
+package models
+
+import (
+	"time"
+)
+
+type CmContracts struct {
+	Id            int       `xorm:"not null pk autoincr comment('自增ID') INT(11)"`
+	TreeId        int       `xorm:"not null default 0 comment('树ID') INT(11)"`
+	ContractsType int       `xorm:"not null comment('合同类型(1收入合同2支出合同)') TINYINT(1)"`
+	ProjectId     int       `xorm:"not null default 0 comment('项目ID') INT(11)"`
+	BidsectionId  int       `xorm:"comment('标段ID') INT(11)"`
+	Name          string    `xorm:"not null comment('名称') VARCHAR(64)"`
+	Code          string    `xorm:"comment('合同编号') VARCHAR(32)"`
+	Price         string    `xorm:"not null comment('合同金额 0') DECIMAL(12,2)"`
+	Returned      string    `xorm:"not null comment('回款总金额 0') DECIMAL(12,2)"`
+	Paid          string    `xorm:"not null default 0.00 comment('合同已支付金额 0') DECIMAL(12,2)"`
+	Status        int       `xorm:"not null comment('合同状态 0') TINYINT(1)"`
+	CreateTime    time.Time `xorm:"comment('创建时间') DATETIME"`
+	UpdateTime    time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
+}

+ 27 - 0
models/cm_tree_contracts.go

@@ -0,0 +1,27 @@
+package models
+
+import (
+	"time"
+)
+
+type CmTreeContracts struct {
+	Id               int       `xorm:"not null pk autoincr comment('自增ID') INT(11)"`
+	TreeId           int       `xorm:"not null comment('树ID') TINYINT(4)"`
+	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('合同状态') TINYINT(1)"`
+	CreateTime       time.Time `xorm:"comment('创建时间') DATETIME"`
+}

+ 9 - 0
services/contract_service.go

@@ -12,6 +12,7 @@ import (
 	"github.com/kataras/iris/v12"
 	"go.mod/dao"
 	"go.mod/datasource"
+	"go.mod/models"
 	"go.mod/web/viewmodels"
 )
 
@@ -35,11 +36,14 @@ type ContractService interface {
 	SectionDelete(treeId int, bidsectionId int, projectId int) error
 	MoveDepth(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error
 	MoveSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error
+
+	GetContract(contractId int) *models.CmContracts
 }
 
 //返回service操作类
 type contractService struct {
 	treeContractDao *dao.TreeContractDao
+	contractDao     *dao.ContractDao
 	// dao *dao.ProjectAccountDao
 	// projectDao        *dao.ProjectDao
 	// bidsectionDao     *dao.BidsectionDao
@@ -177,3 +181,8 @@ func (s *contractService) Get(treeId int, bidsectionId int, projectId int) *view
 func (s *contractService) GetAll() {
 
 }
+
+// 获得合同详情
+func (s *contractService) GetContract(contractId int) *models.CmContracts {
+	return s.contractDao.Get(contractId)
+}

+ 19 - 19
web/api/contract_api.go

@@ -9,6 +9,7 @@ package api
 import (
 	"github.com/kataras/iris/v12"
 	"go.mod/lib"
+	"go.mod/models"
 	"go.mod/services"
 	"go.mod/web/utils"
 	"go.mod/web/viewmodels"
@@ -50,7 +51,7 @@ func (c *ContractApi) GetFolder() {
 	})
 }
 
-// @Summary 获得合同信息
+// @Summary 获得标段收入-项目节信息
 // @Tags 合同管理
 // @Description 未设置合同项目节 返回项目节模板信息
 // @Accept  json
@@ -58,8 +59,8 @@ func (c *ContractApi) GetFolder() {
 // @Security ApiKeyAuth
 // @Param   bidsectionId     path    string     true        "标段ID"
 // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/income [get]
-func (c *ContractApi) GetIncome() {
+// @Router /api/contract/income/section/all [get]
+func (c *ContractApi) GetIncomeSectionAll() {
 
 	sectionData := viewmodels.TreeSectionContract{}
 	err := c.Ctx.ReadForm(&sectionData)
@@ -115,7 +116,7 @@ func (c *ContractApi) GetIncome() {
 	}
 }
 
-// @Summary 获得合同详情和项目节详情
+// @Summary 单个合同详情和项目节详情
 // @Tags 合同管理
 // @Description 获得合同详情和项目节详情
 // @Accept  json
@@ -124,12 +125,12 @@ func (c *ContractApi) GetIncome() {
 // @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 [get]
-func (c *ContractApi) Get() {
+// @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": "解析参数出错"})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
 		return
 	}
 
@@ -142,13 +143,13 @@ func (c *ContractApi) Get() {
 	// 3.标段ID
 	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
 	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "ReadJSON转换异常,请检查参数"})
+		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": "ReadJSON转换异常,请检查参数"})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
 		return
 	}
 
@@ -161,24 +162,23 @@ func (c *ContractApi) Get() {
 	if len(contractList) == 0 {
 		isContract = false
 	}
-	// // 获得合同详情
-	// contractId, err := utils.GetDecryptId(section.ContractId)
-	// if err != nil {
-	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
-	// 	return
-	// }
-	// contract := c.ServiceContract.GetContract(contractId)
+	// 获得合同详情
+	contractId, _ := utils.GetDecryptId(section.ContractId)
+	contract := &models.CmContracts{}
+	if contractId != 0 {
+		contract = c.ServiceContract.GetContract(contractId)
+	}
 	c.Ctx.JSON(iris.Map{
 		"code":       0,
 		"msg":        "",
 		"section":    section,
-		"isContract": isContract,
-		// "contract":   contract,
+		"isContract": isContract, //该项目节(包含子孙)下是否有合同
+		"contract":   contract,
 	})
 }
 
 // 新增合同
-func (c *ContractApi) PostCreate() {
+func (c *ContractApi) PostIncomeCreate() {
 
 	// // 获得模板号
 	// sectionData, err := c.ServiceContract.ValidRuleAdd(c.Ctx)