money_incentives_rule.go
3.4 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package domain
import (
"time"
)
// MoneyIncentivesRule 金额激励规则实体
type MoneyIncentivesRule struct {
// 金额激励规则ID
MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"`
// 关联的共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 激励金额
MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
// 金额激励阶段,阶段返回时需要转换为中文数字
MoneyIncentivesStage int32 `json:"moneyIncentivesStage"`
// 金额激励规则阶段中文表示
MoneyIncentivesStageCN string `json:"moneyIncentivesStageCN"`
// 金额激励阶段有效期结束
MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"`
// 金额激励阶段有效期开始
MoneyIncentivesStageStart time.Time `json:"moneyIncentivesStageStart"`
// 金额激励规则时间
MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`
// 推荐人抽成比例
ReferrerPercentage float64 `json:"referrerPercentage"`
// 业务员抽成比例
SalesmanPercentage float64 `json:"salesmanPercentage"`
// 分红激励规则说明
Remarks string `json:"remarks"`
// 数据所属组织机构
Org *Org `json:"org"`
// 公司
Company *Company `json:"company"`
// 更新时间
UpdatedAt time.Time `json:"-"`
// 删除时间
DeletedAt time.Time `json:"-"`
// 创建时间
CreatedAt time.Time `json:"-"`
}
type MoneyIncentivesRuleRepository interface {
Save(moneyIncentivesRule *MoneyIncentivesRule) (*MoneyIncentivesRule, error)
Remove(moneyIncentivesRule *MoneyIncentivesRule) (*MoneyIncentivesRule, error)
FindOne(queryOptions map[string]interface{}) (*MoneyIncentivesRule, error)
Find(queryOptions map[string]interface{}) (int64, []*MoneyIncentivesRule, error)
}
func (moneyIncentivesRule *MoneyIncentivesRule) Identify() interface{} {
if moneyIncentivesRule.MoneyIncentivesRuleId == 0 {
return nil
}
return moneyIncentivesRule.MoneyIncentivesRuleId
}
func (moneyIncentivesRule *MoneyIncentivesRule) Update(data map[string]interface{}) error {
if moneyIncentivesRuleId, ok := data["moneyIncentivesRuleId"]; ok {
moneyIncentivesRule.MoneyIncentivesRuleId = moneyIncentivesRuleId.(int64)
}
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
moneyIncentivesRule.CooperationContractNumber = cooperationContractNumber.(string)
}
if moneyIncentivesAmount, ok := data["moneyIncentivesAmount"]; ok {
moneyIncentivesRule.MoneyIncentivesAmount = moneyIncentivesAmount.(float64)
}
if moneyIncentivesStage, ok := data["moneyIncentivesStage"]; ok {
moneyIncentivesRule.MoneyIncentivesStage = moneyIncentivesStage.(int32)
}
if moneyIncentivesStageEnd, ok := data["moneyIncentivesStageEnd"]; ok {
moneyIncentivesRule.MoneyIncentivesStageEnd = moneyIncentivesStageEnd.(time.Time)
}
if moneyIncentivesStageStart, ok := data["moneyIncentivesStageStart"]; ok {
moneyIncentivesRule.MoneyIncentivesStageStart = moneyIncentivesStageStart.(time.Time)
}
if moneyIncentivesTime, ok := data["moneyIncentivesTime"]; ok {
moneyIncentivesRule.MoneyIncentivesTime = moneyIncentivesTime.(time.Time)
}
if referrerPercentage, ok := data["referrerPercentage"]; ok {
moneyIncentivesRule.ReferrerPercentage = referrerPercentage.(float64)
}
if salesmanPercentage, ok := data["salesmanPercentage"]; ok {
moneyIncentivesRule.SalesmanPercentage = salesmanPercentage.(float64)
}
moneyIncentivesRule.UpdatedAt = time.Now()
return nil
}