1、商户平台可能有几个账户,基本账户、运营账户、手续费账户
2、境内商户微信只提供交易账单和资金账单,不过其他比如结算账单可以从这两份账单计算出来
3、结算周期T+1、T+7
4、账单都是10点

先获取交易账单,为了方便看,获取完,我直接写入数据库。

     SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");Date date = format.parse(time);String fordate=sdf.format(date);String nonce_str = getRandomStringByLength(32);String bill_type="ALL";Map<String, String> packageParams = new HashMap<>();packageParams.put("appid", PayConfig.appid);packageParams.put("mch_id", PayConfig.mch_id);packageParams.put("nonce_str", nonce_str);packageParams.put("bill_type",bill_type );packageParams.put("bill_date", fordate);String prestr = PayUtil.createLinkString(packageParams); // 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串// MD5运算生成签名String mysign = PayUtil.sign(prestr, PayConfig.key, "utf-8").toUpperCase();String xml = "<xml>" + "<appid>" + PayConfig.appid + "</appid>" + "<mch_id>" + PayConfig.mch_id + "</mch_id>"+ "<nonce_str>" + nonce_str + "</nonce_str>" + "<bill_type>" + bill_type + "</bill_type>"+ "<bill_date>" + fordate + "</bill_date>" + "<sign>" + mysign + "</sign>" + "</xml>";String result = PayUtil.httpRequest("https://api.mch.weixin.qq.com/pay/downloadbill", "POST", xml);int i = result.indexOf("`");int j = result.indexOf("总");String substring = result.substring(i, j - 2);String[] temp = substring.split(",``");for (int k = 0; k < temp.length; k++) {String[] payment = temp[k].replace("`", "").split(",");//写交易账单String sql="insert into oa_trade_bill(trade_time,appid,mch_id,mch_appid,device_info,transaction_id,out_trade_no,openid,trade_type,"+ "trade_status,pay_bank,money_type,order_pay,voucher_amount,refund_number,out_refund_no,refund_amount,refund_amount_voucher,"+ "refunds_type,refunds_status,commodity_name,data_packet,service_charge,rate,order_amount,application_refund_amount"+ ")values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";systemService.executeSql(sql, payment[0],payment[1],payment[2],payment[3],payment[4],payment[5],payment[6],payment[7],payment[8],payment[9],payment[10],payment[11],payment[12],payment[13],payment[14],payment[15],payment[16],payment[17],payment[18],payment[19],payment[20],payment[21],payment[22],payment[23],payment[24],payment[25]);}

交易账单的汇总

      String total=result.substring(j);int t=total.indexOf("`");String totalData=total.substring(t).replace("`", "");String[] l=totalData.split(",");int trade_num_total=Integer.parseInt(l[0]);double order_pay_total=Double.parseDouble(l[1]);double refund_amount_total=Double.parseDouble(l[2]);double refund_amount_voucher_total=Double.parseDouble(l[3]);double service_charge_total=Double.parseDouble(l[4]);double order_amount_total=Double.parseDouble(l[5]);double application_refund_amount_total=Double.parseDouble(l[6]);String addDate=time+" 10:00:00";systemService.executeSql("insert into oa_trade_total(trade_num_total,order_pay_total,refund_amount_total,refund_amount_voucher_total,"+ "service_charge_total,order_amount_total,application_refund_amount_total,add_date)values(?,?,?,?,?,?,?,?)", trade_num_total,order_pay_total,refund_amount_total,refund_amount_voucher_total,service_charge_total,order_amount_total,application_refund_amount_total,addDate);

