|
@@ -8,7 +8,6 @@ import ( |
|
@@ -8,7 +8,6 @@ import ( |
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
|
11
|
- "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
|
|
12
|
)
|
11
|
)
|
13
|
|
12
|
|
14
|
type ConfirmDividendsIncentivesEstimateService struct {
|
13
|
type ConfirmDividendsIncentivesEstimateService struct {
|
|
@@ -85,13 +84,48 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
@@ -85,13 +84,48 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
85
|
|
84
|
|
86
|
// 确认业绩分红预算
|
85
|
// 确认业绩分红预算
|
87
|
var dividendsEstimateDetails []*service.DividendsEstimateDetail
|
86
|
var dividendsEstimateDetails []*service.DividendsEstimateDetail
|
88
|
- go func() {
|
|
|
89
|
- for _, orderGood := range orderGoods {
|
|
|
90
|
- log.Logger.Info("业绩分红预算产品", map[string]interface{}{
|
|
|
91
|
- "orderGood": orderGood,
|
87
|
+ for _, orderGood := range orderGoods {
|
|
|
88
|
+ if orderGood.CooperationContractNumber == "" {
|
|
|
89
|
+ var orderNumber string
|
|
|
90
|
+ if orderGood.DividendsOrderNumber != "" {
|
|
|
91
|
+ orderNumber = orderGood.DividendsOrderNumber
|
|
|
92
|
+ } else {
|
|
|
93
|
+ orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
94
|
+ }
|
|
|
95
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
96
|
+ DividendsUser: nil,
|
|
|
97
|
+ DividendsParticipateType: 0,
|
|
|
98
|
+ DividendsStage: 0,
|
|
|
99
|
+ DividendsAmount: 0,
|
|
|
100
|
+ OrderOrReturnedOrderNumber: orderNumber,
|
|
|
101
|
+ IsSuccessfully: false,
|
|
|
102
|
+ Reason: "产品未关联合约,不能进行分红预算",
|
92
|
})
|
103
|
})
|
|
|
104
|
+ continue
|
|
|
105
|
+ }
|
93
|
|
106
|
|
94
|
- if orderGood.CooperationContractNumber == "" {
|
107
|
+ // 获取合约
|
|
|
108
|
+ var cooperationContract *domain.CooperationContract
|
|
|
109
|
+ if _, ok := cooperationContractsMap[orderGood.CooperationContractNumber]; !ok {
|
|
|
110
|
+ var orderNumber string
|
|
|
111
|
+ if orderGood.DividendsOrderNumber != "" {
|
|
|
112
|
+ orderNumber = orderGood.DividendsOrderNumber
|
|
|
113
|
+ } else {
|
|
|
114
|
+ orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
115
|
+ }
|
|
|
116
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
117
|
+ DividendsUser: nil,
|
|
|
118
|
+ DividendsParticipateType: 0,
|
|
|
119
|
+ DividendsStage: 0,
|
|
|
120
|
+ DividendsAmount: 0,
|
|
|
121
|
+ OrderOrReturnedOrderNumber: orderNumber,
|
|
|
122
|
+ IsSuccessfully: false,
|
|
|
123
|
+ Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
|
|
|
124
|
+ })
|
|
|
125
|
+ continue
|
|
|
126
|
+ } else {
|
|
|
127
|
+ cooperationContract = cooperationContractsMap[orderGood.CooperationContractNumber]
|
|
|
128
|
+ if cooperationContract.Status == 2 {
|
95
|
var orderNumber string
|
129
|
var orderNumber string
|
96
|
if orderGood.DividendsOrderNumber != "" {
|
130
|
if orderGood.DividendsOrderNumber != "" {
|
97
|
orderNumber = orderGood.DividendsOrderNumber
|
131
|
orderNumber = orderGood.DividendsOrderNumber
|
|
@@ -105,363 +139,335 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
@@ -105,363 +139,335 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
105
|
DividendsAmount: 0,
|
139
|
DividendsAmount: 0,
|
106
|
OrderOrReturnedOrderNumber: orderNumber,
|
140
|
OrderOrReturnedOrderNumber: orderNumber,
|
107
|
IsSuccessfully: false,
|
141
|
IsSuccessfully: false,
|
108
|
- Reason: "产品未关联合约,不能进行分红预算",
|
142
|
+ Reason: "共创合约" + orderGood.CooperationContractNumber + "已暂停",
|
109
|
})
|
143
|
})
|
110
|
continue
|
144
|
continue
|
111
|
}
|
145
|
}
|
|
|
146
|
+ }
|
112
|
|
147
|
|
113
|
- // 获取合约
|
|
|
114
|
- var cooperationContract *domain.CooperationContract
|
|
|
115
|
- if _, ok := cooperationContractsMap[orderGood.CooperationContractNumber]; !ok {
|
|
|
116
|
- var orderNumber string
|
|
|
117
|
- if orderGood.DividendsOrderNumber != "" {
|
|
|
118
|
- orderNumber = orderGood.DividendsOrderNumber
|
|
|
119
|
- } else {
|
|
|
120
|
- orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
121
|
- }
|
148
|
+ //cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
|
|
|
149
|
+ // "cooperationContractNumber": orderGood.CooperationContractNumber,
|
|
|
150
|
+ // "companyId": orderGood.CompanyId,
|
|
|
151
|
+ // "orgId": orderGood.OrgId,
|
|
|
152
|
+ //})
|
|
|
153
|
+ //if err != nil {
|
|
|
154
|
+ // var orderNumber string
|
|
|
155
|
+ // if orderGood.DividendsOrderNumber != "" {
|
|
|
156
|
+ // orderNumber = orderGood.DividendsOrderNumber
|
|
|
157
|
+ // } else {
|
|
|
158
|
+ // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
159
|
+ // }
|
|
|
160
|
+ // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
161
|
+ // DividendsUser: nil,
|
|
|
162
|
+ // DividendsParticipateType: 0,
|
|
|
163
|
+ // DividendsStage: 0,
|
|
|
164
|
+ // DividendsAmount: 0,
|
|
|
165
|
+ // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
166
|
+ // IsSuccessfully: false,
|
|
|
167
|
+ // Reason: "共创合约错误",
|
|
|
168
|
+ // })
|
|
|
169
|
+ // continue
|
|
|
170
|
+ //}
|
|
|
171
|
+ //if cooperationContract == nil {
|
|
|
172
|
+ // var orderNumber string
|
|
|
173
|
+ // if orderGood.DividendsOrderNumber != "" {
|
|
|
174
|
+ // orderNumber = orderGood.DividendsOrderNumber
|
|
|
175
|
+ // } else {
|
|
|
176
|
+ // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
177
|
+ // }
|
|
|
178
|
+ // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
179
|
+ // DividendsUser: nil,
|
|
|
180
|
+ // DividendsParticipateType: 0,
|
|
|
181
|
+ // DividendsStage: 0,
|
|
|
182
|
+ // DividendsAmount: 0,
|
|
|
183
|
+ // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
184
|
+ // IsSuccessfully: false,
|
|
|
185
|
+ // Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
|
|
|
186
|
+ // })
|
|
|
187
|
+ // continue
|
|
|
188
|
+ //} else {
|
|
|
189
|
+ // log.Logger.Info("产品相关的合约", map[string]interface{}{
|
|
|
190
|
+ // "cooperationContract": cooperationContract,
|
|
|
191
|
+ // })
|
|
|
192
|
+ // if cooperationContract.Status == 2 {
|
|
|
193
|
+ // var orderNumber string
|
|
|
194
|
+ // if orderGood.DividendsOrderNumber != "" {
|
|
|
195
|
+ // orderNumber = orderGood.DividendsOrderNumber
|
|
|
196
|
+ // } else {
|
|
|
197
|
+ // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
198
|
+ // }
|
|
|
199
|
+ // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
200
|
+ // DividendsUser: nil,
|
|
|
201
|
+ // DividendsParticipateType: 0,
|
|
|
202
|
+ // DividendsStage: 0,
|
|
|
203
|
+ // DividendsAmount: 0,
|
|
|
204
|
+ // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
205
|
+ // IsSuccessfully: false,
|
|
|
206
|
+ // Reason: "共创合约" + orderGood.CooperationContractNumber + "已暂停",
|
|
|
207
|
+ // })
|
|
|
208
|
+ // continue
|
|
|
209
|
+ // }
|
|
|
210
|
+ //}
|
|
|
211
|
+
|
|
|
212
|
+ // 获取共创项目
|
|
|
213
|
+ //if cooperationContract.CooperationProjectNumber != "" {
|
|
|
214
|
+ // cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
|
|
|
215
|
+ // "cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
|
|
|
216
|
+ // "companyId": cooperationContract.Company.CompanyId,
|
|
|
217
|
+ // "orgId": cooperationContract.Org.OrgId,
|
|
|
218
|
+ // })
|
|
|
219
|
+ // if err != nil {
|
|
|
220
|
+ // var orderNumber string
|
|
|
221
|
+ // if orderGood.DividendsOrderNumber != "" {
|
|
|
222
|
+ // orderNumber = orderGood.DividendsOrderNumber
|
|
|
223
|
+ // } else {
|
|
|
224
|
+ // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
225
|
+ // }
|
|
|
226
|
+ // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
227
|
+ // DividendsUser: nil,
|
|
|
228
|
+ // DividendsParticipateType: 0,
|
|
|
229
|
+ // DividendsStage: 0,
|
|
|
230
|
+ // DividendsAmount: 0,
|
|
|
231
|
+ // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
232
|
+ // IsSuccessfully: false,
|
|
|
233
|
+ // Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "查询错误",
|
|
|
234
|
+ // })
|
|
|
235
|
+ // continue
|
|
|
236
|
+ // }
|
|
|
237
|
+ // if cooperationProject == nil {
|
|
|
238
|
+ // var orderNumber string
|
|
|
239
|
+ // if orderGood.DividendsOrderNumber != "" {
|
|
|
240
|
+ // orderNumber = orderGood.DividendsOrderNumber
|
|
|
241
|
+ // } else {
|
|
|
242
|
+ // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
243
|
+ // }
|
|
|
244
|
+ // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
245
|
+ // DividendsUser: nil,
|
|
|
246
|
+ // DividendsParticipateType: 0,
|
|
|
247
|
+ // DividendsStage: 0,
|
|
|
248
|
+ // DividendsAmount: 0,
|
|
|
249
|
+ // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
250
|
+ // IsSuccessfully: false,
|
|
|
251
|
+ // Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
|
|
|
252
|
+ // })
|
|
|
253
|
+ // continue
|
|
|
254
|
+ // }
|
|
|
255
|
+ //}
|
|
|
256
|
+
|
|
|
257
|
+ // 判断共创项目是否存在
|
|
|
258
|
+ if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {
|
|
|
259
|
+ var orderNumber string
|
|
|
260
|
+ if orderGood.DividendsOrderNumber != "" {
|
|
|
261
|
+ orderNumber = orderGood.DividendsOrderNumber
|
|
|
262
|
+ } else {
|
|
|
263
|
+ orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
264
|
+ }
|
|
|
265
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
266
|
+ DividendsUser: nil,
|
|
|
267
|
+ DividendsParticipateType: 0,
|
|
|
268
|
+ DividendsStage: 0,
|
|
|
269
|
+ DividendsAmount: 0,
|
|
|
270
|
+ OrderOrReturnedOrderNumber: orderNumber,
|
|
|
271
|
+ IsSuccessfully: false,
|
|
|
272
|
+ Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
|
|
|
273
|
+ })
|
|
|
274
|
+ continue
|
|
|
275
|
+ }
|
|
|
276
|
+
|
|
|
277
|
+ if orderGood.DividendsOrderNumber != "" { // 获取分红订单
|
|
|
278
|
+ // 获取分红订单
|
|
|
279
|
+ dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
|
|
|
280
|
+ "dividendsOrderNumber": orderGood.DividendsOrderNumber,
|
|
|
281
|
+ "companyId": orderGood.CompanyId,
|
|
|
282
|
+ "orgId": orderGood.OrgId,
|
|
|
283
|
+ })
|
|
|
284
|
+ if err2 != nil {
|
122
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
285
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
123
|
DividendsUser: nil,
|
286
|
DividendsUser: nil,
|
124
|
DividendsParticipateType: 0,
|
287
|
DividendsParticipateType: 0,
|
125
|
DividendsStage: 0,
|
288
|
DividendsStage: 0,
|
126
|
DividendsAmount: 0,
|
289
|
DividendsAmount: 0,
|
127
|
- OrderOrReturnedOrderNumber: orderNumber,
|
290
|
+ OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
|
128
|
IsSuccessfully: false,
|
291
|
IsSuccessfully: false,
|
129
|
- Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
|
292
|
+ Reason: "分红订单" + orderGood.DividendsOrderNumber + "查询错误",
|
130
|
})
|
293
|
})
|
131
|
continue
|
294
|
continue
|
132
|
- } else {
|
|
|
133
|
- cooperationContract = cooperationContractsMap[orderGood.CooperationContractNumber]
|
|
|
134
|
- if cooperationContract.Status == 2 {
|
|
|
135
|
- var orderNumber string
|
|
|
136
|
- if orderGood.DividendsOrderNumber != "" {
|
|
|
137
|
- orderNumber = orderGood.DividendsOrderNumber
|
|
|
138
|
- } else {
|
|
|
139
|
- orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
140
|
- }
|
|
|
141
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
142
|
- DividendsUser: nil,
|
|
|
143
|
- DividendsParticipateType: 0,
|
|
|
144
|
- DividendsStage: 0,
|
|
|
145
|
- DividendsAmount: 0,
|
|
|
146
|
- OrderOrReturnedOrderNumber: orderNumber,
|
|
|
147
|
- IsSuccessfully: false,
|
|
|
148
|
- Reason: "共创合约" + orderGood.CooperationContractNumber + "已暂停",
|
|
|
149
|
- })
|
|
|
150
|
- continue
|
|
|
151
|
- }
|
|
|
152
|
}
|
295
|
}
|
153
|
-
|
|
|
154
|
- //cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
|
|
|
155
|
- // "cooperationContractNumber": orderGood.CooperationContractNumber,
|
|
|
156
|
- // "companyId": orderGood.CompanyId,
|
|
|
157
|
- // "orgId": orderGood.OrgId,
|
|
|
158
|
- //})
|
|
|
159
|
- //if err != nil {
|
|
|
160
|
- // var orderNumber string
|
|
|
161
|
- // if orderGood.DividendsOrderNumber != "" {
|
|
|
162
|
- // orderNumber = orderGood.DividendsOrderNumber
|
|
|
163
|
- // } else {
|
|
|
164
|
- // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
165
|
- // }
|
|
|
166
|
- // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
167
|
- // DividendsUser: nil,
|
|
|
168
|
- // DividendsParticipateType: 0,
|
|
|
169
|
- // DividendsStage: 0,
|
|
|
170
|
- // DividendsAmount: 0,
|
|
|
171
|
- // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
172
|
- // IsSuccessfully: false,
|
|
|
173
|
- // Reason: "共创合约错误",
|
|
|
174
|
- // })
|
|
|
175
|
- // continue
|
|
|
176
|
- //}
|
|
|
177
|
- //if cooperationContract == nil {
|
|
|
178
|
- // var orderNumber string
|
|
|
179
|
- // if orderGood.DividendsOrderNumber != "" {
|
|
|
180
|
- // orderNumber = orderGood.DividendsOrderNumber
|
|
|
181
|
- // } else {
|
|
|
182
|
- // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
183
|
- // }
|
|
|
184
|
- // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
185
|
- // DividendsUser: nil,
|
|
|
186
|
- // DividendsParticipateType: 0,
|
|
|
187
|
- // DividendsStage: 0,
|
|
|
188
|
- // DividendsAmount: 0,
|
|
|
189
|
- // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
190
|
- // IsSuccessfully: false,
|
|
|
191
|
- // Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
|
|
|
192
|
- // })
|
|
|
193
|
- // continue
|
|
|
194
|
- //} else {
|
|
|
195
|
- // log.Logger.Info("产品相关的合约", map[string]interface{}{
|
|
|
196
|
- // "cooperationContract": cooperationContract,
|
|
|
197
|
- // })
|
|
|
198
|
- // if cooperationContract.Status == 2 {
|
|
|
199
|
- // var orderNumber string
|
|
|
200
|
- // if orderGood.DividendsOrderNumber != "" {
|
|
|
201
|
- // orderNumber = orderGood.DividendsOrderNumber
|
|
|
202
|
- // } else {
|
|
|
203
|
- // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
204
|
- // }
|
|
|
205
|
- // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
206
|
- // DividendsUser: nil,
|
|
|
207
|
- // DividendsParticipateType: 0,
|
|
|
208
|
- // DividendsStage: 0,
|
|
|
209
|
- // DividendsAmount: 0,
|
|
|
210
|
- // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
211
|
- // IsSuccessfully: false,
|
|
|
212
|
- // Reason: "共创合约" + orderGood.CooperationContractNumber + "已暂停",
|
|
|
213
|
- // })
|
|
|
214
|
- // continue
|
|
|
215
|
- // }
|
|
|
216
|
- //}
|
|
|
217
|
-
|
|
|
218
|
- // 获取共创项目
|
|
|
219
|
- //if cooperationContract.CooperationProjectNumber != "" {
|
|
|
220
|
- // cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
|
|
|
221
|
- // "cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
|
|
|
222
|
- // "companyId": cooperationContract.Company.CompanyId,
|
|
|
223
|
- // "orgId": cooperationContract.Org.OrgId,
|
|
|
224
|
- // })
|
|
|
225
|
- // if err != nil {
|
|
|
226
|
- // var orderNumber string
|
|
|
227
|
- // if orderGood.DividendsOrderNumber != "" {
|
|
|
228
|
- // orderNumber = orderGood.DividendsOrderNumber
|
|
|
229
|
- // } else {
|
|
|
230
|
- // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
231
|
- // }
|
|
|
232
|
- // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
233
|
- // DividendsUser: nil,
|
|
|
234
|
- // DividendsParticipateType: 0,
|
|
|
235
|
- // DividendsStage: 0,
|
|
|
236
|
- // DividendsAmount: 0,
|
|
|
237
|
- // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
238
|
- // IsSuccessfully: false,
|
|
|
239
|
- // Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "查询错误",
|
|
|
240
|
- // })
|
|
|
241
|
- // continue
|
|
|
242
|
- // }
|
|
|
243
|
- // if cooperationProject == nil {
|
|
|
244
|
- // var orderNumber string
|
|
|
245
|
- // if orderGood.DividendsOrderNumber != "" {
|
|
|
246
|
- // orderNumber = orderGood.DividendsOrderNumber
|
|
|
247
|
- // } else {
|
|
|
248
|
- // orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
249
|
- // }
|
|
|
250
|
- // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
251
|
- // DividendsUser: nil,
|
|
|
252
|
- // DividendsParticipateType: 0,
|
|
|
253
|
- // DividendsStage: 0,
|
|
|
254
|
- // DividendsAmount: 0,
|
|
|
255
|
- // OrderOrReturnedOrderNumber: orderNumber,
|
|
|
256
|
- // IsSuccessfully: false,
|
|
|
257
|
- // Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
|
|
|
258
|
- // })
|
|
|
259
|
- // continue
|
|
|
260
|
- // }
|
|
|
261
|
- //}
|
|
|
262
|
-
|
|
|
263
|
- // 判断共创项目是否存在
|
|
|
264
|
- if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {
|
|
|
265
|
- var orderNumber string
|
|
|
266
|
- if orderGood.DividendsOrderNumber != "" {
|
|
|
267
|
- orderNumber = orderGood.DividendsOrderNumber
|
|
|
268
|
- } else {
|
|
|
269
|
- orderNumber = orderGood.DividendsReturnedOrderNumber
|
|
|
270
|
- }
|
296
|
+ if dividendsOrder == nil {
|
271
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
297
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
272
|
DividendsUser: nil,
|
298
|
DividendsUser: nil,
|
273
|
DividendsParticipateType: 0,
|
299
|
DividendsParticipateType: 0,
|
274
|
DividendsStage: 0,
|
300
|
DividendsStage: 0,
|
275
|
DividendsAmount: 0,
|
301
|
DividendsAmount: 0,
|
276
|
- OrderOrReturnedOrderNumber: orderNumber,
|
302
|
+ OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
|
277
|
IsSuccessfully: false,
|
303
|
IsSuccessfully: false,
|
278
|
- Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",
|
304
|
+ Reason: "分红订单" + orderGood.DividendsOrderNumber + "不存在",
|
279
|
})
|
305
|
})
|
280
|
continue
|
306
|
continue
|
281
|
}
|
307
|
}
|
282
|
|
308
|
|
283
|
- if orderGood.DividendsOrderNumber != "" { // 获取分红订单
|
|
|
284
|
- // 获取分红订单
|
|
|
285
|
- dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
|
|
|
286
|
- "dividendsOrderNumber": orderGood.DividendsOrderNumber,
|
|
|
287
|
- "companyId": orderGood.CompanyId,
|
|
|
288
|
- "orgId": orderGood.OrgId,
|
|
|
289
|
- })
|
|
|
290
|
- if err2 != nil {
|
|
|
291
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
292
|
- DividendsUser: nil,
|
|
|
293
|
- DividendsParticipateType: 0,
|
|
|
294
|
- DividendsStage: 0,
|
|
|
295
|
- DividendsAmount: 0,
|
|
|
296
|
- OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
|
|
|
297
|
- IsSuccessfully: false,
|
|
|
298
|
- Reason: "分红订单" + orderGood.DividendsOrderNumber + "查询错误",
|
|
|
299
|
- })
|
|
|
300
|
- continue
|
|
|
301
|
- }
|
|
|
302
|
- if dividendsOrder == nil {
|
|
|
303
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
304
|
- DividendsUser: nil,
|
|
|
305
|
- DividendsParticipateType: 0,
|
|
|
306
|
- DividendsStage: 0,
|
|
|
307
|
- DividendsAmount: 0,
|
|
|
308
|
- OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
|
|
|
309
|
- IsSuccessfully: false,
|
|
|
310
|
- Reason: "分红订单" + orderGood.DividendsOrderNumber + "不存在",
|
|
|
311
|
- })
|
|
|
312
|
- continue
|
309
|
+ // 匹配分红规则
|
|
|
310
|
+ var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
|
|
|
311
|
+ for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
|
|
|
312
|
+ if (dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
|
|
|
313
|
+ (dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
|
|
|
314
|
+ dividendsIncentivesRuleMatched = dividendsIncentivesRule
|
|
|
315
|
+ break
|
313
|
}
|
316
|
}
|
|
|
317
|
+ }
|
|
|
318
|
+ if dividendsIncentivesRuleMatched == nil {
|
|
|
319
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
320
|
+ DividendsUser: nil,
|
|
|
321
|
+ DividendsParticipateType: 0,
|
|
|
322
|
+ DividendsStage: 0,
|
|
|
323
|
+ DividendsAmount: 0,
|
|
|
324
|
+ OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
|
|
|
325
|
+ IsSuccessfully: false,
|
|
|
326
|
+ Reason: "未匹配到分红规则",
|
|
|
327
|
+ })
|
|
|
328
|
+ continue
|
|
|
329
|
+ }
|
314
|
|
330
|
|
315
|
- // 匹配分红规则
|
|
|
316
|
- var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
|
|
|
317
|
- for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
|
|
|
318
|
- if (dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
|
|
|
319
|
- (dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
|
|
|
320
|
- dividendsIncentivesRuleMatched = dividendsIncentivesRule
|
|
|
321
|
- break
|
331
|
+ // 计算分红
|
|
|
332
|
+ if dividendsIncentivesRuleMatched != nil {
|
|
|
333
|
+ for _, undertaker := range cooperationContract.Undertakers {
|
|
|
334
|
+ // 添加承接人分红预算信息详情
|
|
|
335
|
+ if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
|
|
|
336
|
+ undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
|
|
|
337
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
338
|
+ DividendsUser: &domain.User{
|
|
|
339
|
+ UserId: undertaker.UserId,
|
|
|
340
|
+ UserBaseId: undertaker.UserBaseId,
|
|
|
341
|
+ Org: undertaker.Org,
|
|
|
342
|
+ Orgs: undertaker.Orgs,
|
|
|
343
|
+ Department: undertaker.Department,
|
|
|
344
|
+ Roles: undertaker.Roles,
|
|
|
345
|
+ UserInfo: undertaker.UserInfo,
|
|
|
346
|
+ UserType: undertaker.UserType,
|
|
|
347
|
+ UserName: undertaker.UserInfo.UserName,
|
|
|
348
|
+ UserPhone: undertaker.UserPhone,
|
|
|
349
|
+ Status: undertaker.Status,
|
|
|
350
|
+ Company: undertaker.Company,
|
|
|
351
|
+ },
|
|
|
352
|
+ DividendsParticipateType: domain.UNDERTAKER,
|
|
|
353
|
+ DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
|
|
|
354
|
+ DividendsAmount: undertakerDividendsAmount,
|
|
|
355
|
+ OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
|
|
|
356
|
+ IsSuccessfully: true,
|
|
|
357
|
+ CooperationContractUndertakerId: undertaker.UndertakerId,
|
|
|
358
|
+ DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
|
|
|
359
|
+ })
|
322
|
}
|
360
|
}
|
323
|
- }
|
|
|
324
|
- if dividendsIncentivesRuleMatched == nil {
|
|
|
325
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
326
|
- DividendsUser: nil,
|
|
|
327
|
- DividendsParticipateType: 0,
|
|
|
328
|
- DividendsStage: 0,
|
|
|
329
|
- DividendsAmount: 0,
|
|
|
330
|
- OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
|
|
|
331
|
- IsSuccessfully: false,
|
|
|
332
|
- Reason: "未匹配到分红规则",
|
|
|
333
|
- })
|
|
|
334
|
- continue
|
|
|
335
|
- }
|
|
|
336
|
-
|
|
|
337
|
- // 计算分红
|
|
|
338
|
- if dividendsIncentivesRuleMatched != nil {
|
|
|
339
|
- for _, undertaker := range cooperationContract.Undertakers {
|
|
|
340
|
- // 添加承接人分红预算信息详情
|
|
|
341
|
- if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
|
|
|
342
|
- undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
|
361
|
+ // 添加推荐人分红预算信息详情
|
|
|
362
|
+ if undertaker.Referrer != nil {
|
|
|
363
|
+ if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 {
|
|
|
364
|
+ referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
|
343
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
365
|
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
344
|
DividendsUser: &domain.User{
|
366
|
DividendsUser: &domain.User{
|
345
|
- UserId: undertaker.UserId,
|
|
|
346
|
- UserBaseId: undertaker.UserBaseId,
|
|
|
347
|
- Org: undertaker.Org,
|
|
|
348
|
- Orgs: undertaker.Orgs,
|
|
|
349
|
- Department: undertaker.Department,
|
|
|
350
|
- Roles: undertaker.Roles,
|
|
|
351
|
- UserInfo: undertaker.UserInfo,
|
|
|
352
|
- UserType: undertaker.UserType,
|
|
|
353
|
- UserName: undertaker.UserInfo.UserName,
|
|
|
354
|
- UserPhone: undertaker.UserPhone,
|
|
|
355
|
- Status: undertaker.Status,
|
|
|
356
|
- Company: undertaker.Company,
|
367
|
+ UserId: undertaker.Referrer.UserId,
|
|
|
368
|
+ UserBaseId: undertaker.Referrer.UserBaseId,
|
|
|
369
|
+ Org: undertaker.Referrer.Org,
|
|
|
370
|
+ Orgs: undertaker.Referrer.Orgs,
|
|
|
371
|
+ Department: undertaker.Referrer.Department,
|
|
|
372
|
+ Roles: undertaker.Referrer.Roles,
|
|
|
373
|
+ UserInfo: undertaker.Referrer.UserInfo,
|
|
|
374
|
+ UserType: undertaker.Referrer.UserType,
|
|
|
375
|
+ UserName: undertaker.Referrer.UserName,
|
|
|
376
|
+ UserPhone: undertaker.Referrer.UserPhone,
|
|
|
377
|
+ Company: undertaker.Referrer.Company,
|
357
|
},
|
378
|
},
|
358
|
- DividendsParticipateType: domain.UNDERTAKER,
|
379
|
+ DividendsParticipateType: domain.REFERRER,
|
359
|
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
|
380
|
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
|
360
|
- DividendsAmount: undertakerDividendsAmount,
|
381
|
+ DividendsAmount: referrerDividendsAmount,
|
361
|
OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
|
382
|
OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
|
362
|
IsSuccessfully: true,
|
383
|
IsSuccessfully: true,
|
363
|
CooperationContractUndertakerId: undertaker.UndertakerId,
|
384
|
CooperationContractUndertakerId: undertaker.UndertakerId,
|
364
|
- DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
|
385
|
+ DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
|
365
|
})
|
386
|
})
|
366
|
}
|
387
|
}
|
367
|
- // 添加推荐人分红预算信息详情
|
|
|
368
|
- if undertaker.Referrer != nil {
|
|
|
369
|
- if dividendsIncentivesRuleMatched.ReferrerPercentage > 0 {
|
|
|
370
|
- referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
|
|
|
371
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
372
|
- DividendsUser: &domain.User{
|
|
|
373
|
- UserId: undertaker.Referrer.UserId,
|
|
|
374
|
- UserBaseId: undertaker.Referrer.UserBaseId,
|
|
|
375
|
- Org: undertaker.Referrer.Org,
|
|
|
376
|
- Orgs: undertaker.Referrer.Orgs,
|
|
|
377
|
- Department: undertaker.Referrer.Department,
|
|
|
378
|
- Roles: undertaker.Referrer.Roles,
|
|
|
379
|
- UserInfo: undertaker.Referrer.UserInfo,
|
|
|
380
|
- UserType: undertaker.Referrer.UserType,
|
|
|
381
|
- UserName: undertaker.Referrer.UserName,
|
|
|
382
|
- UserPhone: undertaker.Referrer.UserPhone,
|
|
|
383
|
- Company: undertaker.Referrer.Company,
|
|
|
384
|
- },
|
|
|
385
|
- DividendsParticipateType: domain.REFERRER,
|
|
|
386
|
- DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
|
|
|
387
|
- DividendsAmount: referrerDividendsAmount,
|
|
|
388
|
- OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
|
|
|
389
|
- IsSuccessfully: true,
|
|
|
390
|
- CooperationContractUndertakerId: undertaker.UndertakerId,
|
|
|
391
|
- DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
|
|
|
392
|
- })
|
|
|
393
|
- }
|
|
|
394
|
- }
|
|
|
395
|
- // 添加关联业务员分红预算信息详情
|
|
|
396
|
- if undertaker.Salesman != nil {
|
|
|
397
|
- if dividendsIncentivesRuleMatched.SalesmanPercentage > 0 {
|
|
|
398
|
- salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
|
|
|
399
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
400
|
- DividendsUser: &domain.User{
|
|
|
401
|
- UserId: undertaker.Salesman.UserId,
|
|
|
402
|
- UserBaseId: undertaker.Salesman.UserBaseId,
|
|
|
403
|
- Org: undertaker.Salesman.Org,
|
|
|
404
|
- Orgs: undertaker.Salesman.Orgs,
|
|
|
405
|
- Department: undertaker.Salesman.Department,
|
|
|
406
|
- Roles: undertaker.Salesman.Roles,
|
|
|
407
|
- UserInfo: undertaker.Salesman.UserInfo,
|
|
|
408
|
- UserType: undertaker.Salesman.UserType,
|
|
|
409
|
- UserName: undertaker.Salesman.UserInfo.UserName,
|
|
|
410
|
- UserPhone: undertaker.Salesman.UserPhone,
|
|
|
411
|
- Company: undertaker.Salesman.Company,
|
|
|
412
|
- },
|
|
|
413
|
- DividendsParticipateType: domain.SALESMAN,
|
|
|
414
|
- DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
|
|
|
415
|
- DividendsAmount: salesmanDividendsAmount,
|
|
|
416
|
- OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
|
|
|
417
|
- IsSuccessfully: true,
|
|
|
418
|
- CooperationContractUndertakerId: undertaker.UndertakerId,
|
|
|
419
|
- DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
|
|
|
420
|
- })
|
|
|
421
|
- }
|
388
|
+ }
|
|
|
389
|
+ // 添加关联业务员分红预算信息详情
|
|
|
390
|
+ if undertaker.Salesman != nil {
|
|
|
391
|
+ if dividendsIncentivesRuleMatched.SalesmanPercentage > 0 {
|
|
|
392
|
+ salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
|
|
|
393
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
394
|
+ DividendsUser: &domain.User{
|
|
|
395
|
+ UserId: undertaker.Salesman.UserId,
|
|
|
396
|
+ UserBaseId: undertaker.Salesman.UserBaseId,
|
|
|
397
|
+ Org: undertaker.Salesman.Org,
|
|
|
398
|
+ Orgs: undertaker.Salesman.Orgs,
|
|
|
399
|
+ Department: undertaker.Salesman.Department,
|
|
|
400
|
+ Roles: undertaker.Salesman.Roles,
|
|
|
401
|
+ UserInfo: undertaker.Salesman.UserInfo,
|
|
|
402
|
+ UserType: undertaker.Salesman.UserType,
|
|
|
403
|
+ UserName: undertaker.Salesman.UserInfo.UserName,
|
|
|
404
|
+ UserPhone: undertaker.Salesman.UserPhone,
|
|
|
405
|
+ Company: undertaker.Salesman.Company,
|
|
|
406
|
+ },
|
|
|
407
|
+ DividendsParticipateType: domain.SALESMAN,
|
|
|
408
|
+ DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
|
|
|
409
|
+ DividendsAmount: salesmanDividendsAmount,
|
|
|
410
|
+ OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
|
|
|
411
|
+ IsSuccessfully: true,
|
|
|
412
|
+ CooperationContractUndertakerId: undertaker.UndertakerId,
|
|
|
413
|
+ DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
|
|
|
414
|
+ })
|
422
|
}
|
415
|
}
|
423
|
}
|
416
|
}
|
424
|
}
|
417
|
}
|
425
|
- } else if orderGood.DividendsReturnedOrderNumber != "" { // 获取退货单
|
|
|
426
|
- dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
|
|
|
427
|
- "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
|
|
|
428
|
- "companyId": orderGood.CompanyId,
|
|
|
429
|
- "orgId": orderGood.OrgId,
|
418
|
+ }
|
|
|
419
|
+ } else if orderGood.DividendsReturnedOrderNumber != "" { // 获取退货单
|
|
|
420
|
+ dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
|
|
|
421
|
+ "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
|
|
|
422
|
+ "companyId": orderGood.CompanyId,
|
|
|
423
|
+ "orgId": orderGood.OrgId,
|
|
|
424
|
+ })
|
|
|
425
|
+ if err3 != nil {
|
|
|
426
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
427
|
+ DividendsUser: nil,
|
|
|
428
|
+ DividendsParticipateType: 0,
|
|
|
429
|
+ DividendsStage: 0,
|
|
|
430
|
+ DividendsAmount: 0,
|
|
|
431
|
+ OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
|
|
|
432
|
+ IsSuccessfully: false,
|
|
|
433
|
+ Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
|
430
|
})
|
434
|
})
|
431
|
- if err3 != nil {
|
|
|
432
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
433
|
- DividendsUser: nil,
|
|
|
434
|
- DividendsParticipateType: 0,
|
|
|
435
|
- DividendsStage: 0,
|
|
|
436
|
- DividendsAmount: 0,
|
|
|
437
|
- OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
|
|
|
438
|
- IsSuccessfully: false,
|
|
|
439
|
- Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
|
|
|
440
|
- })
|
|
|
441
|
- continue
|
|
|
442
|
- }
|
|
|
443
|
- if dividendsReturnedOrder == nil {
|
|
|
444
|
- dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
445
|
- DividendsUser: nil,
|
|
|
446
|
- DividendsParticipateType: 0,
|
|
|
447
|
- DividendsStage: 0,
|
|
|
448
|
- DividendsAmount: 0,
|
|
|
449
|
- OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
|
|
|
450
|
- IsSuccessfully: false,
|
|
|
451
|
- Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
|
|
|
452
|
- })
|
|
|
453
|
- continue
|
|
|
454
|
- }
|
|
|
455
|
- // 匹配分红规则
|
|
|
456
|
- var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
|
|
|
457
|
- for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
|
|
|
458
|
- if (dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
|
|
|
459
|
- (dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
|
|
|
460
|
- dividendsIncentivesRuleMatched = dividendsIncentivesRule
|
|
|
461
|
- break
|
|
|
462
|
- }
|
435
|
+ continue
|
|
|
436
|
+ }
|
|
|
437
|
+ if dividendsReturnedOrder == nil {
|
|
|
438
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
439
|
+ DividendsUser: nil,
|
|
|
440
|
+ DividendsParticipateType: 0,
|
|
|
441
|
+ DividendsStage: 0,
|
|
|
442
|
+ DividendsAmount: 0,
|
|
|
443
|
+ OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
|
|
|
444
|
+ IsSuccessfully: false,
|
|
|
445
|
+ Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
|
|
|
446
|
+ })
|
|
|
447
|
+ continue
|
|
|
448
|
+ }
|
|
|
449
|
+ // 匹配分红规则
|
|
|
450
|
+ var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
|
|
|
451
|
+ for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
|
|
|
452
|
+ if (dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
|
|
|
453
|
+ (dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
|
|
|
454
|
+ dividendsIncentivesRuleMatched = dividendsIncentivesRule
|
|
|
455
|
+ break
|
463
|
}
|
456
|
}
|
464
|
- // 计算分红
|
457
|
+ }
|
|
|
458
|
+ // 计算分红
|
|
|
459
|
+ if len(cooperationContract.Undertakers) <= 0 {
|
|
|
460
|
+ dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
|
|
|
461
|
+ DividendsUser: nil,
|
|
|
462
|
+ DividendsParticipateType: 0,
|
|
|
463
|
+ DividendsStage: 0,
|
|
|
464
|
+ DividendsAmount: 0,
|
|
|
465
|
+ OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
|
|
|
466
|
+ IsSuccessfully: false,
|
|
|
467
|
+ Reason: "合约承接人不存在",
|
|
|
468
|
+ })
|
|
|
469
|
+ continue
|
|
|
470
|
+ } else {
|
465
|
for _, undertaker := range cooperationContract.Undertakers {
|
471
|
for _, undertaker := range cooperationContract.Undertakers {
|
466
|
// 添加承接人分红退货预算信息详情
|
472
|
// 添加承接人分红退货预算信息详情
|
467
|
if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
|
473
|
if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
|
|
@@ -551,7 +557,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
@@ -551,7 +557,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
551
|
}
|
557
|
}
|
552
|
}
|
558
|
}
|
553
|
}
|
559
|
}
|
554
|
- }()
|
560
|
+ }
|
555
|
|
561
|
|
556
|
return dividendsEstimateDetails, nil
|
562
|
return dividendsEstimateDetails, nil
|
557
|
}
|
563
|
}
|