Pārlūkot izejas kodu

交费回调走协程

baichengfei 5 gadi atpakaļ
vecāks
revīzija
8d927b92e2

+ 36 - 33
src/dashoo.cn/backend/api/controllers/oilsupplier/paymentinfo.go

@@ -257,7 +257,6 @@ func (this *PaymentInfoController) GetBillInfo() {
 	regSvc := register.GetOilCorporateInfoService(utils.DBE)
 	supplierSvc := supplier.GetOilSupplierService(utils.DBE)
 
-
 	commercialNo := this.GetString("commercialNo")
 	fmt.Println(commercialNo)
 
@@ -398,7 +397,7 @@ func (this *PaymentInfoController) ReceiveMoneyBillListCopy() {
 		if payItem.PayType == "1" { //准入
 
 			var cert suppliercert.OilSupplierCert
-			svc.GetEntityById(payItem.SupplierCertId,&cert)
+			svc.GetEntityById(payItem.SupplierCertId, &cert)
 
 			/*svcActiviti := workflow.GetActivitiService(utils.DBE)
 			businessKey := strconv.Itoa(payItem.SupplierCertId)
@@ -536,7 +535,6 @@ func (this *PaymentInfoController) ReceiveMoneyBillListCopy() {
 	cols := []string{"WorkflowId"}
 	svc.UpdateEntityByIdCols(ivinfo.Id, &ivinfo, cols)
 
-
 	//记录对账日志
 	paymentBankInfo := new(paymentbankinfo.OilPaymentBankInfo)
 	paymentBankInfo.BillIds = billParams.Ids
@@ -619,11 +617,13 @@ func (this *PaymentInfoController) ReceiveMoneyBillList() {
 			ActiComplete.Remarks = "交费成功。"
 			ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 
-			res := svcActiviti.TaskComplete(ActiComplete)
-			if res != "true" {
-				fmt.Println("工作流异常,请联系管理员!" + res)
-				//panic("工作流异常,请联系管理员!" + res)
-			}
+			go func() {
+				res := svcActiviti.TaskComplete(ActiComplete)
+				if res != "true" {
+					fmt.Println("工作流异常,请联系管理员!" + res)
+					//panic("工作流异常,请联系管理员!" + res)
+				}
+			}()
 		} else if payItem.PayType == "2" { //年审
 			//取出年审表信息
 			annualSrv := annualaudit.GetOilAnnualAuditService(utils.DBE)
@@ -638,11 +638,13 @@ func (this *PaymentInfoController) ReceiveMoneyBillList() {
 			ActiComplete.Remarks = "交费成功。"
 			ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 
-			res := svcActiviti.TaskComplete(ActiComplete)
-			if res != "true" {
-				fmt.Println("工作流异常,请联系管理员!" + res)
-				//panic("工作流异常,请联系管理员!" + res)
-			}
+			go func() {
+				res := svcActiviti.TaskComplete(ActiComplete)
+				if res != "true" {
+					fmt.Println("工作流异常,请联系管理员!" + res)
+					//panic("工作流异常,请联系管理员!" + res)
+				}
+			}()
 		} else if payItem.PayType == "3" { //增项
 			//取出增项表信息
 			appendSrv := suppliercertappend.GetOilSupplierCertAppendService(utils.DBE)
@@ -657,11 +659,13 @@ func (this *PaymentInfoController) ReceiveMoneyBillList() {
 			ActiComplete.Remarks = "交费成功。"
 			ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 
-			res := svcActiviti.TaskComplete(ActiComplete)
-			if res != "true" {
-				fmt.Println("工作流异常,请联系管理员!" + res)
-				//panic("工作流异常,请联系管理员!" + res)
-			}
+			go func() {
+				res := svcActiviti.TaskComplete(ActiComplete)
+				if res != "true" {
+					fmt.Println("工作流异常,请联系管理员!" + res)
+					//panic("工作流异常,请联系管理员!" + res)
+				}
+			}()
 		} else if payItem.PayType == "7" { // 信息变更
 			//取出信息变更表信息
 			infoSrv := infochange.GetInfoChangeService(utils.DBE)
@@ -676,11 +680,13 @@ func (this *PaymentInfoController) ReceiveMoneyBillList() {
 			ActiComplete.Remarks = "交费成功。"
 			ActiComplete.CallbackUrl = utils.Cfg.MustValue("workflow", "callbackHost")
 
-			res := svcActiviti.TaskComplete(ActiComplete)
-			if res != "true" {
-				fmt.Println("工作流异常,请联系管理员!" + res)
-				//panic("工作流异常,请联系管理员!" + res)
-			}
+			go func() {
+				res := svcActiviti.TaskComplete(ActiComplete)
+				if res != "true" {
+					fmt.Println("工作流异常,请联系管理员!" + res)
+					//panic("工作流异常,请联系管理员!" + res)
+				}
+			}()
 		}
 	}
 
@@ -720,7 +726,6 @@ func (this *PaymentInfoController) ReceiveMoneyBillList() {
 	cols := []string{"WorkflowId"}
 	svc.UpdateEntityByIdCols(invoiceInfo.Id, &invoiceInfo, cols)
 
-
 	//记录对账日志
 	paymentBankInfo := new(paymentbankinfo.OilPaymentBankInfo)
 	paymentBankInfo.BillIds = billParams.Ids
@@ -889,7 +894,6 @@ func (this *PaymentInfoController) DeleteEntity() {
 	}
 }
 
-
 // @Title 修改金额
 // @Description 修改实体
 // @Param 	body body paymentinfo.Paymentinfo
@@ -924,11 +928,10 @@ func (this *PaymentInfoController) AddPayInfo() {
 		return
 	}
 
-
 	where := "SupplierId=" + strconv.Itoa(supp.Id) + " and USCCode='" + supp.CommercialNo + "' and PayType='" + payType + "' and SupplierCertId=" + strconv.Itoa(cert[0].Id)
 	var model1 paymentinfo.OilPaymentInfo
 	has = svc.GetEntity(&model1, where)
-    if has {
+	if has {
 		errinfo.Message = "已经存在相关交费记录,不能重复添加!"
 		errinfo.Code = -2
 		this.Data["json"] = &errinfo
@@ -937,7 +940,7 @@ func (this *PaymentInfoController) AddPayInfo() {
 	}
 
 	var model paymentinfo.OilPaymentInfo
-	model.SupplierId,_ = strconv.Atoi(supplierId)
+	model.SupplierId, _ = strconv.Atoi(supplierId)
 	model.SupplierCertId = cert[0].Id
 	model.SupplierName = supp.SupplierName
 	model.USCCode = supp.CommercialNo
@@ -948,7 +951,7 @@ func (this *PaymentInfoController) AddPayInfo() {
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
 
-	_,err := svc.InsertEntity(&model)
+	_, err := svc.InsertEntity(&model)
 
 	if err == nil {
 		errinfo.Message = "添加成功!"
@@ -970,7 +973,7 @@ func (this *PaymentInfoController) AddPayInfo() {
 func (this *PaymentInfoController) GetDictList() {
 	dictList := make(map[string]interface{})
 	svcPerm := permission.GetPermissionService(utils.DBE)
-	isallowdel  := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.PaymentInfo.CanDelete")
+	isallowdel := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.PaymentInfo.CanDelete")
 	dictList["IsAllowDel"] = isallowdel
 	var datainfo DataInfo
 	datainfo.Items = dictList
@@ -989,7 +992,7 @@ func (this *PaymentInfoController) ReceiveVerifyBillList() {
 
 	fmt.Println(VerifyBills)
 	svc := paymentinfo.GetPaymentService(utils.DBE)
-	for _,item := range VerifyBills {
+	for _, item := range VerifyBills {
 		var Oilverifybill paymentinfo.OilVerifyBill
 		Oilverifybill.BillIds = strings.Trim(item.BillIds, ",")
 		Oilverifybill.BankSerialNum = item.BankSerialNum
@@ -999,7 +1002,7 @@ func (this *PaymentInfoController) ReceiveVerifyBillList() {
 		Oilverifybill.CreateOn = time.Now()
 		svc.InsertEntity(&Oilverifybill)
 		ids := strings.Split(item.BillIds, ",")
-		for _,id := range ids {
+		for _, id := range ids {
 			var payinfo paymentinfo.OilPaymentInfo
 			//where := "Id= " + id + " and BankSerialNum='" + item.BankSerialNum +"'" + " and IsPay='2'"
 			//has := svc.GetEntity(&payinfo, where)
@@ -1035,4 +1038,4 @@ func (this *PaymentInfoController) IsPermission() {
 	errinfo.Item = dictList
 	this.Data["json"] = &errinfo
 	this.ServeJSON()
-}
+}