...
|
...
|
@@ -62,7 +62,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())
|
...
|
...
|
@@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
|
|
|
|
// 现金池仓储初始化
|
|
|
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())
|
...
|
...
|
@@ -338,7 +338,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC |
|
|
}
|
|
|
// 现金池为空时处理
|
|
|
if count == 0 {
|
|
|
return map[string] interface{} {
|
|
|
return map[string]interface{}{
|
|
|
"cashPoolId": 0,
|
|
|
"cash": 0,
|
|
|
"companyId": getCashPoolQuery.CompanyId,
|
...
|
...
|
@@ -543,7 +543,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
|
var t2 = activity.Deadline
|
|
|
|
|
|
// 获取兑换活动前先更新兑换活动倒计时命令
|
|
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
|
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
|
|
|
ExchangeCashActivityId: activity.ActivityId,
|
|
|
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
|
|
|
Deadline: activity.Deadline,
|
...
|
...
|
@@ -579,7 +579,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma |
|
|
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
|
|
|
cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
|
|
|
suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
|
|
|
activityFormat := map[string]interface{} {
|
|
|
activityFormat := map[string]interface{}{
|
|
|
"activityId": activity.ActivityId,
|
|
|
"exchangeActivityName": activity.ExchangeActivityName,
|
|
|
"companyId": activity.CompanyId,
|
...
|
...
|
@@ -647,7 +647,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
|
var t2 = activityFound.Deadline.Local()
|
|
|
|
|
|
// 更新兑换现金活动倒计时命令
|
|
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
|
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
|
|
|
ExchangeCashActivityId: activityFound.ActivityId,
|
|
|
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
|
|
Deadline: activityFound.Deadline.Local(),
|
...
|
...
|
@@ -684,7 +684,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas |
|
|
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
|
|
|
cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
|
|
|
suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
|
|
|
activityWithTs := map[string]interface{} {
|
|
|
activityWithTs := map[string]interface{}{
|
|
|
"activityId": activityFound.ActivityId,
|
|
|
"exchangeActivityName": activityFound.ExchangeActivityName,
|
|
|
"companyId": activityFound.CompanyId,
|
...
|
...
|
@@ -798,7 +798,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA |
|
|
var t2 = activityFound.Deadline
|
|
|
|
|
|
// 更新兑换现金活动倒计时命令
|
|
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
|
|
|
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
|
|
|
ExchangeCashActivityId: activityFound.ActivityId,
|
|
|
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
|
|
|
Deadline: activityFound.Deadline,
|
...
|
...
|
@@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
|
|
|
// 现金池仓储初始化
|
|
|
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())
|
...
|
...
|
@@ -970,7 +970,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
|
|
|
if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
|
|
|
// 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
|
|
|
if activityFoundExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
|
|
|
if activityFoundExchangedSuMoney*updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
}
|
|
|
|
...
|
...
|
@@ -988,7 +988,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
|
|
|
// 更新兑换清单命令
|
|
|
exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
|
|
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
|
|
|
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand{
|
|
|
//ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
|
|
|
ExchangedCash: exchangeCash,
|
|
|
ExchangedSuMoney: personFoundExchangedSuMoney,
|
...
|
...
|
@@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang |
|
|
}
|
|
|
|
|
|
// 保存素币兑换清单更新
|
|
|
if _, err := exchangeCashPersonListRepository.Save(personFound);err != nil {
|
|
|
if _, err := exchangeCashPersonListRepository.Save(personFound); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
|
|
|
// 现金池仓储初始化
|
|
|
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())
|
...
|
...
|
@@ -1218,9 +1218,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
|
|
|
activityFoundExchangedCash := activityFound.ExchangedCash
|
|
|
|
|
|
// TODO 更改:根据uid和companyId,判断当前员工是否有效
|
|
|
//更改:根据uid和companyId,判断当前员工是否有效
|
|
|
getEmployee := map[string]interface{}{
|
|
|
"account": personFound.EmployeeInfo.EmployeeAccount,
|
|
|
"uid": personFound.EmployeeInfo.Uid,
|
|
|
//"account": personFound.EmployeeInfo.EmployeeAccount,
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}
|
|
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
...
|
...
|
@@ -1338,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
|
|
|
// 判断是否超过平台未兑换现金
|
|
|
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
|
|
|
if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
|
|
|
if (activityUpdated.ExchangedSuMoney-activityFoundExchangedSuMoney)*activityUpdated.Rate > cashPoolFoundUnExchangeCash {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -1443,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
|
|
|
|
// 现金池仓储初始化
|
|
|
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 []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -1535,8 +1536,9 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
|
cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
|
|
|
cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
|
|
|
|
|
|
// TODO 更改:根据uid和companyId,判断当前员工是否有效
|
|
|
// 更改:根据uid、account和companyId,判断当前员工是否有效(身份有效、手机账号有效)
|
|
|
getEmployee := map[string]interface{}{
|
|
|
"uid": createExchangeCashPersonCommand.Uid,
|
|
|
"account": createExchangeCashPersonCommand.PersonAccount,
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}
|
...
|
...
|
@@ -1563,8 +1565,9 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
|
}
|
|
|
employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
|
|
|
|
|
|
// TODO 更改:根据uid和activityId判断当前员工是否已经在素币兑换清单中,
|
|
|
// 更改:根据uid、employeeAccount和activityId判断当前员工是否已经在素币兑换清单中,
|
|
|
personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
|
|
|
"uid": employeeFound.EmployeeInfo.Uid,
|
|
|
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
|
|
|
"activityId": activityFound.ActivityId,
|
|
|
})
|
...
|
...
|
@@ -1693,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc |
|
|
}
|
|
|
|
|
|
// 判断是否超过平台未兑换现金
|
|
|
if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
|
|
|
if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
|
|
|
row := []interface{}{
|
|
|
createExchangeCashPersonCommand.PersonName,
|
|
|
createExchangeCashPersonCommand.PersonAccount,
|
...
|
...
|
@@ -2271,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
|
|
|
// 现金池仓储初始化
|
|
|
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())
|
...
|
...
|
@@ -2429,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC |
|
|
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
|
|
|
|
|
|
// 判断是否超过平台未兑换现金
|
|
|
if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
|
|
|
if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
|
|
|
}
|
|
|
|
...
|
...
|
@@ -2665,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC |
|
|
|
|
|
// 现金池仓储初始化
|
|
|
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())
|
...
|
...
|
@@ -2999,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ |
|
|
}
|
|
|
|
|
|
// 兑换素币清单排行榜
|
|
|
for i, _ := range exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int}) {
|
|
|
uid := exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].Uid
|
|
|
for i, _ := range exchangeCashListRankingStatistics["people"].([]struct {
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
|
|
Ranking int
|
|
|
}) {
|
|
|
uid := exchangeCashListRankingStatistics["people"].([]struct {
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
|
|
Ranking int
|
|
|
})[i].Uid
|
|
|
if uidName[uid] != nil {
|
|
|
exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].EmployeeName = uidName[uid].(string)
|
|
|
exchangeCashListRankingStatistics["people"].([]struct {
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
|
|
Ranking int
|
|
|
})[i].EmployeeName = uidName[uid].(string)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 个人素币兑换清单
|
|
|
if exchangeCashListRankingStatistics["currentEmployee"] != nil {
|
|
|
currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int})
|
|
|
uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int}).Uid
|
|
|
currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
|
|
Ranking int
|
|
|
})
|
|
|
uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
|
|
Ranking int
|
|
|
}).Uid
|
|
|
if uidName[uidExchangeCashList] != nil {
|
|
|
currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string)
|
|
|
}
|
...
|
...
|
|