Browse Source

更新

one_orenge
huangjiajun 5 months ago
parent
commit
ad5fc6d65e
5 changed files with 117 additions and 1 deletions
  1. +2
    -1
      app/db/dbs_map.go
  2. +1
    -0
      consume/init.go
  3. +10
    -0
      consume/md/consume_key.go
  4. +2
    -0
      consume/md/md.go
  5. +102
    -0
      consume/zhios_new_video_reward_exchange.go

+ 2
- 1
app/db/dbs_map.go View File

@@ -110,7 +110,8 @@ func GetAllDatabaseDev() *[]model.DbMapping {
fmt.Println("cfg.Local is: ", cfg.Local)
if cfg.Local { // 本地调试 加快速度
fmt.Println("notice:LOCAL TEST, only masterId:** 99813608 ** available!")
err = Db.Where("deleted_at != ? AND db_master_id=?", 1, 31585332).Find(&m)
err = Db.Where("deleted_at != ? AND is_dev = '1' AND db_master_id=?", 1, 123456).Find(&m)

} else {
err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m)
}


+ 1
- 0
consume/init.go View File

@@ -94,6 +94,7 @@ func initConsumes() {
jobs[consumeMd.ZhiosTaskRewardConsumeFunName] = ZhiosTaskRewardExchange //兑换
jobs[consumeMd.CanalOneOrengeUserVirtualCcoinFlowFunName] = CanalOneOrengeUserVirtualCoinFlowConsume
jobs[consumeMd.ZhiosTaskVideoRewardConsumeFunName] = ZhiosTaskVideoRewardExchange //视频分佣
jobs[consumeMd.ZhiosNewVideoRewardConsumeFunName] = ZhiosNewVideoRewardExchange //短视频奖励

}



+ 10
- 0
consume/md/consume_key.go View File

@@ -470,6 +470,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "ZhiosTaskVideoRewardExchange",
},
{
ExchangeName: "zhios.new_video_reward.exchange",
Name: "zhios_new_video_reward",
Type: FanOutQueueType,
IsPersistent: false,
RoutKey: "new_video_reward",
BindKey: "",
ConsumeFunName: "ZhiosNewVideoRewardExchange",
},
{
ExchangeName: "canal.topic", //
Name: "canal_fin_user_flow",
@@ -545,5 +554,6 @@ const (
CancalUserIntegralExchangeConsumeFunName = "CancalUserIntegralExchange"
ZhiosTaskRewardConsumeFunName = "ZhiosTaskRewardExchange"
ZhiosTaskVideoRewardConsumeFunName = "ZhiosTaskVideoRewardExchange"
ZhiosNewVideoRewardConsumeFunName = "ZhiosNewVideoRewardExchange"
CanalOneOrengeUserVirtualCcoinFlowFunName = "CanalOneOrengeUserVirtualCoinFlowConsume"
)

+ 2
- 0
consume/md/md.go View File

@@ -8,6 +8,8 @@ type ZhiosAcquisition struct {
Id string `json:"id"`
}
type ZhiosTaskReward struct {
CoinId string `json:"coin_id"`
Money string `json:"money"`
Uid string `json:"uid"`
Mid string `json:"mid"`
Reward string `json:"reward"`


+ 102
- 0
consume/zhios_new_video_reward_exchange.go View File

@@ -0,0 +1,102 @@
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 ZhiosNewVideoRewardExchange(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 = handleZhiosNewVideoRewardExchange(res.Body)
//_ = res.Reject(false)
fmt.Println(err)
_ = res.Ack(true)
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleZhiosNewVideoRewardExchange(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
}
amount := canalMsg.Money
//奖励
oid := canalMsg.Oid
uid := canalMsg.Uid
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
_, err = svc.ExchangeUserVirFinValidAndInterFlowWithSession(sess,
utils.StrToFloat64(amount), "看视频奖励", "0", 1, 170, utils.StrToInt(uid), utils.StrToInt(canalMsg.CoinId), 0, utils.StrToInt64(oid), "", 0, 0)
if err != nil {
sess.Rollback()
return err
}
sess.Commit()
if canalMsg.Mode != "" {
//计算佣金
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
}

Loading…
Cancel
Save