...
|
...
|
@@ -102,24 +102,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 更新现金池
|
|
|
func (cashPoolService *CashPoolService) UpdateCashPool(updateCashPoolCommand *command.UpdateCashPoolCommand) (interface{}, error) {
|
|
|
if err := updateCashPoolCommand.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()
|
|
|
}()
|
|
|
return nil , nil
|
|
|
}
|
|
|
|
|
|
// 返回现金池
|
|
|
func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) {
|
|
|
if err := getCashPoolQuery.ValidateQuery(); err != nil {
|
...
|
...
|
@@ -425,7 +407,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
|
}
|
|
|
}
|
|
|
|
|
|
// TODO 更新兑换现金活动
|
|
|
// 更新兑换现金活动
|
|
|
func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
|
|
|
if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
...
|
...
|
@@ -613,7 +595,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
} else {
|
|
|
exchangeCashActivityRepository = value
|
|
|
}
|
|
|
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"exchangeCashActivityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
|
|
|
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -628,7 +610,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
employeeRepository = value
|
|
|
}
|
|
|
getEmployee := map[string]interface{}{}
|
|
|
if createExchangeCashPersonCommand.PersonName == "" {
|
|
|
if createExchangeCashPersonCommand.PersonAccount == "" {
|
|
|
getEmployee = map[string]interface{}{
|
|
|
"uid": createExchangeCashPersonCommand.Uid,
|
|
|
}
|
...
|
...
|
@@ -637,6 +619,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
"account": createExchangeCashPersonCommand.PersonAccount,
|
|
|
}
|
|
|
}
|
|
|
fmt.Print(getEmployee, "\n")
|
|
|
employee, err := employeeRepository.FindOne(getEmployee)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -686,6 +669,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
OperationType: 3,
|
|
|
OperationDescription: "素币兑换现金",
|
|
|
}
|
|
|
fmt.Print(operationSuMoneyCommand, "\n")
|
|
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -693,6 +677,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
if task == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
|
|
|
}
|
|
|
fmt.Print(task, "\n")
|
|
|
// 更新兑换活动
|
|
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -946,6 +931,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
|
OperationType: 1,
|
|
|
OperationDescription: "素币兑换现金调整",
|
|
|
}
|
|
|
fmt.Print(removeExchangeCashPersonCommand.Operator, "\n")
|
|
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -1160,6 +1146,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
employeeDao = value
|
|
|
}
|
|
|
systemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
|
|
|
fmt.Print(activitySuMoney , "\n")
|
|
|
fmt.Print(updateExchangeCashActivityCommand.ExchangeRate, "\n")
|
|
|
fmt.Print(systemCashStatistics["systemUnExchangeCash"].(float64), "\n")
|
|
|
if activitySuMoney * updateExchangeCashActivityCommand.ExchangeRate > systemCashStatistics["systemUnExchangeCash"].(float64) {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
}
|
...
|
...
|
@@ -1171,6 +1160,13 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
OperationType: 0,
|
|
|
OperationDescription: "参与兑换素币活动",
|
|
|
}
|
|
|
//if (person.ExchangedSuMoney - updateExchangeCashPersonCommand.ExchangedSuMoney) > 0 {
|
|
|
// operationSuMoneyCommand.SuMoney = math.Abs(person.ExchangedSuMoney - updateExchangeCashPersonCommand.ExchangedSuMoney)
|
|
|
// operationSuMoneyCommand.OperationType = 1
|
|
|
//} else {
|
|
|
// operationSuMoneyCommand.SuMoney = math.Abs(person.ExchangedSuMoney - updateExchangeCashPersonCommand.ExchangedSuMoney)
|
|
|
// operationSuMoneyCommand.OperationType = 3
|
|
|
//}
|
|
|
if updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney > 0 {
|
|
|
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney)
|
|
|
operationSuMoneyCommand.OperationType = 5
|
...
|
...
|
@@ -1178,6 +1174,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - person.ExchangedSuMoney)
|
|
|
operationSuMoneyCommand.OperationType = 3
|
|
|
}
|
|
|
fmt.Print(updateExchangeCashPersonCommand.Operator, "\n")
|
|
|
task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -1186,7 +1183,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operationSuMoneyCommand.Uid)))
|
|
|
}
|
|
|
// 更新现金池
|
|
|
// 获取平台现金状况
|
|
|
newSystemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
|