|
@@ -60,11 +60,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -60,11 +60,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
60
|
var dividendsEstimatesCanceled []*domain.DividendsEstimate
|
60
|
var dividendsEstimatesCanceled []*domain.DividendsEstimate
|
61
|
var orderOrReturnOrderNums []string
|
61
|
var orderOrReturnOrderNums []string
|
62
|
for _, dividendsEstimate := range dividendsEstimates {
|
62
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
63
|
+ if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理
|
63
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
64
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
64
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
65
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
65
|
"companyId": dividendsEstimate.Company.CompanyId,
|
66
|
"companyId": dividendsEstimate.Company.CompanyId,
|
66
|
"orgId": dividendsEstimate.Org.OrgId,
|
67
|
"orgId": dividendsEstimate.Org.OrgId,
|
67
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
68
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
69
|
+ "offsetLimit": false,
|
68
|
}); err2 != nil {
|
70
|
}); err2 != nil {
|
69
|
return nil, err2
|
71
|
return nil, err2
|
70
|
} else {
|
72
|
} else {
|
|
@@ -83,11 +85,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -83,11 +85,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
83
|
}
|
85
|
}
|
84
|
}
|
86
|
}
|
85
|
}
|
87
|
}
|
|
|
88
|
+ }
|
86
|
|
89
|
|
87
|
// 分红订单或分红退货单状态变更
|
90
|
// 分红订单或分红退货单状态变更
|
88
|
var orderNums []string
|
91
|
var orderNums []string
|
89
|
var returnedOrderNums []string
|
92
|
var returnedOrderNums []string
|
90
|
|
93
|
|
|
|
94
|
+ if len(orderOrReturnOrderNums) > 0 {
|
91
|
// 订单/退货单号数组去重
|
95
|
// 订单/退货单号数组去重
|
92
|
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
|
96
|
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
|
93
|
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
|
97
|
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
|
|
@@ -99,6 +103,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -99,6 +103,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
99
|
}
|
103
|
}
|
100
|
|
104
|
|
101
|
// 获取分红订单
|
105
|
// 获取分红订单
|
|
|
106
|
+ if len(orderNums) > 0 {
|
102
|
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
|
107
|
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
|
103
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
108
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
104
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
109
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
|
@@ -120,6 +125,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -120,6 +125,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
120
|
ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber)
|
125
|
ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber)
|
121
|
}
|
126
|
}
|
122
|
// 获取分红订单产品并更新产品状态
|
127
|
// 获取分红订单产品并更新产品状态
|
|
|
128
|
+ if len(ordersNumbers) > 0 {
|
123
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
129
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
124
|
"orderNumbers": ordersNumbers,
|
130
|
"orderNumbers": ordersNumbers,
|
125
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
131
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
|
@@ -138,8 +144,11 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -138,8 +144,11 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
138
|
}
|
144
|
}
|
139
|
}
|
145
|
}
|
140
|
}
|
146
|
}
|
|
|
147
|
+ }
|
|
|
148
|
+ }
|
141
|
|
149
|
|
142
|
// 获取分红退货单
|
150
|
// 获取分红退货单
|
|
|
151
|
+ if len(returnedOrderNums) > 0 {
|
143
|
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
|
152
|
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
|
144
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
153
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
145
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
154
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
|
@@ -161,6 +170,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -161,6 +170,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
161
|
returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber)
|
170
|
returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber)
|
162
|
}
|
171
|
}
|
163
|
// 获取退货单产品并更新产品状态
|
172
|
// 获取退货单产品并更新产品状态
|
|
|
173
|
+ if len(returnedOrdersNumbers) > 0 {
|
164
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
174
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
165
|
"returnedOrderNumbers": returnedOrdersNumbers,
|
175
|
"returnedOrderNumbers": returnedOrdersNumbers,
|
166
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
176
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
|
@@ -179,7 +189,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
@@ -179,7 +189,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
179
|
}
|
189
|
}
|
180
|
}
|
190
|
}
|
181
|
}
|
191
|
}
|
182
|
-
|
192
|
+ }
|
|
|
193
|
+ }
|
|
|
194
|
+ }
|
183
|
return dividendsEstimatesCanceled, nil
|
195
|
return dividendsEstimatesCanceled, nil
|
184
|
}
|
196
|
}
|
185
|
}
|
197
|
}
|