From 87efca7f6823aa0fab81105a4ccca897a1b76525 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 26 Apr 2024 19:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/svc/svc_deal_commission.go | 19 ++++- consume/init.go | 1 + consume/md/consume_key.go | 10 +++ consume/md/md.go | 1 + consume/zhios_task_video_reward_exchange.go | 86 +++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 consume/zhios_task_video_reward_exchange.go diff --git a/app/svc/svc_deal_commission.go b/app/svc/svc_deal_commission.go index 8615223..64c3f17 100644 --- a/app/svc/svc_deal_commission.go +++ b/app/svc/svc_deal_commission.go @@ -308,14 +308,23 @@ func CommSettleMoney(session *xorm.Session, item *model.TaskOrdListRelate, appNa } else { orderAction = 11 // 推广 } - ItemTitle := "任务分佣" + var ItemTitle = "任务分佣结算" + if item.Pvd == "adset_video" { + ItemTitle = "看视频奖励" + } + if item.Level > 0 { + ItemTitle = "团队任务奖励" + if item.Pvd == "adset_video" { + ItemTitle = "团队看视频奖励" + } + } finUserFlow := model.FinUserFlow{ Type: 0, Uid: item.Uid, Amount: utils.Float64ToStrByPrec(item.Amount, 8), BeforeAmount: beforeAmount, AfterAmount: afterAmount, - OrdType: "task_center", + OrdType: item.Pvd, OrdId: utils.AnyToString(item.Oid), OrdAction: orderAction, OrdDetail: "", @@ -395,8 +404,14 @@ func CommSettleVirtualCoin(session *xorm.Session, virtualCoinRelateItem *model.V } } var title = "任务分佣结算" + if virtualCoinRelateItem.Pvd == "adset_video" { + title = "看视频奖励" + } if virtualCoinRelateItem.Level > 0 { title = "团队任务奖励" + if virtualCoinRelateItem.Pvd == "adset_video" { + title = "团队看视频奖励" + } } // 用户虚拟币流水表新增记录 var userVirtualCoinFlow = model.UserVirtualCoinFlow{ diff --git a/consume/init.go b/consume/init.go index 55fbf99..18a64a6 100644 --- a/consume/init.go +++ b/consume/init.go @@ -93,6 +93,7 @@ func initConsumes() { jobs[consumeMd.CancalUserIntegralExchangeConsumeFunName] = CancalUserIntegralExchange //兑换 jobs[consumeMd.ZhiosTaskRewardConsumeFunName] = ZhiosTaskRewardExchange //兑换 jobs[consumeMd.CanalOneOrengeUserVirtualCcoinFlowFunName] = CanalOneOrengeUserVirtualCoinFlowConsume + jobs[consumeMd.ZhiosTaskVideoRewardConsumeFunName] = ZhiosTaskVideoRewardExchange //视频分佣 } diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 25c981e..c77b4db 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -461,6 +461,15 @@ var RabbitMqQueueKeyList = []*MqQueue{ BindKey: "", ConsumeFunName: "ZhiosTaskRewardExchange", }, + { + ExchangeName: "zhios.task_video_reward.exchange", + Name: "zhios_task_video_reward_dev", + Type: FanOutQueueType, + IsPersistent: false, + RoutKey: "task_video_reward_dev", + BindKey: "", + ConsumeFunName: "ZhiosTaskVideoRewardExchange", + }, { ExchangeName: "canal.topic", // Name: "canal_fin_user_flow", @@ -535,5 +544,6 @@ const ( CancalUserRelateConsumeFunName = "CancalUserRelateConsume" CancalUserIntegralExchangeConsumeFunName = "CancalUserIntegralExchange" ZhiosTaskRewardConsumeFunName = "ZhiosTaskRewardExchange" + ZhiosTaskVideoRewardConsumeFunName = "ZhiosTaskVideoRewardExchange" CanalOneOrengeUserVirtualCcoinFlowFunName = "CanalOneOrengeUserVirtualCoinFlowConsume" ) diff --git a/consume/md/md.go b/consume/md/md.go index b940767..1bcc00d 100644 --- a/consume/md/md.go +++ b/consume/md/md.go @@ -17,6 +17,7 @@ type ZhiosTaskReward struct { DeviceModel string `json:"device_model"` Oid string `json:"oid"` RewardType string `json:"reward_type"` + PlanType string `json:"plan_type"` } type AcquisitionCfg struct { Id string `json:"id"` diff --git a/consume/zhios_task_video_reward_exchange.go b/consume/zhios_task_video_reward_exchange.go new file mode 100644 index 0000000..a03c23e --- /dev/null +++ b/consume/zhios_task_video_reward_exchange.go @@ -0,0 +1,86 @@ +package consume + +import ( + "applet/app/db" + "applet/app/svc" + "applet/app/utils" + "applet/app/utils/logx" + "applet/consume/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" + "encoding/json" + "errors" + "fmt" + "github.com/streadway/amqp" +) + +// +func ZhiosTaskVideoRewardExchange(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(">>>>>>>>>>>>>>>>CanalOrderConsume<<<<<<<<<<<<<<<<<<<<<<<<<") + err = handleZhiosVideoTaskVideoRewardExchange(res.Body) + //_ = res.Reject(false) + fmt.Println(err) + _ = res.Ack(true) + } else { + panic(errors.New("error getting message")) + } + } + fmt.Println("get msg done") +} + +func handleZhiosVideoTaskVideoRewardExchange(msg []byte) error { + //1、解析canal采集至mq中queue的数据结构体 + var canalMsg *md.ZhiosTaskReward + fmt.Println(string(msg)) + var tmpString string + err := json.Unmarshal(msg, &tmpString) + if err != nil { + fmt.Println(err.Error()) + return err + } + fmt.Println(tmpString) + err = json.Unmarshal([]byte(tmpString), &canalMsg) + if err != nil { + return err + } + mid := canalMsg.Mid + eg := db.DBs[mid] + if eg == nil { + return nil + } + uid := canalMsg.Uid + //计算佣金 + var CommissionParam md3.CommissionFirstParam + CommissionParam.CommissionParam.Commission = canalMsg.Reward + CommissionParam.Uid = uid + CommissionParam.Provider = canalMsg.PlanType + title := canalMsg.Title + var mapData = map[string]string{ + "coin_id_type": canalMsg.CoinIdType, + "mode": canalMsg.Mode, + "title": title, + "device_model": canalMsg.DeviceModel, + "reward_type": canalMsg.RewardType, + } + svc.GetLvUser(eg, CommissionParam, utils.StrToInt64(canalMsg.Oid), mid, mapData) + return nil +}