package dto

import (
	"time"

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

	"github.com/shopspring/decimal"
)

type MemberRenwaLogGetPageReq struct {
	dto.Pagination `search:"-"`
	MemberRenwaLogOrder
}

type MemberRenwalLogPageAppReq struct {
	dto.Pagination `search:"-"`
	Language       string `search:"-"`
	MemberRenwaLogOrder
}

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

type MemberRenwalLogResp struct {
	Id                  int             `json:"id"`
	NetworkName         string          `json:"networkName"`
	ReceiveAddress      string          `json:"receiveAddress"`
	RenwalName          string          `json:"renwalName" comment:"续期套餐名称"`
	RenwalDuration      int             `json:"renwalDuration" comment:"续期时长(天数)"`
	Status              string          `json:"status" comment:"订单状态(member_renwal_log_status)"`
	StatusLabel         string          `json:"statusLabel"`
	PayableAmount       decimal.Decimal `json:"payableAmount" comment:"应付金额"`
	ActualPaymentAmount decimal.Decimal `json:"actualPaymentAmount" comment:"实付金额"`
	FromAddress         string          `json:"fromAddress" comment:"付款地址"`
	Coin                string          `json:"coin" comment:"代币"`
	PaymentTimeUnix     int64           `json:"paymentTimeUnix" comment:"支付时间"`
	ExpirationTimeUnix  int64           `json:"expirationTimeUnix" comment:"过期时间"`
}

type MemberRenwaLogOrder struct {
	Id                  string `form:"idOrder"  search:"type:order;column:id;table:member_renwa_log"`
	RenwalId            string `form:"renwalIdOrder"  search:"type:order;column:renwal_id;table:member_renwa_log"`
	RenwalName          string `form:"renwalNameOrder"  search:"type:order;column:renwal_name;table:member_renwa_log"`
	RenwalDuration      string `form:"renwalDurationOrder"  search:"type:order;column:renwal_duration;table:member_renwa_log"`
	Status              string `form:"statusOrder"  search:"type:order;column:status;table:member_renwa_log"`
	PayableAmount       string `form:"payableAmountOrder"  search:"type:order;column:payable_amount;table:member_renwa_log"`
	ActualPaymentAmount string `form:"actualPaymentAmountOrder"  search:"type:order;column:actual_payment_amount;table:member_renwa_log"`
	FromAddress         string `form:"fromAddressOrder"  search:"type:order;column:from_address;table:member_renwa_log"`
	Coin                string `form:"coinOrder"  search:"type:order;column:coin;table:member_renwa_log"`
	PaymentTime         string `form:"paymentTimeOrder"  search:"type:order;column:payment_time;table:member_renwa_log"`
	CreatedAt           string `form:"createdAtOrder"  search:"type:order;column:created_at;table:member_renwa_log"`
	UpdatedAt           string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:member_renwa_log"`
	DeletedAt           string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:member_renwa_log"`
	CreateBy            string `form:"createByOrder"  search:"type:order;column:create_by;table:member_renwa_log"`
	UpdateBy            string `form:"updateByOrder"  search:"type:order;column:update_by;table:member_renwa_log"`
}

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

type MemberRenwaLogInsertReq struct {
	Id                  int             `json:"-" comment:"主键"` // 主键
	RenwalId            int             `json:"renwalId" comment:"套餐id"`
	RenwalName          string          `json:"renwalName" comment:"续期套餐名称"`
	RenwalDuration      int             `json:"renwalDuration" comment:"续期时长(天数)"`
	Status              string          `json:"status" comment:"订单状态(member_renwal_log_status)"`
	PayableAmount       decimal.Decimal `json:"payableAmount" comment:"应付金额"`
	ActualPaymentAmount decimal.Decimal `json:"actualPaymentAmount" comment:"实付金额"`
	FromAddress         string          `json:"fromAddress" comment:"付款地址"`
	Coin                string          `json:"coin" comment:"代币"`
	PaymentTime         time.Time       `json:"paymentTime" comment:"支付时间"`
	common.ControlBy
}

func (s *MemberRenwaLogInsertReq) Generate(model *models.MemberRenwaLog) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.RenwalId = s.RenwalId
	model.RenwalName = s.RenwalName
	model.RenwalDuration = s.RenwalDuration
	model.Status = s.Status
	model.PayableAmount = s.PayableAmount
	model.ActualPaymentAmount = s.ActualPaymentAmount
	model.FromAddress = s.FromAddress
	model.Coin = s.Coin
	// model.PaymentTime = s.PaymentTime
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type MemberRenwaLogUpdateReq struct {
	Id                  int             `uri:"id" comment:"主键"` // 主键
	RenwalId            int             `json:"renwalId" comment:"套餐id"`
	RenwalName          string          `json:"renwalName" comment:"续期套餐名称"`
	RenwalDuration      int             `json:"renwalDuration" comment:"续期时长(天数)"`
	Status              string          `json:"status" comment:"订单状态(member_renwal_log_status)"`
	PayableAmount       decimal.Decimal `json:"payableAmount" comment:"应付金额"`
	ActualPaymentAmount decimal.Decimal `json:"actualPaymentAmount" comment:"实付金额"`
	FromAddress         string          `json:"fromAddress" comment:"付款地址"`
	Coin                string          `json:"coin" comment:"代币"`
	// PaymentTime         time.Time       `json:"paymentTime" comment:"支付时间"`
	common.ControlBy
}

func (s *MemberRenwaLogUpdateReq) Generate(model *models.MemberRenwaLog) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.RenwalId = s.RenwalId
	model.RenwalName = s.RenwalName
	model.RenwalDuration = s.RenwalDuration
	model.Status = s.Status
	model.PayableAmount = s.PayableAmount
	model.ActualPaymentAmount = s.ActualPaymentAmount
	model.FromAddress = s.FromAddress
	model.Coin = s.Coin
	// model.PaymentTime = s.PaymentTime
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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

type MemberRenwalCreateAppReq struct {
	ConfigId int `json:"configId"`
	UserId   int `json:"-"`
}

type MemberRenwalCreateAppResp struct {
	NetworkName        string          `json:"networkName"` //网络名称
	Amount             decimal.Decimal `json:"amount"`
	ToAddress          string          `json:"toAddress"`          //收款地址
	ExpirationTimeUnix int64           `json:"expirationTimeUnix"` //过期时间
}
