Przeglądaj źródła

update

one_orenge
DengBiao 7 miesięcy temu
rodzic
commit
d261b4c51c
6 zmienionych plików z 116 dodań i 2 usunięć
  1. +1
    -1
      app/db/dbs_map.go
  2. +1
    -0
      consume/init.go
  3. +10
    -0
      consume/md/consume_key.go
  4. +6
    -0
      consume/md/md_one_circles.go
  5. +97
    -0
      consume/one_circles_start_level_dividend_consume.go
  6. +1
    -1
      go.mod

+ 1
- 1
app/db/dbs_map.go Wyświetl plik

@@ -110,7 +110,7 @@ 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, 72190665).Find(&m)
err = Db.Where("deleted_at != ? AND db_master_id=?", 1, 31585332).Find(&m)
} else {
err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m)
}


+ 1
- 0
consume/init.go Wyświetl plik

@@ -79,6 +79,7 @@ func initConsumes() {

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
//jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume

//////////////////////////////////////// withdraw /////////////////////////////////////////////////////


+ 10
- 0
consume/md/consume_key.go Wyświetl plik

@@ -407,6 +407,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "OneCirclesSignInGreenEnergyConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_start_level_dividend",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "star_level_dividend",
BindKey: "",
ConsumeFunName: "OneCirclesStartLevelDividendConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_sign_in_green_energy_copy",
@@ -473,6 +482,7 @@ const (
MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume"
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume"
OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume"
OneCirclesStartLevelDividendFunName = "OneCirclesStartLevelDividendConsume"
OneCirclesSignInCopyGreenEnergyFunName = "OneCirclesSignInCopyGreenEnergyConsume"
WithdrawConsumeFunName = "WithdrawConsume"
)

+ 6
- 0
consume/md/md_one_circles.go Wyświetl plik

@@ -5,3 +5,9 @@ type OneCirclesStructForSignIn struct {
Uid int `json:"uid"`
Id int64 `json:"id"`
}

type OneCirclesStructForStarLevelDividends struct {
MasterId string `json:"master_id"`
Uid int `json:"uid"`
SignDividend float64 `json:"sign_dividend"`
}

+ 97
- 0
consume/one_circles_start_level_dividend_consume.go Wyświetl plik

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

import (
"applet/app/cfg"
"applet/app/db"
utils2 "applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
db2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
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"
"fmt"
"github.com/streadway/amqp"
"time"
)

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

one_circles.Init(cfg.RedisAddr)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesStartLevelDividendConsume(res.Body)
if err != nil {
fmt.Println("OneCirclesStartLevelDividendConsume_ERR:::::", err.Error())
utils2.FilePutContents("OneCirclesStartLevelDividendConsume_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"))
}
}
fmt.Println("get msg done")
}

func handleOneCirclesStartLevelDividendConsume(msgData []byte) error {
time.Sleep(time.Duration(100) * time.Millisecond) //休眠100毫秒
//1、解析mq中queue的数据结构体
var msg *md.OneCirclesStructForStarLevelDividends
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
engine := db.DBs[msg.MasterId]
//2、查找 `one_circles_green_energy_basic_setting` 基础设置
oneCirclesGreenEnergyBasicSetting, err := db2.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
return err
}
if oneCirclesGreenEnergyBasicSetting == nil {
return nil
}

//3、给相应的用户加上个人的绿色积分(结算数量)
session := engine.NewSession()
err = rule.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "add",
Mid: msg.MasterId,
Title: md2.OneCirclesSettlementStarLevelDividends,
TransferType: md2.OneCirclesSettlementStarLevelDividendsForUserVirtualCoinFlow,
OrdId: "",
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId,
Uid: msg.Uid,
Amount: msg.SignDividend,
})
if err != nil {
return err
}
return nil
}

+ 1
- 1
go.mod Wyświetl plik

@@ -6,7 +6,7 @@ require (
code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git v1.1.2-0.20240222023917-c31b53f7e8cb
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.4
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240313053338-5e7ef7507328
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240315113731-a22c0fb96812
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.20240126015516-38ca248db2fd
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5


Ładowanie…
Anuluj
Zapisz