|
@@ -50,6 +50,8 @@ public class WithdrawSdk {
|
|
|
//结算第三方url
|
|
|
@Value("${withdraw.apiUrl}")
|
|
|
private String apiUrl;
|
|
|
+ @Value("${withdraw.privateKey}")
|
|
|
+ private String privateKey;
|
|
|
|
|
|
/**
|
|
|
* 签署协议
|
|
@@ -243,4 +245,40 @@ public class WithdrawSdk {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商户余额(单位为:分,范围:1~10000000000)
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String balanceQuery(){
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ requestMap.put("outMemberNo", memberNo);
|
|
|
+ requestMap.put("charset", "UTF-8");
|
|
|
+ requestMap.put("service", "bpotop.zx.pay.order");
|
|
|
+ requestMap.put("version", "2.0");
|
|
|
+ requestMap.put("signType", "RSA");
|
|
|
+
|
|
|
+ String jsonStr = JSONObject.toJSONString(requestMap);
|
|
|
+ String encryptStr = null;
|
|
|
+ try {
|
|
|
+ encryptStr = RSA.encryptPub(jsonStr, publicKey);
|
|
|
+ requestMap.put("sign", encryptStr);
|
|
|
+ logger.info("查询余额请求参数:{}", requestMap);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ThirdpartyException("加密失败:{}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ String resultJsonStr = null;
|
|
|
+ try {
|
|
|
+ resultJsonStr = HttpUtil.postForHttp(apiUrl + "/bpotop_trade/balance_query", JSONObject.toJSONString(requestMap), null);
|
|
|
+ logger.info("查询余额响应参数:{}", resultJsonStr);
|
|
|
+
|
|
|
+ String decryptStr = RSA.decryptPri(resultJsonStr, privateKey);
|
|
|
+ Map stringToMap = JSONObject.parseObject(decryptStr);
|
|
|
+ return String.valueOf(stringToMap.get("balance"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|