|
@@ -1001,6 +1001,8 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
@@ -1001,6 +1001,8 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
1001
|
defer func() {
|
1001
|
defer func() {
|
1002
|
_ = transactionContext.RollbackTransaction()
|
1002
|
_ = transactionContext.RollbackTransaction()
|
1003
|
}()
|
1003
|
}()
|
|
|
1004
|
+
|
|
|
1005
|
+ // 分红订单仓储初始化
|
1004
|
var dividendsOrderRepository domain.DividendsOrderRepository
|
1006
|
var dividendsOrderRepository domain.DividendsOrderRepository
|
1005
|
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
|
1007
|
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
|
1006
|
"transactionContext": transactionContext,
|
1008
|
"transactionContext": transactionContext,
|
|
@@ -1010,6 +1012,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
@@ -1010,6 +1012,16 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
1010
|
dividendsOrderRepository = value
|
1012
|
dividendsOrderRepository = value
|
1011
|
}
|
1013
|
}
|
1012
|
|
1014
|
|
|
|
1015
|
+ // 分红退货单仓储初始化
|
|
|
1016
|
+ var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
|
|
|
1017
|
+ if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
|
|
|
1018
|
+ "transactionContext": transactionContext,
|
|
|
1019
|
+ }); err != nil {
|
|
|
1020
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1021
|
+ } else {
|
|
|
1022
|
+ dividendsReturnedOrderRepository = value
|
|
|
1023
|
+ }
|
|
|
1024
|
+
|
1013
|
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
|
1025
|
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
|
1014
|
if err != nil {
|
1026
|
if err != nil {
|
1015
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
|
1027
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
|
|
@@ -1020,6 +1032,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
|
@@ -1020,6 +1032,22 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba |
1020
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1032
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1021
|
} else {
|
1033
|
} else {
|
1022
|
if count > 0 {
|
1034
|
if count > 0 {
|
|
|
1035
|
+ // 校验分红订单是否有退货单关联
|
|
|
1036
|
+ for _, dividendsOrder := range dividendsOrders {
|
|
|
1037
|
+ if countReturnedOrder, dividendsReturnedOrders, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
|
|
|
1038
|
+ "dividendsOrderNumber": dividendsOrder.DividendsOrderNumber,
|
|
|
1039
|
+ "companyId": dividendsOrder.Company.CompanyId,
|
|
|
1040
|
+ "limit": 1,
|
|
|
1041
|
+ "offset": 0,
|
|
|
1042
|
+ }); err != nil {
|
|
|
1043
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1044
|
+ } else {
|
|
|
1045
|
+ if countReturnedOrder > 0 {
|
|
|
1046
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("分红订单%s有关联的退货单,不可删除", dividendsReturnedOrders[0].DividendsOrderNumber))
|
|
|
1047
|
+ }
|
|
|
1048
|
+ }
|
|
|
1049
|
+ }
|
|
|
1050
|
+
|
1023
|
dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
|
1051
|
dividendsOrdersRemoved, err := dividendsOrderRepository.BatchRemove(dividendsOrders)
|
1024
|
if err != nil {
|
1052
|
if err != nil {
|
1025
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1053
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|