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. 生信分析-PS修改坐标
  2. 大数据分布式集群搭建(6)
  3. 互联网普适性职业生涯?
  4. Android 设计模式一:EIT造型
  5. 20169217 《Linux内核原理与分析》第七周作业
  6. 借用构造函数 组合继承 拷贝继承 总结继承
  7. basename php 中文,php basename不支持中文怎么办
  8. 利用vi编辑器创建和编辑正文文件(二)
  9. 【Elasticsearch】Elasticsearch底层系列之Shard Allocation机制
  10. 20非常有用的Java程序片段(1)
  11. Oracle 11g 下载安装
  12. AR5B22刷win10的killer驱动
  13. 《逻辑:你认为正确,就一定正确吗?》
  14. 两个分数化简比怎么化_分数化简比的方法什么,六年级上求比值与化简比的对比...
  15. 粉刷匠计算机音乐,音乐《粉刷匠》
  16. 支付宝提现要手续费吗?
  17. AD9854+STM32正弦波信号发生器
  18. Kubernets集群管理-升级 kubernetes 集群版本到v1.21.14
  19. 认识电子计算机评课稿,《千以内数的认识》评课稿(最新整理)
  20. 电子工程师高端PCB设计工具:20种完全免费的PCB设计必备工具

热门文章

  1. Python-等额本息计算
  2. 首月流水2.39亿美元,《原神》的发行策略是什么?
  3. Codeforces 4D. Mysterious Present
  4. 安装postgreSQL出现configure:error:readline library not found解决方法及pg安装全过程
  5. 短视频发布之前要注意什么?从配音到发布时间,选对才能吸粉引流
  6. 计算机系统概论(原书第2版)完整课后习题答案(一、二章)
  7. 精准定位直播爆品、快速打造爆款上热门,视频号工具人手必备!
  8. java代码实现一个月内不再提醒,通用到期问题
  9. bzoj3207主席树
  10. 解决Windows11能登录QQ微信,但不可以使用浏览器上网