Explorar el Código

update

master
dengbiao hace 3 meses
padre
commit
176829b377
Se han modificado 7 ficheros con 64 adiciones y 47 borrados
  1. +10
    -8
      consume/init.go
  2. +4
    -4
      consume/md/consume_key.go
  3. +31
    -18
      consume/one_circles_sign_in_consume.go
  4. +11
    -9
      consume/one_circles_sign_in_copy_consume.go
  5. BIN
     
  6. +1
    -1
      go.mod
  7. +7
    -7
      k8s/zyos-go-mq-consume-prd.yaml

+ 10
- 8
consume/init.go Ver fichero

@@ -85,14 +85,16 @@ func initConsumes() {
//jobs[consumeMd.CanalO2oPayOrderForNumericalStatementConsumeFunName] = CanalO2oPayOrderForNumericalStatementConsume
//jobs[consumeMd.CanalB2cOrderForNumericalStatementConsumeFunName] = CanalB2cOrderForNumericalStatementConsume

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume
jobs[consumeMd.OneCirclesSignInUpdateRecordsGreenEnergyFunName] = OneCirclesSignInUpdateRecordsGreenEnergyConsume
//////////////////////////////////////// oneCircles-v1 /////////////////////////////////////////////////////
//jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
//jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
//jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
//jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
//jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
//jobs[consumeMd.OneCirclesAddPublicPlatoonUserRelationCommissionFunName] = OneCirclesAddPublicPlatoonUserRelationCommissionConsume

//////////////////////////////////////// oneCircles-v2 /////////////////////////////////////////////////////
jobs[consumeMd.OneCirclesDealUserCoinConsumeFunName] = OneCirclesDealUserCoinConsume

//////////////////////////////////////// withdraw /////////////////////////////////////////////////////
//jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume


+ 4
- 4
consume/md/consume_key.go Ver fichero

@@ -562,12 +562,12 @@ var RabbitMqQueueKeyList = []*MqQueue{
},
{
ExchangeName: "one.circles",
Name: "one_circles_sign_in_update_records",
Name: "one_circles_reward_user_coin",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "sign_in_update_records",
RoutKey: "reward_user_coin",
BindKey: "",
ConsumeFunName: "OneCirclesSignInUpdateRecordsGreenEnergyConsume",
ConsumeFunName: "OneCirclesDealUserCoinConsume",
},
{
ExchangeName: "zhios.app.user.withdraw.apply.exchange",
@@ -661,7 +661,7 @@ const (
MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume"
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume"
OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume"
OneCirclesSignInUpdateRecordsGreenEnergyFunName = "OneCirclesSignInUpdateRecordsGreenEnergyConsume"
OneCirclesDealUserCoinConsumeFunName = "OneCirclesDealUserCoinConsume"
OneCirclesStartLevelDividendFunName = "OneCirclesStartLevelDividendConsume"
OneCirclesActivityCoinAutoExchangeGreenEnergyFunName = "OneCirclesActivityCoinAutoExchangeGreenEnergyConsume"
OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName = "OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume"


+ 31
- 18
consume/one_circles_sign_in_consume.go Ver fichero

@@ -12,6 +12,8 @@ import (
"errors"
"fmt"
"github.com/streadway/amqp"
"os"
"runtime/pprof"
)

func OneCirclesSignInGreenEnergyConsume(queue md.MqQueue) {
@@ -32,33 +34,44 @@ func OneCirclesSignInGreenEnergyConsume(queue md.MqQueue) {

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesSignInGreenEnergy(ch, res.Body)
if err != nil {
fmt.Println("err ::: ", err)
utils.FilePutContents("OneCirclesSignInGreenEnergyConsume_ERR", "[err]:"+err.Error())
_ = res.Reject(true)
//_ = res.Reject(false)
////TODO::重新推回队列末尾,避免造成队列堵塞
//var msg *md.OneCirclesStructForSignIn
//json.Unmarshal(res.Body, &msg)
//ch.Publish(queue.ExchangeName, msg, queue.RoutKey)
} else {
_ = res.Ack(true)
}
//for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesSignInGreenEnergy(ch, res.Body)
if err != nil {
fmt.Println("err ::: ", err)
utils.FilePutContents("OneCirclesSignInGreenEnergyConsume_ERR", "[err]:"+err.Error())
_ = res.Reject(true)
//_ = res.Reject(false)
////TODO::重新推回队列末尾,避免造成队列堵塞
//var msg *md.OneCirclesStructForSignIn
//json.Unmarshal(res.Body, &msg)
//ch.Publish(queue.ExchangeName, msg, queue.RoutKey)
} else {
panic(errors.New("error getting message"))
_ = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
//}
fmt.Println("get msg done")
}

func handleOneCirclesSignInGreenEnergy(ch *rabbit.Channel, msgData []byte) error {
cpuProfile, err := os.Create("./cpu_profile")
if err != nil {
fmt.Printf("创建文件失败:%s", err.Error())
return err
}
defer cpuProfile.Close()

//采集CPU信息
pprof.StartCPUProfile(cpuProfile)
defer pprof.StopCPUProfile()

//1、解析mq中queue的数据结构体
var msg *md.OneCirclesStructForSignIn
err := json.Unmarshal(msgData, &msg)
err = json.Unmarshal(msgData, &msg)
if err != nil {
return err
}


+ 11
- 9
consume/one_circles_sign_in_copy_consume.go Ver fichero

@@ -6,8 +6,8 @@ import (
"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/db/model"
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"
@@ -15,8 +15,8 @@ import (
"github.com/streadway/amqp"
)

func OneCirclesSignInUpdateRecordsGreenEnergyConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesSignInUpdateRecordsGreenEnergyConsume>>>>>>>>>>>>")
func OneCirclesDealUserCoinConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesDealUserCoinConsume>>>>>>>>>>>>")
ch, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
logx.Error(err)
@@ -36,10 +36,10 @@ func OneCirclesSignInUpdateRecordsGreenEnergyConsume(queue md.MqQueue) {
for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesSignInUpdateRecordsGreenEnergyConsume(res.Body)
err = handleOneCirclesDealUserCoinConsume(res.Body)
if err != nil {
fmt.Println("err ::: ", err)
fmt.Println("OneCirclesSignInUpdateRecordsGreenEnergyConsume_ERR:::::", err.Error())
fmt.Println("OneCirclesDealUserCoinConsume_ERR:::::", err.Error())
////TODO::重新推回队列末尾,避免造成队列堵塞
//_ = res.Reject(false)
_ = res.Reject(true)
@@ -53,15 +53,17 @@ func OneCirclesSignInUpdateRecordsGreenEnergyConsume(queue md.MqQueue) {
fmt.Println("get msg done")
}

func handleOneCirclesSignInUpdateRecordsGreenEnergyConsume(msgData []byte) error {
func handleOneCirclesDealUserCoinConsume(msgData []byte) error {
//1、解析mq中queue的数据结构体
var msg *md2.UpdateOneCirclesStructForSignInRecords
var msg *md2.DealUserCoinReq
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
engine := db.DBs["31585332"]
_, err = engine.Where("id =?", msg.Id).Update(&model.OneCirclesGreenEnergySignIn{IsCompleted: 1})

//2、进行虚拟币奖励发放
engine := db.DBs[msg.Mid]
err = rule.DealUserCoin(engine.NewSession(), *msg)
if err != nil {
fmt.Println("err::::", err)
return err



+ 1
- 1
go.mod Ver fichero

@@ -9,7 +9,7 @@ require (
code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git v1.1.2-0.20240607091816-3df1433a2f0d
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.5
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240727102826-b17347dfda58
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240727115614-da7c2fc02dd7
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.20240726151134-db88648c83ef
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20240726093338-fed880ca12ce


+ 7
- 7
k8s/zyos-go-mq-consume-prd.yaml Ver fichero

@@ -2,25 +2,25 @@ kind: Deployment
apiVersion: apps/v1
# 元数据
metadata:
name: zyos-go-mq-consume-v6
name: zyos-go-mq-consume-one-circles-v2
namespace: zhios
labels:
app: zyos-go-mq-consume-v6
app: zyos-go-mq-consume-one-circles-v2
annotations:
kubesphere.io/creator: dengbiao
kubesphere.io/description: 绿色双链积分
kubesphere.io/description: 一个圈圈v2
# deployment主要部分
spec:
replicas: 1
selector:
matchLabels:
# 名称与上面的labels对应
app: zyos-go-mq-consume-v6
app: zyos-go-mq-consume-one-circles-v2
template:
metadata:
labels:
# 名称与上面的matchLabels对应
app: zyos-go-mq-consume-v6
app: zyos-go-mq-consume-one-circles-v2
spec:
# 声明挂载卷(将外部已存在的pvc、config等挂载进来)
volumes:
@@ -37,9 +37,9 @@ spec:
defaultMode: 420
containers:
# 主容器
- name: zhios-zyos-go-mq-consume-v6-container
- name: zhios-zyos-go-mq-consume-one-circles-v2-container
# 镜像地址(提前打包好并推送的镜像仓库)
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-zyos-go-mq-consume-v6:20240310-01'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/zyos-go-mq-consume-one-circles-v2:20240727-01'
# 将前面volume声明的需要用到的pvc、config挂载上来
volumeMounts:
- name: host-time


Cargando…
Cancelar
Guardar