package dto

import (
	"github.com/shopspring/decimal"
	"time"

	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type VtsRechargeGetPageReq struct {
	dto.Pagination `search:"-"`
	CoinCode       string `form:"coinCode"  search:"type:exact;column:coin_code;table:vts_recharge" comment:"币种"`
	OrderNo        string `form:"orderNo"  search:"type:exact;column:order_no;table:vts_recharge" comment:"订单号"`
	AdUserId       int64  `form:"adUserId"  search:"type:exact;column:ad_user_id;table:vts_recharge" comment:"用户id"`
	VtsRechargeOrder
}

type VtsRechargeOrder struct {
	Id              string `form:"idOrder"  search:"type:order;column:id;table:vts_recharge"`
	CoinCode        string `form:"coinCodeOrder"  search:"type:order;column:coin_code;table:vts_recharge"`
	TranType        string `form:"tranTypeOrder"  search:"type:order;column:tran_type;table:vts_recharge"`
	OrderNo         string `form:"orderNoOrder"  search:"type:order;column:order_no;table:vts_recharge"`
	AdUserId        string `form:"adUserIdOrder"  search:"type:order;column:ad_user_id;table:vts_recharge"`
	Amount          string `form:"amountOrder"  search:"type:order;column:amount;table:vts_recharge"`
	PriceCurrency   string `form:"priceCurrencyOrder"  search:"type:order;column:price_currency;table:vts_recharge"`
	ReceiveAmount   string `form:"receiveAmountOrder"  search:"type:order;column:receive_amount;table:vts_recharge"`
	PayAmount       string `form:"payAmountOrder"  search:"type:order;column:pay_amount;table:vts_recharge"`
	PayCurrency     string `form:"payCurrencyOrder"  search:"type:order;column:pay_currency;table:vts_recharge"`
	UnderpaidAmount string `form:"underpaidAmountOrder"  search:"type:order;column:underpaid_amount;table:vts_recharge"`
	OverpaidAmount  string `form:"overpaidAmountOrder"  search:"type:order;column:overpaid_amount;table:vts_recharge"`
	IsRefundable    string `form:"isRefundableOrder"  search:"type:order;column:is_refundable;table:vts_recharge"`
	WalletCreateAt  string `form:"walletCreateAtOrder"  search:"type:order;column:wallet_create_at;table:vts_recharge"`
	WalletId        string `form:"walletIdOrder"  search:"type:order;column:wallet_id;table:vts_recharge"`
	Fee             string `form:"feeOrder"  search:"type:order;column:fee;table:vts_recharge"`
	CallbackAt      string `form:"callbackAtOrder"  search:"type:order;column:callback_at;table:vts_recharge"`
	Status          string `form:"statusOrder"  search:"type:order;column:status;table:vts_recharge"`
	ConfirmStatus   string `form:"confirmStatusOrder"  search:"type:order;column:confirm_status;table:vts_recharge"`
	Remark          string `form:"remarkOrder"  search:"type:order;column:remark;table:vts_recharge"`
	CreatedAt       string `form:"createdAtOrder"  search:"type:order;column:created_at;table:vts_recharge"`
	UpdatedAt       string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:vts_recharge"`
	DeletedAt       string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:vts_recharge"`
	CreateBy        string `form:"createByOrder"  search:"type:order;column:create_by;table:vts_recharge"`
	UpdateBy        string `form:"updateByOrder"  search:"type:order;column:update_by;table:vts_recharge"`
}

func (m *VtsRechargeGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type VtsRechargeInsertReq struct {
	Id              int             `json:"-" comment:""` //
	CoinCode        string          `json:"coinCode" comment:"币种"`
	TranType        int             `json:"tranType" comment:"类型：1-线上 2-内部"`
	OrderNo         string          `json:"orderNo" comment:"订单号"`
	AdUserId        int             `json:"adUserId" comment:"用户id"`
	Amount          decimal.Decimal `json:"amount" comment:"订单价格"`
	PriceCurrency   string          `json:"priceCurrency" comment:"CoinGate结算货币代码"`
	ReceiveAmount   decimal.Decimal `json:"receiveAmount" comment:"实收数量"`
	PayAmount       decimal.Decimal `json:"payAmount" comment:"实际支付数量"`
	PayCurrency     string          `json:"payCurrency" comment:"实际支付的加密货币"`
	UnderpaidAmount decimal.Decimal `json:"underpaidAmount" comment:"买家少付数量"`
	OverpaidAmount  decimal.Decimal `json:"overpaidAmount" comment:"买家多付数量"`
	IsRefundable    int             `json:"isRefundable" comment:"指示购物者是否可以请求发票退款"`
	WalletCreateAt  time.Time       `json:"walletCreateAt" comment:"第三方创建时间"`
	WalletId        int             `json:"walletId" comment:"第三方钱包订单"`
	Fee             decimal.Decimal `json:"fee" comment:"手续费"`
	CallbackAt      time.Time       `json:"callbackAt" comment:"回调时间"`
	Status          string          `json:"status" comment:"状态"`
	ConfirmStatus   string          `json:"confirmStatus" comment:"确认状态"`
	Remark          string          `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *VtsRechargeInsertReq) Generate(model *models.VtsRecharge) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.CoinCode = s.CoinCode
	model.TranType = s.TranType
	model.OrderNo = s.OrderNo
	model.AdUserId = s.AdUserId
	model.Amount = s.Amount
	model.PriceCurrency = s.PriceCurrency
	model.ReceiveAmount = s.ReceiveAmount
	model.PayAmount = s.PayAmount
	model.PayCurrency = s.PayCurrency
	model.UnderpaidAmount = s.UnderpaidAmount
	model.OverpaidAmount = s.OverpaidAmount
	model.IsRefundable = s.IsRefundable
	model.WalletCreateAt = s.WalletCreateAt
	model.WalletId = s.WalletId
	model.Fee = s.Fee
	model.CallbackAt = s.CallbackAt
	model.Status = s.Status
	model.ConfirmStatus = s.ConfirmStatus
	model.Remark = s.Remark
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *VtsRechargeInsertReq) GetId() interface{} {
	return s.Id
}

type VtsRechargeUpdateReq struct {
	Id              int             `uri:"id" comment:""` //
	CoinCode        string          `json:"coinCode" comment:"币种"`
	TranType        int             `json:"tranType" comment:"类型：1-线上 2-内部"`
	OrderNo         string          `json:"orderNo" comment:"订单号"`
	AdUserId        int             `json:"adUserId" comment:"用户id"`
	Amount          decimal.Decimal `json:"amount" comment:"订单价格"`
	PriceCurrency   string          `json:"priceCurrency" comment:"CoinGate结算货币代码"`
	ReceiveAmount   decimal.Decimal `json:"receiveAmount" comment:"实收数量"`
	PayAmount       decimal.Decimal `json:"payAmount" comment:"实际支付数量"`
	PayCurrency     string          `json:"payCurrency" comment:"实际支付的加密货币"`
	UnderpaidAmount decimal.Decimal `json:"underpaidAmount" comment:"买家少付数量"`
	OverpaidAmount  decimal.Decimal `json:"overpaidAmount" comment:"买家多付数量"`
	IsRefundable    int             `json:"isRefundable" comment:"指示购物者是否可以请求发票退款"`
	WalletCreateAt  time.Time       `json:"walletCreateAt" comment:"第三方创建时间"`
	WalletId        int             `json:"walletId" comment:"第三方钱包订单"`
	Fee             decimal.Decimal `json:"fee" comment:"手续费"`
	CallbackAt      time.Time       `json:"callbackAt" comment:"回调时间"`
	Status          string          `json:"status" comment:"状态"`
	ConfirmStatus   string          `json:"confirmStatus" comment:"确认状态"`
	Remark          string          `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *VtsRechargeUpdateReq) Generate(model *models.VtsRecharge) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.CoinCode = s.CoinCode
	model.TranType = s.TranType
	model.OrderNo = s.OrderNo
	model.AdUserId = s.AdUserId
	model.Amount = s.Amount
	model.PriceCurrency = s.PriceCurrency
	model.ReceiveAmount = s.ReceiveAmount
	model.PayAmount = s.PayAmount
	model.PayCurrency = s.PayCurrency
	model.UnderpaidAmount = s.UnderpaidAmount
	model.OverpaidAmount = s.OverpaidAmount
	model.IsRefundable = s.IsRefundable
	model.WalletCreateAt = s.WalletCreateAt
	model.WalletId = s.WalletId
	model.Fee = s.Fee
	model.CallbackAt = s.CallbackAt
	model.Status = s.Status
	model.ConfirmStatus = s.ConfirmStatus
	model.Remark = s.Remark
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *VtsRechargeUpdateReq) GetId() interface{} {
	return s.Id
}

// VtsRechargeGetReq 功能获取请求参数
type VtsRechargeGetReq struct {
	Id int `uri:"id"`
}

func (s *VtsRechargeGetReq) GetId() interface{} {
	return s.Id
}

// VtsRechargeDeleteReq 功能删除请求参数
type VtsRechargeDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *VtsRechargeDeleteReq) GetId() interface{} {
	return s.Ids
}
