package dto

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

	"github.com/shopspring/decimal"
)

type MemberBalanceGetPageReq struct {
	dto.Pagination `search:"-"`
	MemberBalanceOrder
}

type MemberBalanceOrder struct {
	Id           string `form:"idOrder"  search:"type:order;column:id;table:member_balance"`
	TotalAmont   string `form:"totalAmontOrder"  search:"type:order;column:total_amont;table:member_balance"`
	FreeAmount   string `form:"freeAmountOrder"  search:"type:order;column:free_amount;table:member_balance"`
	FrozenAmount string `form:"frozenAmountOrder"  search:"type:order;column:frozen_amount;table:member_balance"`
	CreatedAt    string `form:"createdAtOrder"  search:"type:order;column:created_at;table:member_balance"`
	UpdatedAt    string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:member_balance"`
	DeletedAt    string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:member_balance"`
	CreateBy     string `form:"createByOrder"  search:"type:order;column:create_by;table:member_balance"`
	UpdateBy     string `form:"updateByOrder"  search:"type:order;column:update_by;table:member_balance"`
}

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

type MemberBalanceInsertReq struct {
	Id           int             `json:"-" comment:"主键"` // 主键
	TotalAmont   decimal.Decimal `json:"totalAmont" comment:"总余额"`
	FreeAmount   decimal.Decimal `json:"freeAmount" comment:"可用余额"`
	FrozenAmount decimal.Decimal `json:"frozenAmount" comment:"冻结金额"`
	common.ControlBy
}

func (s *MemberBalanceInsertReq) Generate(model *models.MemberBalance) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.TotalAmount = s.TotalAmont
	model.FreeAmount = s.FreeAmount
	model.FrozenAmount = s.FrozenAmount
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type MemberBalanceUpdateReq struct {
	Id           int             `uri:"id" comment:"主键"` // 主键
	TotalAmont   decimal.Decimal `json:"totalAmont" comment:"总余额"`
	FreeAmount   decimal.Decimal `json:"freeAmount" comment:"可用余额"`
	FrozenAmount decimal.Decimal `json:"frozenAmount" comment:"冻结金额"`
	common.ControlBy
}

func (s *MemberBalanceUpdateReq) Generate(model *models.MemberBalance) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.TotalAmount = s.TotalAmont
	model.FreeAmount = s.FreeAmount
	model.FrozenAmount = s.FrozenAmount
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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