浏览代码

add 分付自动扣款消费脚本

order_statistics
dengbiao 5 个月前
父节点
当前提交
c55782302e
共有 3 个文件被更改,包括 84 次插入5 次删除
  1. +8
    -5
      consume/init.go
  2. +10
    -0
      consume/md/consume_key.go
  3. +66
    -0
      consume/zhios_installment_payment_auto_repaid_consume.go

+ 8
- 5
consume/init.go 查看文件

@@ -80,11 +80,11 @@ func initConsumes() {

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////

jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
//jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
//jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
//jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
//jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
//jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
//jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume

//////////////////////////////////////// withdraw /////////////////////////////////////////////////////
@@ -94,6 +94,9 @@ func initConsumes() {

//jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
//jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化

jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款

}

func Run() {


+ 10
- 0
consume/md/consume_key.go 查看文件

@@ -497,6 +497,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "FlexibleEmploymentWithdrawForPupiaoConsume",
},
{
ExchangeName: "installment.payment",
Name: "zhios_installment_payment_auto_repaid",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "auto_repaid",
BindKey: "",
ConsumeFunName: "InstallmentPaymentAutoRepaidConsume",
},
}

const (
@@ -555,4 +564,5 @@ const (
FlexibleEmploymentWithdrawForGongMaoConsumeFunName = "FlexibleEmploymentWithdrawForGongMaoConsume"
FlexibleEmploymentWithdrawForPupiaoConsumeFunName = "FlexibleEmploymentWithdrawForPupiaoConsume"
ZhiosTaskTotal = "zhiosTaskTotal"
InstallmentPaymentAutoRepaidConsumeFunName = "InstallmentPaymentAutoRepaidConsume"
)

+ 66
- 0
consume/zhios_installment_payment_auto_repaid_consume.go 查看文件

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

import (
"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/installment_payment"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/installment_payment/md"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"time"
)

func InstallmentPaymentAutoRepaidConsume(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(">>>>>>>>>>>>>>>>InstallmentPaymentAutoRepaidConsume<<<<<<<<<<<<<<<<<<<<<<<<<")
err = handleZhiosOneCirclesCoinConsume(res.Body)
if err != nil {
fmt.Println("handleInstallmentPaymentAutoRepaidConsumeERR:::::", 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 handleInstallmentPaymentAutoRepaidConsume(msgData []byte) error {
time.Sleep(time.Duration(2) * time.Millisecond) //休眠2毫秒

//1、解析mq中queue的数据结构体
var msg *md2.InstallmentPaymentStructForAutoRepaid
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
engine := db.DBs[msg.MasterId]

//2、调用 `DealInstallmentPaymentAutoRepaid` 制度方法进行扣款
err = installment_payment.DealInstallmentPaymentAutoRepaid(engine, *msg, msg.MasterId)
return nil
}

正在加载...
取消
保存