Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	consume/init.go
#	go.mod
one_orenge
huangjiajun 9 months ago
parent
commit
39d868ab03
7 changed files with 209 additions and 47 deletions
  1. +1
    -1
      app/db/dbs_map.go
  2. +44
    -41
      consume/init.go
  3. +22
    -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. +66
    -0
      consume/one_circles_sign_in_copy_consume.go
  7. +3
    -3
      etc/cfg.yml

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

@@ -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)
}


+ 44
- 41
consume/init.go View File

@@ -17,49 +17,48 @@ func Init() {

// 增加消费任务队列
func initConsumes() {
jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume
jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
//jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge
//jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv
//jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
//jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
//jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
//jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
////
//jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
//jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
//jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
////
//jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
//jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
//
jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
//jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
//jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
//
//jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
//
//jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
//jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
//jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
//jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
//jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
//
//jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
//jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
//jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
//jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
//
//jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
//
//jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
//
//jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
//jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
//jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
//
//jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
//jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
//jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
//
jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder

jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser

jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition

jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv

jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond

jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore

jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail

jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate

jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
////

////////////////////////////////////// V1 /////////////////////////////////////////////////////
//jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
@@ -75,6 +74,10 @@ func initConsumes() {
//jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
//jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
//jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume

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

func Run() {


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

@@ -396,7 +396,25 @@ 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",
},
{
ExchangeName: "one.circles",
Name: "one_circles_sign_in_green_energy_copy",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "sign_in_copy",
BindKey: "",
ConsumeFunName: "OneCirclesSignInCopyGreenEnergyConsume",
},
}

@@ -444,5 +462,7 @@ const (
ZhiosAcquisitionConditionDevFunName = "ZhiosAcquisitionConditionDev"
SupplyCloudChainFenxiaoNewChangeFunName = "SupplyCloudChainFenxiaoNewChangeConsume"
MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume"
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCcoinFlowConsume"
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume"
OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume"
OneCirclesSignInCopyGreenEnergyFunName = "OneCirclesSignInCopyGreenEnergyConsume"
)

+ 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
}

+ 66
- 0
consume/one_circles_sign_in_copy_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 OneCirclesSignInCopyGreenEnergyConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesSignInCopyGreenEnergyConsume>>>>>>>>>>>>")
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 = handleOneCirclesSignInCopyGreenEnergy(res.Body)
if err != nil {
fmt.Println("OneCirclesSignInCopyGreenEnergyConsume_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 handleOneCirclesSignInCopyGreenEnergy(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


Loading…
Cancel
Save