/**
   * 关闭定单
   *
   * @param request
   * @param response
   * @return
   * @throws IOException
   */
  @RequestMapping("/order/colse.do")
  public String colse(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String tid = request.getParameter("tid");
    Trade trade = tradeFacade.findById(tid);
    trade.setStatus("TRADE_CLOSED");
    tradeFacade.update(trade);
    Page<Order> page = new Page<Order>(20);
    page = orderFacade.findByProperty("tid", trade.getTid(), page);
    if (page.getResult() != null && page.getResult().size() > 0) {
      for (Order obj : page.getResult()) {
        obj.setRefundStatus("CLOSED");

        orderFacade.update(obj);
      }
    }
    JSONObject json = new JSONObject();
    json.put("success", true);
    json.put("msg", "关闭交易成功!");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/xml");
    response.getWriter().write(json.toString());
    return null;
  }
  @RequestMapping("/order/order.do")
  public String order(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String tid = request.getParameter("tid");
    Trade trade = tradeFacade.findById(tid);
    Page<Order> page = new Page<Order>(20);
    page = orderFacade.findByProperty("trade", trade, page);
    if (page.getResult() != null && page.getResult().size() > 0) {
      Document doc = new Document();
      Element rootElement = new Element("rows");
      doc.addContent(rootElement);
      Element totalElement = new Element("total");
      totalElement.setText(page.getResult().size() + "");
      rootElement.addContent(totalElement);
      for (Order obj : page.getResult()) {

        Element childElement = new Element("record");
        Element id = new Element("id");
        id.setText(obj.getKey().toString());
        childElement.addContent(id);

        Element picPath = new Element("picPath");
        picPath.setText(obj.getPicPath());
        childElement.addContent(picPath);

        Element title = new Element("title");
        childElement.addContent(title);

        Element price = new Element("price");
        price.setText(obj.getPrice().toString());
        childElement.addContent(price);

        Element outerIid = new Element("outerIid");
        outerIid.setText(obj.getOuterIid());
        childElement.addContent(outerIid);

        /*Element colorName = new Element("colorName");
        				colorName.setText(obj.getColorName());
        				childElement.addContent(colorName);

        				Element sizeName = new Element("sizeName");
        				sizeName.setText(obj.getSizeName());
        				childElement.addContent(sizeName);
        */
        Element num = new Element("num");
        num.setText(obj.getNum().toString());
        childElement.addContent(num);

        Element payment = new Element("payment");
        payment.setText(obj.getPayment().toString());
        childElement.addContent(payment);

        Element totalFee = new Element("totalFee");
        totalFee.setText(obj.getTotalFee().toString());
        childElement.addContent(totalFee);

        Element discountFee = new Element("discountFee");
        discountFee.setText(obj.getDiscountFee().toString());
        childElement.addContent(discountFee);

        Element adjustFee = new Element("adjustFee");
        adjustFee.setText(obj.getAdjustFee().toString());
        childElement.addContent(adjustFee);

        Element refundStatus = new Element("refundStatus");
        refundStatus.setText(obj.getRefundStatus());
        childElement.addContent(refundStatus);

        /*Element refundDesc = new Element("refundDesc");
        refundDesc.setText(obj.getRefundDesc());
        childElement.addContent(refundDesc);*/

        rootElement.addContent(childElement);
      }
      XMLOutputter xml = new XMLOutputter();
      response.setCharacterEncoding("UTF-8");
      response.setContentType("text/xml");
      response.getWriter().write(xml.outputString(doc));
      return null;
    }
    return null;
  }