@Transactional
 public ResultInfo addServiceOrder(
     String date,
     String price,
     String countyGuid,
     String address,
     String name,
     String mobile,
     String checkCode) {
   try {
     // boolean flag = codeService.updateCheckCode(mobile, checkCode,
     // CheckCodeService.PUBLISH_ORDER);
     // if (!flag) {
     // throw new CheckErrorException();
     // }
     Employer employer = employerService.getEmployerByMobile(mobile);
     // County county = dao.getResultByGUID(County.class, countyGuid);
     if (employer == null) {
       employer = Employer.getInstance();
       employer.setMobilePhone(mobile.replace(" ", ""));
       // employer.setCounty(county);
       employer.setAddress(address);
       employer.setUsername(name);
       employerService.addEmployer(employer);
     }
     // 月嫂提交私单不需要向月嫂抢单表中添加数据正常添加私单。
     ServiceOrder order = ServiceOrder.getInstance();
     order.setEmployer(employer);
     order.setOrderPrice(Long.valueOf(price));
     order.setAddress(address);
     // order.setCounty(county);
     order.setMobilePhone(mobile.replace(" ", ""));
     Map<String, Date> expectedDate = ExpectedDateCreate.getExpectedDate(date);
     order.setServiceBeginDate(expectedDate.get(ExpectedDateCreate.BEGIN_DATE));
     order.setServiceEndDate(expectedDate.get(ExpectedDateCreate.END_DATE));
     dao.add(order);
   } catch (CheckErrorException e) {
     return ResultInfo.CHECK_CODE_ERROR;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return ResultInfo.SUCCESS;
 }
 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;
 }
 @Transactional
 public ServiceOrder addEmployerServiceOrder(
     String date,
     String countyLevelGuid,
     String countyGuid,
     String address,
     String name,
     String mobile,
     String checkCode,
     String openid) {
   Employer employer = employerService.getEmployerByMobile(mobile);
   County county = dao.getResultByGUID(County.class, countyGuid);
   CountyLevel countyLevel = dao.getResultByGUID(CountyLevel.class, countyLevelGuid);
   if (countyLevel == null) return null;
   if (employer == null) {
     employer = Employer.getInstance();
     employer.setMobilePhone(mobile.replace(" ", ""));
     // employer.setCounty(county);
     employer.setAddress(address);
     employer.setUsername(name);
     employer.setOpenid(openid);
     employerService.addEmployer(employer);
   }
   // 添加雇主订单
   ServiceOrder order = ServiceOrder.getInstance();
   order.setEmployer(employer);
   order.setCounty(county);
   order.setOrderPrice(Long.valueOf(countyLevel.getMoney()));
   order.setRate(countyLevel.getRate());
   order.setAddress(address);
   order.setMobilePhone(mobile);
   order.setEmployerName(name);
   order.setMobilePhone(mobile);
   Map<String, Date> expectedDate = ExpectedDateCreate.getExpectedDate(date);
   order.setServiceBeginDate(expectedDate.get(ExpectedDateCreate.BEGIN_DATE));
   order.setServiceEndDate(expectedDate.get(ExpectedDateCreate.END_DATE));
   dao.add(order);
   return order;
 }