...
|
...
|
@@ -147,12 +147,14 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
|
// 预算明细
|
|
|
var creditAccounts []*domain.CreditAccount
|
|
|
var accountDetail []*domain.AccountDetail
|
|
|
var settlementAmount float64
|
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
accountDetail = append(accountDetail, &domain.AccountDetail{
|
|
|
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
|
|
|
DividendsType: dividendsEstimate.DividendsType,
|
|
|
DividendsAmount: dividendsEstimate.DividendsAmount,
|
|
|
})
|
|
|
settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount
|
|
|
}
|
|
|
|
|
|
// 生成账期结算单号
|
...
|
...
|
@@ -167,7 +169,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
|
CreditAccountOrderNum: creditAccountNumber,
|
|
|
PaymentStatus: 1,
|
|
|
PaymentTime: time.Time{},
|
|
|
SettlementAmount: dividendsEstimates[0].DividendsAmount,
|
|
|
SettlementAmount: settlementAmount,
|
|
|
SettlementTime: time.Now(),
|
|
|
Participator: &domain.Participator{ // 共创参与
|
|
|
UserId: dividendsEstimates[0].DividendsUser.UserId,
|
...
|
...
|
@@ -183,7 +185,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
|
Status: dividendsEstimates[0].DividendsUser.Status,
|
|
|
Company: dividendsEstimates[0].DividendsUser.Company,
|
|
|
},
|
|
|
AccountDetail: accountDetail,
|
|
|
AccountDetail: accountDetail, // 结算明细,多笔分红预算单
|
|
|
PaymentDocumentAttachment: nil,
|
|
|
Org: organization,
|
|
|
Company: company,
|
...
|
...
|
@@ -318,8 +320,11 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 参数类型转换
|
|
|
creditAccountId, _ := strconv.ParseInt(payCreditAccountCommand.CreditAccountId, 10, 64)
|
|
|
|
|
|
// 账期结算仓储初始化
|
|
|
var creditAccountRepository domain.CreditAccountRepository
|
|
|
if value, err1 := factory.CreateCreditAccountRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -328,6 +333,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
|
} else {
|
|
|
creditAccountRepository = value
|
|
|
}
|
|
|
|
|
|
// 获取待支付的账期结算单
|
|
|
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": creditAccountId})
|
|
|
if err != nil {
|
...
|
...
|
@@ -339,8 +345,11 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
|
if err2 := creditAccount.Update(tool_funs.SimpleStructToMap(payCreditAccountCommand)); err2 != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err2.Error())
|
|
|
}
|
|
|
// 支付状态设置
|
|
|
|
|
|
// 支付更新设置
|
|
|
creditAccount.PaymentStatus = 2
|
|
|
creditAccount.PaymentTime = time.Now()
|
|
|
|
|
|
if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
|
|
} else {
|
...
|
...
|
|