瀏覽代碼

update

master
dengbiao 1 周之前
父節點
當前提交
ece384206e
共有 3 個文件被更改,包括 110 次插入26 次删除
  1. +74
    -0
      consume/add_public_platoon_user_relation_commission.go
  2. +35
    -25
      consume/md/consume_key.go
  3. +1
    -1
      go.mod

+ 74
- 0
consume/add_public_platoon_user_relation_commission.go 查看文件

@@ -0,0 +1,74 @@
package consume

import (
"applet/app/cfg"
"applet/app/db"
"applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
"code.fnuoos.com/EggPlanet/egg_system_rules.git"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
)

func AddPublicPlatoonUserRelationCommissionConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>AddPublicPlatoonUserRelationCommissionConsume>>>>>>>>>>>>")
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)

egg_system_rules.Init(cfg.RedisAddr)
var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleAddPublicPlatoonUserRelationCommissionConsume(res.Body)
if err != nil {
fmt.Println("err ::: ", err)
utils.FilePutContents("AddPublicPlatoonUserRelationCommissionConsume_ERR", "[err]:"+err.Error())
_ = res.Reject(false)
//TODO::重新推回队列末尾,避免造成队列堵塞
var msg *md2.AddPublicPlatoonUserRelationCommissionReq
json.Unmarshal(res.Body, &msg)
ch.Publish(queue.ExchangeName, msg, queue.RoutKey)
} else {
_ = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleAddPublicPlatoonUserRelationCommissionConsume(msgData []byte) error {
//1、解析mq中queue的数据结构体
var msg *md2.AddPublicPlatoonUserRelationCommissionReq
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}

var req []*md2.AddPublicPlatoonUserRelationCommissionReq
req = append(req, msg)
_, err = rule.AddPublicPlatoonUserRelationCommission(db.Db, req)
fmt.Println("err::::", err)
if err != nil {
return err
}
return nil
}

+ 35
- 25
consume/md/consume_key.go 查看文件

@@ -101,6 +101,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "EggEnergyAutoExchangeGreenEnergyConsume",
},
{
ExchangeName: "egg.app",
Name: "add_public_platoon_user_relation_commission",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "add_public_platoon_user_relation_commission",
BindKey: "",
ConsumeFunName: "AddPublicPlatoonUserRelationCommissionConsume",
},
{
ExchangeName: "egg.jpush",
Name: "egg_jpush_record_queue",
@@ -239,29 +248,30 @@ var RabbitMqQueueKeyList = []*MqQueue{
}

const (
AdvertisingSignConsume = "AdvertisingSignConsume"
AdvertisingSmashConsume = "AdvertisingSmashConsume"
JpushRecordFunName = "JpushRecordConsume"
AliyunSmsRecordFunName = "AliyunSmsRecordConsume"
EggEnergyStartLevelDividendFunName = "EggEnergyStartLevelDividendConsume"
EggEnergyDealFundDataFunName = "EggEnergyDealFundDataConsume"
EggEnergyDealPlatformRevenueDataFunName = "EggEnergyDealPlatformRevenueDataConsume"
EggEnergyDealUserVirtualCoinDataFunName = "EggEnergyDealUserVirtualCoinDataConsume"
IMEggEnergyBatchSendMessageDataFunName = "IMEggEnergyBatchSendMessageDataConsume"
IMEggEnergyDelFriendCircleDataFunName = "IMEggEnergyDelFriendCircleDataConsume"
EggFinWithdrawApplyDataConsumeFunName = "EggFinWithdrawApplyDataConsume"
EggEnergySettlementPublicGiveActivityCoinFunName = "EggEnergySettlementPublicGiveActivityCoinConsume"
EggEnergyStartExchangeGreenEnergyFunName = "EggEnergyStartExchangeGreenEnergyConsume"
EggEnergyAutoExchangeGreenEnergyFunName = "EggEnergyAutoExchangeGreenEnergyConsume"
EggEnergyNewUserRegisterDataFunName = "EggEnergyNewUserRegisterDataConsume"
EggEnergyDealUserECPMFunName = "EggEnergyDealUserECPMConsume"
EggCanalInviteUserNumsFunName = "EggCanalInviteUserNumsConsume"
EggCanalViolateNumsFunName = "EggCanalViolateNumsConsume"
IMEggEnergySendRedPackageFunName = "IMEggEnergySendRedPackageConsume"
EggRecordActiveDataFunName = "EggRecordActiveDataConsume"
EggCanalPersonAddActivityValueFunName = "EggCanalPersonAddActivityValueConsume"
VideoRewardFunName = "VideoRewardFunName"
PlayletRewardFunName = "PlayletRewardFunName"
UserDeleteFunName = "UserDeleteConsume"
EggEnergyAutoScoreDataFunName = "EggEnergyAutoScoreConsume"
AdvertisingSignConsume = "AdvertisingSignConsume"
AdvertisingSmashConsume = "AdvertisingSmashConsume"
JpushRecordFunName = "JpushRecordConsume"
AliyunSmsRecordFunName = "AliyunSmsRecordConsume"
EggEnergyStartLevelDividendFunName = "EggEnergyStartLevelDividendConsume"
EggEnergyDealFundDataFunName = "EggEnergyDealFundDataConsume"
EggEnergyDealPlatformRevenueDataFunName = "EggEnergyDealPlatformRevenueDataConsume"
EggEnergyDealUserVirtualCoinDataFunName = "EggEnergyDealUserVirtualCoinDataConsume"
IMEggEnergyBatchSendMessageDataFunName = "IMEggEnergyBatchSendMessageDataConsume"
IMEggEnergyDelFriendCircleDataFunName = "IMEggEnergyDelFriendCircleDataConsume"
EggFinWithdrawApplyDataConsumeFunName = "EggFinWithdrawApplyDataConsume"
EggEnergySettlementPublicGiveActivityCoinFunName = "EggEnergySettlementPublicGiveActivityCoinConsume"
EggEnergyStartExchangeGreenEnergyFunName = "EggEnergyStartExchangeGreenEnergyConsume"
EggEnergyAutoExchangeGreenEnergyFunName = "EggEnergyAutoExchangeGreenEnergyConsume"
EggEnergyNewUserRegisterDataFunName = "EggEnergyNewUserRegisterDataConsume"
EggEnergyDealUserECPMFunName = "EggEnergyDealUserECPMConsume"
EggCanalInviteUserNumsFunName = "EggCanalInviteUserNumsConsume"
EggCanalViolateNumsFunName = "EggCanalViolateNumsConsume"
IMEggEnergySendRedPackageFunName = "IMEggEnergySendRedPackageConsume"
EggRecordActiveDataFunName = "EggRecordActiveDataConsume"
EggCanalPersonAddActivityValueFunName = "EggCanalPersonAddActivityValueConsume"
VideoRewardFunName = "VideoRewardFunName"
PlayletRewardFunName = "PlayletRewardFunName"
UserDeleteFunName = "UserDeleteConsume"
EggEnergyAutoScoreDataFunName = "EggEnergyAutoScoreConsume"
PublicPlatoonUserRelationCommissionConsumeFunName = "AddPublicPlatoonUserRelationCommissionConsume"
)

+ 1
- 1
go.mod 查看文件

@@ -8,7 +8,7 @@ go 1.19

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241212120727-3681308aeb14
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212122404-22c05dd7f73c
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212140020-c99f60b4f868
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/boombuler/barcode v1.0.1


Loading…
取消
儲存