|
@@ -40,7 +40,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -40,7 +40,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
40
|
return nil, err
|
40
|
return nil, err
|
41
|
} else {
|
41
|
} else {
|
42
|
dividendsReturnedOrderRepository = repo
|
42
|
dividendsReturnedOrderRepository = repo
|
43
|
-
|
|
|
44
|
}
|
43
|
}
|
45
|
|
44
|
|
46
|
// 订单产品仓储初始化
|
45
|
// 订单产品仓储初始化
|
|
@@ -60,14 +59,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -60,14 +59,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
60
|
var dividendsEstimatesCanceled []*domain.DividendsEstimate
|
59
|
var dividendsEstimatesCanceled []*domain.DividendsEstimate
|
61
|
var orderOrReturnOrderNums []string
|
60
|
var orderOrReturnOrderNums []string
|
62
|
for _, dividendsEstimate := range dividendsEstimates {
|
61
|
for _, dividendsEstimate := range dividendsEstimates {
|
63
|
- if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理
|
|
|
64
|
- // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
65
|
- if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
62
|
+ if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
|
|
|
63
|
+ // 自定义查询
|
|
|
64
|
+ queryOptions := make(map[string]interface{})
|
|
|
65
|
+
|
|
|
66
|
+ //参与分红类型,1承接人,2推荐人,3关联业务员
|
|
|
67
|
+ if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
|
|
|
68
|
+ queryOptions = map[string]interface{}{
|
|
|
69
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
70
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
71
|
+ "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
72
|
+ "dividendsParticipateTypes": []int32{2, 3},
|
|
|
73
|
+ "offsetLimit": false,
|
|
|
74
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
75
|
+ "dividendsTypes": []int32{1, 2},
|
|
|
76
|
+ }
|
|
|
77
|
+ } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
|
|
|
78
|
+ queryOptions = map[string]interface{}{
|
66
|
"companyId": dividendsEstimate.Company.CompanyId,
|
79
|
"companyId": dividendsEstimate.Company.CompanyId,
|
67
|
"orgId": dividendsEstimate.Org.OrgId,
|
80
|
"orgId": dividendsEstimate.Org.OrgId,
|
68
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
81
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
82
|
+ "dividendsParticipateTypes": []int32{1, 3},
|
69
|
"offsetLimit": false,
|
83
|
"offsetLimit": false,
|
70
|
- }); err2 != nil {
|
84
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
85
|
+ "dividendsTypes": []int32{1, 2},
|
|
|
86
|
+ }
|
|
|
87
|
+ } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
|
|
|
88
|
+ queryOptions = map[string]interface{}{
|
|
|
89
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
90
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
91
|
+ "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
92
|
+ "dividendsParticipateTypes": []int32{1, 2},
|
|
|
93
|
+ "offsetLimit": false,
|
|
|
94
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
95
|
+ "dividendsTypes": []int32{1, 2},
|
|
|
96
|
+ }
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
100
|
+ if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
71
|
return nil, err2
|
101
|
return nil, err2
|
72
|
} else {
|
102
|
} else {
|
73
|
if countRelative > 0 {
|
103
|
if countRelative > 0 {
|
|
@@ -84,15 +114,44 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -84,15 +114,44 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
84
|
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
|
114
|
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
|
85
|
}
|
115
|
}
|
86
|
}
|
116
|
}
|
87
|
- } else if dividendsEstimate.DividendsType == 3 {
|
|
|
88
|
- // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
89
|
- if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
117
|
+ } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
|
|
|
118
|
+ // 自定义查询
|
|
|
119
|
+ queryOptions := make(map[string]interface{})
|
|
|
120
|
+
|
|
|
121
|
+ //参与分红类型,1承接人,2推荐人,3关联业务员
|
|
|
122
|
+ if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
|
|
|
123
|
+ queryOptions = map[string]interface{}{
|
90
|
"companyId": dividendsEstimate.Company.CompanyId,
|
124
|
"companyId": dividendsEstimate.Company.CompanyId,
|
91
|
"orgId": dividendsEstimate.Org.OrgId,
|
125
|
"orgId": dividendsEstimate.Org.OrgId,
|
92
|
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
126
|
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
127
|
+ "dividendsParticipateTypes": []int32{2, 3},
|
|
|
128
|
+ "offsetLimit": false,
|
|
|
129
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
93
|
"dividendsType": int32(3),
|
130
|
"dividendsType": int32(3),
|
|
|
131
|
+ }
|
|
|
132
|
+ } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
|
|
|
133
|
+ queryOptions = map[string]interface{}{
|
|
|
134
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
135
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
136
|
+ "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
137
|
+ "dividendsParticipateTypes": []int32{1, 3},
|
|
|
138
|
+ "offsetLimit": false,
|
|
|
139
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
140
|
+ "dividendsType": int32(3),
|
|
|
141
|
+ }
|
|
|
142
|
+ } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
|
|
|
143
|
+ queryOptions = map[string]interface{}{
|
|
|
144
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
145
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
146
|
+ "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
147
|
+ "dividendsParticipateTypes": []int32{1, 2},
|
94
|
"offsetLimit": false,
|
148
|
"offsetLimit": false,
|
95
|
- }); err2 != nil {
|
149
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
150
|
+ "dividendsType": int32(3),
|
|
|
151
|
+ }
|
|
|
152
|
+ }
|
|
|
153
|
+ // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
154
|
+ if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
96
|
return nil, err2
|
155
|
return nil, err2
|
97
|
} else {
|
156
|
} else {
|
98
|
if countRelative > 0 {
|
157
|
if countRelative > 0 {
|
|
@@ -110,20 +169,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -110,20 +169,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
110
|
}
|
169
|
}
|
111
|
}
|
170
|
}
|
112
|
|
171
|
|
113
|
- // 分红订单或分红退货单状态变更
|
172
|
+ // 分红订单
|
114
|
var orderNums []string
|
173
|
var orderNums []string
|
|
|
174
|
+
|
|
|
175
|
+ // 分红退货单
|
115
|
var returnedOrderNums []string
|
176
|
var returnedOrderNums []string
|
116
|
|
177
|
|
117
|
if len(orderOrReturnOrderNums) > 0 {
|
178
|
if len(orderOrReturnOrderNums) > 0 {
|
118
|
// 订单/退货单号数组去重
|
179
|
// 订单/退货单号数组去重
|
119
|
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
|
180
|
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
|
|
|
181
|
+
|
|
|
182
|
+ // 分离订单和退货单
|
120
|
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
|
183
|
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
|
|
|
184
|
+ if len(orderNullNum) > 0 {
|
121
|
if orderNullNum[:2] == "RE" { // 分红退后单
|
185
|
if orderNullNum[:2] == "RE" { // 分红退后单
|
122
|
returnedOrderNums = append(returnedOrderNums, orderNullNum)
|
186
|
returnedOrderNums = append(returnedOrderNums, orderNullNum)
|
123
|
} else if orderNullNum[:2] == "SL" { // 分红订单
|
187
|
} else if orderNullNum[:2] == "SL" { // 分红订单
|
124
|
orderNums = append(orderNums, orderNullNum)
|
188
|
orderNums = append(orderNums, orderNullNum)
|
125
|
}
|
189
|
}
|
126
|
}
|
190
|
}
|
|
|
191
|
+ }
|
127
|
|
192
|
|
128
|
// 获取分红订单并更新分红订单产品的状态
|
193
|
// 获取分红订单并更新分红订单产品的状态
|
129
|
if len(orderNums) > 0 {
|
194
|
if len(orderNums) > 0 {
|