以上是交易账单的,下面进行资金账单的下载,注意账户类型:下面是基本账户的,account_type=“Basic”,换运营账户,改这个参数就行,account_type=“Operation”

     String nonce_str = getRandomStringByLength(32);String account_type="Basic";SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");Date date = format.parse(time);String fordate=sdf.format(date);Map<String, String> packageParams = new HashMap<>();packageParams.put("appid", PayConfig.appid);packageParams.put("mch_id", PayConfig.mch_id);packageParams.put("nonce_str", nonce_str);packageParams.put("account_type",account_type );packageParams.put("bill_date", fordate);System.out.println("组装参数:" + packageParams);//int year = date.getYear() + 1900 ;// sha256_HMAC运算生成签名String mysign=PayUtil.paySignDesposit(packageParams, PayConfig.key);String xml = "<xml>" + "<appid>" + PayConfig.appid + "</appid>" + "<mch_id>" + PayConfig.mch_id + "</mch_id>"+ "<nonce_str>" + nonce_str + "</nonce_str>" + "<account_type>" + account_type + "</account_type>"+ "<bill_date>" + fordate + "</bill_date>" + "<sign>" + mysign + "</sign>" + "</xml>";System.out.println("xml:" + xml);String result=PayUtil.reqWithCert(xml, PayConfig.fundflow_url);System.out.println("下载基本账户资金账单结果:"+result);int i = result.indexOf("`");int j = result.indexOf("资金流水总笔数");String substring = result.substring(i, j);//方法比较简单暴力,通过年份(比如2018 + `) 去切割,最后再把年份拼接上去String[] temp = substring.split("`" +time);//ArrayList<FundFlowBean> list = new ArrayList<FundFlowBean>();for (int m = 1; m < temp.length; m++) {String[] payment = temp[m].replace("`", "").split(",");if (payment.length==10) {if (payment[9].equals("system")) {//                              bean.setVoucher_number("");String sql="insert into oa_fund_bill(trade_time,payment_number,flow_number,business_name,business_type,inout_type,"+ "inout_money,account_balance,applicant,remarks,voucher_number,account_type)values(?,?,?,?,?,?,?,?,?,?,?,?)";systemService.executeSql(sql, time + payment[0],payment[1],payment[2],payment[3],payment[4],payment[5],payment[6],payment[7],payment[8],payment[9],"",account_type);}}else if (payment.length==11){//                          bean.setVoucher_number(payment[10].split("\r\n")[0]);String sql="insert into oa_fund_bill(trade_time,payment_number,flow_number,business_name,business_type,inout_type,"+ "inout_money,account_balance,applicant,remarks,voucher_number,account_type)values(?,?,?,?,?,?,?,?,?,?,?,?)";systemService.executeSql(sql, time + payment[0],payment[1],payment[2],payment[3],payment[4],payment[5],payment[6],payment[7],payment[8],payment[9],payment[10].split("\r\n")[0],account_type);}}

资金账单的汇总

         String total=result.substring(j);int t=total.indexOf("`");String totalData=total.substring(t).replace("`", "");String[] l=totalData.split(",");int fundNum=Integer.parseInt(l[0]);int incomeNum=Integer.parseInt(l[1]);double incomeAmount=Double.parseDouble(l[2]);int paidNum=Integer.parseInt(l[3]);double paidAmount=Double.parseDouble(l[4]);String addDate=time+" 10:00:00";String sql="insert into oa_fund_total(fund_num,income_num,income_amount,paid_num,paid_amount,add_date,account_type) values(?,?,?,?,?,?,?)";systemService.executeSql(sql, fundNum,incomeNum,incomeAmount,paidNum,paidAmount,addDate,account_type);

