作者 陈志颖

fix:批量移除分红预算单

@@ -20,7 +20,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -20,7 +20,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
20 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 20 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
21 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 21 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
22 var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储 22 var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储
23 - //var cooperationContactRepository domain.CooperationContractRepository // 合约仓储  
24 23
25 // 分红预算单仓储初始化 24 // 分红预算单仓储初始化
26 if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil { 25 if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
@@ -50,16 +49,10 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -50,16 +49,10 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
50 orderGoodRepository = repo 49 orderGoodRepository = repo
51 } 50 }
52 51
53 - // 共创合约仓储初始化  
54 - //if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {  
55 - // return nil, err  
56 - //} else {  
57 - // cooperationContactRepository = repo  
58 - //}  
59 -  
60 // 获取分红预算单 52 // 获取分红预算单
61 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ 53 if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
62 "dividendsEstimateIds": dividendsEstimateIds, 54 "dividendsEstimateIds": dividendsEstimateIds,
  55 + "offsetLimit": false,
63 }); err != nil { 56 }); err != nil {
64 return nil, err 57 return nil, err
65 } else { 58 } else {
@@ -154,6 +147,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -154,6 +147,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
154 "companyId": dividendsEstimates[0].Company.CompanyId, 147 "companyId": dividendsEstimates[0].Company.CompanyId,
155 "orgId": dividendsEstimates[0].Org.OrgId, 148 "orgId": dividendsEstimates[0].Org.OrgId,
156 "dividendsOrderNumbers": orderNums, 149 "dividendsOrderNumbers": orderNums,
  150 + "offsetLimit": false,
157 }); err4 != nil { 151 }); err4 != nil {
158 return nil, err4 152 return nil, err4
159 } else { 153 } else {
@@ -193,6 +187,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -193,6 +187,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
193 "orderGoodIds": orderGoodIds, 187 "orderGoodIds": orderGoodIds,
194 "companyId": dividendsEstimates[0].Company.CompanyId, 188 "companyId": dividendsEstimates[0].Company.CompanyId,
195 "orgId": dividendsEstimates[0].Org.OrgId, 189 "orgId": dividendsEstimates[0].Org.OrgId,
  190 + "offsetLimit": false,
196 }); err != nil { 191 }); err != nil {
197 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 192 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
198 } else { 193 } else {
@@ -216,6 +211,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -216,6 +211,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
216 "companyId": dividendsEstimates[0].Company.CompanyId, 211 "companyId": dividendsEstimates[0].Company.CompanyId,
217 "orgId": dividendsEstimates[0].Org.OrgId, 212 "orgId": dividendsEstimates[0].Org.OrgId,
218 "dividendsReturnedOrderNumbers": returnedOrderNums, 213 "dividendsReturnedOrderNumbers": returnedOrderNums,
  214 + "offsetLimit": false,
219 }); err5 != nil { 215 }); err5 != nil {
220 return nil, err5 216 return nil, err5
221 } else { 217 } else {
@@ -256,6 +252,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -256,6 +252,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
256 "orderGoodIds": orderGoodIds, 252 "orderGoodIds": orderGoodIds,
257 "companyId": dividendsEstimates[0].Company.CompanyId, 253 "companyId": dividendsEstimates[0].Company.CompanyId,
258 "orgId": dividendsEstimates[0].Org.OrgId, 254 "orgId": dividendsEstimates[0].Org.OrgId,
  255 + "offsetLimit": false,
259 }); err != nil { 256 }); err != nil {
260 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 257 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
261 } else { 258 } else {
@@ -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