|
@@ -69,50 +69,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -69,50 +69,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
69
|
var orderGoodIds []int64
|
69
|
var orderGoodIds []int64
|
70
|
for _, dividendsEstimate := range dividendsEstimates {
|
70
|
for _, dividendsEstimate := range dividendsEstimates {
|
71
|
if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
|
71
|
if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
|
72
|
- // 自定义查询
|
|
|
73
|
-
|
|
|
74
|
- //queryOptions := map[string]interface{}{
|
|
|
75
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
76
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
77
|
- // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
78
|
- // "dividendsParticipateTypes": []int32{1, 2, 3},
|
|
|
79
|
- // "offsetLimit": false,
|
|
|
80
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
81
|
- // "dividendsTypes": []int32{1, 2},
|
|
|
82
|
- //}
|
|
|
83
|
- //参与分红类型,1承接人,2推荐人,3关联业务员
|
|
|
84
|
- //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
|
|
|
85
|
- // queryOptions = map[string]interface{}{
|
|
|
86
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
87
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
88
|
- // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
89
|
- // "dividendsParticipateTypes": []int32{1, 2, 3},
|
|
|
90
|
- // "offsetLimit": false,
|
|
|
91
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
92
|
- // "dividendsTypes": []int32{1, 2},
|
|
|
93
|
- // }
|
|
|
94
|
- //} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
|
|
|
95
|
- // queryOptions = map[string]interface{}{
|
|
|
96
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
97
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
98
|
- // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
99
|
- // "dividendsParticipateTypes": []int32{1, 3},
|
|
|
100
|
- // "offsetLimit": false,
|
|
|
101
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
102
|
- // "dividendsTypes": []int32{1, 2},
|
|
|
103
|
- // }
|
|
|
104
|
- //} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
|
|
|
105
|
- // queryOptions = map[string]interface{}{
|
|
|
106
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
107
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
108
|
- // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
109
|
- // "dividendsParticipateTypes": []int32{1, 2},
|
|
|
110
|
- // "offsetLimit": false,
|
|
|
111
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
112
|
- // "dividendsTypes": []int32{1, 2},
|
|
|
113
|
- // }
|
|
|
114
|
- //}
|
|
|
115
|
-
|
|
|
116
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
72
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
117
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
73
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
118
|
"companyId": dividendsEstimate.Company.CompanyId,
|
74
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
@@ -143,60 +99,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -143,60 +99,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
143
|
}
|
99
|
}
|
144
|
}
|
100
|
}
|
145
|
} else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
|
101
|
} else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
|
146
|
-
|
|
|
147
|
- // 查询合约
|
|
|
148
|
- //cooperationContract, err3 := cooperationContactRepository.FindOne(map[string]interface{}{
|
|
|
149
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
150
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
151
|
- // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
152
|
- //})
|
|
|
153
|
- //if err3 != nil {
|
|
|
154
|
- // return nil, err3
|
|
|
155
|
- //}
|
|
|
156
|
-
|
|
|
157
|
- // 自定义查询
|
|
|
158
|
- //queryOptions := map[string]interface{}{
|
|
|
159
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
160
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
161
|
- // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
162
|
- // "dividendsParticipateTypes": []int32{1, 2, 3},
|
|
|
163
|
- // "offsetLimit": false,
|
|
|
164
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
165
|
- // "dividendsType": int32(3),
|
|
|
166
|
- //}
|
|
|
167
|
- //参与分红类型,1承接人,2推荐人,3关联业务员
|
|
|
168
|
- //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
|
|
|
169
|
- // queryOptions = map[string]interface{}{
|
|
|
170
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
171
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
172
|
- // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
173
|
- // "dividendsParticipateTypes": []int32{2, 3},
|
|
|
174
|
- // "offsetLimit": false,
|
|
|
175
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
176
|
- // "dividendsType": int32(3),
|
|
|
177
|
- // }
|
|
|
178
|
- //} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
|
|
|
179
|
- // queryOptions = map[string]interface{}{
|
|
|
180
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
181
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
182
|
- // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
183
|
- // "dividendsParticipateTypes": []int32{1, 3},
|
|
|
184
|
- // "offsetLimit": false,
|
|
|
185
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
186
|
- // "dividendsType": int32(3),
|
|
|
187
|
- // }
|
|
|
188
|
- //} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
|
|
|
189
|
- // queryOptions = map[string]interface{}{
|
|
|
190
|
- // "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
191
|
- // "orgId": dividendsEstimate.Org.OrgId,
|
|
|
192
|
- // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
193
|
- // "dividendsParticipateTypes": []int32{1, 2},
|
|
|
194
|
- // "offsetLimit": false,
|
|
|
195
|
- // "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
196
|
- // "dividendsType": int32(3),
|
|
|
197
|
- // }
|
|
|
198
|
- //}
|
|
|
199
|
-
|
|
|
200
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
102
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
201
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
103
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
202
|
"companyId": dividendsEstimate.Company.CompanyId,
|
104
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
@@ -288,7 +190,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -288,7 +190,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
288
|
// 获取分红订单产品并更新产品状态
|
190
|
// 获取分红订单产品并更新产品状态
|
289
|
if len(ordersNumbers) > 0 {
|
191
|
if len(ordersNumbers) > 0 {
|
290
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
192
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
291
|
- //"orderNumbers": ordersNumbers,
|
|
|
292
|
"orderGoodIds": orderGoodIds,
|
193
|
"orderGoodIds": orderGoodIds,
|
293
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
194
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
294
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
195
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
|
@@ -318,11 +219,21 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -318,11 +219,21 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
318
|
}); err5 != nil {
|
219
|
}); err5 != nil {
|
319
|
return nil, err5
|
220
|
return nil, err5
|
320
|
} else {
|
221
|
} else {
|
|
|
222
|
+ // orderGoodIds去重
|
|
|
223
|
+ newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds)
|
|
|
224
|
+
|
321
|
if countDividendsReturnedOrder > 0 {
|
225
|
if countDividendsReturnedOrder > 0 {
|
322
|
for i, returnedOrder := range returnedOrders {
|
226
|
for i, returnedOrder := range returnedOrders {
|
323
|
- if len(returnedOrder.Goods) == len(orderGoodIds) { // 1.全部产品取消分红预算
|
227
|
+ goods := make([]*domain.OrderGood, 0)
|
|
|
228
|
+ for _, good := range returnedOrder.Goods {
|
|
|
229
|
+ if good.OrderGoodDividendsStatus == 2 {
|
|
|
230
|
+ goods = append(goods, good)
|
|
|
231
|
+ }
|
|
|
232
|
+ }
|
|
|
233
|
+
|
|
|
234
|
+ if len(goods) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红
|
324
|
returnedOrders[i].DividendStatus = 1
|
235
|
returnedOrders[i].DividendStatus = 1
|
325
|
- } else if len(returnedOrder.Goods) > len(orderGoodIds) { // 3.部分产品被取消分红预算
|
236
|
+ } else if len(goods) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红
|
326
|
returnedOrders[i].DividendStatus = 3
|
237
|
returnedOrders[i].DividendStatus = 3
|
327
|
}
|
238
|
}
|
328
|
returnedOrders[i].DividendStatus = returnedOrder.DividendStatus
|
239
|
returnedOrders[i].DividendStatus = returnedOrder.DividendStatus
|
|
@@ -342,7 +253,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -342,7 +253,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
342
|
// 获取退货单产品并更新产品状态
|
253
|
// 获取退货单产品并更新产品状态
|
343
|
if len(returnedOrdersNumbers) > 0 {
|
254
|
if len(returnedOrdersNumbers) > 0 {
|
344
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
255
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
345
|
- //"returnedOrderNumbers": returnedOrdersNumbers,
|
|
|
346
|
"orderGoodIds": orderGoodIds,
|
256
|
"orderGoodIds": orderGoodIds,
|
347
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
257
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
348
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
258
|
"orgId": dividendsEstimates[0].Org.OrgId,
|