You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
service/customer/user/wallet.go

94 lines
2.3 KiB

package user
import (
"context"
"git.oa00.com/supply-chain/service/client"
"github.com/shopspring/decimal"
)
type wallet struct {
}
type walletType uint // 费用类型
const (
2 years ago
WalletTypeIncome walletType = 1 // 收入 +
WalletTypeExpend walletType = 2 // 支出 -
WalletTypeBack walletType = 3 // 退款 +
WalletTypeCash walletType = 4 // 提现 -
WalletStatusHandle = 1 // 处理中
WalletStatusSuccess = 2 // 成功
WalletStatusFail = 3 // 失败
)
type ArgsWalletDirect struct {
UserId uint // 客户id
WalletType walletType // 收支类型
Amount decimal.Decimal // 金额 正数
ServiceId uint // 服务id
TradeChannel string // 交易渠道
TradeSerialSn string // 交易渠道流水号
Remark string // 备注信息
}
// Direct @Title 直接消费
func (w *wallet) Direct(ctx context.Context, args ArgsWalletDirect) error {
reply := 0
xClient, err := client.GetClient(w)
if err != nil {
return err
}
return xClient.Call(ctx, "Direct", args, &reply)
}
type ArgsWalletCreate struct {
UserId uint // 客户id
WalletType walletType // 收支类型
Amount decimal.Decimal // 金额 正数
ServiceId uint // 服务id
TradeChannel string // 交易渠道
TradeSerialSn string // 交易渠道流水号
Remark string // 备注信息
CancelSecond int64 // 自动取消秒
}
// Create @Title 创建消费
func (w *wallet) Create(ctx context.Context, args ArgsWalletCreate) (walletId uint, err error) {
xClient, err := client.GetClient(w)
if err != nil {
return
}
err = xClient.Call(ctx, "Create", args, &walletId)
return
}
type ArgsWalletSuccess struct {
UserId uint // 客户id
WalletId uint // 消费id
}
// Success @Title 成功
2 years ago
func (w *wallet) Success(ctx context.Context, args ArgsWalletSuccess) error {
reply := 0
xClient, err := client.GetClient(w)
if err != nil {
2 years ago
return err
}
2 years ago
return xClient.Call(ctx, "Success", args, &reply)
}
type ArgsWalletFail struct {
UserId uint // 客户id
WalletId uint // 消费id
}
// Fail @Title 失败
2 years ago
func (w *wallet) Fail(ctx context.Context, args ArgsWalletFail) error {
reply := 0
xClient, err := client.GetClient(w)
if err != nil {
2 years ago
return err
}
2 years ago
return xClient.Call(ctx, "Fail", args, &reply)
}