package user

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

type depositAudit struct {
}

type ArgsDepositAuditLists struct {
	Search DepositAuditSearch
	Page   bean.Page
}

type DepositAuditSearch struct {
	Status         uint            // 审核状态 1=待审核 2=通过 3=驳回
	Name           string          // 客户名称
	Amount         decimal.Decimal // 充值金额
	ApplyDateStart string          // 申请日期
	ApplyDateEnd   string          // 申请日期
	AuditDateStart string          // 审核日期
	AuditDateEnd   string          // 审核日期
	ApplyUserId    uint            // 充值申请人
}
type ReplyDepositAuditList struct {
	Lists []DepositAuditItem `json:"lists"`
	Total int64              `json:"total"`
}
type DepositAuditItem 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"`
	AuditStatus uint            `json:"auditStatus"`
	AuditUserId uint            `json:"auditUserId"`
	AuditAt     int64           `json:"auditAt"`
	Reason      string          `json:"reason"`
}

// Lists @Title 充值审核列表
func (d *depositAudit) Lists(ctx context.Context, args ArgsDepositAuditLists) (reply ReplyDepositAuditList, err error) {
	xClient, err := client.GetClient(d)
	if err != nil {
		return
	}
	err = xClient.Call(ctx, "Lists", args, &reply)
	return
}

type ArgsDepositAuditAdopt struct {
	DepositId   uint // 充值记录id
	AuditUserId uint // 审核人id
}

// Adopt @Title 通过
func (d *depositAudit) Adopt(ctx context.Context, args ArgsDepositAuditAdopt) error {
	reply := 0
	xClient, err := client.GetClient(d)
	if err != nil {
		return err
	}
	return xClient.Call(ctx, "Adopt", args, &reply)

}

type ArgsDepositAuditReject struct {
	DepositId   uint   // 充值记录id
	AuditUserId uint   // 审核人id
	Reason      string // 驳回原因
}

// Reject @Title 驳回
func (d *depositAudit) Reject(ctx context.Context, args ArgsDepositAuditReject) error {
	reply := 0
	xClient, err := client.GetClient(d)
	if err != nil {
		return err
	}
	return xClient.Call(ctx, "Reject", args, &reply)
}