cash_pool.go
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package domain
import "time"
// 现金池
type CashPool struct {
CashPoolId int64 `json:"cashPoolId"` // 现金池id
Cash float64 `json:"cash"` // 投入现金池的现金
CompanyId int64 `json:"companyId"` // 公司id
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币
Rate float64 `json:"rate"` // 平均兑换汇率
LastRate float64 `json:"lastRate"` // 上期活动兑换汇率
CreateTime time.Time `json:"createTime"` // 现金投入现金池时间
}
type CashPoolRepository interface {
Save(cashPool *CashPool) (*CashPool, error)
FindOne(queryOptions map[string]interface{}) (*CashPool, error)
Find(queryOptions map[string]interface{}) (int64, []*CashPool, error)
}
func (cashPool *CashPool) Update(data map[string]interface{}) error {
if exchangedCash, ok := data["exchangedCash"]; ok {
cashPool.ExchangedCash = exchangedCash.(float64)
}
if unExchangeCash, ok := data["unExchangeCash"]; ok {
cashPool.UnExchangeCash = unExchangeCash.(float64)
}
if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok {
cashPool.ExchangedSuMoney = exchangedSuMoney.(float64)
}
if unExchangeSuMoney, ok := data["unExchangeSuMoney"]; ok {
cashPool.UnExchangeSuMoney = unExchangeSuMoney.(float64)
}
if rate, ok := data["rate"]; ok {
cashPool.Rate = rate.(float64)
}
return nil
}
func (cashPool *CashPool) Identity() interface{} {
if cashPool.CashPoolId == 0 {
return nil
}
return cashPool.CashPoolId
}