...
|
...
|
@@ -57,7 +57,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司id")
|
|
|
}
|
|
|
|
|
|
// 获取平台素币兑换情况
|
|
|
var employeeDao *dao.EmployeeDao
|
|
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -66,7 +65,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
} else {
|
|
|
employeeDao = value
|
|
|
}
|
|
|
|
|
|
// 获取平台素币兑换情况
|
|
|
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -93,7 +92,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 新建现金池
|
|
|
newCashPool := &domain.CashPool{
|
|
|
CompanyId: createCashPoolCommand.CompanyId,
|
|
|
Cash: createCashPoolCommand.Cash,
|
...
|
...
|
@@ -998,6 +996,11 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 返回素币兑换现金活动总清单
|
|
|
//func (cashPoolService *CashPoolService) ListSystemExchangeCashPerson(listSystemExchangeCashPersonQuery *query.ListSystemExchangeCashPersonQuery) (interface{}, error) {
|
|
|
//
|
|
|
//}
|
|
|
|
|
|
// 返回兑换素币清单列表
|
|
|
func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) {
|
|
|
if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil {
|
...
|
...
|
@@ -1023,7 +1026,46 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
|
|
exchangeCashPersonListRepository = value
|
|
|
}
|
|
|
|
|
|
// TODO 增加总榜单查询
|
|
|
// 返回兑换现金活动总榜
|
|
|
if listExchangeCashPersonQuery.ExchangeCashActivityId == 0 && listExchangeCashPersonQuery.CompanyId != 0 {
|
|
|
// 找到该公司下的所有活动id
|
|
|
var exchangeActivityRepository domain.ExchangeActivityRepository
|
|
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
exchangeActivityRepository = value
|
|
|
}
|
|
|
|
|
|
if _, activities, err := exchangeActivityRepository.FindAll(map[string]interface{}{
|
|
|
"companyId": listExchangeCashPersonQuery.CompanyId,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
var activityIds []int64
|
|
|
for _, activity := range activities {
|
|
|
activityIds = append(activityIds, activity.ActivityId)
|
|
|
}
|
|
|
|
|
|
if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{
|
|
|
"exchangeCashActivityIds": activityIds,
|
|
|
"offset": listExchangeCashPersonQuery.Offset,
|
|
|
"limit": listExchangeCashPersonQuery.Limit,
|
|
|
}); 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 map[string]interface{}{
|
|
|
"count": count,
|
|
|
"people": people,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if count, people, err := exchangeCashPersonListRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashPersonQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -1462,6 +1504,45 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 根据id获取兑换清单
|
|
|
func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchangeCashListCommand *command.ExportExchangeCashListCommand) ([]*domain.ExchangeCashPersonList, error) {
|
|
|
if err := exportExchangeCashListCommand.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()
|
|
|
}()
|
|
|
|
|
|
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
|
|
|
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
exchangeCashPersonListRepository = value
|
|
|
}
|
|
|
|
|
|
if _, people, err := exchangeCashPersonListRepository.FindById(tool_funs.SimpleStructToMap(exportExchangeCashListCommand)); 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 map[string]interface{}{
|
|
|
// "count": count,
|
|
|
// "people": people,
|
|
|
//}, nil
|
|
|
return people, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func NewCashPoolService(options map[string]interface{}) *CashPoolService {
|
|
|
newCashPoolService := &CashPoolService{}
|
|
|
return newCashPoolService
|
...
|
...
|
|