@@ -78,5 +78,5 @@ func handleEggEnergyDealUserVirtualCoinDataConsume(msgData []byte) error { | |||||
return err | return err | ||||
} | } | ||||
return nil | |||||
return session.Commit() | |||||
} | } |
@@ -77,5 +77,5 @@ func handleEggEnergySettlementPublicGiveActivityCoinConsume(msgData []byte) erro | |||||
session.Rollback() | session.Rollback() | ||||
return err | return err | ||||
} | } | ||||
return session.Begin() | |||||
return session.Commit() | |||||
} | } |
@@ -0,0 +1,72 @@ | |||||
package consume | |||||
import ( | |||||
"applet/app/cfg" | |||||
utils2 "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/egg_energy" | |||||
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" | |||||
"time" | |||||
) | |||||
func EggEnergyNewUserRegisterDataConsume(queue md.MqQueue) { | |||||
fmt.Println(">>>>>>>>>>>>EggEnergyNewUserRegisterDataConsume>>>>>>>>>>>>") | |||||
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 = handleEggEnergyNewUserRegisterDataConsume(res.Body) | |||||
if err != nil { | |||||
fmt.Println("EggEnergyNewUserRegisterDataConsume_ERR:::::", err.Error()) | |||||
utils2.FilePutContents("EggEnergyNewUserRegisterDataConsume_ERR", utils2.SerializeStr(map[string]interface{}{ | |||||
"body": res.Body, | |||||
"err": err.Error(), | |||||
})) | |||||
} | |||||
//_ = res.Reject(false) | |||||
err = res.Ack(true) | |||||
fmt.Println("err ::: ", err) | |||||
} else { | |||||
panic(errors.New("error getting message")) | |||||
} | |||||
} | |||||
} | |||||
func handleEggEnergyNewUserRegisterDataConsume(msgData []byte) error { | |||||
time.Sleep(time.Duration(100) * time.Millisecond) //休眠100毫秒 | |||||
// 1.解析mq中queue的数据结构体 | |||||
var msg *md2.EggNewUserRegisterData | |||||
err := json.Unmarshal(msgData, &msg) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
// 2.为新注册的用户新增蛋蛋分记录 | |||||
err = egg_energy.ExistOrDefaultUserEggScore(msg.Uid) | |||||
if err != nil { | |||||
return err | |||||
} | |||||
return nil | |||||
} |
@@ -18,19 +18,20 @@ func Init() { | |||||
// 增加消费任务队列 | // 增加消费任务队列 | ||||
func initConsumes() { | func initConsumes() { | ||||
jobs[consumeMd.EggEnergyStartLevelDividendFunName] = EggEnergyStartLevelDividendConsume | jobs[consumeMd.EggEnergyStartLevelDividendFunName] = EggEnergyStartLevelDividendConsume | ||||
jobs[consumeMd.EggEnergyDealPlatformRevenueDataFunName] = EggEnergyDealPlatformRevenueDataConsume | |||||
jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume | |||||
jobs[consumeMd.AliyunSmsRecordFunName] = AliyunSmsRecordConsume //阿里云短信 | |||||
jobs[consumeMd.JpushRecordFunName] = JpushRecordConsume //极光推送 | |||||
jobs[consumeMd.AdvertisingSmashConsume] = AdvertisingSmashConsume //砸蛋 | |||||
jobs[consumeMd.AdvertisingSignConsume] = AdvertisingSignConsume //签到 | |||||
jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume | |||||
jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume | |||||
jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume | |||||
jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume | |||||
jobs[consumeMd.EggEnergyDealPlatformRevenueDataFunName] = EggEnergyDealPlatformRevenueDataConsume // 平台营收 | |||||
jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume // 资金数据 | |||||
jobs[consumeMd.AliyunSmsRecordFunName] = AliyunSmsRecordConsume //阿里云短信 | |||||
jobs[consumeMd.JpushRecordFunName] = JpushRecordConsume //极光推送 | |||||
jobs[consumeMd.AdvertisingSmashConsume] = AdvertisingSmashConsume //砸蛋 | |||||
jobs[consumeMd.AdvertisingSignConsume] = AdvertisingSignConsume //签到 | |||||
jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume // 视频奖励给相应团队发放积分 | |||||
jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume // 批量发送信息 | |||||
jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume // 删除朋友圈 | |||||
jobs[consumeMd.EggFinWithdrawApplyDataConsumeFunName] = EggFinWithdrawApplyDataConsume // 支付宝打款 | |||||
jobs[consumeMd.EggEnergySettlementPublicGiveActivityCoinFunName] = EggEnergySettlementPublicGiveActivityCoinConsume | jobs[consumeMd.EggEnergySettlementPublicGiveActivityCoinFunName] = EggEnergySettlementPublicGiveActivityCoinConsume | ||||
jobs[consumeMd.EggEnergyStartExchangeGreenEnergyFunName] = EggEnergyStartExchangeGreenEnergyConsume | jobs[consumeMd.EggEnergyStartExchangeGreenEnergyFunName] = EggEnergyStartExchangeGreenEnergyConsume | ||||
jobs[consumeMd.EggEnergyAutoExchangeGreenEnergyFunName] = EggEnergyAutoExchangeGreenEnergyConsume | jobs[consumeMd.EggEnergyAutoExchangeGreenEnergyFunName] = EggEnergyAutoExchangeGreenEnergyConsume | ||||
jobs[consumeMd.EggEnergyNewUserRegisterDataFunName] = EggEnergyNewUserRegisterDataConsume // 新用户注册 | |||||
} | } | ||||
func Run() { | func Run() { | ||||
@@ -137,6 +137,15 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||||
BindKey: "", | BindKey: "", | ||||
ConsumeFunName: "AdvertisingSignConsume", | ConsumeFunName: "AdvertisingSignConsume", | ||||
}, | }, | ||||
{ | |||||
ExchangeName: "egg.app", | |||||
Name: "egg_new_user_register_queue", | |||||
Type: DirectQueueType, | |||||
IsPersistent: false, | |||||
RoutKey: "egg_new_user_register", | |||||
BindKey: "", | |||||
ConsumeFunName: "EggEnergyNewUserRegisterDataConsume", | |||||
}, | |||||
} | } | ||||
const ( | const ( | ||||
@@ -154,4 +163,5 @@ const ( | |||||
EggEnergySettlementPublicGiveActivityCoinFunName = "EggEnergySettlementPublicGiveActivityCoinConsume" | EggEnergySettlementPublicGiveActivityCoinFunName = "EggEnergySettlementPublicGiveActivityCoinConsume" | ||||
EggEnergyStartExchangeGreenEnergyFunName = "EggEnergyStartExchangeGreenEnergyConsume" | EggEnergyStartExchangeGreenEnergyFunName = "EggEnergyStartExchangeGreenEnergyConsume" | ||||
EggEnergyAutoExchangeGreenEnergyFunName = "EggEnergyAutoExchangeGreenEnergyConsume" | EggEnergyAutoExchangeGreenEnergyFunName = "EggEnergyAutoExchangeGreenEnergyConsume" | ||||
EggEnergyNewUserRegisterDataFunName = "EggEnergyNewUserRegisterDataConsume" | |||||
) | ) |
@@ -7,8 +7,8 @@ go 1.19 | |||||
//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules | //replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules | ||||
require ( | require ( | ||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241204145112-7b4c29691a6d | |||||
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205022841-e4ca039b4006 | |||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241205041102-0e106357c399 | |||||
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205061938-91f42710d6cd | |||||
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be | 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 | code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | ||||
github.com/boombuler/barcode v1.0.1 | github.com/boombuler/barcode v1.0.1 | ||||