...
|
...
|
@@ -2,10 +2,8 @@ package domain_service |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
coreDomain "github.com/linmadan/egglib-go/core/domain"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
...
|
...
|
@@ -22,7 +20,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 |
|
|
var employeeRepository domain.EmployeeRepository
|
|
|
var taskRepository domain.TaskRepository
|
|
|
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
|
|
|
var cashPoolRepository domain.CashPoolRepository
|
|
|
//var cashPoolRepository domain.CashPoolRepository
|
|
|
|
|
|
var employeeDao *dao.EmployeeDao
|
|
|
if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
|
...
|
...
|
@@ -40,11 +38,11 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 |
|
|
} else {
|
|
|
suMoneyTransactionRecordRepository = repository
|
|
|
}
|
|
|
if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
cashPoolRepository = repository
|
|
|
}
|
|
|
//if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil {
|
|
|
// return nil, err
|
|
|
//} else {
|
|
|
// cashPoolRepository = repository
|
|
|
//}
|
|
|
if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
...
|
...
|
@@ -136,40 +134,40 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 |
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
// 更新现金池未兑换素币
|
|
|
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
|
|
"companyId": task.CompanyId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if cashPoolFound != nil {
|
|
|
// 获取平台素币兑换情况
|
|
|
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if systemSuMoneyStatistics == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
}
|
|
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
|
|
cashPool := &domain.CashPool{
|
|
|
Cash: cashPoolFound.Cash,
|
|
|
CompanyId: cashPoolFound.CompanyId,
|
|
|
ExchangedCash: cashPoolFound.ExchangedCash,
|
|
|
UnExchangeCash: cashPoolFound.UnExchangeCash,
|
|
|
ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
|
|
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
Rate: cashPoolFound.Rate,
|
|
|
LastRate: cashPoolFound.LastRate,
|
|
|
}
|
|
|
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if _, err := cashPoolRepository.Save(cashPool); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
//// 更新现金池未兑换素币
|
|
|
//cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
|
|
|
// "companyId": task.CompanyId,
|
|
|
//})
|
|
|
//if err != nil {
|
|
|
// return nil, err
|
|
|
//}
|
|
|
//if cashPoolFound != nil {
|
|
|
// // 获取平台素币兑换情况
|
|
|
// systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
|
|
|
// if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if systemSuMoneyStatistics == nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
// }
|
|
|
// systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
|
|
// cashPool := &domain.CashPool{
|
|
|
// Cash: cashPoolFound.Cash,
|
|
|
// CompanyId: cashPoolFound.CompanyId,
|
|
|
// ExchangedCash: cashPoolFound.ExchangedCash,
|
|
|
// UnExchangeCash: cashPoolFound.UnExchangeCash,
|
|
|
// ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
|
|
|
// UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
// Rate: cashPoolFound.Rate,
|
|
|
// LastRate: cashPoolFound.LastRate,
|
|
|
// }
|
|
|
// if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {
|
|
|
// return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
// }
|
|
|
// if _, err := cashPoolRepository.Save(cashPool); err != nil {
|
|
|
// return nil, err
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
if task, err := taskRepository.Save(task); err != nil {
|
|
|
return nil, err
|
...
|
...
|
|