微信对账文件的处理

获取对账文件的方法跟获取pre_id的方法相同,只是请求的URL不同,若要是不会请参考前面的微信支付的博客。
我这是说获取到对账文件后的处理

String res_bill = WXPay.requestDownloadBillService(new DownloadBillReqData("", BillDate, "ALL"), 0);
if (res_bill.startsWith("<xml>"))
            {
                Map<String, Object> resmap = XMLParser.getMapFromXML(res_bill);
                if (resmap.get("return_code").equals("FAIL"))
                {
                    System.out.println("get bill fail !!");
                    return;
                }
            }
            String res_bill_utf = new String(res_bill.getBytes("UTF-8"));
            System.out.println("res_bill--------------->>>" + res_bill_utf);
            BufferedReader br = new BufferedReader(new StringReader(res_bill));
            String titleLine = br.readLine();
            // 交易时间,公众账号ID,商户号,子商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,总金额,现金券金额,
            // 微信退款单号,商户退款单号,退款金额,现金券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率
            List<String> titles = Arrays.asList(titleLine.split(","));
            int idxTranId = titles.indexOf("微信订单号");
            int idxPayOrderNo = titles.indexOf("商户订单号");
            int idxBankType = titles.indexOf("付款银行");
            int idxFeeType = titles.indexOf("货币种类");
            int idxRcvAmt = titles.indexOf("总金额");
            int idxDiscount = titles.indexOf("现金券金额");
            int idxRefundNo = titles.indexOf("商户退款单号");
            int idxRefundFee = titles.indexOf("退款金额");
            int idxCouponFee = titles.indexOf("现金券退款金额");
            int idxPoundage = titles.indexOf("手续费");
            int idxCmsRate = titles.indexOf("费率");
            int idxTimePaid = titles.indexOf("交易时间");
            int idxAppId = titles.indexOf("公众账号ID");
            int idxShopNo = titles.indexOf("商户号");
            int idxSubShopNo = titles.indexOf("子商户号");
            int idxCustId = titles.indexOf("用户标识");
            int idxTradeType = titles.indexOf("交易类型");
            int idxTradeStatus = titles.indexOf("交易状态");
            int idxRefundType = titles.indexOf("退款类型");
            int idxRefundStatus = titles.indexOf("退款状态");
            int idxSubject = titles.indexOf("商品名称");
            int idxMerchantData = titles.indexOf("商户数据包");
            String line = br.readLine();
            String TradeTime = null;
            String payOrder = null;
            String content = "";
            while (line.startsWith("`"))
            {
                line = line.substring(1);
                String values[] = line.split(",`");
                payOrder = idxPayOrderNo > -1 ? values[idxPayOrderNo] : "";//商户订单号
                String ORDER_NO = idxTranId > -1 ? values[idxTranId] : "";//微信订单号
                String BankType = idxBankType > -1 ? values[idxBankType] : "";//付款银行
                String RcvAmt = idxRcvAmt > -1 ? values[idxRcvAmt] : "";//总金额
                int Rcv = (int) (Float.parseFloat(RcvAmt) * 100);
                TradeTime = values[0];//交易时间
                String ShopNo = idxShopNo > -1 ? values[idxShopNo] : "";//商户号
                String MerchantData = idxMerchantData > -1 ? values[idxMerchantData] : "";//商户数据包
                line = br.readLine();
            }
            content = content.substring(0, content.length() - 2);
            line = br.readLine();
            line = line.substring(1);
            String totalValues[] = line.split(",`");
            String DEAL_COUNT = totalValues[0];
            String SUCCESS_AMT = totalValues[1];
            int sucess_amt = (int) (Double.valueOf(SUCCESS_AMT) * 100);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值