caipin 1 gadu atpakaļ
vecāks
revīzija
41e9dbe002

+ 2 - 2
comm/functions.go

@@ -429,14 +429,14 @@ func AesDecrypt(cryted string, key string) (string, error) {
 	return string(orig), nil
 }
 
-//补码
+// 补码
 func PKCS7Padding(ciphertext []byte, blocksize int) []byte {
 	padding := blocksize - len(ciphertext)%blocksize
 	padtext := bytes.Repeat([]byte{byte(padding)}, padding)
 	return append(ciphertext, padtext...)
 }
 
-//去码
+// 去码
 func PKCS7UnPadding(origData []byte) []byte {
 	length := len(origData)
 	unpadding := int(origData[length-1])

+ 8 - 3
dao/contract_paid_dao.go

@@ -109,14 +109,18 @@ func (d *ContractPaidDao) UpdatePaidTotalPrice(projectId int, bidsectionId int,
 	contractsPrice := 0.00
 	// 扣款金额合计
 	contractDeductionTotal := 0.00
+	// 总扣款金额
+	contractDeductionPrice := 0.00
 	for _, item := range datalist {
 		price, _ := strconv.ParseFloat(item.Price, 64)
 		priceTotal = priceTotal + price
 
+		contractDeduction, _ := strconv.ParseFloat(item.ContractDeduction, 64)
+		contractDeductionPrice = contractDeductionPrice + contractDeduction
+
 		if item.ContractsId == contractsId {
 			contractsPrice = contractsPrice + price
 
-			contractDeduction, _ := strconv.ParseFloat(item.ContractDeduction, 64)
 			contractDeductionTotal = contractDeductionTotal + contractDeduction
 		}
 	}
@@ -145,8 +149,9 @@ func (d *ContractPaidDao) UpdatePaidTotalPrice(projectId int, bidsectionId int,
 		session.Rollback()
 		return errors.New("金额更新失败")
 	}
-	// 4.更新标段树 整个标段下回款总金额
-	_, err = session.Exec("UPDATE  cm_tree SET `contracts_paid` = ? where project_id = ? and bidsection_id=? ", priceTotal, projectId, bidsectionId)
+	// 4.更新标段树 整个标段下回款总金额 TODO
+	_, err = session.Exec("UPDATE  cm_tree SET `contracts_paid` = ? ,contract_deduction_total = ? where project_id = ? and bidsection_id=? ",
+		priceTotal, contractDeductionPrice, projectId, bidsectionId)
 	if err != nil {
 		session.Rollback()
 		return errors.New("金额更新失败")

+ 3 - 3
services/contract_paid_service.go

@@ -60,8 +60,8 @@ func (s *contractService) PaidCreate(returnData *viewmodels.ContractsPaid, proje
 	paidPrice, _ := decimal.NewFromString(contract.Paid)
 	paidContractDeductionTotal, _ := decimal.NewFromString(contract.ContractDeductionTotal)
 	resultPrice := contractPrice.Sub(paidPrice)
-	resultPrice = resultPrice.Add(contractDeductionPrice)
-	resultPrice = resultPrice.Add(paidContractDeductionTotal)
+	resultPrice = resultPrice.Sub(contractDeductionPrice)
+	resultPrice = resultPrice.Sub(paidContractDeductionTotal)
 
 	//  合同额-已支付金额+已扣款金额
 	if price.GreaterThan(resultPrice) {
@@ -138,7 +138,7 @@ func (s *contractService) PaidUpdate(returnData *viewmodels.ContractsPaid, proje
 	subPrice := paidPrice.Sub(returnedPresentPrice)
 	// 合同金额-subPrice
 	resultPrice := contractPrice.Sub(subPrice)
-	resultPrice = resultPrice.Add(paidContractDeductionTotal)
+	resultPrice = resultPrice.Sub(paidContractDeductionTotal)
 
 	if price.GreaterThan(resultPrice) {
 		return errors.New("支付金额不能超过合同金额")

+ 3 - 0
services/contract_section_tree_service.go

@@ -468,6 +468,9 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
 
 	section.CreateTime = data.CreateTime.Format(conf.SysTimeform)
 
+	section.ContractDeductionTotal = data.ContractDeductionTotal
+	section.SettlementCode = data.SettlementCode
+
 	//
 	section.Title = fmt.Sprintf("%s%d ", data.Attribution, data.Serial) + data.Name
 	section.Key = id

+ 2 - 0
web/viewmodels/folder_contract.go

@@ -25,6 +25,8 @@ type FolderContract struct {
 	ContractsPaid           string `form:"contractsPaid" json:"contractsPaid"`
 	ContractsPayProgress    string `form:"contractsPayProgress" json:"contractsPayProgress"`
 
+	ContractDeductionTotal string `form:"contractDeductionTotal" json:"contractDeductionTotal"`
+
 	// 安全巡检字段-后期做接口后移动-TODO
 	SafeTotal               int `form:"safeTotal" json:"safeTotal"`
 	SafeRectification       int `form:"safeRectification" json:"safeRectification"`

+ 4 - 1
web/viewmodels/tree_section_contract.go

@@ -42,6 +42,9 @@ type TreeSectionContract struct {
 	ElderBrother   bool   `form:"elderBrother" json:"elderBrother"`
 	IsEnd          bool   `form:"isEnd" json:"isEnd"`
 
+	ContractDeductionTotal string `form:"contractDeductionTotal" json:"contractDeductionTotal"`
+	SettlementCode         string `form:"settlementCode" json:"settlementCode"`
+
 	// 前端需要
 	Key   string `form:"key" json:"key"`
 	Value string `form:"value" json:"value"`
@@ -85,7 +88,7 @@ func (l TreeSectionContract) ValidateSectionDelete() error {
 	)
 }
 
-//is.Int.Error("请检查输入是否是整形")  validation.Match(regexp.MustCompile("^[0-9]*$")).Error("请检查输入是否是整形")
+// is.Int.Error("请检查输入是否是整形")  validation.Match(regexp.MustCompile("^[0-9]*$")).Error("请检查输入是否是整形")
 func (l TreeSectionContract) ValidateSectionSerial() error {
 	return validation.ValidateStruct(&l,
 		validation.Field(&l.Id, validation.Required.Error("项目节ID不能为空")),