create_exchange_cash_activity.go 1.5 KB
package command

import (
	"fmt"
	"github.com/astaxie/beego/validation"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
	"time"
)

// 创建现金兑换活动
type CreateExchangeActivityCommand struct {
	CompanyId int64                                     `json:"companyId" valid:"Required"` // 公司id
	ExchangeActivityName string                         `json:"exchangeActivityName"`       // 活动名称
	CashPool *domain.CashPool                           `json:"cashPool"`                   // 兑换现金活动关联的现金池,最新的现金池
	Deadline time.Time                                  `json:"deadline"`                   // 活动截止时间
	CountDown int64                                     `json:"countDown"`                  // 活动倒计时
	ExchangedSuMoney float64                            `json:"exchangedSuMoney"`           // 已兑换素币
	ExchangedCash float64                               `json:"exchangedCash"`              // 已兑换现金
	ExchangeRate float64                                `json:"exchangeRate"`               // 兑换汇率
	ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"`               // 兑换活动清单
}

func (createExchangeActivityCommand *CreateExchangeActivityCommand) ValidateCommand() error {
	valid := validation.Validation{}
	b, err := valid.Valid(createExchangeActivityCommand)
	if err != nil {
		return err
	}
	if !b {
		for _, validErr := range valid.Errors {
			return fmt.Errorf("%s  %s", validErr.Key, validErr.Message)
		}
	}
	return nil
}