public PageResult endWechatOrder(String orderNo, String ip, PageResult result, String openid) { String hql = "from BabysitterOrder t where t.orderId = ?"; BabysitterOrder order = dao.getSingleResultByHQL(BabysitterOrder.class, hql, orderNo); if (order == null) { result.setResult(ResultInfo.BABYSITTER_ORDER_NULL); return result; } if (order.getState() != Constants.EARNEST_MONEY) { result.setResult(ResultInfo.INVALID_ORDER); return result; } BigDecimal orderPrice = new BigDecimal(order.getOrderPrice()); orderPrice = orderPrice.add(new BigDecimal(0 - order.getOrderFrontPrice())); orderPrice = orderPrice.multiply(new BigDecimal(100)); Map<String, String> params = RequestXMLCreater.getInstance() .getPayRequestMap( order.getGuid(), "月嫂尾款", order.getOrderId() + BabysitterOrderService.END, orderPrice.toString(), ip, openid); String xml = RequestXMLCreater.getInstance() .buildXmlString(params, Constants.WECHAT_OPENID_PAY_APPSECRET); System.out.println("======================>" + xml); sendPaymentToWeChatServer(result, order, xml); return result; }
public PageResult payFrontMoney(String orderNo, String ip, PageResult result, String openid) { String hql = "from BabysitterOrder t where t.orderId = ?"; BabysitterOrder order = dao.getSingleResultByHQL(BabysitterOrder.class, hql, orderNo); if (order == null) { result.setResult(ResultInfo.BABYSITTER_ORDER_NULL); return result; } if (order.getState() != Constants.NEW_ORDER) { result.setResult(ResultInfo.INVALID_ORDER); return result; } Map<String, String> params = RequestXMLCreater.getInstance() .getPayRequestMap( order.getGuid(), "月嫂定金", order.getOrderId() + BabysitterOrderService.FRONT, String.valueOf(order.getOrderFrontPrice() * 100), ip, openid); String xml = RequestXMLCreater.getInstance() .buildXmlString(params, Constants.WECHAT_OPENID_PAY_APPSECRET); System.out.println("======================>" + xml); sendPaymentToWeChatServer(result, order, xml); return result; }
public CustomerManager getCustomerManager(String countyGuid, String week) { String hql = "from CustomerManagerDuty t where t.ovld = true and t.county.guid = ? and t.week = ?"; CustomerManagerDuty duty = dao.getSingleResultByHQL(CustomerManagerDuty.class, hql, countyGuid, week); return duty == null ? null : duty.getManager(); }
@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; } }
public Pagination<RoleView> getPageRoleList(Pagination<Role> page) { String hql = "from Role r"; String countHql = "select count(r.id) from Role r"; Pagination<Role> p = dao.getPageResult(Role.class, hql, page.getPageNo(), page.getPageSize()); List<Role> list = p.getResult(); List<RoleView> result = new ArrayList<RoleView>(); for (Role role : list) { result.add(role.view()); } Pagination<RoleView> pageView = new Pagination<RoleView>(result, p.getPageNo(), p.getPageSize()); Long count = dao.getSingleResultByHQL(Long.class, countHql); pageView.setResultSize(count); return pageView; }
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; }