money_incentives_rule.go
3.7 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
88
89
90
91
92
93
94
95
package domain
import "time"
// 金额激励规则实体
type MoneyIncentivesRule struct {
// 金额激励规则ID
MoneyIncentivesRuleId int64 `json:"moneyIncentivesRuleId,string"`
// 关联的共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 激励金额
MoneyIncentivesAmount float64 `json:"moneyIncentivesAmount"`
// 金额激励阶段,阶段返回时需要转换为中文数字
MoneyIncentivesStage int64 `json:"moneyIncentivesStage,string"`
// 金额激励阶段有效期结束
MoneyIncentivesStageEnd time.Time `json:"moneyIncentivesStageEnd"`
// 金额激励阶段有效期开始
MoneyIncentivesStageStart time.Time `json:"moneyIncentivesStageStart"`
// 金额激励规则时间
MoneyIncentivesTime time.Time `json:"moneyIncentivesTime"`
// 推荐人抽成比例
ReferrerPercentage float64 `json:"referrerPercentage"`
// 业务员抽成比例
SalesmanPercentage float64 `json:"salesmanPercentage"`
// 数据所属组织机构
Org *Org `json:"org"`
// 公司
Company *Company `json:"company"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
}
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.(int64)
}
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)
}
if orgId, ok := data["orgId"]; ok {
moneyIncentivesRule.Org.OrgId = orgId.(int64)
}
if orgName, ok := data["orgName"]; ok {
moneyIncentivesRule.Org.OrgName = orgName.(string)
}
if companyId, ok := data["companyId"]; ok {
moneyIncentivesRule.Org.Company.CompanyId = companyId.(int64)
}
if companyLogo, ok := data["companyLogo"]; ok {
moneyIncentivesRule.Org.Company.CompanyLogo = companyLogo.(string)
}
if companyName, ok := data["companyName"]; ok {
moneyIncentivesRule.Org.Company.CompanyName = companyName.(string)
}
return nil
}