package user

import (
	"context"
	"git.oa00.com/supply-chain/service/client"
	"github.com/shopspring/decimal"
)

type deposit struct {
}
type applyType uint // 申请人类型
const (
	ApplyTypeCustomer = 1 // 客户
	ApplyTypePlatform = 2 // 平台

	DepositAuditStatusWait   = 1 // 待审核
	DepositAuditStatusAdopt  = 2 // 审核通过
	DepositAuditStatusReject = 3 // 审核驳回
)

type ArgsDepositAdd struct {
	UserId      uint            // 客户id
	ApplyType   uint            // 申请人类型 1=客户 2=平台
	ApplyUserId uint            // 申请人id
	Amount      decimal.Decimal // 充值金额
	Proof       string          // 充值凭证
	DepositAt   int64           // 充值时间
	Remark      string          // 备注
}

// Add @Title 充值
func (d *deposit) Add(ctx context.Context, args ArgsDepositAdd) error {
	reply := 0
	xClient, err := client.GetClient(d)
	if err != nil {
		return err
	}
	return xClient.Call(ctx, "Add", args, &reply)
}

type ArgsDepositInfo struct {
	DepositId uint // 充值记录id 必须
	UserId    uint // 用户id 可选
}
type ReplyDepositInfo struct {
	Id          uint            `json:"id"`
	UserId      uint            `json:"userId"`
	UserName    string          `json:"userName"`
	Amount      decimal.Decimal `json:"amount"`
	ApplyType   uint            `json:"applyType"`
	ApplyUserId uint            `json:"applyUserId"`
	ApplyAt     int64           `json:"applyAt"`
	Proof       string          `json:"proof"`
	DepositAt   int64           `json:"depositAt"`
	Remark      string          `json:"remark"`
	AuditStatus uint            `json:"auditStatus"`
	AuditUserId uint            `json:"auditUserId"`
	AuditAt     int64           `json:"auditAt"`
	Reason      string          `json:"reason"`
}

// Info @Title 详情
func (d *deposit) Info(ctx context.Context, args ArgsDepositInfo) (reply ReplyDepositInfo, err error) {
	xClient, err := client.GetClient(d)
	if err != nil {
		return
	}
	err = xClient.Call(ctx, "Info", args, &reply)
	return
}