business_bonus.go
4.0 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package domain
import "time"
// 业务分红信息 是否有效【0;无效】【1:有效】
const (
BUSINESS_BONUS_ENABLE int8 = 1
BUSINESS_BONUS_DISABLE int8 = 0
)
// 分红状态 1:待支付分红 2:已支付分红
const (
//空状态
BUSINESS_BONUS_NULL int8 = 0
//待支付
BUSINESS_BONUS_WAIT_PAY int8 = 1
//已支付
BUSINESS_BONUS_HAS_PAY int8 = 2
)
func DescribeBusinessBonusStatus(i int8) string {
m := map[int8]string{
BUSINESS_BONUS_WAIT_PAY: "待支付分红",
BUSINESS_BONUS_HAS_PAY: "已支付分红",
}
if v, ok := m[i]; ok {
return v
}
return ""
}
//分红状态
type BusinessBonusBonusStatus interface {
//状态变更为空
NullPayPartnerBonus(*BusinessBonus) error
//状态变更为待支付
WartPayPartnerBonus(*BusinessBonus) error
//状态变更为已支付
PayPartnerBonus(*BusinessBonus) error
}
// 业务分红信息
type BusinessBonus struct {
// 唯一标识
Id int64 `json:"id"`
// 公司编号
CompanyId int64 `json:"companyId"`
// 合伙人信息Id
PartnerInfoId int64 `json:"partnerInfoId"`
// 应收分红
Bonus float64 `json:"bonus"`
// 未收分红
BonusNot float64 `json:"bonusNot"`
//已收分红
BonusHas float64 `json:"bonusHas"`
// 分红支出
BonusExpense float64 `json:"bonusExpense"`
// 是否关闭【0;否】【1:是】
IsDisable int8 `json:"isDisable"`
// 分红状态 1:待支付分红 2:已支付分红
BonusStatus int8 `json:"bonusStatus"`
// 创建时间
CreateAt time.Time `json:"createAt"`
// 更新时间
UpdateAt time.Time `json:"updateAt"`
// 删除时间
DeleteAt time.Time `json:"deleteAt"`
BusinessBonusPayStatus BusinessBonusBonusStatus
}
type BusinessBonusNullPay struct{}
var _ BusinessBonusBonusStatus = (*BusinessBonusNullPay)(nil)
type BusinessBonusWaitPay struct{}
var _ BusinessBonusBonusStatus = (*BusinessBonusWaitPay)(nil)
//OrderGoodBonusHasPay 货品分红已支付
type BusinessBonusHasPay struct{}
var _ BusinessBonusBonusStatus = (*BusinessBonusHasPay)(nil)
// -----默认空状态-----
//状态变更为空
func (pay BusinessBonusNullPay) NullPayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusStatus = 0
return nil
}
//状态变更为待支付
func (pay BusinessBonusNullPay) WartPayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusNot = bonus.Bonus
bonus.BonusStatus = BUSINESS_BONUS_WAIT_PAY
return nil
}
//状态变更为已支付
func (pay BusinessBonusNullPay) PayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusNot = 0
bonus.BonusHas = bonus.Bonus
bonus.BonusStatus = BUSINESS_BONUS_HAS_PAY
return nil
}
// -----待支付状态-----
//状态变更为空
func (pay BusinessBonusWaitPay) NullPayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusStatus = 0
return nil
}
//状态变更为待支付
func (pay BusinessBonusWaitPay) WartPayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusNot = bonus.Bonus
bonus.BonusStatus = BUSINESS_BONUS_WAIT_PAY
return nil
}
//状态变更为已支付
func (pay BusinessBonusWaitPay) PayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusNot = 0
bonus.BonusHas = bonus.Bonus
bonus.BonusStatus = BUSINESS_BONUS_HAS_PAY
return nil
}
// -----已经支付状态-----
//状态变更为空
func (pay BusinessBonusHasPay) NullPayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusStatus = 0
return nil
}
//状态变更为待支付
func (pay BusinessBonusHasPay) WartPayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusNot = bonus.Bonus
bonus.BonusStatus = BUSINESS_BONUS_WAIT_PAY
return nil
}
//状态变更为已支付
func (pay BusinessBonusHasPay) PayPartnerBonus(bonus *BusinessBonus) error {
bonus.BonusNot = 0
bonus.BonusHas = bonus.Bonus
bonus.BonusStatus = BUSINESS_BONUS_HAS_PAY
return nil
}
type BusinessBonusFindOneQuery struct {
Id int64
PartnerId int64
CompanyId int64
}
type BusinessBonusFindQuery struct {
Offset int
Limit int
}
type BusinessBonusRepository interface {
Add(dm *BusinessBonus) error
Edit(dm *BusinessBonus) error
FindOne(BusinessBonusFindOneQuery) (*BusinessBonus, error)
Find(BusinessBonusFindQuery) (int, []BusinessBonus, error)
}