记录从微信商户获取微信支付账单过程相关推荐

  1. 微信开发 ━━ 微信商户v3微信支付H5方式开发之php篇

    native方式开发纪要:<微信开发 ━━ 微信商户native方式支付v3开发之php篇> 一.流程 流程是必须要弄懂的,弄懂之后遇到问题也能知道出在哪里. 官方说明:<H5支付统 ...

  2. 微信中获取微信用户信息的2种方式

    微信中获取微信用户信息的2中方式 1, 在公众号底部菜单栏地址配置h5地址,如 http://test.dingdong.com/page1 然后前端在所有页面前拦截如login页面,查看是否有tok ...

  3. 从微信官方获取微信公众号名片:https://open.weixin.qq.com/qr/code?username=haihongruanjian...

    从微信官方获取微信公众号名片: https://open.weixin.qq.com/qr/code?username=haihongruanjian (http://open.weixin.qq.c ...

  4. 从微信官方获取微信公众号二维码(名片)

    从微信官方获取微信公众号二维码(名片) src="http://open.weixin.qq.com/qr/code?username=微信号" <img src=" ...

  5. linux安装微信商户证书,微信支付-证书安装+使用+CentOS+Python+Tornado

    本篇要讲的是: 如何在CentOS下通过Python+Tornado搭建的网站使用微信支付相关的接口证书的问题 官方文档:https://pay.weixin.qq.com/wiki/doc/api/ ...

  6. CocosCreator微信小游戏接入微信登录获取微信名、头像、经纬度等信息

    前言 微信小游戏接入微信登录还是很简单的,不像原生平台开发,还需要提供appid,appsecret等信息,并有一系列的和微信平台的交互,才能最终授权成功. 下面TS代码演示了,老的接入流程. exp ...

  7. 微信授权-获取微信授权后用户信息

    微信授权登陆: 我采用的是自定义的子菜单:登陆微信公众平台 第一步:用户同意授权.获取code 第二步:通过code换取网页授权access_token 详细步骤参考微信公众号平台 在页面地址输入授权 ...

  8. 【逆向】【Android微信】获取微信聊天记录

    2020-02-23 晴 郑州 出场人物 沉瓶 - 产品经理 饭咸 - 程序员 工作环境 硬件:MacBook Pro (Retina, 13-inch, Early 2015) 硬件相应系统:mac ...

  9. 微信开发 ━━ 微信商户v3微信支付回调之php篇

    开发内容都在这里: 微信支付API v3 证书和回调报文解密 在微信支付时提供一个回调地址,支付完成后微信会向这个回调地址发送一个json格式的报文,将报文内容解密后获取订单号等数据 报文内容: {& ...

  10. php开发微信商户平台支付宝支付,不用申请服务号就可以开发微信支付/支付宝/QQ钱包支付!附:直接可用的代码+demo...

    我们知道,开发微信支付需要申请服务号并且需要一系列的资料才可以开通.怪麻烦的,现在我们可以用第三方开放的免签约微信支付接口,支付宝接口和QQ钱包接口,实现实时到帐的微信支付开发. 我们只需要在第三方的 ...

最新文章

  1. vue踩坑- 报错npm ERR! cb() never called!
  2. CGTN专访第四范式裴沵思 阐释数字化转型背后的驱动力
  3. android 退出应用没有走ondestory方法,Android退出应用最优雅的方式(改进版)
  4. C#使用线程窗口调试多线程程序
  5. 牙齿间隙变大怎么办_牙齿之间的间隙越来越大怎么办?
  6. 如何修改Git仓库的URL(地址)
  7. 比特币最主流,以太坊大跌,区块链技术“万金油”红利已结束 | 区块链开发者年度报告...
  8. win 8.1 安装framework3.5
  9. Script To Monitor RDBMS Session UGA and PGA Current And Maximum Usage Over Time
  10. Java中找出s字符串的回文_给定一个字符串 s,找到 s 中最长的回文子串。
  11. 初始MySQL数据库
  12. UVA10066(DP)
  13. 人工智能在智慧城市建设的应用场景
  14. 手动计算Q-Learning的一个实例
  15. macbook linux 双系统,mac安装linux双系统的吐槽
  16. 16-MySQL基础语法(数据库)
  17. 用月壤实现太阳能发电,人类离「定居月球」又近一步 | 来自贝索斯蓝色起源...
  18. 如何进入BIOS模式,BIOS进不去解决方案
  19. python get sheet_python复制excel的sheet表的方法
  20. 盈一眸恬淡,在明媚的春天等你

热门文章

  1. 外贸企业出口退税流程/经验分享
  2. Excel字符串拼接
  3. Black-Scholes期权定价公式
  4. 双目立体匹配之代价聚合
  5. 洛谷Java入门级代码之分汽水
  6. Python读取NC格式数据绘制水汽通量等值线和和流场
  7. Java编写的“滑稽”表情屏保程序
  8. 【指数数据处理】1. 指数的成分股参考日调整
  9. ape格式转换ogg格式使用什么软件
  10. 定性分析 or 定量分析