From 35e9489fb953aeca64cc8cd378cd2246ddf4b3db Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 23 Dec 2024 16:50:33 +0800 Subject: [PATCH] update --- consume/egg_fin_withdraw_apply_consume.go | 10 ++-- .../egg_fin_withdraw_apply_consume_test.go | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 consume/egg_fin_withdraw_apply_consume_test.go diff --git a/consume/egg_fin_withdraw_apply_consume.go b/consume/egg_fin_withdraw_apply_consume.go index 71dacb8..2798f81 100644 --- a/consume/egg_fin_withdraw_apply_consume.go +++ b/consume/egg_fin_withdraw_apply_consume.go @@ -22,7 +22,6 @@ import ( "github.com/go-pay/gopay" "github.com/go-pay/gopay/alipay" "github.com/go-pay/xlog" - "github.com/jinzhu/copier" "github.com/streadway/amqp" "time" ) @@ -73,12 +72,9 @@ func EggFinWithdrawApplyDataConsume(queue md.MqQueue) { data.Ext = res.Body } else { // 解析成功 - err2 := copier.Copy(&data, &msg) - if err2 != nil { - data.Ext = res.Body - } + data.EggFinWithdrawApplyData = *msg } - ch.Publish(md2.EggAppExchange, utils2.SerializeStr(data), md2.EggFinWithdrawApplyError) + ch.Publish(md2.EggAppExchange, data, md2.EggFinWithdrawApplyError) } //_ = res.Reject(false) err = res.Ack(true) @@ -98,6 +94,8 @@ func handleEggFinWithdrawApplyDataConsume(msgData []byte, client *alipay.Client, return err } + return errors.New("测试") + applyDb := implement.NewFinWithdrawApplyDb(db.Db) apply, err := applyDb.FinWithdrawApplyGet(msg.Id) if err != nil { diff --git a/consume/egg_fin_withdraw_apply_consume_test.go b/consume/egg_fin_withdraw_apply_consume_test.go new file mode 100644 index 0000000..0bce56a --- /dev/null +++ b/consume/egg_fin_withdraw_apply_consume_test.go @@ -0,0 +1,54 @@ +package consume + +import ( + "applet/app/cfg" + "applet/app/db" + md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + "fmt" + "testing" +) + +func TestHandleEggFinWithdrawApplyDataConsume(t *testing.T) { + dbcfg := cfg.DBCfg{ + Host: "119.23.182.117:3306", + Name: "egg", + User: "root", + Psw: "Fnuo123com@", + ShowLog: true, + MaxLifetime: 30, + MaxOpenConns: 100, + MaxIdleConns: 100, + Path: "tmp/%s.log", + } + db.InitDB(&dbcfg) + err := rabbit.Init("120.77.153.180", "5672", "guest", "guest") + if err != nil { + return + } + ch, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + fmt.Println("DealFundDataGetRabbitChannel_ERR:::::", err.Error()) + return + } + defer ch.Release() + ch.Publish(md2.EggAppExchange, md2.EggFinWithdrawApplyData{ + Id: 1, + Uid: 2, + AdmId: 3, + Amount: "10", + RealAmount: "10", + Fee: "4", + Type: 1, + WithdrawAccount: "3", + WithdrawName: "2", + Reason: 2, + PaymentDate: "2", + State: 2, + WithdrawKind: 2, + IsFirst: 2, + Memo: "测试报错例子2", + UpdateAt: "", + CreateAt: "", + }, md2.EggFinWithdrawApply) +}