...
|
...
|
@@ -1001,6 +1001,8 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 分红订单仓储初始化
|
|
|
var dividendsOrderRepository domain.DividendsOrderRepository
|
|
|
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -1010,6 +1012,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
|
dividendsOrderRepository = value
|
|
|
}
|
|
|
|
|
|
// 分红退货单仓储初始化
|
|
|
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
|
|
|
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
dividendsReturnedOrderRepository = value
|
|
|
}
|
|
|
|
|
|
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
|
...
|
...
|
@@ -1020,6 +1032,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if count > 0 {
|
|
|
// 校验分红订单是否有退货单关联
|
|
|
for _, dividendsOrder := range dividendsOrders {
|
|
|
if countReturnedOrder, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
|
|
|
"dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
|
|
|
"companyId": dividendsOrder.Company.CompanyId,
|
|
|
"limit": 1,
|
|
|
"offset": 0,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if countReturnedOrder > 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsReturnedOrders[0].DividendsOrderNumber))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
|