|
@@ -17,25 +17,9 @@ type ConfirmDividendsIncentivesEstimateService struct { |
|
@@ -17,25 +17,9 @@ type ConfirmDividendsIncentivesEstimateService struct { |
17
|
|
17
|
|
18
|
// Confirm 确认业绩分红预算
|
18
|
// Confirm 确认业绩分红预算
|
19
|
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64, cooperationContractsMap map[string]*domain.CooperationContract, cooperationProjectsMap map[string]*domain.CooperationProject) ([]*service.DividendsEstimateDetail, error) {
|
19
|
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood, companyId int64, orgId int64, cooperationContractsMap map[string]*domain.CooperationContract, cooperationProjectsMap map[string]*domain.CooperationProject) ([]*service.DividendsEstimateDetail, error) {
|
20
|
- //var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
|
|
|
21
|
- //var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
|
|
|
22
|
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
|
20
|
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
|
23
|
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
|
21
|
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
|
24
|
|
22
|
|
25
|
- // 共创合约仓储初始化
|
|
|
26
|
- //if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
|
|
|
27
|
- // return nil, err
|
|
|
28
|
- //} else {
|
|
|
29
|
- // cooperationContractRepository = repo
|
|
|
30
|
- //}
|
|
|
31
|
-
|
|
|
32
|
- // 共创项目仓储初始化
|
|
|
33
|
- //if repo, err := repository.NewCooperationProjectRepository(domainService.transactionContext); err != nil {
|
|
|
34
|
- // return nil, err
|
|
|
35
|
- //} else {
|
|
|
36
|
- // cooperationProjectRepository = repo
|
|
|
37
|
- //}
|
|
|
38
|
-
|
|
|
39
|
// 分红订单仓储初始化
|
23
|
// 分红订单仓储初始化
|
40
|
if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
|
24
|
if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
|
41
|
return nil, err
|
25
|
return nil, err
|
|
@@ -50,38 +34,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
@@ -50,38 +34,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
50
|
dividendsReturnedOrderRepository = repo
|
34
|
dividendsReturnedOrderRepository = repo
|
51
|
}
|
35
|
}
|
52
|
|
36
|
|
53
|
- // 查询共创合约
|
|
|
54
|
- //cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
|
|
|
55
|
- //if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
|
|
|
56
|
- // "companyId": companyId,
|
|
|
57
|
- // "orgId": orgId,
|
|
|
58
|
- // "offsetLimit": false,
|
|
|
59
|
- //}); err != nil {
|
|
|
60
|
- // return nil, err
|
|
|
61
|
- //} else {
|
|
|
62
|
- // if count > 0 {
|
|
|
63
|
- // for _, cooperationContractFound := range cooperationContractsFound {
|
|
|
64
|
- // cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
|
|
|
65
|
- // }
|
|
|
66
|
- // }
|
|
|
67
|
- //}
|
|
|
68
|
-
|
|
|
69
|
- // 查询共创项目
|
|
|
70
|
- //cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
|
|
|
71
|
- //if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
|
|
|
72
|
- // "companyId": companyId,
|
|
|
73
|
- // "orgId": orgId,
|
|
|
74
|
- // "offsetLimit": false,
|
|
|
75
|
- //}); err != nil {
|
|
|
76
|
- // return nil, err
|
|
|
77
|
- //} else {
|
|
|
78
|
- // if count > 0 {
|
|
|
79
|
- // for _, cooperationProjectFound := range cooperationProjectsFound {
|
|
|
80
|
- // cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
|
|
|
81
|
- // }
|
|
|
82
|
- // }
|
|
|
83
|
- //}
|
|
|
84
|
-
|
|
|
85
|
// 确认业绩分红预算
|
37
|
// 确认业绩分红预算
|
86
|
var dividendsEstimateDetails []*service.DividendsEstimateDetail
|
38
|
var dividendsEstimateDetails []*service.DividendsEstimateDetail
|
87
|
for _, orderGood := range orderGoods {
|
39
|
for _, orderGood := range orderGoods {
|
|
@@ -145,115 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
|
@@ -145,115 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo |
145
|
}
|
97
|
}
|
146
|
}
|
98
|
}
|
147
|
|
99
|
|
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
|
// 判断共创项目是否存在
|
100
|
// 判断共创项目是否存在
|
258
|
if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {
|
101
|
if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {
|
259
|
var orderNumber string
|
102
|
var orderNumber string
|