package dto

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

	"github.com/shopspring/decimal"
)

type MemberBalanceLogGetPageReq struct {
	dto.Pagination `search:"-"`
	ChangeSource   string `form:"changeSource"  search:"type:exact;column:change_source;table:member_balance_log" comment:"变更来源 (member_change_source)"`
	ChangeType     string `form:"changeType"  search:"type:exact;column:change_type;table:member_balance_log" comment:"变更类别 1-收入 2-支出"`
	MemberBalanceLogOrder
}

type MemberBalanceLogOrder struct {
	Id            string `form:"idOrder" query:"idOrder"  search:"type:order;column:id;table:member_balance_log"`
	UserId        string `form:"userIdOrder"  search:"type:order;column:user_id;table:member_balance_log"`
	ChangeSource  string `form:"changeSourceOrder"  search:"type:order;column:change_source;table:member_balance_log"`
	ChangeType    string `form:"changeTypeOrder"  search:"type:order;column:change_type;table:member_balance_log"`
	Amount        string `form:"amountOrder"  search:"type:order;column:amount;table:member_balance_log"`
	BalanceBefore string `form:"balanceBeforeOrder"  search:"type:order;column:balance_before;table:member_balance_log"`
	BalanceAfter  string `form:"balanceAfterOrder"  search:"type:order;column:balance_after;table:member_balance_log"`
	Remark        string `form:"remarkOrder"  search:"type:order;column:remark;table:member_balance_log"`
	CreatedAt     string `form:"createdAtOrder"  search:"type:order;column:created_at;table:member_balance_log"`
	UpdatedAt     string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:member_balance_log"`
	DeletedAt     string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:member_balance_log"`
	CreateBy      string `form:"createByOrder"  search:"type:order;column:create_by;table:member_balance_log"`
	UpdateBy      string `form:"updateByOrder"  search:"type:order;column:update_by;table:member_balance_log"`
}

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

type MemberBalanceLogInsertReq struct {
	Id            int             `json:"-" comment:"主键"` // 主键
	UserId        int             `json:"userId" comment:"用户id"`
	ChangeSource  string          `json:"changeSource" comment:"变更来源 (member_change_source)"`
	ChangeType    int             `json:"changeType" comment:"变更类别 1-收入 2-支出"`
	Amount        decimal.Decimal `json:"amount" comment:"变更金额"`
	BalanceBefore decimal.Decimal `json:"balanceBefore" comment:"变更前余额"`
	BalanceAfter  decimal.Decimal `json:"balanceAfter" comment:"变更后余额"`
	Remark        string          `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *MemberBalanceLogInsertReq) Generate(model *models.MemberBalanceLog) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.UserId = s.UserId
	model.ChangeSource = s.ChangeSource
	model.ChangeType = s.ChangeType
	model.Amount = s.Amount
	model.BalanceBefore = s.BalanceBefore
	model.BalanceAfter = s.BalanceAfter
	model.Remark = s.Remark
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

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

type MemberBalanceLogUpdateReq struct {
	Id            int             `uri:"id" comment:"主键"` // 主键
	UserId        int             `json:"userId" comment:"用户id"`
	ChangeSource  string          `json:"changeSource" comment:"变更来源 (member_change_source)"`
	ChangeType    int             `json:"changeType" comment:"变更类别 1-收入 2-支出"`
	Amount        decimal.Decimal `json:"amount" comment:"变更金额"`
	BalanceBefore decimal.Decimal `json:"balanceBefore" comment:"变更前余额"`
	BalanceAfter  decimal.Decimal `json:"balanceAfter" comment:"变更后余额"`
	Remark        string          `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *MemberBalanceLogUpdateReq) Generate(model *models.MemberBalanceLog) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.UserId = s.UserId
	model.ChangeSource = s.ChangeSource
	model.ChangeType = s.ChangeType
	model.Amount = s.Amount
	model.BalanceBefore = s.BalanceBefore
	model.BalanceAfter = s.BalanceAfter
	model.Remark = s.Remark
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

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

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

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

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

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

type MemberBalanceLogPageAppReq struct {
	dto.Pagination `search:"-"`
	ChangeSource   string `form:"changeSource"  search:"type:exact;column:change_source;table:member_balance_log" comment:"变更来源 (member_change_source)"`
	ChangeType     string `form:"changeType"  search:"type:exact;column:change_type;table:member_balance_log" comment:"变更类别 1-收入 2-支出"`
	UserId         int    `json:"userId" search:"-"`
	Language       string `json:"language" search:"-"`
	MemberBalanceLogOrder
}

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

type MemberBalanceLogAppResp struct {
	Id               int             `json:"-" comment:"主键"` // 主键
	UserId           int             `json:"userId" comment:"用户id"`
	UserName         string          `json:"userName" comment:"用户名"`
	ChangeSource     string          `json:"changeSource" comment:"变更来源 (member_change_source)"`
	ChangeSourceName string          `json:"changeSourceName"`
	ChangeType       int             `json:"changeType" comment:"变更类别 1-收入 2-支出"`
	Amount           decimal.Decimal `json:"amount" comment:"变更金额"`
	Remark           string          `json:"remark" comment:"备注"`
	CreateTimeUnix   int64           `json:"createTime" comment:"创建时间"`
}
