first commit
This commit is contained in:
625
pkg/partner/mq/message_client.go
Normal file
625
pkg/partner/mq/message_client.go
Normal file
@ -0,0 +1,625 @@
|
||||
package mq
|
||||
|
||||
import (
|
||||
"servicebase/pkg/common/HyTools"
|
||||
mq_http "servicebase/pkg/partner/mq/http"
|
||||
message2 "servicebase/pkg/partner/mq/message"
|
||||
"servicebase/pkg/partner/mq/pusher"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
client pusher.PushClient
|
||||
)
|
||||
|
||||
// MessageClient Message客户端
|
||||
type MessageClient struct {
|
||||
}
|
||||
|
||||
type MessageClientStarter struct {
|
||||
}
|
||||
|
||||
func (s *MessageClientStarter) Init() error {
|
||||
client = mq_http.NewHttpClient()
|
||||
return nil
|
||||
}
|
||||
|
||||
// PushRewardMessage 发布打赏消息
|
||||
func (*MessageClient) PushRewardMessage(from, to string, fromAmount, toAmount, createTime, rewardId, roomId, fromPlatform, guildId string, code message2.TransactionCodeEnum) (e error) {
|
||||
fromA, _ := strconv.Atoi(fromAmount)
|
||||
toA, _ := strconv.Atoi(toAmount)
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: from, FromCurrency: message2.DIAMOND, FromAmount: fromAmount,
|
||||
ToUserId: to, ToCurrency: message2.CRYSTAL, ToAmount: toAmount,
|
||||
TransactionRate: strconv.Itoa(fromA - toA),
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.REWARD,
|
||||
TransactionId: rewardId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: roomId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: fromAmount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: fromAmount,
|
||||
FromPlatform: fromPlatform,
|
||||
GuildId: guildId,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushRewardNCoinMessage 发布打赏消息
|
||||
func (*MessageClient) PushRewardNCoinMessage(from, to string, fromAmount, toAmount, createTime, rewardId, roomId, fromPlatform, guildId string, code message2.TransactionCodeEnum) (e error) {
|
||||
fromA, _ := strconv.Atoi(fromAmount)
|
||||
toA, _ := strconv.Atoi(toAmount)
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: from, FromCurrency: message2.DIAMOND, FromAmount: fromAmount,
|
||||
ToUserId: to, ToCurrency: message2.CRYSTAL, ToAmount: toAmount,
|
||||
TransactionRate: strconv.Itoa(fromA - toA),
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.REWARDNCoin,
|
||||
TransactionId: rewardId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: roomId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: fromAmount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: fromAmount,
|
||||
FromPlatform: fromPlatform,
|
||||
GuildId: guildId,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushGuardMessage 发布购买守护消息
|
||||
func (*MessageClient) PushGuardMessage(from, to string, fromAmount, toAmount, createTime, rewardId, roomId, fromPlatform string, code message2.TransactionCodeEnum) (e error) {
|
||||
fromA, _ := strconv.Atoi(fromAmount)
|
||||
toA, _ := strconv.Atoi(toAmount)
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: from, FromCurrency: message2.DIAMOND, FromAmount: fromAmount,
|
||||
ToUserId: to, ToCurrency: message2.CRYSTAL, ToAmount: toAmount,
|
||||
TransactionRate: strconv.Itoa(fromA - toA),
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.GUARD,
|
||||
TransactionId: rewardId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: roomId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: fromAmount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: fromAmount,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushExchangeMessage 发布兑换消息
|
||||
func (*MessageClient) PushExchangeMessage(userId, crystal, exchangeId, createTime, fromPlatform string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.CRYSTAL, FromAmount: crystal,
|
||||
ToUserId: userId, ToCurrency: message2.DIAMOND, ToAmount: crystal,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.EXCHANGE,
|
||||
TransactionId: exchangeId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: crystal,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: crystal,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushExchangeNCoinMessage 发布兑换消息
|
||||
func (*MessageClient) PushExchangeNCoinMessage(userId, crystal, exchangeId, createTime, fromPlatform string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.CRYSTAL, FromAmount: crystal,
|
||||
ToUserId: userId, ToCurrency: message2.DIAMOND, ToAmount: crystal,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.EXCHANGENCoin,
|
||||
TransactionId: exchangeId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: crystal,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: crystal,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushHuntingMessage 发布星空寻宝(砸蛋)消息
|
||||
func (*MessageClient) PushHuntingMessage(userId, pay, win, huntingId, solutionId, createTime, fromPlatform string, code message2.TransactionCodeEnum) (e error) {
|
||||
payAmount, _ := strconv.Atoi(pay)
|
||||
winAmount, _ := strconv.Atoi(win)
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.DIAMOND, FromAmount: pay,
|
||||
ToUserId: userId, ToCurrency: message2.DIAMOND, ToAmount: win,
|
||||
TransactionRate: strconv.Itoa(payAmount - winAmount),
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.HUNTING,
|
||||
TransactionId: huntingId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: solutionId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: pay,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: pay,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushLuckGiftMessage 发布幸运礼物消息
|
||||
func (*MessageClient) PushLuckGiftMessage(userId, toUserId, pay, win, luckId, solutionId, createTime, fromPlatform string, code message2.TransactionCodeEnum) (e error) {
|
||||
payAmount, _ := strconv.Atoi(pay)
|
||||
winAmount, _ := strconv.Atoi(win)
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.DIAMOND, FromAmount: pay,
|
||||
ToUserId: toUserId, ToCurrency: message2.DIAMOND, ToAmount: win,
|
||||
TransactionRate: strconv.Itoa(payAmount - winAmount),
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.LuckGift,
|
||||
TransactionId: luckId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: solutionId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: pay,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: pay,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushLuckGiftNCoinMessage 发布幸运礼物消息
|
||||
func (*MessageClient) PushLuckGiftNCoinMessage(userId, toUserId, pay, win, luckId, solutionId, createTime, fromPlatform string, code message2.TransactionCodeEnum) (e error) {
|
||||
payAmount, _ := strconv.Atoi(pay)
|
||||
winAmount, _ := strconv.Atoi(win)
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.DIAMOND, FromAmount: pay,
|
||||
ToUserId: toUserId, ToCurrency: message2.DIAMOND, ToAmount: win,
|
||||
TransactionRate: strconv.Itoa(payAmount - winAmount),
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.LuckGiftNCoin,
|
||||
TransactionId: luckId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: solutionId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: pay,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: pay,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushRechargeMessage 发布充值消息(还未到账)
|
||||
func (*MessageClient) PushRechargeMessage(userId, pay, get, rechargeId, productId, createTime, fromPlatform string, code message2.TransactionCodeEnum) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.MONEY, FromAmount: pay,
|
||||
ToUserId: userId, ToCurrency: message2.DIAMOND, ToAmount: get,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.RECHARGE,
|
||||
TransactionId: rechargeId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: productId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: pay,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: pay,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushRechargeNCoinMessage 发布充值N币消息(还未到账)
|
||||
func (*MessageClient) PushRechargeNCoinMessage(userId, pay, get, rechargeId, productId, createTime, fromPlatform string, code message2.TransactionCodeEnum) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.MONEY, FromAmount: pay,
|
||||
ToUserId: userId, ToCurrency: message2.NCoin, ToAmount: get,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.RechargeNCoin,
|
||||
TransactionId: rechargeId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: productId,
|
||||
TransactionCode: code,
|
||||
TransactionAmount: pay,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: pay,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOperationDiamondMessage 发布加钻石消息
|
||||
func (*MessageClient) PushOperationDiamondMessage(userId, amount, businessId, createTime string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.MONEY, FromAmount: "0",
|
||||
ToUserId: userId, ToCurrency: message2.DIAMOND, ToAmount: amount,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.OperationDiamond,
|
||||
TransactionId: businessId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: amount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: "0",
|
||||
FromPlatform: "OPERATION",
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOperationDiamondRetrieveMessage 发布钻石回收消息
|
||||
func (*MessageClient) PushOperationDiamondRetrieveMessage(userId, amount, businessId, createTime string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.MONEY, FromAmount: "0",
|
||||
ToUserId: userId, ToCurrency: message2.DIAMOND, ToAmount: amount,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.OperationDiamond,
|
||||
TransactionId: businessId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: amount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: "0",
|
||||
FromPlatform: "OPERATION",
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOperationCrystalMessage 发布加晶石消息
|
||||
func (*MessageClient) PushOperationCrystalMessage(userId, amount, businessId, createTime string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.MONEY, FromAmount: "0",
|
||||
ToUserId: userId, ToCurrency: message2.CRYSTAL, ToAmount: amount,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.OperationCrystal,
|
||||
TransactionId: businessId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: amount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: "0",
|
||||
FromPlatform: "OPERATION",
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOperationCrystalReduceMessage 发布扣除晶石消息
|
||||
func (*MessageClient) PushOperationCrystalReduceMessage(userId, amount, businessId, createTime string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.MONEY, FromAmount: "0",
|
||||
ToUserId: userId, ToCurrency: message2.CRYSTAL, ToAmount: amount,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.SUCCESS,
|
||||
TransactionType: message2.OperationCrystalReduce,
|
||||
TransactionId: businessId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: createTime,
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: amount,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: "0",
|
||||
FromPlatform: "OPERATION",
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushWithdrawMessage 发布提现消息(还未完成)
|
||||
func (*MessageClient) PushWithdrawMessage(userId, crystal, money, huntingId, createTime, fromPlatform string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.CRYSTAL, FromAmount: crystal,
|
||||
ToUserId: userId, ToCurrency: message2.MONEY, ToAmount: money,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.WITHDRAW,
|
||||
TransactionId: huntingId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: crystal,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: crystal,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushWithdrawNCoinMessage 发布N币提现消息(还未完成)
|
||||
func (*MessageClient) PushWithdrawNCoinMessage(userId, crystal, money, huntingId, createTime, fromPlatform string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.NCoin, FromAmount: crystal,
|
||||
ToUserId: userId, ToCurrency: message2.MONEY, ToAmount: money,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.WithdrawNCoin,
|
||||
TransactionId: huntingId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: crystal,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: crystal,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushWithdrawTimelyMessage 发布提现消息(还未完成)
|
||||
func (*MessageClient) PushWithdrawTimelyMessage(userId, crystal, money, rate, payMoney, huntingId, createTime, fromPlatform string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: userId, FromCurrency: message2.CRYSTAL, FromAmount: crystal,
|
||||
ToUserId: userId, ToCurrency: message2.MONEY, ToAmount: money,
|
||||
TransactionRate: rate,
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.WithdrawTimely,
|
||||
TransactionId: huntingId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: "",
|
||||
TransactionCode: "",
|
||||
TransactionAmount: crystal,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: crystal,
|
||||
FromPlatform: fromPlatform,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOrderMessage 发布订单消息(还未完成)下单用户、接单用户、支付钻石、到账晶石、订单id、技能id、创建时间、下单平台
|
||||
func (*MessageClient) PushOrderMessage(fromUserId, toUserId, diamond, crystal, orderId, skillId, createTime, fromPlatform, guildId string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: fromUserId, FromCurrency: message2.DIAMOND, FromAmount: diamond,
|
||||
ToUserId: toUserId, ToCurrency: message2.CRYSTAL, ToAmount: crystal,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.ORDER,
|
||||
TransactionId: orderId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: skillId,
|
||||
TransactionCode: "",
|
||||
TransactionAmount: diamond,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: diamond,
|
||||
FromPlatform: fromPlatform,
|
||||
GuildId: guildId,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOrderNCoinMessage 发布订单消息(还未完成)下单用户、接单用户、支付钻石、到账晶石、订单id、技能id、创建时间、下单平台
|
||||
func (*MessageClient) PushOrderNCoinMessage(fromUserId, toUserId, diamond, crystal, orderId, skillId, createTime, fromPlatform, guildId string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: fromUserId, FromCurrency: message2.DIAMOND, FromAmount: diamond,
|
||||
ToUserId: toUserId, ToCurrency: message2.CRYSTAL, ToAmount: crystal,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.ORDERNCoin,
|
||||
TransactionId: orderId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: skillId,
|
||||
TransactionCode: "",
|
||||
TransactionAmount: diamond,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: diamond,
|
||||
FromPlatform: fromPlatform,
|
||||
GuildId: guildId,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOrderMessageH5 发布订单消息(还未完成)下单用户、接单用户、支付钻石、到账晶石、订单id、技能id、创建时间、下单平台
|
||||
func (*MessageClient) PushOrderMessageH5(fromUserId, toUserId, diamond, crystal, orderId, skillId, createTime, fromPlatform, guildId, channel string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: fromUserId, FromCurrency: message2.DIAMOND, FromAmount: diamond,
|
||||
ToUserId: toUserId, ToCurrency: message2.CRYSTAL, ToAmount: crystal,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.OrderH5,
|
||||
TransactionId: orderId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: skillId,
|
||||
TransactionCode: message2.TransactionCodeEnum(channel),
|
||||
TransactionAmount: diamond,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: diamond,
|
||||
FromPlatform: fromPlatform,
|
||||
GuildId: guildId,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushOrderNCoinMessageH5 发布订单消息(还未完成)下单用户、接单用户、支付钻石、到账晶石、订单id、技能id、创建时间、下单平台
|
||||
func (*MessageClient) PushOrderNCoinMessageH5(fromUserId, toUserId, diamond, crystal, orderId, skillId, createTime, fromPlatform, guildId, channel string) (e error) {
|
||||
message := message2.TransactionMessage{
|
||||
FromUserId: fromUserId, FromCurrency: message2.DIAMOND, FromAmount: diamond,
|
||||
ToUserId: toUserId, ToCurrency: message2.CRYSTAL, ToAmount: crystal,
|
||||
TransactionRate: "0",
|
||||
TransactionState: message2.CREATED,
|
||||
TransactionType: message2.OrderH5NCoin,
|
||||
TransactionId: orderId,
|
||||
TransactionCreateTime: createTime,
|
||||
TransactionCompleteTime: "",
|
||||
TransactionSubjectId: skillId,
|
||||
TransactionCode: message2.TransactionCodeEnum(channel),
|
||||
TransactionAmount: diamond,
|
||||
TransactionAmountCoupon: "0",
|
||||
TransactionAmountCouponId: "",
|
||||
TransactionAmountPay: diamond,
|
||||
FromPlatform: fromPlatform,
|
||||
GuildId: guildId,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushTransactionCompleteMessage 发布交易更新消息(提现完成、充值到账等)
|
||||
func (*MessageClient) PushTransactionCompleteMessage(businessId, completeTime string, state message2.TransactionStateEnum) (e error) {
|
||||
if (state) != (message2.SUCCESS) && (state) != (message2.FAILED) {
|
||||
e = errors.New("交易状态只能是完成状态")
|
||||
return
|
||||
}
|
||||
message := message2.TransactionUpdateMessage{
|
||||
TransactionState: state,
|
||||
TransactionId: businessId,
|
||||
TransactionCompleteTime: completeTime,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushTransactionUpdateMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushActiveMessage 发布活跃消息
|
||||
func (*MessageClient) PushActiveMessage(userId, deviceId, time, platform, deviceModel, ip string) (e error) {
|
||||
if len(strings.Split(time, " ")) != 2 {
|
||||
e = errors.New("活跃时间格式错误!")
|
||||
return
|
||||
}
|
||||
message := message2.ActiveMessage{
|
||||
UserId: userId,
|
||||
DeviceId: deviceId,
|
||||
ActiveTime: time,
|
||||
ActivePlatform: platform,
|
||||
ActiveDeviceModel: deviceModel,
|
||||
ActiveIp: ip,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushActiveTopicMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushErrorMessage 发布错误消息
|
||||
func (*MessageClient) PushErrorMessage(code string, content interface{}, tag message2.ErrorTag) (e error) {
|
||||
b, e := json.Marshal(content)
|
||||
if nil != e {
|
||||
return
|
||||
}
|
||||
message := message2.ErrorMessage{
|
||||
Code: code,
|
||||
Content: string(b),
|
||||
Tag: tag,
|
||||
}
|
||||
e = client.PushErrorTopicMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushEventMessage 发布事件消息
|
||||
func (*MessageClient) PushEventMessage(tag message2.EventTag, flag message2.EventFlag, eventId string, content interface{}) (e error) {
|
||||
message := message2.EventMessage{
|
||||
Tag: tag,
|
||||
Flag: flag,
|
||||
EventId: eventId,
|
||||
EventContent: content,
|
||||
}
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
e = client.PushEventTopicMessage(message)
|
||||
return
|
||||
}
|
||||
|
||||
// PushActiveNewTopicMessage 发布激活消息
|
||||
func (*MessageClient) PushActiveNewTopicMessage(message message2.ActiveNewMessage) (e error) {
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
return client.PushActiveNewTopicMessage(message)
|
||||
}
|
||||
|
||||
// PushRegisterMessage 发布注册消息
|
||||
func (*MessageClient) PushRegisterMessage(message message2.RegisterMessage) (e error) {
|
||||
message.MessageId = HyTools.GetUUID()
|
||||
return client.PushRegisterMessage(message)
|
||||
}
|
||||
Reference in New Issue
Block a user