package jccommon

import (
	"q5"
	"f5"
)

type ActivitySaleEvent struct {
	EventName string `json:"event_name"`
	EventId string `json:"event_id"`
	Chain string `json:"chain"`
	Data struct {
		Details struct {
			To string `json:"to"`
			From string `json:"from"`
			OrderId string `json:"order_id"`
			Asset [] struct {
				TokenId string `json:"token_id"`
				ContractType string `json:"contract_type"`
				ContractAddress string `json:"contract_address"`
			} `json:"asset"`
		} `json:"details"`
		IndexedAt interface{} `json:"indexed_at"`
	} `json:"data"`
}

type OrderUpdatedEvent struct {
	EventName string `json:"event_name"`
	EventId string `json:"event_id"`
	Chain string `json:"chain"`
	Data struct {
		Id string `json:"id"`
		AccountAddress string `json:"account_address"`
		Buy [] struct {
			Amount string `json:"amount"`
			ContractAddress string `json:"contract_address"`
			ItemType string `json:"item_type"`
		} `json:"buy"`
		Sell [] struct {
			TokenId string `json:"token_id"`
			ItemType string `json:"item_type"`
			EndAmount string `json:"end_amount"`
			StartAmount string `json:"start_amount"`
			ContractAddress string `json:"contract_address"`
		} `json:"sell"`
		Fees [] struct {
			Amount string `json:"amount"`
		} `json:"fees"`
		Status struct {
			Name string `json:"name"`
		} `json:"status"`
		StartAt interface{} `json:"start_at"`
		EndAt interface{} `json:"end_at"`
		CreatedAt interface{} `json:"created_at"`
		UpdatedAt interface{} `json:"updated_at"`
	} `json:"data"`
}

type MailConfig struct {
	MailName string
	Tag1 int32
	Tag2 int32
}

type MailEvent struct {
	EventName string `gorm:"column:event_name" json:"event_name"`
	Param1 string `gorm:"column:param1" json:"param1"`
	CreateTime int32 `gorm:"column:createtime;<-:create" json:"createtime"`
	ModifyTime int32 `gorm:"column:modifytime" json:"modifytime"`
}

func (MailEvent) TableName() string {
	return "t_event"
}

type NftStacking struct {
	NetId int32
	ContractAddress string
	TokenType int32
	TokenId string
	ItemId int32
	Quality int32
}

type NftStackingPo struct {
	TokenId string `json:"t"`
	ItemId int32 `json:"i"`
	Quality int32 `json:"q"`
}

type ContractCall struct {
	TransId string `json:"trans_id"`
	TransReq struct {
		To string `json:"to"`
		Data string `json:"data"`
	} `json:"trans_req"`
}

type ContractStackingPo struct {
	NetId int32 `json:"net_id"`
	ContractAddress string `json:"contract_address"`
	TokenType int32 `json:"token_type"`
	Nfts []*NftStackingPo `json:"nfts"`
}

type UserStackingPo struct {
	AccountAddress string `json:"account_address"`
	Contracts []*ContractStackingPo `json:"contracts"`
}

type ContractStakeAndUnstakeCecPo struct {
	Account string `json:"account"`
	Token string `json:"token"`
	Amount string `json:"amount"`
}

type Erc20TransferPo struct {
	From string `json:"from"`
	To string `json:"to"`
	Value string `json:"value"`
}

type BlockDataPo struct {
	TimeStamp int32 `json:"timestamp"`
}

type VesterClaimPo struct {
	Receiverstring string `json:"receiver"`
	Amount string `json:"amount"`
}

type VesterDepositPo struct {
	Account string `json:"account"`
	Amount string `json:"amount"`
}

type VesterWithdrawPo struct {
	Account string `json:"account"`
	ClaimedAmount string `json:"claimedAmount"`
	Balance string `json:"balance"`
}

type NftIdentity struct {
	NetId int32
	ContractAddress string
	TokenId string
}

type NftIdentityAndExtData struct {
	NetId int32
	ContractAddress string
	TokenId string
	ItemId int32
	Quality int32
}

func (this *NftIdentityAndExtData) LoadFromDb(ds *f5.DataSet) {
	this.NetId = q5.ToInt32(ds.GetByName("net_id"))
	this.ContractAddress = ds.GetByName("contract_address")
	this.TokenId = ds.GetByName("token_id")
	this.ItemId = q5.ToInt32(ds.GetByName("item_id"))
	this.Quality = q5.ToInt32(ds.GetByName("quality"))
}

func NewNftStackingPo() *NftStackingPo {
	p := new(NftStackingPo)
	return p
}

func NewContractStackingPo() *ContractStackingPo {
	p := new(ContractStackingPo)
	p.Nfts = []*NftStackingPo{}
	return p
}

func NewContractStakeAndUnstakeCecPo() *ContractStakeAndUnstakeCecPo {
	p := new(ContractStakeAndUnstakeCecPo)
	return p
}

func NewUserStackingPo() *UserStackingPo {
	p := new(UserStackingPo)
	p.Contracts = []*ContractStackingPo{}
	return p
}

func NewErc20TransferPo() *Erc20TransferPo {
	p := new(Erc20TransferPo)
	return p
}

func NewBlockDataPo() *BlockDataPo {
	p := new(BlockDataPo)
	return p
}
