|
@@ -147,12 +147,14 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
@@ -147,12 +147,14 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
147
|
// 预算明细
|
147
|
// 预算明细
|
|
148
|
var creditAccounts []*domain.CreditAccount
|
148
|
var creditAccounts []*domain.CreditAccount
|
|
149
|
var accountDetail []*domain.AccountDetail
|
149
|
var accountDetail []*domain.AccountDetail
|
|
|
|
150
|
+ var settlementAmount float64
|
|
150
|
for _, dividendsEstimate := range dividendsEstimates {
|
151
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
151
|
accountDetail = append(accountDetail, &domain.AccountDetail{
|
152
|
accountDetail = append(accountDetail, &domain.AccountDetail{
|
|
152
|
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
|
153
|
DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
|
|
153
|
DividendsType: dividendsEstimate.DividendsType,
|
154
|
DividendsType: dividendsEstimate.DividendsType,
|
|
154
|
DividendsAmount: dividendsEstimate.DividendsAmount,
|
155
|
DividendsAmount: dividendsEstimate.DividendsAmount,
|
|
155
|
})
|
156
|
})
|
|
|
|
157
|
+ settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount
|
|
156
|
}
|
158
|
}
|
|
157
|
|
159
|
|
|
158
|
// 生成账期结算单号
|
160
|
// 生成账期结算单号
|
|
@@ -167,7 +169,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
@@ -167,7 +169,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
167
|
CreditAccountOrderNum: creditAccountNumber,
|
169
|
CreditAccountOrderNum: creditAccountNumber,
|
|
168
|
PaymentStatus: 1,
|
170
|
PaymentStatus: 1,
|
|
169
|
PaymentTime: time.Time{},
|
171
|
PaymentTime: time.Time{},
|
|
170
|
- SettlementAmount: dividendsEstimates[0].DividendsAmount,
|
172
|
+ SettlementAmount: settlementAmount,
|
|
171
|
SettlementTime: time.Now(),
|
173
|
SettlementTime: time.Now(),
|
|
172
|
Participator: &domain.Participator{ // 共创参与
|
174
|
Participator: &domain.Participator{ // 共创参与
|
|
173
|
UserId: dividendsEstimates[0].DividendsUser.UserId,
|
175
|
UserId: dividendsEstimates[0].DividendsUser.UserId,
|
|
@@ -183,7 +185,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
@@ -183,7 +185,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
183
|
Status: dividendsEstimates[0].DividendsUser.Status,
|
185
|
Status: dividendsEstimates[0].DividendsUser.Status,
|
|
184
|
Company: dividendsEstimates[0].DividendsUser.Company,
|
186
|
Company: dividendsEstimates[0].DividendsUser.Company,
|
|
185
|
},
|
187
|
},
|
|
186
|
- AccountDetail: accountDetail,
|
188
|
+ AccountDetail: accountDetail, // 结算明细,多笔分红预算单
|
|
187
|
PaymentDocumentAttachment: nil,
|
189
|
PaymentDocumentAttachment: nil,
|
|
188
|
Org: organization,
|
190
|
Org: organization,
|
|
189
|
Company: company,
|
191
|
Company: company,
|
|
@@ -318,8 +320,11 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
@@ -318,8 +320,11 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
318
|
defer func() {
|
320
|
defer func() {
|
|
319
|
_ = transactionContext.RollbackTransaction()
|
321
|
_ = transactionContext.RollbackTransaction()
|
|
320
|
}()
|
322
|
}()
|
|
|
|
323
|
+
|
|
321
|
// 参数类型转换
|
324
|
// 参数类型转换
|
|
322
|
creditAccountId, _ := strconv.ParseInt(payCreditAccountCommand.CreditAccountId, 10, 64)
|
325
|
creditAccountId, _ := strconv.ParseInt(payCreditAccountCommand.CreditAccountId, 10, 64)
|
|
|
|
326
|
+
|
|
|
|
327
|
+ // 账期结算仓储初始化
|
|
323
|
var creditAccountRepository domain.CreditAccountRepository
|
328
|
var creditAccountRepository domain.CreditAccountRepository
|
|
324
|
if value, err1 := factory.CreateCreditAccountRepository(map[string]interface{}{
|
329
|
if value, err1 := factory.CreateCreditAccountRepository(map[string]interface{}{
|
|
325
|
"transactionContext": transactionContext,
|
330
|
"transactionContext": transactionContext,
|
|
@@ -328,6 +333,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
@@ -328,6 +333,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
328
|
} else {
|
333
|
} else {
|
|
329
|
creditAccountRepository = value
|
334
|
creditAccountRepository = value
|
|
330
|
}
|
335
|
}
|
|
|
|
336
|
+
|
|
331
|
// 获取待支付的账期结算单
|
337
|
// 获取待支付的账期结算单
|
|
332
|
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": creditAccountId})
|
338
|
creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": creditAccountId})
|
|
333
|
if err != nil {
|
339
|
if err != nil {
|
|
@@ -339,8 +345,11 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
@@ -339,8 +345,11 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
339
|
if err2 := creditAccount.Update(tool_funs.SimpleStructToMap(payCreditAccountCommand)); err2 != nil {
|
345
|
if err2 := creditAccount.Update(tool_funs.SimpleStructToMap(payCreditAccountCommand)); err2 != nil {
|
|
340
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err2.Error())
|
346
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err2.Error())
|
|
341
|
}
|
347
|
}
|
|
342
|
- // 支付状态设置
|
348
|
+
|
|
|
|
349
|
+ // 支付更新设置
|
|
343
|
creditAccount.PaymentStatus = 2
|
350
|
creditAccount.PaymentStatus = 2
|
|
|
|
351
|
+ creditAccount.PaymentTime = time.Now()
|
|
|
|
352
|
+
|
|
344
|
if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil {
|
353
|
if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil {
|
|
345
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
354
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
|
346
|
} else {
|
355
|
} else {
|