工行回调接口

/** 北京notify **/

    public void paynotifySc( String orderpayid, String amount, String source, String result) throws SQLException {

        if(NumberHelper.isInt(orderpayid)||StringHelper.checkstr(amount))

            return ;

        View view = App.db.queryFirst("select id, type, status, orderid, customerid, payamount from orderpay where id = " + orderpayid);

        if (view.size() > 0) {

        String url = App.getInitParameter("icbc_callbackURL");

            String status = view.getString(1, "status");

            log.error("icbc paynotifySc -- > result:   "+result);

            if("success".equals(result)){

            if (!"y".equals(status.trim())) {

                    Orderpay orderpay = new Orderpay();

                    orderpay.setId(orderpayid.toString()); // 支付ID

                    orderpay.setStatus(view.getString(1, "status")); // 支付状态

                    orderpay.setType(view.getString(1, "type")); // 类别

                    orderpay.setOrderid(view.getString(1, "orderid")); // 订单号

                    orderpay.setCustomerid(view.getString(1, "customerid")); // 客户号

                    String payamount = view.getString(1, "payamount");

                    orderpay.setPayamount(payamount); // 支付金额

                    String payinfo = source + "sc ID=" + orderpayid;

                    orderpay.setPayinfo(payinfo);

                    OrderPayedManager.orderPayed(orderpay);

                }

            try {

            log.error("out println callbackurl --- > "+url);

            //使用方式一 发送 有效

            PrintWriter out1 = ServletActionContext.getResponse().getWriter();

            out1.println(url);

//            HttpServletResponse response =(HttpServletResponse) ServletActionContext.getResponse();

            //使用方式一 发送 无效

//                    response.setHeader("HTTP/1.1 200", "OK");

//                    response.setHeader("Server", "Apache/1.39");

//                    response.setContentType( "text/html;charset=GBK");

//                    response.setContentLength(url.length());

//        OutputStream out = response.getOutputStream();

//    out.write(url.getBytes("GBK"));

//        out.flush();

//        out.close();

        log.error("out println callbackurl success ,waiting for icbc callback ... ");

    } catch (IOException e) {

    e.getMessage();

    }

            }

        } 

    }

猜你喜欢

转载自luckyhua.iteye.com/blog/2231967