public PageResult orderList(String mobile, String openid, PageResult result) { Employer employer = null; List<ServiceOrderView> view = new ArrayList<ServiceOrderView>(); if (StringUtils.isEmpty(openid)) { String mobileHql = "from Employer t where t.ovld = true and t.mobilePhone = ?"; employer = dao.getSingleResultByHQL(Employer.class, mobileHql, mobile); } else { String openidHql = "from Employer t where t.ovld = true and t.openid = ?"; List<Employer> listEmployers = dao.getListResultByHQL(Employer.class, openidHql, openid); if (listEmployers == null || listEmployers.size() == 0) { result.setResult(ResultInfo.SUCCESS); result.put("result", view); return result; } if (listEmployers.size() > 1) { result.setResult(ResultInfo.MULTI_EMPLYER); List<EmployerView> listViews = new ArrayList<EmployerView>(); for (Employer e : listEmployers) { listViews.add(e.view()); } result.put("result", listViews); return result; } else { employer = listEmployers.get(0); } } if (employer == null) { result.setResult(ResultInfo.SUCCESS); result.put("result", view); return result; } String hql = "from ServiceOrder t where t.ovld = true and t.employer.id=?"; List<ServiceOrder> orders = dao.getListResultByHQL(ServiceOrder.class, hql, employer.getId()); if (orders == null) orders = new ArrayList<ServiceOrder>(); for (ServiceOrder order : orders) { view.add(order.view()); } result.setResult(ResultInfo.SUCCESS); result.put("result", view); return result; }