...
|
...
|
@@ -1125,6 +1125,7 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD |
|
|
|
|
|
// BatchRemoveDividendsOrder 批量移除分红订单实体对象
|
|
|
func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(batchRemoveDividendsOrderCommand *command.BatchRemoveDividendsOrderCommand) (interface{}, error) {
|
|
|
start := time.Now()
|
|
|
if err := batchRemoveDividendsOrderCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -1169,19 +1170,42 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
|
dividendsEstimateRepository = value
|
|
|
}
|
|
|
|
|
|
// 分红预算单DAO初始化
|
|
|
//var dividendsEstimateDao *dao.DividendsEstimateDao
|
|
|
//if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
//}); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
//} else {
|
|
|
// dividendsEstimateDao = value
|
|
|
//}
|
|
|
|
|
|
// 分红退货单DAO初始化
|
|
|
//var dividendsReturnedOrderDao *dao.DividendsReturnedOrderDao
|
|
|
//if value, err := factory.CreateDividendsReturnedOrderDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
//}); err != nil {
|
|
|
// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
//} else {
|
|
|
// dividendsReturnedOrderDao = value
|
|
|
//}
|
|
|
|
|
|
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
|
|
|
}
|
|
|
|
|
|
if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{
|
|
|
"dividendsOrderIds": dividendsOrderIds,
|
|
|
"offsetLimit": false,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
fmt.Println("截止目前耗时1:", time.Since(start))
|
|
|
if count > 0 {
|
|
|
// 校验分红订单是否有退货单关联
|
|
|
for _, dividendsOrder := range dividendsOrders {
|
|
|
// 校验分红订单是否有关联的退货单
|
|
|
startCount := time.Now()
|
|
|
if countReturnedOrder, _, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
|
|
|
"dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
|
|
|
"companyId": dividendsOrder.Company.CompanyId,
|
...
|
...
|
@@ -1194,13 +1218,29 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber))
|
|
|
}
|
|
|
}
|
|
|
fmt.Println("退货单计数:", time.Since(startCount))
|
|
|
|
|
|
//startCount := time.Now()
|
|
|
//if returnedOrderExist, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderExist(map[string]interface{}{
|
|
|
// "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
|
|
|
// "companyId": dividendsOrder.Company.CompanyId,
|
|
|
//}); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
//} else {
|
|
|
// if returnedOrderExist {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsOrder.DividendsOrderNumber))
|
|
|
// }
|
|
|
//}
|
|
|
//fmt.Println("退货单计数:", time.Since(startCount))
|
|
|
|
|
|
// 校验分红订单是否有分红预算
|
|
|
startEstimateCount := time.Now()
|
|
|
if countRelative, _, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsOrder.Company.CompanyId,
|
|
|
"orgId": dividendsOrder.Org.OrgId,
|
|
|
"orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,
|
|
|
"offsetLimit": false,
|
|
|
"limit": 1,
|
|
|
"offset": 0,
|
|
|
"isCanceled": false,
|
|
|
}); err2 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
|
...
|
...
|
@@ -1209,15 +1249,34 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
|
|
|
}
|
|
|
}
|
|
|
fmt.Println("预算单计数:", time.Since(startEstimateCount))
|
|
|
|
|
|
//startEstimateCount := time.Now()
|
|
|
//if estimateOrderExist, err3 := dividendsEstimateDao.CheckDividendsEstimateOrderExist(map[string]interface{}{
|
|
|
// "companyId": dividendsOrder.Company.CompanyId,
|
|
|
// "orgId": dividendsOrder.Org.OrgId,
|
|
|
// "orderOrReturnedOrderNum": dividendsOrder.DividendsOrderNumber,
|
|
|
// "isCanceled": false,
|
|
|
//}); err3 != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
|
|
|
//} else {
|
|
|
// if estimateOrderExist {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的预算单,不可删除", dividendsOrder.DividendsOrderNumber))
|
|
|
// }
|
|
|
//}
|
|
|
//fmt.Println("预算单计数:", time.Since(startEstimateCount))
|
|
|
}
|
|
|
fmt.Println("截止目前耗时2:", time.Since(start))
|
|
|
|
|
|
dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
fmt.Println("截止目前耗时3:", time.Since(start))
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
fmt.Println("截止目前耗时4:", time.Since(start))
|
|
|
return dividendsOrdersRemoved, nil
|
|
|
} else {
|
|
|
return map[string]interface{}{}, nil
|
...
|
...
|
|