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

90 lines
2.1 KiB

package user
import (
"context"
"git.oa00.com/supply-chain/service/client"
"github.com/shopspring/decimal"
)
type wallet struct {
}
type walletType uint // 费用类型
const (
WalletTypeIncome walletType = 1 // 收入
WalletTypeExpend walletType = 2 // 支出
WalletTypeBack = 3 // 退款
WalletTypeConsumption = 4 // 消费
WalletStatusHandle = 1 // 处理中
WalletStatusSuccess = 2 // 成功
WalletStatusFail = 3 // 失败
)
type ArgsWalletDirect struct {
UserId uint // 客户id
WalletType walletType // 收支类型
Amount decimal.Decimal // 金额 正数
ServiceId uint // 服务id
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
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 成功
func (w *wallet) Success(ctx context.Context, args ArgsWalletSuccess) error {
reply := 0
xClient, err := client.GetClient(w)
if err != nil {
return err
}
return xClient.Call(ctx, "Success", args, &reply)
}
type ArgsWalletFail struct {
UserId uint // 客户id
WalletId uint // 消费id
}
// Fail @Title 失败
func (w *wallet) Fail(ctx context.Context, args ArgsWalletFail) error {
reply := 0
xClient, err := client.GetClient(w)
if err != nil {
return err
}
return xClient.Call(ctx, "Fail", args, &reply)
}