Browse Source

update

one_orenge
DengBiao 8 months ago
parent
commit
08fb0a00a2
7 changed files with 98 additions and 12 deletions
  1. +2
    -2
      app/db/dbs_map.go
  2. +7
    -4
      consume/init.go
  3. +12
    -2
      consume/md/consume_key.go
  4. +7
    -0
      consume/md/md_one_circles.go
  5. +66
    -0
      consume/one_circles_sign_in_consume.go
  6. +3
    -3
      etc/cfg.yml
  7. +1
    -1
      go.mod

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

@@ -21,7 +21,7 @@ func InitMapDbs(c *cfg.DBCfg, prd bool) {
logx.Fatalf("db_mapping not exists : %v", err)
}
// tables := MapAllDatabases(debug)
if true {
if cfg.Prd {
tables = GetAllDatabasePrd() //debug 获取生产
} else {
tables = GetAllDatabaseDev() //debug 获取开发
@@ -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, 32053480).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)
}


+ 7
- 4
consume/init.go View File

@@ -70,10 +70,13 @@ func initConsumes() {
//jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume

//////////////////////////////////////// bigData /////////////////////////////////////////////////////
jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
//jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
//jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
//jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
//jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
}

func Run() {


+ 12
- 2
consume/md/consume_key.go View File

@@ -387,7 +387,16 @@ var RabbitMqQueueKeyList = []*MqQueue{
IsPersistent: false,
RoutKey: "canal_user_virtual_coin_flow",
BindKey: "",
ConsumeFunName: "CanalUserVirtualCcoinFlowConsume",
ConsumeFunName: "CanalUserVirtualCoinFlowConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_sign_in_green_energy",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "sign_in",
BindKey: "",
ConsumeFunName: "OneCirclesSignInGreenEnergyConsume",
},
}

@@ -433,5 +442,6 @@ const (
ZhiosAcquisitionConditionDevFunName = "ZhiosAcquisitionConditionDev"
SupplyCloudChainFenxiaoNewChangeFunName = "SupplyCloudChainFenxiaoNewChangeConsume"
MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume"
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCcoinFlowConsume"
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume"
OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume"
)

+ 7
- 0
consume/md/md_one_circles.go View File

@@ -0,0 +1,7 @@
package md

type OneCirclesStructForSignIn struct {
MasterId string `json:"master_id"`
Uid int `json:"uid"`
Id int64 `json:"id"`
}

+ 66
- 0
consume/one_circles_sign_in_consume.go View File

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

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

func OneCirclesSignInGreenEnergyConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesSignInGreenEnergyConsume>>>>>>>>>>>>")
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 = handleOneCirclesSignInGreenEnergy(res.Body)
if err != nil {
fmt.Println("OneCirclesSignInGreenEnergyConsume_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 handleOneCirclesSignInGreenEnergy(msgData []byte) error {
//1、解析mq中queue的数据结构体
var msg *md.OneCirclesStructForSignIn
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}

engine := db.DBs[msg.MasterId]
err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid)
fmt.Println("err::::", err)
if err != nil {
return err
}
return nil
}

+ 3
- 3
etc/cfg.yml View File

@@ -29,10 +29,10 @@ wxapplet_filepath:

# 连接官网数据库获取db mapping
db:
host: 'zhios123.rwlb.rds.aliyuncs.com:3306'
host: '119.23.182.117:3306'
name: 'zyos_website'
user: 'canal'
psw: 'canal'
user: 'root'
psw: 'Fnuo123com@'
show_log: true
max_lifetime: 30
max_open_conns: 100


+ 1
- 1
go.mod View File

@@ -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.20240119104238-05c3962029ff
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240228103137-25bbc2fa494f
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


Loading…
Cancel
Save