作者 陈志颖

refactor:优化批量删除分红订单

@@ -1161,14 +1161,14 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -1161,14 +1161,14 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
1161 } 1161 }
1162 1162
1163 // 分红预算单仓储初始化 1163 // 分红预算单仓储初始化
1164 - var dividendsEstimateRepository domain.DividendsEstimateRepository  
1165 - if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{  
1166 - "transactionContext": transactionContext,  
1167 - }); err != nil {  
1168 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1169 - } else {  
1170 - dividendsEstimateRepository = value  
1171 - } 1164 + //var dividendsEstimateRepository domain.DividendsEstimateRepository
  1165 + //if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
  1166 + // "transactionContext": transactionContext,
  1167 + //}); err != nil {
  1168 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1169 + //} else {
  1170 + // dividendsEstimateRepository = value
  1171 + //}
1172 1172
1173 // 分红预算单DAO初始化 1173 // 分红预算单DAO初始化
1174 //var dividendsEstimateDao *dao.DividendsEstimateDao 1174 //var dividendsEstimateDao *dao.DividendsEstimateDao
@@ -1234,22 +1234,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -1234,22 +1234,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
1234 //fmt.Println("退货单计数:", time.Since(startCount)) 1234 //fmt.Println("退货单计数:", time.Since(startCount))
1235 1235
1236 // 校验分红订单是否有分红预算 1236 // 校验分红订单是否有分红预算
1237 - startEstimateCount := time.Now()  
1238 - if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{  
1239 - "companyId": dividendsOrder.Company.CompanyId,  
1240 - "orgId": dividendsOrder.Org.OrgId,  
1241 - "orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,  
1242 - "limit": 1,  
1243 - "offset": 0,  
1244 - "isCanceled": false,  
1245 - }); err2 != nil {  
1246 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())  
1247 - } else {  
1248 - if countRelative > 0 {  
1249 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))  
1250 - }  
1251 - }  
1252 - fmt.Println("预算单计数:", time.Since(startEstimateCount)) 1237 + //startEstimateCount := time.Now()
  1238 + //if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
  1239 + // "companyId": dividendsOrder.Company.CompanyId,
  1240 + // "orgId": dividendsOrder.Org.OrgId,
  1241 + // "orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,
  1242 + // "limit": 1,
  1243 + // "offset": 0,
  1244 + // "isCanceled": false,
  1245 + //}); err2 != nil {
  1246 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
  1247 + //} else {
  1248 + // if countRelative > 0 {
  1249 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
  1250 + // }
  1251 + //}
  1252 + //fmt.Println("预算单计数:", time.Since(startEstimateCount))
1253 1253
1254 //startEstimateCount := time.Now() 1254 //startEstimateCount := time.Now()
1255 //if estimateOrderExist, err3 := dividendsEstimateDao.CheckDividendsEstimateOrderExist(map[string]interface{}{ 1255 //if estimateOrderExist, err3 := dividendsEstimateDao.CheckDividendsEstimateOrderExist(map[string]interface{}{
@@ -1265,6 +1265,10 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -1265,6 +1265,10 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
1265 // } 1265 // }
1266 //} 1266 //}
1267 //fmt.Println("预算单计数:", time.Since(startEstimateCount)) 1267 //fmt.Println("预算单计数:", time.Since(startEstimateCount))
  1268 +
  1269 + if dividendsOrder.DividendStatus != 1 {
  1270 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
  1271 + }
1268 } 1272 }
1269 fmt.Println("截止目前耗时2:", time.Since(start)) 1273 fmt.Println("截止目前耗时2:", time.Since(start))
1270 1274