...
|
...
|
@@ -17,16 +17,16 @@ func (repository *ExchangeCashPersonListRepository) Save(exchangeCashList *domai |
|
|
tx := repository.transactionContext.PgTx
|
|
|
if exchangeCashList.Identity() == nil {
|
|
|
if _, err := tx.QueryOne(
|
|
|
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.CompanyId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.ExchangeCashPerson, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
|
|
|
"INSERT INTO exchange_cash_list (company_id, exchange_cash_activity_id, exchange_cash_person, exchanged_su_money, exchanged_cash) VALUES (?, ?, ?, ?, ?) RETURNING id, company_id, exchange_cash_activity_id, exchange_cash_person, exchanged_su_money, exchanged_cash",
|
|
|
exchangeCashList.CompanyId, exchangeCashList.ExchangeCashActivityId, exchangeCashList.ExchangeCashPerson, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
|
|
|
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.EmployeeInfo.Uid, &exchangeCashList.EmployeeInfo.EmployeeName, &exchangeCashList.EmployeeInfo.EmployeeAccount, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
|
|
|
"INSERT INTO exchange_cash_person_lists (activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash) VALUES (?, ?, ?, ?, ?, ?) RETURNING id, activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash",
|
|
|
exchangeCashList.ExchangeCashActivityId, exchangeCashList.EmployeeInfo.Uid, exchangeCashList.EmployeeInfo.EmployeeName, exchangeCashList.EmployeeInfo.EmployeeAccount, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
|
|
|
return exchangeCashList, err
|
|
|
}
|
|
|
} else {
|
|
|
if _, err := tx.QueryOne(
|
|
|
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.CompanyId, &exchangeCashList.ExchangeCashPerson, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
|
|
|
"UPDATE exchange_cash_list SET company_id = ?, exchange_cash_activity_id=?, exchange_cash_person=?, exchanged_su_money=?, exchanged_cash=? WHERE id=? RETURNING id, company_id, exchange_cash_activity_id, exchange_cash_person, exchanged_su_money, exchanged_cash",
|
|
|
exchangeCashList.CompanyId, exchangeCashList.ExchangeCashPerson, exchangeCashList.ExchangeCashActivityId, exchangeCashList.ExchangedSuMoney, exchangeCashList.ExchangedCash); err != nil {
|
|
|
pg.Scan(&exchangeCashList.ExchangeCashPersonListId, &exchangeCashList.ExchangeCashActivityId, &exchangeCashList.EmployeeInfo.Uid, &exchangeCashList.EmployeeInfo.EmployeeName, &exchangeCashList.EmployeeInfo.EmployeeAccount, &exchangeCashList.ExchangedSuMoney, &exchangeCashList.ExchangedCash),
|
|
|
"UPDATE exchange_cash_person_lists SET exchanged_su_money=? WHERE uid=? RETURNING id, activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash",
|
|
|
exchangeCashList.ExchangedSuMoney, exchangeCashList.EmployeeInfo.Uid); err != nil {
|
|
|
return exchangeCashList, err
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -38,7 +38,7 @@ func (repository *ExchangeCashPersonListRepository) FindOne(queryOptions map[str |
|
|
exchangeCashListModel := new(models.ExchangeCashPersonList)
|
|
|
query := tx.Model(exchangeCashListModel)
|
|
|
if exchangeCashListId, ok := queryOptions["exchangeCashListId"]; ok {
|
|
|
query = query.Where("exchange_cash_list.id = ?", exchangeCashListId)
|
|
|
query = query.Where("exchange_cash_person_lists.id = ?", exchangeCashListId)
|
|
|
}
|
|
|
if err := query.First(); err != nil {
|
|
|
if err.Error() == "pg: no rows in result set" {
|
...
|
...
|
@@ -60,16 +60,16 @@ func (repository *ExchangeCashPersonListRepository) Find(queryOptions map[string |
|
|
exchangeCashPeople := make([]*domain.ExchangeCashPersonList, 0)
|
|
|
query := tx.Model(&exchangeCashListModels)
|
|
|
// 根据公司id查找兑换现金人员清单
|
|
|
if companyId, ok := queryOptions["companyId"]; ok {
|
|
|
query = query.Where("exchange_cash_list.company_id = ?", companyId)
|
|
|
}
|
|
|
//if companyId, ok := queryOptions["companyId"]; ok {
|
|
|
// query = query.Where("exchange_cash_person_lists.company_id = ?", companyId)
|
|
|
//}
|
|
|
// 根据活动id查找兑换现金人员清单
|
|
|
if exchangeCashActivityId, ok := queryOptions["activityId"]; ok {
|
|
|
query = query.Where("exchange_cash_list.exchange_cash_activity_id = ?", exchangeCashActivityId)
|
|
|
query = query.Where("exchange_cash_person_lists.activity_id = ?", exchangeCashActivityId)
|
|
|
}
|
|
|
// 根据兑换现金人员名称搜索人员清单
|
|
|
if personNameMatch, ok := queryOptions["personNameMatch"]; ok && (personNameMatch != ""){
|
|
|
query = query.Where("exchange_cash_list.exchange_cash_person LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
|
|
|
query = query.Where("exchange_cash_person_lists.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
|
|
|
}
|
|
|
if offset, ok := queryOptions["offset"]; ok {
|
|
|
offset := offset.(int)
|
...
|
...
|
|