ziwen 2 жил өмнө
parent
commit
7154332dfd

+ 10 - 0
controller/contract/pre_payment.go

@@ -162,6 +162,16 @@ func (rg *PrePaymentController) Add(c *gin.Context) {
 		resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
 		return
 	}
+	//// 开票到款汇总
+	//nowTime := time.Now().Local()
+	//v := new(fms.InvoicePaymentSummary)
+	//v.CreateTime = nowTime
+	//v.ModifyTime = nowTime
+	//v.PrePayid = ob.PrePayId
+	//
+	//if e = v.Create(); e != nil {
+	//	err = fmt.Errorf("新增汇总数据失败, Err: %s", e.Error())
+	//}
 
 	resp.Ok("操作成功", c)
 }

+ 8 - 5
controller/contract/register.go

@@ -274,17 +274,18 @@ func (rg *RegisterController) Add(c *gin.Context) {
 
 	// 新增合同及套餐
 	if req.Supplement == 1 {
-		//新增合同信息
-		if e = fms.CreateContractRegisterAndServicesAndPayMent(ob, serviceList, req.PrePayId); e != nil {
-			resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
-			return
-		}
 		//新增到款信息
 		if ob.HasPayment == 1 {
 			resp.Fail("合同存在代付不允许添加开票/到款登记", c)
 			return
 		}
 
+		//新增合同信息
+		if e = fms.CreateContractRegisterAndServicesAndPayMent(ob, serviceList, req.PrePayId); e != nil {
+			resp.FailMsg("操作失败", "新增合同及套餐失败, Err: "+e.Error(), c)
+			return
+		}
+
 		prePayOB := new(fms.ContractPrePayment)
 		ppItem, e := prePayOB.Fetch(req.PrePayId)
 		if e != nil {
@@ -361,6 +362,8 @@ func (rg *RegisterController) Add(c *gin.Context) {
 			resp.FailMsg("删除预到款记录失败", "Err:"+e.Error(), c)
 			return
 		}
+		// 校验金额-是否修改状态
+		go fmsService.CheckContractRegisterAmount(ob.ContractRegisterId)
 
 		// 开票到款汇总
 		go fmsService.SummaryInvoicePaymentByContractRegisterId(ob.ContractRegisterId)

+ 4 - 0
models/fms/invoice_payment_summary.go

@@ -21,6 +21,10 @@ func (c *InvoicePaymentSummary) TableName() string {
 	return "invoice_payment_summary"
 }
 
+func (c *InvoicePaymentSummary) Create() (err error) {
+	err = global.DEFAULT_MYSQL.Create(c).Error
+	return
+}
 // DeleteAndCreate 删除并新增汇总
 func (c *InvoicePaymentSummary) DeleteAndCreate(registerId int, summaryList []*InvoicePaymentSummary) (err error) {
 	tx := global.DEFAULT_MYSQL.Begin()