作者 陈志颖

fix:修复员工权限字典列表

... ... @@ -165,7 +165,7 @@ func (configService *ConfigService) ListBidTimeMatch(listBidTimeMatchQuery *quer
}, nil
}
// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理)
// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理,4标签管理,5排行榜管理
func (configService *ConfigService) ListEmployeePermission(listEmployeePermissionQuery *query.ListEmployeePermissionQuery) (interface{}, error) {
if err := listEmployeePermissionQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -175,6 +175,7 @@ func (configService *ConfigService) ListEmployeePermission(listEmployeePermissio
2: "素币管理",
3: "成员管理",
4: "标签管理",
5: "排行榜管理",
}
var list []map[string]interface{}
for key, value := range employeePermissionMap {
... ...
... ... @@ -501,7 +501,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
"deadline": activity.Deadline.UnixNano() / 1e6,
"countDown": activity.CountDown,
"rate": activity.Rate,
"createTime": activity.Deadline,
"createTime": activity.CreateTime,
}
activitiesWithTs = append(activitiesWithTs, activityWithTs)
}
... ... @@ -815,7 +815,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
// 计算倒计时
updateExchangeCashActivityCommand.CountDown = int64(t2.Sub(t1).Hours() / 24)
//updateExchangeCashActivityCommand.Deadline = deadline
// 倒计时结束
if t2.Before(t1) {
... ... @@ -1247,6 +1246,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
transactionContext.RollbackTransaction()
}()
// 兑换素币清单仓储初始化
var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1256,15 +1256,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
exchangeCashPersonListRepository = value
}
// 获取兑换清单
person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"listId": updateExchangeCashPersonCommand.ListId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if person == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
}
// 兑换现金活动仓储初始化
var exchangeCashActivityRepository domain.ExchangeActivityRepository
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1274,36 +1266,48 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
exchangeCashActivityRepository = value
}
// 获取相关兑换活动
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": person.ExchangeCashActivityId})
// 获取兑换清单
personFound, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"listId": updateExchangeCashPersonCommand.ListId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if activityFound == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(person.ExchangeCashActivityId)))
if personFound == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
}
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
ExchangeCashActivityId: person.ExchangeCashActivityId,
ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney),
ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
Deadline: activityFound.Deadline,
CountDown: activityFound.CountDown,
ExchangeRate: activityFound.Rate,
// 获取相关兑换活动
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if activityFound == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(personFound.ExchangeCashActivityId)))
}
// 更新兑换清单,个人已兑换现金计算
updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
// 更新兑换素币清单
if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
personUpdated, err := exchangeCashPersonListRepository.Save(person)
// 保存兑换清单更新
personUpdated, err := exchangeCashPersonListRepository.Save(personFound)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 更新素币兑换活动命令
updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
ExchangeCashActivityId: personFound.ExchangeCashActivityId,
ExchangedSuMoney: activityFound.ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney),
ExchangedCash: activityFound.ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney) * activityFound.Rate,
Deadline: activityFound.Deadline,
CountDown: activityFound.CountDown,
ExchangeRate: activityFound.Rate,
}
// 更新员工素币,生成素币兑换流水记录
var operationSuMoneyService service.OperationSuMoneyService
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
... ... @@ -1315,10 +1319,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
}
operationSuMoneyCommand := &command.OperationSuMoneyCommand{
Uid: person.EmployeeInfo.Uid,
Operator: updateExchangeCashPersonCommand.Operator,
SuMoney: 0,
OperationType: 0,
Uid: personFound.EmployeeInfo.Uid,
Operator: updateExchangeCashPersonCommand.Operator,
SuMoney: 0,
OperationType: 0,
OperationDescription: activityFound.ExchangeActivityName + "素币调整",
}
... ... @@ -1448,10 +1452,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
updateCashPoolCommand := &command.UpdateCashPoolCommand{
CashPoolId: cashPools[0].CashPoolId,
ExchangedCash: cashPools[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
UnExchangeCash: cashPools[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney) * activityFound.Rate,
ExchangedCash: cashPools[0].ExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney) * activityFound.Rate,
UnExchangeCash: cashPools[0].UnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney) * activityFound.Rate,
Rate: newRate,
ExchangedSuMoney: cashPools[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - person.ExchangedSuMoney),
ExchangedSuMoney: cashPools[0].ExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFound.ExchangedSuMoney),
UnExchangeSuMoney: systemUnExchangeSuMoney,
}
... ...