...
|
...
|
@@ -33,6 +33,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
}()
|
|
|
|
|
|
// TODO 判断公司是否存在
|
|
|
|
|
|
//var cashPoolDao *dao.CashPoolDao
|
|
|
//if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
...
|
...
|
@@ -43,6 +44,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
//}
|
|
|
|
|
|
// TODO 统计系统已兑换现金、未兑换现金、已兑换素币、未兑换素币
|
|
|
|
|
|
var systemUnExchangeCash float64
|
|
|
//systemExchangedCash, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId)
|
|
|
//if err != nil {
|
...
|
...
|
@@ -55,7 +57,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
//}
|
|
|
|
|
|
var cashPoolRepository domain.CashPoolRepository
|
|
|
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
|
|
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -64,6 +66,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
}
|
|
|
|
|
|
// TODO 获取系统未兑换现金
|
|
|
|
|
|
//count, cashPools, err := cashPoolRepository.Find(map[string]interface{}{
|
|
|
// "companyId": createCashPoolCommand.CompanyId,
|
|
|
//})
|
...
|
...
|
@@ -94,7 +97,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co |
|
|
CreateTime: time.Now(),
|
|
|
}
|
|
|
|
|
|
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
|
|
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -128,7 +131,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
var cashPoolRepository domain.CashPoolRepository
|
|
|
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
|
|
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -143,20 +146,21 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
|
}
|
|
|
// TODO 初始状态下,现金池返回默认值
|
|
|
if count == 0 {
|
|
|
return map[string]interface{}{
|
|
|
return map[string] interface{} {
|
|
|
"cashPoolId": 0,
|
|
|
"cash": 0,
|
|
|
"companyId": 0,
|
|
|
"companyId": getCashPoolQuery.CompanyId,
|
|
|
"exchangedCash": 0,
|
|
|
"unExchangeCash": 0,
|
|
|
"exchangedSuMoney": 0,
|
|
|
"unExchangeSuMoney": 0,
|
|
|
"rate": 0,
|
|
|
"createTime": "2020-11-03T17:23:00.848676+08:00",
|
|
|
"createTime": time.Now(),
|
|
|
}, nil
|
|
|
}
|
|
|
} else {
|
|
|
return cashPools[0], nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 新增兑换现金活动
|
...
|
...
|
@@ -254,7 +258,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang |
|
|
if err := removeExchangeCashActivityCommand.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())
|
...
|
...
|
@@ -265,7 +268,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
|
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -274,7 +276,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchang |
|
|
} else {
|
|
|
exchangeCashActivityRepository = value
|
|
|
}
|
|
|
|
|
|
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": removeExchangeCashActivityCommand.ActivityId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -334,7 +335,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
if err := updateExchangeCashActivityCommand.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())
|
...
|
...
|
@@ -345,7 +345,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
|
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -354,7 +353,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
} else {
|
|
|
exchangeCashActivityRepository = value
|
|
|
}
|
|
|
|
|
|
activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": updateExchangeCashActivityCommand.ExchangeCashActivityId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -369,6 +367,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
// TODO 更新现金池已兑换素币、已兑换现金值、未兑换素币、未兑换现金值、平均汇率
|
|
|
|
|
|
//var cashPoolRepository domain.CashPoolRepository
|
|
|
//if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
...
|
...
|
@@ -390,7 +389,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
if err := createExchangeCashPersonCommand.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())
|
...
|
...
|
@@ -403,6 +401,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
}()
|
|
|
|
|
|
// TODO 获取兑换活动兑换汇率
|
|
|
|
|
|
//var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
|
|
//activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"exchangeCashActivityId": createExchangeCashPersonCommand.ExchangeCashActivityId})
|
|
|
//if err != nil {
|
...
|
...
|
@@ -414,12 +413,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
// fmt.Print(activity.Rate)
|
|
|
//}
|
|
|
|
|
|
|
|
|
// TODO 清单中现金总额超过现金池时创建失败,提示:“已超过投入现金池的未兑换现金”
|
|
|
|
|
|
// TODO 新增兑换清单时,根据uid判断成员是否存在,判断素币值是否超过本人持有的素币
|
|
|
|
|
|
// TODO 新增兑换人员时,判断成员是否存在,判断素币值是否超过本人持有的素币,以手机账号为判断依据
|
|
|
|
|
|
// TODO 导入兑换清单时,时根据手机账号判断成员是否存在,判断素币是否超过本人持有的素币
|
|
|
|
|
|
newPerson := &domain.ExchangeCashPersonList{
|
|
|
EmployeeInfo: &domain.EmployeeInfo{
|
...
|
...
|
@@ -444,7 +442,6 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
} else {
|
|
|
// TODO 更新活动已兑换素币值、已兑换现金值、兑换汇率
|
|
|
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -457,7 +454,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer |
|
|
if err := getExchangeCashPersonQuery.ValidateQuery(); 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())
|
...
|
...
|
@@ -468,7 +464,6 @@ func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPer |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
|
|
|
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -514,7 +509,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP |
|
|
} else {
|
|
|
exchangeCashPersonListRepository = value
|
|
|
}
|
|
|
|
|
|
if count, people, err := exchangeCashPersonListRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashPersonQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -533,7 +527,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
|
if err := removeExchangeCashPersonCommand.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())
|
...
|
...
|
@@ -544,7 +537,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
|
|
|
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -553,7 +545,6 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
|
} else {
|
|
|
exchangeCashPersonListRepository = value
|
|
|
}
|
|
|
|
|
|
person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"id": removeExchangeCashPersonCommand.ListId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -611,7 +602,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
} else {
|
|
|
// TODO 更新个人当前可用素币值,生成素币兑换流水记录(获取更新前的已兑换素币值,判断是扣除还是增加),记录描述:参与素币兑换现金活动(红色表示取活动名称)
|
|
|
|
|
|
|
|
|
// TODO 更新相应兑换活动已兑换素币值、已兑换现金值、兑换汇率
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
|