作者 陈志颖

fix:修复更新兑换素币清单时的判断问题

... ... @@ -990,13 +990,14 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
}
// 判断当前员工是否已经在素币兑换清单中
employeeExist, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
count, _, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
"uid": employeeFound.EmployeeInfo.Uid,
"activityId": activityFound.ActivityId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeExist != nil {
if count > 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "当前员工已经在素币兑换清单中")
}
... ... @@ -1404,11 +1405,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
}
// 判断操作素币类型
if updateExchangeCashActivityCommand.ExchangedSuMoney - personFound.ExchangedSuMoney > 0 { // 追加素币兑换
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
operationSuMoneyCommand.OperationType = 4
} else { // 撤回素币兑换
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashActivityCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
operationSuMoneyCommand.OperationType = 41
}
... ...
... ... @@ -37,9 +37,15 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str
tx := repository.transactionContext.PgTx
exchangeCashListModel := new(models.ExchangeCashPersonList)
query := tx.Model(exchangeCashListModel)
if uid, ok := queryOptions["uid"]; ok {
query = query.Where("exchange_cash_person_list.uid = ?", uid)
}
if exchangeCashListId, ok := queryOptions["listId"]; ok {
query = query.Where("exchange_cash_person_list.id = ?", exchangeCashListId)
}
if activityId, ok := queryOptions["activityId"]; ok {
query = query.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
... ... @@ -131,6 +137,9 @@ func (repository *ExchangeCashPersonListRepository) Find(queryOptions map[string
if personNameMatch, ok := queryOptions["exchangeCashPersonNameMatch"]; ok && (personNameMatch != ""){
query = query.Where("exchange_cash_person_list.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
}
if uid, ok := queryOptions["uid"]; ok {
query = query.Where("exchange_cash_person_list.uid = ?", uid)
}
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
... ...