...
|
...
|
@@ -9,7 +9,6 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/utils"
|
|
|
)
|
|
|
|
|
|
// 素币服务
|
...
|
...
|
@@ -31,6 +30,7 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var operationSuMoneyService service.OperationSuMoneyService
|
|
|
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -39,6 +39,7 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * |
|
|
} else {
|
|
|
operationSuMoneyService = value
|
|
|
}
|
|
|
|
|
|
if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -64,6 +65,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
|
|
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -72,6 +74,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran |
|
|
} else {
|
|
|
suMoneyTransactionRecordRepository = value
|
|
|
}
|
|
|
|
|
|
if suMoneyTransactionRecord, err := suMoneyTransactionRecordRepository.FindOne(map[string]interface{}{"suMoneyTransactionRecordId": getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -97,6 +100,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var exchangeSuMoneyService service.ExchangeSuMoneyService
|
|
|
if value, err := factory.CreateExchangeSuMoneyService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -105,6 +109,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co |
|
|
} else {
|
|
|
exchangeSuMoneyService = value
|
|
|
}
|
|
|
|
|
|
if task, err := exchangeSuMoneyService.Exchange(exchangeSuMoneyCommand.Uid, exchangeSuMoneyCommand.Operator, exchangeSuMoneyCommand.SuMoney, exchangeSuMoneyCommand.ExchangeDescription); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -131,6 +136,7 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 素币事务记录仓储初始化
|
|
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
|
|
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -140,43 +146,43 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon |
|
|
suMoneyTransactionRecordRepository = value
|
|
|
}
|
|
|
|
|
|
// 获取素币兑换事务记录
|
|
|
if count, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.Find(tool_funs.SimpleStructToMap(searchSuMoneyTransactionRecordCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
for _, suMoneyTransactionRecord := range suMoneyTransactionRecords {
|
|
|
contributions := []int{2,3,4}
|
|
|
suMoney := []int{1,2,3,4,5}
|
|
|
// 查询贡献值时规范描述
|
|
|
if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, contributions) {
|
|
|
switch suMoneyTransactionRecord.RecordType {
|
|
|
case 2: // 任务奖励
|
|
|
suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
case 3: // 增加
|
|
|
suMoneyTransactionRecord.RecordDescription = "增加贡献"
|
|
|
case 4: // 扣除
|
|
|
suMoneyTransactionRecord.RecordDescription = "扣除贡献"
|
|
|
}
|
|
|
}
|
|
|
// 查询素币值时规范描述
|
|
|
if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, suMoney) {
|
|
|
switch suMoneyTransactionRecord.RecordType {
|
|
|
case 1: // 兑换物资
|
|
|
suMoneyTransactionRecord.RecordDescription = "兑换物资"
|
|
|
case 2: // 任务奖励
|
|
|
suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
case 3: // 增加
|
|
|
suMoneyTransactionRecord.RecordDescription = "增加素币"
|
|
|
case 4: // 扣除
|
|
|
suMoneyTransactionRecord.RecordDescription = "扣除素币"
|
|
|
case 5: // 兑换现金
|
|
|
suMoneyTransactionRecord.RecordDescription = "素币兑换现金"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//for _, suMoneyTransactionRecord := range suMoneyTransactionRecords {
|
|
|
// contributions := []int{2,3,4}
|
|
|
// suMoney := []int{1,2,3,4,5}
|
|
|
// // 查询贡献值时规范描述
|
|
|
// if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, contributions) {
|
|
|
// switch suMoneyTransactionRecord.RecordType {
|
|
|
// case 2: // 任务奖励
|
|
|
// suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
// case 3: // 增加
|
|
|
// suMoneyTransactionRecord.RecordDescription = "增加贡献"
|
|
|
// case 4: // 扣除
|
|
|
// suMoneyTransactionRecord.RecordDescription = "扣除贡献"
|
|
|
// }
|
|
|
// }
|
|
|
// // 查询素币值时规范描述
|
|
|
// if utils.StringSliceEqualBCE(searchSuMoneyTransactionRecordCommand.RecordTypes, suMoney) {
|
|
|
// switch suMoneyTransactionRecord.RecordType {
|
|
|
// case 1: // 兑换物资
|
|
|
// suMoneyTransactionRecord.RecordDescription = "兑换物资"
|
|
|
// case 2: // 任务奖励
|
|
|
// suMoneyTransactionRecord.RecordDescription = suMoneyTransactionRecord.RecordDescription + "奖励"
|
|
|
// case 3: // 增加
|
|
|
// suMoneyTransactionRecord.RecordDescription = "增加素币"
|
|
|
// case 4: // 扣除
|
|
|
// suMoneyTransactionRecord.RecordDescription = "扣除素币"
|
|
|
// case 5: // 兑换现金
|
|
|
// suMoneyTransactionRecord.RecordDescription = "素币兑换现金"
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
return map[string]interface{}{
|
|
|
"count": count,
|
|
|
"suMoneyTransactionRecords": suMoneyTransactionRecords,
|
...
|
...
|
@@ -200,6 +206,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 员工DAO初始化
|
|
|
var employeeDao *dao.EmployeeDao
|
|
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -254,7 +261,47 @@ func (suMoneyService *SuMoneyService) ContributionsTransactionRecordStatistics(c |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 根据id获取事务记录
|
|
|
// 根据uid获取员工素币(导出素币流水)
|
|
|
func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *command.ExportSuMoneyCommand) ([]*domain.Employee, error) {
|
|
|
if err := exportSuMoneyCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
}
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
if len(exportSuMoneyCommand.IDs) == 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
|
|
|
}
|
|
|
|
|
|
// 员工仓储初始化
|
|
|
var employeeRepository domain.EmployeeRepository
|
|
|
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
employeeRepository = value
|
|
|
}
|
|
|
|
|
|
if _, employees, err := employeeRepository.Find(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return employees, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 根据id获取事务记录(导出素币流水记录)
|
|
|
func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuMoneyTransactionRecordCommand *command.ExportTransactionRecordCommand) ([]*domain.SuMoneyTransactionRecord, error) {
|
|
|
if err := exportSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
...
|
...
|
|