exchange_cash_person_list.go 1.7 KB
package domain

import (
	"fmt"
	"strconv"
)

// 参与兑换现金人员
type ExchangeCashPersonList struct {
	ListId int64 						`json:"listId"`   // 清单id
	EmployeeInfo *EmployeeInfo 			`json:"employeeInfo"`                   // 兑换人信息
	ExchangeCashActivityId   int64     `json:"exchangeActivityId"` 				// 参与的兑换活动id
	ExchangedSuMoney         float64   `json:"suMoney"`            				// 已兑换的素币
	ExchangedCash           float64   `json:"cash"`               				// 已兑换的现金
}

type ExchangeCashPersonListRepository interface {
	Save(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error)
	Remove(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error)
	FindOne(queryOptions map[string]interface{}) (*ExchangeCashPersonList, error)
	Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
	FindAll(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
	FindById(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
}

func (exchangeCashPersonList *ExchangeCashPersonList) Identity() interface{} {
	if exchangeCashPersonList.ListId == 0 {
		return nil
	}
	return exchangeCashPersonList.ListId
}

func (exchangeCashPersonList *ExchangeCashPersonList) Update(data map[string]interface{}) error {
	if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok && exchangedSuMoney != 0 {
		exchangeCashPersonList.ExchangedSuMoney = exchangedSuMoney.(float64)
	}
	if exchangedCash, ok := data["exchangedCash"]; ok && exchangedCash != 0 {
		exchangeCashPersonList.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2F", exchangedCash.(float64)), 64)
	}
	return nil
}