作者 陈志颖

fix:导入素币流水优化

... ... @@ -298,7 +298,7 @@ func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *comm
employeeRepository = value
}
if _, employees, err := employeeRepository.Find(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil {
if _, employees, err := employeeRepository.FindByIds(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -21,6 +21,7 @@ type EmployeeRepository interface {
Remove(employee *Employee) (*Employee, error)
FindOne(queryOptions map[string]interface{}) (*Employee, error)
Find(queryOptions map[string]interface{}) (int64, []*Employee, error)
FindByIds(queryOptions map[string]interface{}) (int64, []*Employee, error)
}
func (employee *Employee) Identify() interface{} {
... ...
... ... @@ -317,7 +317,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
queryWealth = queryWealth.Where(`e.status = ?`, 1)
queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤
queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6}))
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryWealth = queryWealth.Where("e.company_id = ?", companyId)
... ...
... ... @@ -84,6 +84,37 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{
}
}
func (repository *EmployeeRepository) FindByIds(queryOptions map[string]interface{}) (int64, []*domain.Employee, error) {
tx := repository.transactionContext.PgTx
var employeeModels []*models.Employee
employees := make([]*domain.Employee, 0)
query := tx.Model(&employeeModels)
if ids, ok := queryOptions["ids"]; ok && len(ids.([]int)) != 0 {
query = query.Where("employee.uid IN (?)", pg.In(ids.([]int)) )
}
if where, ok := queryOptions["where"]; ok && where.(map[string]interface{}) != nil {
if personNameMatch, ok := where.(map[string]interface{})["personNameMatch"]; ok && (personNameMatch != "") {
query = query.Where("employee.employee_name LIKE ?", fmt.Sprintf("%%%s%%", personNameMatch.(string)))
}
if companyId, ok := where.(map[string]interface{})["companyId"]; ok && companyId.(float64) != 0 {
query = query.Where("employee.company_id = ?", companyId)
}
}
query = query.Where(`employee.status = ?`, 1)
if count, err := query.Order("uid DESC").SelectAndCount(); err != nil {
return 0, employees, err
} else {
for _, employeeModel := range employeeModels {
if employee, err := repository.transformPgModelToDomainModel(employeeModel); err != nil {
return 0, employees, err
} else {
employees = append(employees, employee)
}
}
return int64(count), employees, nil
}
}
func (repository *EmployeeRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.Employee, error) {
tx := repository.transactionContext.PgTx
var employeeModels []*models.Employee
... ...