@Transactional public ResultInfo manageAddOrder( String guid, String beginDate, String endDate, String price, String address, String employerName, String telephone, String rate, String countyGuid) { try { String hql = "from Employer e where e.ovld = true and e.guid = ?"; Employer employer = dao.getSingleResultByHQL(Employer.class, hql, guid); County county = dao.getResultByGUID(County.class, countyGuid); ServiceOrder order = ServiceOrder.getInstance(); order.setAddress(address); order.setEmployer(employer); order.setMobilePhone(telephone); order.setOrderPrice(Long.valueOf(price)); order.setRate(Double.valueOf(rate)); order.setCounty(county); order.setServiceBeginDate(ExpectedDateCreate.parseDate(beginDate)); order.setServiceEndDate( ExpectedDateCreate.addDays( ExpectedDateCreate.parseDate(beginDate), Integer.valueOf(endDate))); dao.add(order); return ResultInfo.SUCCESS; } catch (Exception e) { e.printStackTrace(); return ResultInfo.BAD_REQUEST; } }
@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; }