...
|
...
|
@@ -99,6 +99,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
UnExchangeCash: createCashPoolCommand.Cash,
|
|
|
ExchangedSuMoney: 0,
|
|
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
LastRate: 0,
|
|
|
Rate: 0,
|
|
|
CreateTime: time.Now(),
|
|
|
}
|
...
|
...
|
@@ -123,6 +124,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
ExchangedSuMoney: systemExchangedSuMoney,
|
|
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
Rate: cashPools[0].Rate,
|
|
|
LastRate: cashPools[0].LastRate,
|
|
|
CreateTime: time.Now(),
|
|
|
}
|
|
|
if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
|
...
|
...
|
@@ -610,11 +612,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getExchangeCashActivityQuery.ExchangeCashActivityId)))
|
|
|
}
|
|
|
|
|
|
//var timeNow = time.Now()
|
|
|
//var deadline = activityFound.Deadline
|
|
|
//var t1 = time.Date(timeNow.Year(), timeNow.Month(), timeNow.Day(), 0, 0, 0, 0, time.Local)
|
|
|
var t1 = time.Now()
|
|
|
//var t2 = time.Date(deadline.Year(), deadline.Month(), deadline.Day(), 23, 59, 59, 0, time.Local)
|
|
|
var t2 = activityFound.Deadline
|
|
|
|
|
|
// 更新兑换现金活动倒计时命令
|
...
|
...
|
@@ -790,6 +788,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
}
|
|
|
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
|
|
|
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
|
|
|
|
|
|
// 获取平台现金状况
|
|
|
systemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
|
...
|
...
|
@@ -812,14 +811,14 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
|
|
|
// 更新现金池命令
|
|
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
|
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
ExchangedCash: systemUnExchangeCash,
|
|
|
UnExchangeCash: systemUnExchangeCash,
|
|
|
Rate: rate,
|
|
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
ExchangedCash: systemUnExchangeCash,
|
|
|
UnExchangeCash: systemUnExchangeCash,
|
|
|
ExchangedSuMoney: systemExchangedSuMoney,
|
|
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
Rate: rate,
|
|
|
}
|
|
|
|
|
|
fmt.Printf("更新现金池命令:%+v\n", updateCashPoolCommand)
|
|
|
|
|
|
// 更新现金池
|
|
|
if err := cashPoolsFound[0].Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -854,8 +853,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
// 更新兑换活动命令已兑换素币
|
|
|
updateExchangeCashActivityCommand.ExchangedSuMoney = activityFound.ExchangedSuMoney
|
|
|
|
|
|
fmt.Printf("更新兑换活动命令:%+v\n", updateExchangeCashActivityCommand)
|
|
|
|
|
|
// 更新兑换活动
|
|
|
if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -868,7 +865,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
return activityUpdated, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -970,10 +966,12 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
if createExchangeCashPersonCommand.PersonAccount == "" {
|
|
|
getEmployee = map[string]interface{}{
|
|
|
"uid": createExchangeCashPersonCommand.Uid,
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}
|
|
|
} else {
|
|
|
getEmployee = map[string]interface{}{
|
|
|
"account": createExchangeCashPersonCommand.PersonAccount,
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1030,6 +1028,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
// 更新兑换活动命令
|
|
|
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
|
|
|
ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
|
|
|
ExchangeActivityName: activityFound.ExchangeActivityName,
|
|
|
ExchangedSuMoney: activityFound.ExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
|
|
|
ExchangedCash: activityFound.ExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
|
|
|
Deadline: activityFound.Deadline,
|
...
|
...
|
@@ -1052,7 +1051,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
}
|
|
|
|
|
|
// 获取兑换活动素币兑换情况
|
|
|
activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityFound.CompanyId)
|
|
|
activitySuMoneyStatistics, err := cashPoolDao.CalculateActivityExchangedSuMoney(activityFound.ActivityId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -1110,11 +1109,15 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
// 更新现金池命令
|
|
|
updateCashPoolCommand := &command.UpdateCashPoolCommand{
|
|
|
CashPoolId: cashPoolsFound[0].CashPoolId,
|
|
|
Cash: cashPoolsFound[0].Cash,
|
|
|
//CompanyId: cashPoolsFound[0].CompanyId,
|
|
|
ExchangedCash: cashPoolsFound[0].ExchangedCash + personSaved.ExchangedCash,
|
|
|
UnExchangeCash: cashPoolsFound[0].UnExchangeCash - personSaved.ExchangedCash,
|
|
|
ExchangedSuMoney: systemExchangedSuMoney,
|
|
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
Rate: newRate,
|
|
|
LastRate: cashPoolsFound[0].LastRate,
|
|
|
//CreateTime: time.Now(),
|
|
|
}
|
|
|
|
|
|
// 更新现金池
|
...
|
...
|
@@ -1459,17 +1462,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过现金池未兑换现金")
|
|
|
}
|
|
|
|
|
|
// 重新获取系统现金兑换情况
|
|
|
//newSystemCashStatistics, err := employeeDao.CalculateSystemCash(activityFound.CompanyId)
|
|
|
//if err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
//}
|
|
|
//if newSystemCashStatistics == nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
|
|
|
//}
|
|
|
//newSystemExchangedCash := newSystemCashStatistics["systemExchangedCash"].(float64)
|
|
|
//newSystemUnExchangeCash := newSystemCashStatistics["systemUnExchangeCash"].(float64)
|
|
|
|
|
|
// 获取当前现金池
|
|
|
_, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
|
|
|
"companyId": activityUpdated.CompanyId,
|
...
|
...
|
@@ -1497,6 +1489,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
Rate: newRate,
|
|
|
ExchangedSuMoney: cashPoolsFound[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
|
|
|
UnExchangeSuMoney: systemUnExchangeSuMoney,
|
|
|
LastRate: cashPoolsFound[0].LastRate,
|
|
|
//CompanyId: cashPoolsFound[0].CompanyId,
|
|
|
//CreateTime: time.Now(),
|
|
|
}
|
|
|
|
|
|
// 更新现金池
|
...
|
...
|
@@ -1743,6 +1738,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 兑换素币清单仓储初始化
|
|
|
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
|
|
|
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -1752,10 +1748,11 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang |
|
|
exchangeCashPersonListRepository = value
|
|
|
}
|
|
|
|
|
|
if len(exportExchangeCashListCommand.IDs) == 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
|
|
|
}
|
|
|
//if len(exportExchangeCashListCommand.IDs) == 0 {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
|
|
|
//}
|
|
|
|
|
|
// 获取兑换清单
|
|
|
if _, people, err := exchangeCashPersonListRepository.FindById(tool_funs.SimpleStructToMap(exportExchangeCashListCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -1782,6 +1779,7 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 现金池DAO初始化
|
|
|
var cashPoolDao *dao.CashPoolDao
|
|
|
if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -1791,6 +1789,7 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ |
|
|
cashPoolDao = value
|
|
|
}
|
|
|
|
|
|
// 素币兑换清单榜单
|
|
|
if exchangeCashListRankingStatistics, err := cashPoolDao.ExchangeCashListRanking(tool_funs.SimpleStructToMap(exchangeListRankingQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
|