|
@@ -9,7 +9,6 @@ import ( |
|
@@ -9,7 +9,6 @@ import ( |
9
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
10
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
10
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
11
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
11
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
12
|
- "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
|
|
13
|
)
|
12
|
)
|
14
|
|
13
|
|
15
|
// 素币服务
|
14
|
// 素币服务
|
|
@@ -31,6 +30,7 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * |
|
@@ -31,6 +30,7 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * |
31
|
defer func() {
|
30
|
defer func() {
|
32
|
transactionContext.RollbackTransaction()
|
31
|
transactionContext.RollbackTransaction()
|
33
|
}()
|
32
|
}()
|
|
|
33
|
+
|
34
|
var operationSuMoneyService service.OperationSuMoneyService
|
34
|
var operationSuMoneyService service.OperationSuMoneyService
|
35
|
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
|
35
|
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
|
36
|
"transactionContext": transactionContext,
|
36
|
"transactionContext": transactionContext,
|
|
@@ -39,6 +39,7 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * |
|
@@ -39,6 +39,7 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * |
39
|
} else {
|
39
|
} else {
|
40
|
operationSuMoneyService = value
|
40
|
operationSuMoneyService = value
|
41
|
}
|
41
|
}
|
|
|
42
|
+
|
42
|
if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil {
|
43
|
if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil {
|
43
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
44
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
44
|
} else {
|
45
|
} else {
|
|
@@ -64,6 +65,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran |
|
@@ -64,6 +65,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran |
64
|
defer func() {
|
65
|
defer func() {
|
65
|
transactionContext.RollbackTransaction()
|
66
|
transactionContext.RollbackTransaction()
|
66
|
}()
|
67
|
}()
|
|
|
68
|
+
|
67
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
69
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
68
|
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
|
70
|
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
|
69
|
"transactionContext": transactionContext,
|
71
|
"transactionContext": transactionContext,
|
|
@@ -72,6 +74,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran |
|
@@ -72,6 +74,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran |
72
|
} else {
|
74
|
} else {
|
73
|
suMoneyTransactionRecordRepository = value
|
75
|
suMoneyTransactionRecordRepository = value
|
74
|
}
|
76
|
}
|
|
|
77
|
+
|
75
|
if suMoneyTransactionRecord, err := suMoneyTransactionRecordRepository.FindOne(map[string]interface{}{"suMoneyTransactionRecordId": getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId}); err != nil {
|
78
|
if suMoneyTransactionRecord, err := suMoneyTransactionRecordRepository.FindOne(map[string]interface{}{"suMoneyTransactionRecordId": getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId}); err != nil {
|
76
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
79
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
77
|
} else {
|
80
|
} else {
|
|
@@ -97,6 +100,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co |
|
@@ -97,6 +100,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co |
97
|
defer func() {
|
100
|
defer func() {
|
98
|
transactionContext.RollbackTransaction()
|
101
|
transactionContext.RollbackTransaction()
|
99
|
}()
|
102
|
}()
|
|
|
103
|
+
|
100
|
var exchangeSuMoneyService service.ExchangeSuMoneyService
|
104
|
var exchangeSuMoneyService service.ExchangeSuMoneyService
|
101
|
if value, err := factory.CreateExchangeSuMoneyService(map[string]interface{}{
|
105
|
if value, err := factory.CreateExchangeSuMoneyService(map[string]interface{}{
|
102
|
"transactionContext": transactionContext,
|
106
|
"transactionContext": transactionContext,
|
|
@@ -105,6 +109,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co |
|
@@ -105,6 +109,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co |
105
|
} else {
|
109
|
} else {
|
106
|
exchangeSuMoneyService = value
|
110
|
exchangeSuMoneyService = value
|
107
|
}
|
111
|
}
|
|
|
112
|
+
|
108
|
if task, err := exchangeSuMoneyService.Exchange(exchangeSuMoneyCommand.Uid, exchangeSuMoneyCommand.Operator, exchangeSuMoneyCommand.SuMoney, exchangeSuMoneyCommand.ExchangeDescription); err != nil {
|
113
|
if task, err := exchangeSuMoneyService.Exchange(exchangeSuMoneyCommand.Uid, exchangeSuMoneyCommand.Operator, exchangeSuMoneyCommand.SuMoney, exchangeSuMoneyCommand.ExchangeDescription); err != nil {
|
109
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
114
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
110
|
} else {
|
115
|
} else {
|
|
@@ -131,6 +136,7 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon |
|
@@ -131,6 +136,7 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon |
131
|
transactionContext.RollbackTransaction()
|
136
|
transactionContext.RollbackTransaction()
|
132
|
}()
|
137
|
}()
|
133
|
|
138
|
|
|
|
139
|
+ // 素币事务记录仓储初始化
|
134
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
140
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
135
|
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
|
141
|
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
|
136
|
"transactionContext": transactionContext,
|
142
|
"transactionContext": transactionContext,
|
|
@@ -140,43 +146,43 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon |
|
@@ -140,43 +146,43 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon |
140
|
suMoneyTransactionRecordRepository = value
|
146
|
suMoneyTransactionRecordRepository = value
|
141
|
}
|
147
|
}
|
142
|
|
148
|
|
|
|
149
|
+ // 获取素币兑换事务记录
|
143
|
if count, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.Find(tool_funs.SimpleStructToMap(searchSuMoneyTransactionRecordCommand)); err != nil {
|
150
|
if count, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.Find(tool_funs.SimpleStructToMap(searchSuMoneyTransactionRecordCommand)); err != nil {
|
144
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
151
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
145
|
} else {
|
152
|
} else {
|
146
|
if err := transactionContext.CommitTransaction(); err != nil {
|
153
|
if err := transactionContext.CommitTransaction(); err != nil {
|
147
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
154
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
148
|
}
|
155
|
}
|
149
|
-
|
|
|
150
|
- for _, suMoneyTransactionRecord := range suMoneyTransactionRecords {
|
|
|
151
|
- contributions := []int{2,3,4}
|
|
|
152
|
- suMoney := []int{1,2,3,4,5}
|
|
|
153
|
- // 查询贡献值时规范描述
|
|
|
154
|
- if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, contributions) {
|
|
|
155
|
- switch suMoneyTransactionRecord.RecordType {
|
|
|
156
|
- case 2: // 任务奖励
|
|
|
157
|
- suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
158
|
- case 3: // 增加
|
|
|
159
|
- suMoneyTransactionRecord.RecordDescription = "增加贡献"
|
|
|
160
|
- case 4: // 扣除
|
|
|
161
|
- suMoneyTransactionRecord.RecordDescription = "扣除贡献"
|
|
|
162
|
- }
|
|
|
163
|
- }
|
|
|
164
|
- // 查询素币值时规范描述
|
|
|
165
|
- if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, suMoney) {
|
|
|
166
|
- switch suMoneyTransactionRecord.RecordType {
|
|
|
167
|
- case 1: // 兑换物资
|
|
|
168
|
- suMoneyTransactionRecord.RecordDescription = "兑换物资"
|
|
|
169
|
- case 2: // 任务奖励
|
|
|
170
|
- suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
171
|
- case 3: // 增加
|
|
|
172
|
- suMoneyTransactionRecord.RecordDescription = "增加素币"
|
|
|
173
|
- case 4: // 扣除
|
|
|
174
|
- suMoneyTransactionRecord.RecordDescription = "扣除素币"
|
|
|
175
|
- case 5: // 兑换现金
|
|
|
176
|
- suMoneyTransactionRecord.RecordDescription = "素币兑换现金"
|
|
|
177
|
- }
|
|
|
178
|
- }
|
|
|
179
|
- }
|
156
|
+ //for _, suMoneyTransactionRecord := range suMoneyTransactionRecords {
|
|
|
157
|
+ // contributions := []int{2,3,4}
|
|
|
158
|
+ // suMoney := []int{1,2,3,4,5}
|
|
|
159
|
+ // // 查询贡献值时规范描述
|
|
|
160
|
+ // if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, contributions) {
|
|
|
161
|
+ // switch suMoneyTransactionRecord.RecordType {
|
|
|
162
|
+ // case 2: // 任务奖励
|
|
|
163
|
+ // suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
164
|
+ // case 3: // 增加
|
|
|
165
|
+ // suMoneyTransactionRecord.RecordDescription = "增加贡献"
|
|
|
166
|
+ // case 4: // 扣除
|
|
|
167
|
+ // suMoneyTransactionRecord.RecordDescription = "扣除贡献"
|
|
|
168
|
+ // }
|
|
|
169
|
+ // }
|
|
|
170
|
+ // // 查询素币值时规范描述
|
|
|
171
|
+ // if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, suMoney) {
|
|
|
172
|
+ // switch suMoneyTransactionRecord.RecordType {
|
|
|
173
|
+ // case 1: // 兑换物资
|
|
|
174
|
+ // suMoneyTransactionRecord.RecordDescription = "兑换物资"
|
|
|
175
|
+ // case 2: // 任务奖励
|
|
|
176
|
+ // suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
177
|
+ // case 3: // 增加
|
|
|
178
|
+ // suMoneyTransactionRecord.RecordDescription = "增加素币"
|
|
|
179
|
+ // case 4: // 扣除
|
|
|
180
|
+ // suMoneyTransactionRecord.RecordDescription = "扣除素币"
|
|
|
181
|
+ // case 5: // 兑换现金
|
|
|
182
|
+ // suMoneyTransactionRecord.RecordDescription = "素币兑换现金"
|
|
|
183
|
+ // }
|
|
|
184
|
+ // }
|
|
|
185
|
+ //}
|
180
|
return map[string]interface{}{
|
186
|
return map[string]interface{}{
|
181
|
"count": count,
|
187
|
"count": count,
|
182
|
"suMoneyTransactionRecords": suMoneyTransactionRecords,
|
188
|
"suMoneyTransactionRecords": suMoneyTransactionRecords,
|
|
@@ -200,6 +206,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney |
|
@@ -200,6 +206,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney |
200
|
transactionContext.RollbackTransaction()
|
206
|
transactionContext.RollbackTransaction()
|
201
|
}()
|
207
|
}()
|
202
|
|
208
|
|
|
|
209
|
+ // 员工DAO初始化
|
203
|
var employeeDao *dao.EmployeeDao
|
210
|
var employeeDao *dao.EmployeeDao
|
204
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
211
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
205
|
"transactionContext": transactionContext,
|
212
|
"transactionContext": transactionContext,
|
|
@@ -254,7 +261,47 @@ func (suMoneyService *SuMoneyService) ContributionsTransactionRecordStatistics(c |
|
@@ -254,7 +261,47 @@ func (suMoneyService *SuMoneyService) ContributionsTransactionRecordStatistics(c |
254
|
}
|
261
|
}
|
255
|
}
|
262
|
}
|
256
|
|
263
|
|
257
|
-// 根据id获取事务记录
|
264
|
+// 根据uid获取员工素币(导出素币流水)
|
|
|
265
|
+func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *command.ExportSuMoneyCommand) ([]*domain.Employee, error) {
|
|
|
266
|
+ if err := exportSuMoneyCommand.ValidateCommand(); err != nil {
|
|
|
267
|
+ return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
268
|
+ }
|
|
|
269
|
+ transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
270
|
+ if err != nil {
|
|
|
271
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
272
|
+ }
|
|
|
273
|
+ if err := transactionContext.StartTransaction(); err != nil {
|
|
|
274
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
275
|
+ }
|
|
|
276
|
+ defer func() {
|
|
|
277
|
+ transactionContext.RollbackTransaction()
|
|
|
278
|
+ }()
|
|
|
279
|
+
|
|
|
280
|
+ if len(exportSuMoneyCommand.IDs) == 0 {
|
|
|
281
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
|
|
|
282
|
+ }
|
|
|
283
|
+
|
|
|
284
|
+ // 员工仓储初始化
|
|
|
285
|
+ var employeeRepository domain.EmployeeRepository
|
|
|
286
|
+ if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
|
|
|
287
|
+ "transactionContext": transactionContext,
|
|
|
288
|
+ }); err != nil {
|
|
|
289
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
290
|
+ } else {
|
|
|
291
|
+ employeeRepository = value
|
|
|
292
|
+ }
|
|
|
293
|
+
|
|
|
294
|
+ if _, employees, err := employeeRepository.Find(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil {
|
|
|
295
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
296
|
+ } else {
|
|
|
297
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
298
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
299
|
+ }
|
|
|
300
|
+ return employees, nil
|
|
|
301
|
+ }
|
|
|
302
|
+}
|
|
|
303
|
+
|
|
|
304
|
+// 根据id获取事务记录(导出素币流水记录)
|
258
|
func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuMoneyTransactionRecordCommand *command.ExportTransactionRecordCommand) ([]*domain.SuMoneyTransactionRecord, error) {
|
305
|
func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuMoneyTransactionRecordCommand *command.ExportTransactionRecordCommand) ([]*domain.SuMoneyTransactionRecord, error) {
|
259
|
if err := exportSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil {
|
306
|
if err := exportSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil {
|
260
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
307
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|