caipin преди 4 години
родител
ревизия
64f7669c02
променени са 4 файла, в които са добавени 36 реда и са изтрити 8 реда
  1. 2 2
      dao/contract_paid_dao.go
  2. 4 4
      dao/contract_return_dao.go
  3. 13 1
      services/contract_paid_service.go
  4. 17 1
      services/contract_return_service.go

+ 2 - 2
dao/contract_paid_dao.go

@@ -123,13 +123,13 @@ func (d *ContractPaidDao) UpdatePaidTotalPrice(projectId int, bidsectionId int,
 	}
 
 	// 2.更新合同表 合同下回款总金额
-	_, err = session.Exec("UPDATE  cm_contracts SET `paid` = ? , status = ? where id = ? ", contractsPrice, contractStatus, contractsId)
+	_, err = session.Exec("UPDATE  cm_contracts SET `paid` = ? , status = ?,locking=0 where id = ? ", contractsPrice, contractStatus, contractsId)
 	if err != nil {
 		session.Rollback()
 		return errors.New("金额更新失败")
 	}
 	// 3.更新项目节 合同下回款总金额
-	_, err = session.Exec("UPDATE  cm_tree_contracts SET `contracts_paid` = ? , contract_status = ? where project_id = ? and bidsection_id=? and contract_id=? ",
+	_, err = session.Exec("UPDATE  cm_tree_contracts SET `contracts_paid` = ? , contract_status = ?,contract_locking=0 where project_id = ? and bidsection_id=? and contract_id=? ",
 		contractsPrice, contractStatus, projectId, bidsectionId, contractsId)
 	if err != nil {
 		session.Rollback()

+ 4 - 4
dao/contract_return_dao.go

@@ -78,9 +78,9 @@ func (d *ContractReturnDao) Add(contractsReturn *models.CmContractsReturn) error
 }
 
 // 更新回款
-func (d *ContractReturnDao) Update(contractsReturn *models.CmContractsReturn, contracts_id int, bidsectionId int) error {
+func (d *ContractReturnDao) Update(contractsReturn *models.CmContractsReturn, contracts_id int, bidsectionId int, columns []string) error {
 
-	_, err := d.engine.Where("id = ? and contracts_id = ? and bidsection_id=? ", contractsReturn.Id, contracts_id, bidsectionId).Update(contractsReturn)
+	_, err := d.engine.Where("id = ? and contracts_id = ? and bidsection_id=? ", contractsReturn.Id, contracts_id, bidsectionId).MustCols(columns...).Update(contractsReturn)
 
 	return err
 }
@@ -139,13 +139,13 @@ func (d *ContractReturnDao) UpdateTotalPrice(projectId int, bidsectionId int, co
 	}
 
 	// 2.更新合同表 合同下回款总金额
-	_, err = session.Exec("UPDATE  cm_contracts SET `returned` = ? , status = ? where id = ? ", contractsPrice, contractStatus, contractsId)
+	_, err = session.Exec("UPDATE  cm_contracts SET `returned` = ? , status = ?,locking=0 where id = ? ", contractsPrice, contractStatus, contractsId)
 	if err != nil {
 		session.Rollback()
 		return errors.New("金额更新失败")
 	}
 	// 3.更新项目节 合同下回款总金额
-	_, err = session.Exec("UPDATE  cm_tree_contracts SET `contract_returned` = ? , contract_status = ? where project_id = ? and bidsection_id=? and contract_id=? ",
+	_, err = session.Exec("UPDATE  cm_tree_contracts SET `contract_returned` = ? , contract_status = ?,contract_locking=0 where project_id = ? and bidsection_id=? and contract_id=? ",
 		contractsPrice, contractStatus, projectId, bidsectionId, contractsId)
 	if err != nil {
 		session.Rollback()

+ 13 - 1
services/contract_paid_service.go

@@ -42,6 +42,10 @@ func (s *contractService) PaidCreate(returnData *viewmodels.ContractsPaid, proje
 	if contract.Id == 0 {
 		return errors.New("未找到合同")
 	}
+	// 1-2 合同关闭 不能操作
+	if contract.Status == 2 {
+		return errors.New("合同已关闭")
+	}
 
 	// 2.已支付信息
 	contractsReturnCm := &models.CmContractsPaid{}
@@ -95,6 +99,11 @@ func (s *contractService) PaidUpdate(returnData *viewmodels.ContractsPaid, proje
 	if contractPaid.Id == 0 {
 		return errors.New("未找到已支付")
 	}
+	// 1-2 合同关闭 不能操作
+	if contract.Status == 2 {
+		return errors.New("合同已关闭")
+	}
+
 	// 2.已支付信息
 	contractsReturnCm := &models.CmContractsPaid{}
 	contractsReturnCm.Id = id
@@ -141,7 +150,10 @@ func (s *contractService) PaidDelete(projectId int, bidsectionId int, contractsI
 	if contractPaid.Id == 0 {
 		return errors.New("未找到已支付")
 	}
-
+	// 1-2 合同关闭 不能操作
+	if contract.Status == 2 {
+		return errors.New("合同已关闭")
+	}
 	// 3.合同锁定 不能删除
 	if contract.Locking == 1 {
 		return errors.New("该合同已锁定")

+ 17 - 1
services/contract_return_service.go

@@ -127,6 +127,10 @@ func (s *contractService) ReturnCreate(returnData *viewmodels.ContractsReturn, p
 	if contract.Id == 0 {
 		return errors.New("未找到合同")
 	}
+	// 1-2 合同关闭 不能操作回款
+	if contract.Status == 2 {
+		return errors.New("合同已关闭")
+	}
 
 	// 2.回款信息
 	contractsReturnCm := &models.CmContractsReturn{}
@@ -180,6 +184,11 @@ func (s *contractService) ReturnUpdate(returnData *viewmodels.ContractsReturn, p
 	if contractReturn.Id == 0 {
 		return errors.New("未找到回款")
 	}
+	// 1-2 合同关闭 不能操作回款
+	if contract.Status == 2 {
+		return errors.New("合同已关闭")
+	}
+
 	// 2.回款信息
 	contractsReturnCm := &models.CmContractsReturn{}
 	contractsReturnCm.Id = id
@@ -199,8 +208,10 @@ func (s *contractService) ReturnUpdate(returnData *viewmodels.ContractsReturn, p
 	}
 	contractsReturnCm.Price = returnData.Price
 
+	columns := []string{"Way", "Remarks", "Time", "Price"}
+
 	// 3.更新回款信息
-	err = s.contractReturnDao.Update(contractsReturnCm, contractsId, bidsectionId)
+	err = s.contractReturnDao.Update(contractsReturnCm, contractsId, bidsectionId, columns)
 	if err != nil {
 		return err
 	}
@@ -221,6 +232,11 @@ func (s *contractService) ReturnDelete(projectId int, bidsectionId int, contract
 	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 {