...
|
...
|
@@ -150,6 +150,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
|
var goodAmountCount float64
|
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
accountDetail = append(accountDetail, &domain.AccountDetail{
|
|
|
DividendsEstimateOrderId: dividendsEstimate.DividendsEstimateId,
|
|
|
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
|
|
|
DividendsType: dividendsEstimate.DividendsType,
|
|
|
DividendsAmount: dividendsEstimate.DividendsAmount,
|
...
|
...
|
@@ -393,6 +394,7 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
// 账期结算单仓储初始化
|
|
|
var creditAccountRepository domain.CreditAccountRepository
|
|
|
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -401,20 +403,55 @@ func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCred |
|
|
} else {
|
|
|
creditAccountRepository = value
|
|
|
}
|
|
|
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": removeCreditAccountCommand.CreditAccountId})
|
|
|
|
|
|
// 分红预算单仓储初始化
|
|
|
var dividendsEstimateRepository domain.DividendsEstimateRepository
|
|
|
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
dividendsEstimateRepository = value
|
|
|
}
|
|
|
|
|
|
// 获取账期阶段单
|
|
|
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{
|
|
|
"creditAccountId": removeCreditAccountCommand.CreditAccountId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if creditAccount == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCreditAccountCommand.CreditAccountId, 10)))
|
|
|
}
|
|
|
if creditAccount, err := creditAccountRepository.Remove(creditAccount); err != nil {
|
|
|
if creditAccountRemoved, err := creditAccountRepository.Remove(creditAccount); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
// 更新相关分红预算单结算状态
|
|
|
dividendsEstimateIds := make([]int64, 0)
|
|
|
if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"dividendsEstimateIds": dividendsEstimateIds,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if count > 0 {
|
|
|
for i, dividendsEstimate := range dividendsEstimates {
|
|
|
if !dividendsEstimate.IsCanceled {
|
|
|
dividendsEstimates[i].DividendsAccountStatus = int32(1)
|
|
|
}
|
|
|
}
|
|
|
// 保存分红预算单
|
|
|
_, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimates)
|
|
|
if err3 != nil {
|
|
|
return nil, err3
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return creditAccount, nil
|
|
|
return creditAccountRemoved, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|