...
|
...
|
@@ -902,6 +902,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
exchangeCashPersonListRepository = value
|
|
|
}
|
|
|
|
|
|
// 员工仓储初始化
|
|
|
var employeeRepository domain.EmployeeRepository
|
|
|
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
employeeRepository = value
|
|
|
}
|
|
|
|
|
|
// 兑换现金活动仓储初始化
|
|
|
var exchangeCashActivityRepository domain.ExchangeActivityRepository
|
|
|
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
|
...
|
...
|
@@ -951,9 +961,6 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ListId)))
|
|
|
}
|
|
|
|
|
|
// 获取兑换清单员工已兑换素币
|
|
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
|
|
|
|
|
// 获取相关兑换活动
|
|
|
activityFound, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": personFound.ExchangeCashActivityId})
|
|
|
if err != nil {
|
...
|
...
|
@@ -963,6 +970,29 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC |
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(personFound.ExchangeCashActivityId)))
|
|
|
}
|
|
|
|
|
|
// 获取员工查询条件
|
|
|
getEmployee := map[string]interface{}{
|
|
|
"account": personFound.EmployeeInfo.EmployeeAccount,
|
|
|
"companyId": activityFound.CompanyId,
|
|
|
}
|
|
|
|
|
|
// 判断当前员工是否有效
|
|
|
employeeFound, err := employeeRepository.FindOne(getEmployee)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if employeeFound == nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
|
|
|
}
|
|
|
|
|
|
// 判断该员工兑换的素币是否超过本人持有的素币
|
|
|
if employeeFound.SuMoney < updateExchangeCashPersonCommand.ExchangedSuMoney {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前兑换素币超过本人持有的素币值")
|
|
|
}
|
|
|
|
|
|
// 获取兑换清单员工已兑换素币
|
|
|
personFoundExchangedSuMoney := personFound.ExchangedSuMoney
|
|
|
|
|
|
// 更新兑换清单,个人已兑换现金计算
|
|
|
updateExchangeCashPersonCommand.ExchangedCash = updateExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate
|
|
|
|
...
|
...
|
|