src/main/java/com/hx/corp/entity/CorpPayRequest.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/hx/corp/entity/CorpPayResponse.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/hx/corp/util/WxCorpPayUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/hx/corp/entity/CorpPayRequest.java
@@ -26,7 +26,7 @@ /*(O)收款用户姓名,如果check_name设置为FORCE_CHECK,则必填用户真实姓名*/ private String re_user_name; /*(Y)金额*/ private int amount; private Integer amount; /*(Y)企业付款备注*/ private String desc; /*(N)Ip地址,该IP同在商户平台设置的IP白名单中的IP没有关联,该IP可传用户端或者服务端的IP*/ @@ -101,11 +101,11 @@ this.re_user_name = re_user_name; } public int getAmount() { public Integer getAmount() { return amount; } public void setAmount(int amount) { public void setAmount(Integer amount) { this.amount = amount; } src/main/java/com/hx/corp/entity/CorpPayResponse.java
@@ -7,7 +7,11 @@ /*(Y)业务结果,SUCCESS/FAIL,注意:当状态为FAIL时,存在业务结果未明确的情况。如果状态为FAIL,请务必关注错误代码(err_code字段),通过查询接口确认此次付款的结果*/ private String result_code = "FAIL"; /*(Y)错误代码,成功:SUCCESS*/ /*(Y)返回状态码,SUCCESS/FAIL,此字段是通信标识,非交易标识,交易是否成功需要查看result_code来判断*/ private String return_code; /*(Y) 返回信息 */ private String return_msg; /*(Y)错误代码*/ private String err_code; /*(Y)错误代码描述*/ private String err_code_des; @@ -114,10 +118,28 @@ this.payment_time = payment_time; } public String getReturn_code() { return return_code; } public void setReturn_code(String return_code) { this.return_code = return_code; } public String getReturn_msg() { return return_msg; } public void setReturn_msg(String return_msg) { this.return_msg = return_msg; } @Override public String toString() { return "CorpPayResponse{" + "result_code='" + result_code + '\'' + ", return_code='" + return_code + '\'' + ", return_msg='" + return_msg + '\'' + ", err_code='" + err_code + '\'' + ", err_code_des='" + err_code_des + '\'' + ", mch_appid='" + mch_appid + '\'' + src/main/java/com/hx/corp/util/WxCorpPayUtil.java
@@ -71,20 +71,22 @@ parameters.put("nonce_str", corpPayRequest.getNonce_str()); parameters.put("openid", corpPayRequest.getOpenid()); parameters.put("check_name", corpPayRequest.getCheck_name()); parameters.put("amount", corpPayRequest.getAmount()); parameters.put("amount", corpPayRequest.getAmount().toString()); parameters.put("spbill_create_ip", corpPayRequest.getSpbill_create_ip()); parameters.put("desc", corpPayRequest.getDesc()); String sign = WXSignUtils.createSign("UTF-8", parameters, mchKey); parameters.put("sign", sign); corpPayRequest.setSign(WXSignUtils.createSign("UTF-8", parameters, mchKey)); parameters.put("sign", corpPayRequest.getSign()); String xmlInfo = HttpXmlUtils.transferXml(parameters); try { CloseableHttpResponse response = HttpUtil.Post(CORP_PAY_URL, xmlInfo, true, certPath, corpPayRequest.getMchid()); String transfersXml = EntityUtils.toString(response.getEntity(), "utf-8"); // System.out.println("渠道端企业付款:" + transfersXml); Map<String, String> transferMap = HttpXmlUtils.parseRefundXml(transfersXml); System.out.println("渠道端企业付款:" + transfersXml); //Map<String, String> transferMap = HttpXmlUtils.parseRefundXml(transfersXml); Map<String,Object> transferMap = XMLUtil.doXMLParse(transfersXml); // 将 Map 转换为 实体类 corpPayResponse = JSON.parseObject(JSON.toJSONString(transferMap),CorpPayResponse.class); } catch (Exception e) {