@@ -80,11 +80,11 @@ func initConsumes() { | |||||
//////////////////////////////////////// oneCircles ///////////////////////////////////////////////////// | //////////////////////////////////////// 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 | //jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume | ||||
//////////////////////////////////////// withdraw ///////////////////////////////////////////////////// | //////////////////////////////////////// withdraw ///////////////////////////////////////////////////// | ||||
@@ -94,6 +94,9 @@ func initConsumes() { | |||||
//jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分 | //jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分 | ||||
//jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化 | //jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化 | ||||
jobs[consumeMd.InstallmentPaymentAutoRepaidConsumeFunName] = InstallmentPaymentAutoRepaidConsume //分期付 - 自动扣款 | |||||
} | } | ||||
func Run() { | func Run() { | ||||
@@ -497,6 +497,15 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||||
BindKey: "", | BindKey: "", | ||||
ConsumeFunName: "FlexibleEmploymentWithdrawForPupiaoConsume", | ConsumeFunName: "FlexibleEmploymentWithdrawForPupiaoConsume", | ||||
}, | }, | ||||
{ | |||||
ExchangeName: "installment.payment", | |||||
Name: "zhios_installment_payment_auto_repaid", | |||||
Type: DirectQueueType, | |||||
IsPersistent: false, | |||||
RoutKey: "auto_repaid", | |||||
BindKey: "", | |||||
ConsumeFunName: "InstallmentPaymentAutoRepaidConsume", | |||||
}, | |||||
} | } | ||||
const ( | const ( | ||||
@@ -555,4 +564,5 @@ const ( | |||||
FlexibleEmploymentWithdrawForGongMaoConsumeFunName = "FlexibleEmploymentWithdrawForGongMaoConsume" | FlexibleEmploymentWithdrawForGongMaoConsumeFunName = "FlexibleEmploymentWithdrawForGongMaoConsume" | ||||
FlexibleEmploymentWithdrawForPupiaoConsumeFunName = "FlexibleEmploymentWithdrawForPupiaoConsume" | FlexibleEmploymentWithdrawForPupiaoConsumeFunName = "FlexibleEmploymentWithdrawForPupiaoConsume" | ||||
ZhiosTaskTotal = "zhiosTaskTotal" | ZhiosTaskTotal = "zhiosTaskTotal" | ||||
InstallmentPaymentAutoRepaidConsumeFunName = "InstallmentPaymentAutoRepaidConsume" | |||||
) | ) |
@@ -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 | |||||
} |