|
@@ -9,6 +9,8 @@ import ( |
|
@@ -9,6 +9,8 @@ import ( |
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
|
|
12
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
|
|
13
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
12
|
"strconv"
|
14
|
"strconv"
|
13
|
"time"
|
15
|
"time"
|
14
|
)
|
16
|
)
|
|
@@ -17,7 +19,7 @@ import ( |
|
@@ -17,7 +19,7 @@ import ( |
17
|
type CreditAccountService struct {
|
19
|
type CreditAccountService struct {
|
18
|
}
|
20
|
}
|
19
|
|
21
|
|
20
|
-// CreateCreditAccount 创建账期结算单服务
|
22
|
+// CreateCreditAccount 创建账期结算单服务(账期结算)
|
21
|
func (creditAccountService *CreditAccountService) CreateCreditAccount(createCreditAccountCommand *command.CreateCreditAccountCommand) (interface{}, error) {
|
23
|
func (creditAccountService *CreditAccountService) CreateCreditAccount(createCreditAccountCommand *command.CreateCreditAccountCommand) (interface{}, error) {
|
22
|
if err := createCreditAccountCommand.ValidateCommand(); err != nil {
|
24
|
if err := createCreditAccountCommand.ValidateCommand(); err != nil {
|
23
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
25
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -81,25 +83,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
@@ -81,25 +83,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
81
|
operator = data
|
83
|
operator = data
|
82
|
}
|
84
|
}
|
83
|
|
85
|
|
84
|
- newCreditAccount := &domain.CreditAccount{
|
|
|
85
|
- ActuallyPaidAmount: 0,
|
|
|
86
|
- CreditAccountOrderNum: "",
|
|
|
87
|
- PaymentStatus: 0,
|
|
|
88
|
- PaymentTime: time.Time{},
|
|
|
89
|
- SettlementAmount: 0,
|
|
|
90
|
- SettlementTime: time.Time{},
|
|
|
91
|
- CooperationContractNumber: "",
|
|
|
92
|
- Participator: nil,
|
|
|
93
|
- PaymentDocumentAttachment: nil,
|
|
|
94
|
- Org: organization,
|
|
|
95
|
- Company: company,
|
|
|
96
|
- Operator: operator,
|
|
|
97
|
- OperateTime: time.Now(),
|
|
|
98
|
- CreatedAt: time.Now(),
|
|
|
99
|
- DeletedAt: time.Time{},
|
|
|
100
|
- UpdatedAt: time.Time{},
|
|
|
101
|
- }
|
|
|
102
|
-
|
86
|
+ // 账期结算单仓储初始化
|
103
|
var creditAccountRepository domain.CreditAccountRepository
|
87
|
var creditAccountRepository domain.CreditAccountRepository
|
104
|
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
|
88
|
if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
|
105
|
"transactionContext": transactionContext,
|
89
|
"transactionContext": transactionContext,
|
|
@@ -108,13 +92,82 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
|
@@ -108,13 +92,82 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred |
108
|
} else {
|
92
|
} else {
|
109
|
creditAccountRepository = value
|
93
|
creditAccountRepository = value
|
110
|
}
|
94
|
}
|
111
|
- if creditAccount, err := creditAccountRepository.Save(newCreditAccount); err != nil {
|
95
|
+
|
|
|
96
|
+ // 账期结算单DAO初始化
|
|
|
97
|
+ var creditAccountDao *dao.CreditAccountDao
|
|
|
98
|
+ if value, err := factory.CreateCreditAccountDao(map[string]interface{}{
|
|
|
99
|
+ "transactionContext": transactionContext,
|
|
|
100
|
+ }); err != nil {
|
|
|
101
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
102
|
+ } else {
|
|
|
103
|
+ creditAccountDao = value
|
|
|
104
|
+ }
|
|
|
105
|
+
|
|
|
106
|
+ // 分红预算单仓储初始化
|
|
|
107
|
+ var dividendsEstimateRepository domain.DividendsEstimateRepository
|
|
|
108
|
+ if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
|
|
|
109
|
+ "transactionContext": transactionContext,
|
|
|
110
|
+ }); err != nil {
|
|
|
111
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
112
|
+ } else {
|
|
|
113
|
+ dividendsEstimateRepository = value
|
|
|
114
|
+ }
|
|
|
115
|
+ dividendsEstimateIds, _ := utils.SliceAtoi(createCreditAccountCommand.DividendsEstimateIds)
|
|
|
116
|
+ // 获取所选分红预算单
|
|
|
117
|
+ if _, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
118
|
+ "dividendsEstimateIds": dividendsEstimateIds,
|
|
|
119
|
+ }); err != nil {
|
112
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
120
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
113
|
} else {
|
121
|
} else {
|
|
|
122
|
+ var creditAccounts []*domain.CreditAccount
|
|
|
123
|
+ for _, dividendsEstimate := range dividendsEstimates {
|
|
|
124
|
+ // 生成账期结算单号
|
|
|
125
|
+ creditAccountNumber, err := creditAccountDao.GenerateCreditAccountNumber()
|
|
|
126
|
+ if err != nil {
|
|
|
127
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
128
|
+ }
|
|
|
129
|
+ // 生成账期结算单
|
|
|
130
|
+ newCreditAccount := &domain.CreditAccount{
|
|
|
131
|
+ ActuallyPaidAmount: 0,
|
|
|
132
|
+ CreditAccountOrderNum: creditAccountNumber,
|
|
|
133
|
+ PaymentStatus: 1,
|
|
|
134
|
+ PaymentTime: time.Time{},
|
|
|
135
|
+ SettlementAmount: dividendsEstimate.DividendsAmount,
|
|
|
136
|
+ SettlementTime: time.Now(),
|
|
|
137
|
+ CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
|
|
|
138
|
+ Participator: &domain.Participator{
|
|
|
139
|
+ UserId: dividendsEstimate.DividendsUser.UserId,
|
|
|
140
|
+ UserBaseId: dividendsEstimate.DividendsUser.UserBaseId,
|
|
|
141
|
+ Org: dividendsEstimate.DividendsUser.Org,
|
|
|
142
|
+ Orgs: dividendsEstimate.DividendsUser.Orgs,
|
|
|
143
|
+ Department: dividendsEstimate.DividendsUser.Department,
|
|
|
144
|
+ Roles: dividendsEstimate.DividendsUser.Roles,
|
|
|
145
|
+ UserInfo: dividendsEstimate.DividendsUser.UserInfo,
|
|
|
146
|
+ UserName: dividendsEstimate.DividendsUser.UserName,
|
|
|
147
|
+ UserPhone: dividendsEstimate.DividendsUser.UserPhone,
|
|
|
148
|
+ UserType: dividendsEstimate.DividendsUser.UserType,
|
|
|
149
|
+ Status: dividendsEstimate.DividendsUser.Status,
|
|
|
150
|
+ Company: dividendsEstimate.DividendsUser.Company,
|
|
|
151
|
+ },
|
|
|
152
|
+ PaymentDocumentAttachment: nil,
|
|
|
153
|
+ Org: organization,
|
|
|
154
|
+ Company: company,
|
|
|
155
|
+ Operator: operator,
|
|
|
156
|
+ OperateTime: time.Now(),
|
|
|
157
|
+ CreatedAt: time.Now(),
|
|
|
158
|
+ DeletedAt: time.Time{},
|
|
|
159
|
+ UpdatedAt: time.Time{},
|
|
|
160
|
+ }
|
|
|
161
|
+ if creditAccount, err := creditAccountRepository.Save(newCreditAccount); err != nil {
|
|
|
162
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
163
|
+ } else {
|
|
|
164
|
+ creditAccounts = append(creditAccounts, creditAccount)
|
|
|
165
|
+ }
|
|
|
166
|
+ }
|
114
|
if err := transactionContext.CommitTransaction(); err != nil {
|
167
|
if err := transactionContext.CommitTransaction(); err != nil {
|
115
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
168
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
116
|
}
|
169
|
}
|
117
|
- return creditAccount, nil
|
170
|
+ return creditAccounts, nil
|
118
|
}
|
171
|
}
|
119
|
}
|
172
|
}
|
120
|
|
173
|
|
|
@@ -139,7 +192,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc |
|
@@ -139,7 +192,7 @@ func (creditAccountService *CreditAccountService) CreditAccountRanking(creditAcc |
139
|
return nil, nil
|
192
|
return nil, nil
|
140
|
}
|
193
|
}
|
141
|
|
194
|
|
142
|
-// GetCreditAccount 返回账期结算单服务
|
195
|
+// GetCreditAccount 返回账期结算单详情
|
143
|
func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAccountQuery *query.GetCreditAccountQuery) (interface{}, error) {
|
196
|
func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAccountQuery *query.GetCreditAccountQuery) (interface{}, error) {
|
144
|
if err := getCreditAccountQuery.ValidateQuery(); err != nil {
|
197
|
if err := getCreditAccountQuery.ValidateQuery(); err != nil {
|
145
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
198
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -176,7 +229,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco |
|
@@ -176,7 +229,7 @@ func (creditAccountService *CreditAccountService) GetCreditAccount(getCreditAcco |
176
|
}
|
229
|
}
|
177
|
}
|
230
|
}
|
178
|
|
231
|
|
179
|
-// ListCreditAccount 返回账期结算单服务列表
|
232
|
+// ListCreditAccount 返回账期结算单列表
|
180
|
func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAccountQuery *query.ListCreditAccountQuery) (interface{}, error) {
|
233
|
func (creditAccountService *CreditAccountService) ListCreditAccount(listCreditAccountQuery *query.ListCreditAccountQuery) (interface{}, error) {
|
181
|
if err := listCreditAccountQuery.ValidateQuery(); err != nil {
|
234
|
if err := listCreditAccountQuery.ValidateQuery(); err != nil {
|
182
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
235
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -259,7 +312,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
|
@@ -259,7 +312,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco |
259
|
}
|
312
|
}
|
260
|
}
|
313
|
}
|
261
|
|
314
|
|
262
|
-// RemoveCreditAccount 移除账期结算单服务
|
315
|
+// RemoveCreditAccount 移除账期结算单
|
263
|
func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCreditAccountCommand *command.RemoveCreditAccountCommand) (interface{}, error) {
|
316
|
func (creditAccountService *CreditAccountService) RemoveCreditAccount(removeCreditAccountCommand *command.RemoveCreditAccountCommand) (interface{}, error) {
|
264
|
if err := removeCreditAccountCommand.ValidateCommand(); err != nil {
|
317
|
if err := removeCreditAccountCommand.ValidateCommand(); err != nil {
|
265
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
318
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -337,7 +390,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred |
|
@@ -337,7 +390,7 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred |
337
|
}
|
390
|
}
|
338
|
}
|
391
|
}
|
339
|
|
392
|
|
340
|
-// UpdateCreditAccount 更新账期结算单服务
|
393
|
+// UpdateCreditAccount 更新账期结算单
|
341
|
func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCreditAccountCommand *command.UpdateCreditAccountCommand) (interface{}, error) {
|
394
|
func (creditAccountService *CreditAccountService) UpdateCreditAccount(updateCreditAccountCommand *command.UpdateCreditAccountCommand) (interface{}, error) {
|
342
|
if err := updateCreditAccountCommand.ValidateCommand(); err != nil {
|
395
|
if err := updateCreditAccountCommand.ValidateCommand(); err != nil {
|
343
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
396
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|