From c55782302e86ca0e81d94bcaafdfd2b04032e529 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 20 Jun 2024 17:51:52 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=88=86=E4=BB=98=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=89=A3=E6=AC=BE=E6=B6=88=E8=B4=B9=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consume/init.go | 13 ++-- consume/md/consume_key.go | 10 +++ ...installment_payment_auto_repaid_consume.go | 66 +++++++++++++++++++ 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 consume/zhios_installment_payment_auto_repaid_consume.go diff --git a/consume/init.go b/consume/init.go index 45df6f1..91c3517 100644 --- a/consume/init.go +++ b/consume/init.go @@ -80,11 +80,11 @@ func initConsumes() { //////////////////////////////////////// oneCircles ///////////////////////////////////////////////////// - jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume - jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume - jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume - jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume - jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume + //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume + //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume + //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume + //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume + //jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume //jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume //////////////////////////////////////// withdraw ///////////////////////////////////////////////////// @@ -94,6 +94,9 @@ func initConsumes() { //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分 //jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化 + + jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款 + } func Run() { diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 7ab3243..0c3b002 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -497,6 +497,15 @@ var RabbitMqQueueKeyList = []*MqQueue{ BindKey: "", ConsumeFunName: "FlexibleEmploymentWithdrawForPupiaoConsume", }, + { + ExchangeName: "installment.payment", + Name: "zhios_installment_payment_auto_repaid", + Type: DirectQueueType, + IsPersistent: false, + RoutKey: "auto_repaid", + BindKey: "", + ConsumeFunName: "InstallmentPaymentAutoRepaidConsume", + }, } const ( @@ -555,4 +564,5 @@ const ( FlexibleEmploymentWithdrawForGongMaoConsumeFunName = "FlexibleEmploymentWithdrawForGongMaoConsume" FlexibleEmploymentWithdrawForPupiaoConsumeFunName = "FlexibleEmploymentWithdrawForPupiaoConsume" ZhiosTaskTotal = "zhiosTaskTotal" + InstallmentPaymentAutoRepaidConsumeFunName = "InstallmentPaymentAutoRepaidConsume" ) diff --git a/consume/zhios_installment_payment_auto_repaid_consume.go b/consume/zhios_installment_payment_auto_repaid_consume.go new file mode 100644 index 0000000..dec24ae --- /dev/null +++ b/consume/zhios_installment_payment_auto_repaid_consume.go @@ -0,0 +1,66 @@ +package consume + +import ( + "applet/app/db" + "applet/app/utils/logx" + "applet/consume/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/installment_payment" + md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/installment_payment/md" + "encoding/json" + "errors" + "fmt" + "github.com/streadway/amqp" + "time" +) + +func InstallmentPaymentAutoRepaidConsume(queue md.MqQueue) { + fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>") + ch, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + logx.Error(err) + return + } + defer ch.Release() + //1、将自己绑定到交换机上 + ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) + //2、取出数据进行消费 + ch.Qos(1) + delivery := ch.Consume(queue.Name, false) + + var res amqp.Delivery + var ok bool + for { + res, ok = <-delivery + if ok == true { + //fmt.Println(string(res.Body)) + fmt.Println(">>>>>>>>>>>>>>>>InstallmentPaymentAutoRepaidConsume<<<<<<<<<<<<<<<<<<<<<<<<<") + err = handleZhiosOneCirclesCoinConsume(res.Body) + if err != nil { + fmt.Println("handleInstallmentPaymentAutoRepaidConsumeERR:::::", err.Error()) + } + //_ = res.Reject(false) + err = res.Ack(true) + fmt.Println("err ::: ", err) + } else { + panic(errors.New("error getting message")) + } + } + fmt.Println("get msg done") +} + +func handleInstallmentPaymentAutoRepaidConsume(msgData []byte) error { + time.Sleep(time.Duration(2) * time.Millisecond) //休眠2毫秒 + + //1、解析mq中queue的数据结构体 + var msg *md2.InstallmentPaymentStructForAutoRepaid + err := json.Unmarshal(msgData, &msg) + if err != nil { + return err + } + engine := db.DBs[msg.MasterId] + + //2、调用 `DealInstallmentPaymentAutoRepaid` 制度方法进行扣款 + err = installment_payment.DealInstallmentPaymentAutoRepaid(engine, *msg, msg.MasterId) + return nil +}