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;
  }
  @SuppressWarnings("resource")
  private void sendPaymentToWeChatServer(PageResult result, BabysitterOrder order, String xml) {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(Constants.WECHAT_OPENID_PAY_URL);
    StringEntity myEntity = new StringEntity(xml, "UTF-8");
    httppost.addHeader("Content-Type", "text/xml");
    httppost.setEntity(myEntity);
    try {
      HttpResponse response = httpclient.execute(httppost);
      HttpEntity resEntity = response.getEntity();
      InputStreamReader reader = new InputStreamReader(resEntity.getContent(), "UTF-8");
      StringBuffer resultStr = new StringBuffer();
      char[] buff = new char[1024];
      int length = 0;
      while ((length = reader.read(buff)) != -1) {
        resultStr.append(new String(buff, 0, length));
      }
      System.out.println(resultStr.toString());
      httpclient.getConnectionManager().shutdown();
      Map<String, String> responseResult =
          RequestXMLCreater.getInstance().getXmlMapResult(resultStr.toString());
      Map<String, String> resultMap;
      if (Constants.PAY_SUCCESS.equals(responseResult.get("return_code"))
          && Constants.PAY_MESSAGE_OK.equals(responseResult.get("return_msg"))
          && Constants.PAY_SUCCESS.equals(responseResult.get("result_code"))) {
        resultMap =
            RequestXMLCreater.getInstance()
                .getPayResponseMap(responseResult.get("prepay_id"), order.getGuid());

        result.setResult(ResultInfo.SUCCESS);
        result.put("result", resultMap);
      } else {
        result.put("code", responseResult.get("err_code"));
        result.put("msg", responseResult.get("err_code_des"));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }