作者 陈志颖

fix:修复导出素币流水问题

@@ -6,7 +6,7 @@ import ( @@ -6,7 +6,7 @@ import (
6 ) 6 )
7 7
8 type ExportSuMoneyCommand struct { 8 type ExportSuMoneyCommand struct {
9 - IDs []int `json:"ids"` 9 + Ids []int `json:"ids"` // 员工uid
10 Where map[string]interface{} `json:"where"` 10 Where map[string]interface{} `json:"where"`
11 } 11 }
12 12
@@ -6,7 +6,7 @@ import ( @@ -6,7 +6,7 @@ import (
6 ) 6 )
7 7
8 type ExportTransactionRecordCommand struct { 8 type ExportTransactionRecordCommand struct {
9 - IDs []int `json:"ids"` 9 + Ids []int `json:"ids"`
10 } 10 }
11 11
12 func (exportTransactionRecordCommand *ExportTransactionRecordCommand) ValidateCommand() error { 12 func (exportTransactionRecordCommand *ExportTransactionRecordCommand) ValidateCommand() error {
@@ -2118,9 +2118,9 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang @@ -2118,9 +2118,9 @@ func (cashPoolService *CashPoolService) ListExchangeCashPersonById(exportExchang
2118 exchangeCashPersonListRepository = value 2118 exchangeCashPersonListRepository = value
2119 } 2119 }
2120 2120
2121 - //if len(exportExchangeCashListCommand.IDs) == 0 {  
2122 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")  
2123 - //} 2121 + if len(exportExchangeCashListCommand.Ids) == 0 && exportExchangeCashListCommand.Where == nil {
  2122 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
  2123 + }
2124 2124
2125 // 获取兑换清单 2125 // 获取兑换清单
2126 if _, people, err := exchangeCashPersonListRepository.FindById(tool_funs.SimpleStructToMap(exportExchangeCashListCommand)); err != nil { 2126 if _, people, err := exchangeCashPersonListRepository.FindById(tool_funs.SimpleStructToMap(exportExchangeCashListCommand)); err != nil {
@@ -277,7 +277,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *comm @@ -277,7 +277,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *comm
277 transactionContext.RollbackTransaction() 277 transactionContext.RollbackTransaction()
278 }() 278 }()
279 279
280 - if len(exportSuMoneyCommand.IDs) == 0 { 280 + if len(exportSuMoneyCommand.Ids) == 0 && exportSuMoneyCommand.Where == nil {
281 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据") 281 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
282 } 282 }
283 283
@@ -317,7 +317,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuM @@ -317,7 +317,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuM
317 transactionContext.RollbackTransaction() 317 transactionContext.RollbackTransaction()
318 }() 318 }()
319 319
320 - if len(exportSuMoneyTransactionRecordCommand.IDs) == 0 { 320 + if len(exportSuMoneyTransactionRecordCommand.Ids) == 0 {
321 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据") 321 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
322 } 322 }
323 323
@@ -95,9 +95,17 @@ func (repository *EmployeeRepository) Find(queryOptions map[string]interface{}) @@ -95,9 +95,17 @@ func (repository *EmployeeRepository) Find(queryOptions map[string]interface{})
95 if employeeNameMatch, ok := queryOptions["employeeNameMatch"]; ok && (employeeNameMatch != "") { 95 if employeeNameMatch, ok := queryOptions["employeeNameMatch"]; ok && (employeeNameMatch != "") {
96 query = query.Where("employee.employee_name LIKE ?", fmt.Sprintf("%%%s%%", employeeNameMatch.(string))) 96 query = query.Where("employee.employee_name LIKE ?", fmt.Sprintf("%%%s%%", employeeNameMatch.(string)))
97 } 97 }
98 - //if status, ok := queryOptions["status"]; ok && (status != 0) {  
99 - // query = query.Where(`employee.status = ?`, status)  
100 - //} 98 + if ids, ok := queryOptions["ids"]; ok && len(ids.([]int)) != 0 {
  99 + query = query.Where("employee.uid IN (?)", pg.In(ids.([]int)) )
  100 + }
  101 + if where, ok := queryOptions["where"]; ok && where.(map[string]interface{}) != nil {
  102 + if personNameMatch, ok := where.(map[string]interface{})["personNameMatch"]; ok && (personNameMatch != "") {
  103 + query = query.Where("employee.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
  104 + }
  105 + if companyId, ok := where.(map[string]interface{})["companyId"]; ok && companyId.(float64) != 0 {
  106 + query = query.Where("employee.company_id = ?", companyId)
  107 + }
  108 + }
101 query = query.Where(`employee.status = ?`, 1) 109 query = query.Where(`employee.status = ?`, 1)
102 if isPrincipal, ok := queryOptions["isPrincipal"]; ok && isPrincipal.(bool) != false { 110 if isPrincipal, ok := queryOptions["isPrincipal"]; ok && isPrincipal.(bool) != false {
103 query = query.Where("employee.is_principal = ? ", isPrincipal) 111 query = query.Where("employee.is_principal = ? ", isPrincipal)