@Transactional public void addServiceOrderAdvice(String id) { long idl = Long.valueOf(id); ServiceOrder order = dao.getResultById(ServiceOrder.class, idl); // 更新所有通知为已通知 String hql = "from PanicBuyingBabysitterAdvice t where t.ovld = true and t.serviceOrder.id = ?"; List<PanicBuyingBabysitterAdvice> advices = dao.getListResultByHQL(PanicBuyingBabysitterAdvice.class, hql, order.getId()); for (PanicBuyingBabysitterAdvice advice : advices) { advice.setIsAdvice(true); dao.update(advice); } Map<String, Date> dateMap = new HashMap<String, Date>(); dateMap.put(ExpectedDateCreate.BEGIN_DATE, order.getServiceBeginDate()); dateMap.put(ExpectedDateCreate.END_DATE, order.getServiceEndDate()); // 重新加入月嫂通知 addBabysitterAdvice(order.getCounty().getGuid(), order, dateMap); // 更新雇主订单没有完成抢单 order.setOver(true); dao.update(order); }
private BabysitterOrder updateBabysitterOrder( String orderGuid, Babysitter babysitter, ServiceOrder serviceOrder) { // 添加月嫂订单 BabysitterOrder babysitterOrder = BabysitterOrder.getInstance(); babysitterOrder.setBabysitter(babysitter); babysitterOrder.setEmployer(serviceOrder.getEmployer()); babysitterOrder.setEmployerAddress(serviceOrder.getAddress()); babysitterOrder.setEmployerName(serviceOrder.getEmployerName()); babysitterOrder.setEmployerTelephone(serviceOrder.getMobilePhone()); babysitterOrder.setOrderId(recordService.createOrderId()); babysitterOrder.setOrderPrice(serviceOrder.getOrderPrice()); long frontPrice = getFrontPrice(serviceOrder.getOrderPrice()); babysitterOrder.setOrderFrontPrice(frontPrice); babysitterOrder.setServiceBeginDate(serviceOrder.getServiceBeginDate()); babysitterOrder.setServiceEndDate(serviceOrder.getServiceEndDate()); babysitterOrder.setState(Constants.NEW_ORDER); dao.add(babysitterOrder); // 添加月嫂订单变更信息 BabysitterOrderRecordInfo recordInfo = BabysitterOrderRecordInfo.getInstance(); recordInfo.setBabysitterOrder(babysitterOrder); recordInfo.setState(babysitterOrder.getState()); dao.add(recordInfo); // 更新雇主订单 serviceOrder.setOrderGuid(babysitterOrder.getGuid()); dao.update(serviceOrder); // 更新月嫂抢单通知表中该订单的所有记录为不可用即订单已经被抢 String hql = "from PanicBuyingBabysitterAdvice t where t.ovld = true and t.serviceOrder.guid = ?"; List<PanicBuyingBabysitterAdvice> list = dao.getListResultByHQL(PanicBuyingBabysitterAdvice.class, hql, orderGuid); for (PanicBuyingBabysitterAdvice advice : list) { advice.setIsOver(true); dao.update(advice); } return babysitterOrder; }