From 176829b3776fecc0726a57f7060564445a6f4deb Mon Sep 17 00:00:00 2001 From: dengbiao Date: Sat, 27 Jul 2024 20:10:16 +0800 Subject: [PATCH] update --- consume/init.go | 18 +++---- consume/md/consume_key.go | 8 ++-- consume/one_circles_sign_in_consume.go | 49 +++++++++++++------- consume/one_circles_sign_in_copy_consume.go | 20 ++++---- cpu_profile | Bin 3618 -> 2271 bytes go.mod | 2 +- k8s/zyos-go-mq-consume-prd.yaml | 14 +++--- 7 files changed, 64 insertions(+), 47 deletions(-) diff --git a/consume/init.go b/consume/init.go index 8a51219..f4df471 100644 --- a/consume/init.go +++ b/consume/init.go @@ -85,14 +85,16 @@ func initConsumes() { //jobs[consumeMd.CanalO2oPayOrderForNumericalStatementConsumeFunName] = CanalO2oPayOrderForNumericalStatementConsume //jobs[consumeMd.CanalB2cOrderForNumericalStatementConsumeFunName] = CanalB2cOrderForNumericalStatementConsume - //////////////////////////////////////// oneCircles ///////////////////////////////////////////////////// - jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume - jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume - jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume - jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume - jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume - jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume - jobs[consumeMd.OneCirclesSignInUpdateRecordsGreenEnergyFunName] = OneCirclesSignInUpdateRecordsGreenEnergyConsume + //////////////////////////////////////// oneCircles-v1 ///////////////////////////////////////////////////// + //jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume + //jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume + //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume + //jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume + //jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume + //jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume + + //////////////////////////////////////// oneCircles-v2 ///////////////////////////////////////////////////// + jobs[consumeMd.OneCirclesDealUserCoinConsumeFunName] = OneCirclesDealUserCoinConsume //////////////////////////////////////// withdraw ///////////////////////////////////////////////////// //jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 20e5e83..9231e2a 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -562,12 +562,12 @@ var RabbitMqQueueKeyList = []*MqQueue{ }, { ExchangeName: "one.circles", - Name: "one_circles_sign_in_update_records", + Name: "one_circles_reward_user_coin", Type: TopicQueueType, IsPersistent: false, - RoutKey: "sign_in_update_records", + RoutKey: "reward_user_coin", BindKey: "", - ConsumeFunName: "OneCirclesSignInUpdateRecordsGreenEnergyConsume", + ConsumeFunName: "OneCirclesDealUserCoinConsume", }, { ExchangeName: "zhios.app.user.withdraw.apply.exchange", @@ -661,7 +661,7 @@ const ( MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume" CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume" OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume" - OneCirclesSignInUpdateRecordsGreenEnergyFunName = "OneCirclesSignInUpdateRecordsGreenEnergyConsume" + OneCirclesDealUserCoinConsumeFunName = "OneCirclesDealUserCoinConsume" OneCirclesStartLevelDividendFunName = "OneCirclesStartLevelDividendConsume" OneCirclesActivityCoinAutoExchangeGreenEnergyFunName = "OneCirclesActivityCoinAutoExchangeGreenEnergyConsume" OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName = "OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume" diff --git a/consume/one_circles_sign_in_consume.go b/consume/one_circles_sign_in_consume.go index c03a3d4..2ee4b1a 100644 --- a/consume/one_circles_sign_in_consume.go +++ b/consume/one_circles_sign_in_consume.go @@ -12,6 +12,8 @@ import ( "errors" "fmt" "github.com/streadway/amqp" + "os" + "runtime/pprof" ) func OneCirclesSignInGreenEnergyConsume(queue md.MqQueue) { @@ -32,33 +34,44 @@ func OneCirclesSignInGreenEnergyConsume(queue md.MqQueue) { var res amqp.Delivery var ok bool - for { - res, ok = <-delivery - if ok == true { - err = handleOneCirclesSignInGreenEnergy(ch, res.Body) - if err != nil { - fmt.Println("err ::: ", err) - utils.FilePutContents("OneCirclesSignInGreenEnergyConsume_ERR", "[err]:"+err.Error()) - _ = res.Reject(true) - //_ = res.Reject(false) - ////TODO::重新推回队列末尾,避免造成队列堵塞 - //var msg *md.OneCirclesStructForSignIn - //json.Unmarshal(res.Body, &msg) - //ch.Publish(queue.ExchangeName, msg, queue.RoutKey) - } else { - _ = res.Ack(true) - } + //for { + res, ok = <-delivery + if ok == true { + err = handleOneCirclesSignInGreenEnergy(ch, res.Body) + if err != nil { + fmt.Println("err ::: ", err) + utils.FilePutContents("OneCirclesSignInGreenEnergyConsume_ERR", "[err]:"+err.Error()) + _ = res.Reject(true) + //_ = res.Reject(false) + ////TODO::重新推回队列末尾,避免造成队列堵塞 + //var msg *md.OneCirclesStructForSignIn + //json.Unmarshal(res.Body, &msg) + //ch.Publish(queue.ExchangeName, msg, queue.RoutKey) } else { - panic(errors.New("error getting message")) + _ = res.Ack(true) } + } else { + panic(errors.New("error getting message")) } + //} fmt.Println("get msg done") } func handleOneCirclesSignInGreenEnergy(ch *rabbit.Channel, msgData []byte) error { + cpuProfile, err := os.Create("./cpu_profile") + if err != nil { + fmt.Printf("创建文件失败:%s", err.Error()) + return err + } + defer cpuProfile.Close() + + //采集CPU信息 + pprof.StartCPUProfile(cpuProfile) + defer pprof.StopCPUProfile() + //1、解析mq中queue的数据结构体 var msg *md.OneCirclesStructForSignIn - err := json.Unmarshal(msgData, &msg) + err = json.Unmarshal(msgData, &msg) if err != nil { return err } diff --git a/consume/one_circles_sign_in_copy_consume.go b/consume/one_circles_sign_in_copy_consume.go index 3d1e770..eb24744 100644 --- a/consume/one_circles_sign_in_copy_consume.go +++ b/consume/one_circles_sign_in_copy_consume.go @@ -6,8 +6,8 @@ import ( "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/db/model" md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule" "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles" "encoding/json" "errors" @@ -15,8 +15,8 @@ import ( "github.com/streadway/amqp" ) -func OneCirclesSignInUpdateRecordsGreenEnergyConsume(queue md.MqQueue) { - fmt.Println(">>>>>>>>>>>>OneCirclesSignInUpdateRecordsGreenEnergyConsume>>>>>>>>>>>>") +func OneCirclesDealUserCoinConsume(queue md.MqQueue) { + fmt.Println(">>>>>>>>>>>>OneCirclesDealUserCoinConsume>>>>>>>>>>>>") ch, err := rabbit.Cfg.Pool.GetChannel() if err != nil { logx.Error(err) @@ -36,10 +36,10 @@ func OneCirclesSignInUpdateRecordsGreenEnergyConsume(queue md.MqQueue) { for { res, ok = <-delivery if ok == true { - err = handleOneCirclesSignInUpdateRecordsGreenEnergyConsume(res.Body) + err = handleOneCirclesDealUserCoinConsume(res.Body) if err != nil { fmt.Println("err ::: ", err) - fmt.Println("OneCirclesSignInUpdateRecordsGreenEnergyConsume_ERR:::::", err.Error()) + fmt.Println("OneCirclesDealUserCoinConsume_ERR:::::", err.Error()) ////TODO::重新推回队列末尾,避免造成队列堵塞 //_ = res.Reject(false) _ = res.Reject(true) @@ -53,15 +53,17 @@ func OneCirclesSignInUpdateRecordsGreenEnergyConsume(queue md.MqQueue) { fmt.Println("get msg done") } -func handleOneCirclesSignInUpdateRecordsGreenEnergyConsume(msgData []byte) error { +func handleOneCirclesDealUserCoinConsume(msgData []byte) error { //1、解析mq中queue的数据结构体 - var msg *md2.UpdateOneCirclesStructForSignInRecords + var msg *md2.DealUserCoinReq err := json.Unmarshal(msgData, &msg) if err != nil { return err } - engine := db.DBs["31585332"] - _, err = engine.Where("id =?", msg.Id).Update(&model.OneCirclesGreenEnergySignIn{IsCompleted: 1}) + + //2、进行虚拟币奖励发放 + engine := db.DBs[msg.Mid] + err = rule.DealUserCoin(engine.NewSession(), *msg) if err != nil { fmt.Println("err::::", err) return err diff --git a/cpu_profile b/cpu_profile index 96c80f6cabe5890f9c9121ea0e9ad9f9a1636b33..53cca95683857efcd3b33342982e5c05edaee94b 100644 GIT binary patch literal 2271 zcmV<52q5<#iwFP!00004|HM~aY#i0~|F6AkU)!P;7)YY*V(E6{a?G5Wo*lN(|s!t;7KOv0q}X_{&e<6TDV^*|k0nY?S=zviiRkl+go%q}%j|!|4&IDK|#4x7BDUdFF|MAnJ++FZwfOSCv6UrEk z62!keb6S)XVZU^TFplHO1O?KK&wuv3pmoE^pt-t1MOD!#kRE*X*oy+|f%^i<9!O$R znWR8^@$Bm#2&@-=9$>woqps|rK>F~#4?YrDA3POgr4M%EPUR9BCH;8sTMvpB>W8=t zr5|?TF6B}hB?I{PnT~$LHHzyVG#D<9$C>LJpS+>Mb#8|v{8Ce;4-{S5f!C)>f5qv zL-2f1wIR41FIR>skYRk_qi=}xQ+PBuGleVg3W<&2cfKciTj6vBLNrRY;i)(NA!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LZFA(HGjl8r$w`VgBN zE>Uy3dpwn8a|(ZF#g-8mrKL7y#|HYyX`rse{0QjvFMF0Q* diff --git a/go.mod b/go.mod index dc3f549..c356bed 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git v1.1.2-0.20240607091816-3df1433a2f0d code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.0 code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 - code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240727102826-b17347dfda58 + code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240727115614-da7c2fc02dd7 code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git v1.6.2-0.20231116085701-9ba6e19f877b code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240726151134-db88648c83ef code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240726093338-fed880ca12ce diff --git a/k8s/zyos-go-mq-consume-prd.yaml b/k8s/zyos-go-mq-consume-prd.yaml index 608dbb7..a7b97b2 100644 --- a/k8s/zyos-go-mq-consume-prd.yaml +++ b/k8s/zyos-go-mq-consume-prd.yaml @@ -2,25 +2,25 @@ kind: Deployment apiVersion: apps/v1 # 元数据 metadata: - name: zyos-go-mq-consume-v6 + name: zyos-go-mq-consume-one-circles-v2 namespace: zhios labels: - app: zyos-go-mq-consume-v6 + app: zyos-go-mq-consume-one-circles-v2 annotations: kubesphere.io/creator: dengbiao - kubesphere.io/description: 绿色双链积分 + kubesphere.io/description: 一个圈圈v2 # deployment主要部分 spec: replicas: 1 selector: matchLabels: # 名称与上面的labels对应 - app: zyos-go-mq-consume-v6 + app: zyos-go-mq-consume-one-circles-v2 template: metadata: labels: # 名称与上面的matchLabels对应 - app: zyos-go-mq-consume-v6 + app: zyos-go-mq-consume-one-circles-v2 spec: # 声明挂载卷(将外部已存在的pvc、config等挂载进来) volumes: @@ -37,9 +37,9 @@ spec: defaultMode: 420 containers: # 主容器 - - name: zhios-zyos-go-mq-consume-v6-container + - name: zhios-zyos-go-mq-consume-one-circles-v2-container # 镜像地址(提前打包好并推送的镜像仓库) - image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-zyos-go-mq-consume-v6:20240310-01' + image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-go-mq-consume-one-circles-v2:20240727-01' # 将前面volume声明的需要用到的pvc、config挂载上来 volumeMounts: - name: host-time