| | |
| | | tradePayOffData.setPaymentInfos(paymentInfoRequests); |
| | | List<GoodsInfo> goodsInfo = new ArrayList<>(); |
| | | GoodsInfo goodsInfo1 = new GoodsInfo(); |
| | | goodsInfo1.setMerchantCode("B00000905"); |
| | | goodsInfo1.setCustId("CB0000004686"); |
| | | goodsInfo1.setCustName("证联消费平台交易客户"); |
| | | goodsInfo1.setMerchantCode("prod".equals(qianYunTongConfig.getActiveProfile()) ? "B00001404" : "B00000905"); |
| | | goodsInfo1.setCustId("prod".equals(qianYunTongConfig.getActiveProfile()) ? "CB0000004853" : "CB0000004686"); |
| | | goodsInfo1.setCustName("prod".equals(qianYunTongConfig.getActiveProfile()) ? "黔南云码通数字产业运营有限公司" : "证联消费平台交易客户"); |
| | | goodsInfo1.setBusinessType("10408"); |
| | | goodsInfo1.setAgreementNo("prod".equals(qianYunTongConfig.getActiveProfile()) ? "00000402485377063581755054680461" : "00000000468618354161754464398681"); |
| | | goodsInfo1.setProfitSharing("1"); |
| | |
| | | request.setMhltiCenterAppId("52270015"); |
| | | request.setPayType(4); |
| | | request.setPayChannel(6); |
| | | request.setIsCompensate(1); |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/paymentOrder"; |
| | | //私钥文件 |
| | |
| | | OrderInfo orderInfo = jsonObject.getObject("busiResp", OrderInfo.class); |
| | | return orderInfo; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单退款 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static TradeOrderRefund tradeOrderRefund(TradeOrderRefundRequest request) { |
| | | request.setPayPartnerId("prod".equals(qianYunTongConfig.getActiveProfile()) ? "5400004" : "5401007"); |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/tradeOrderRefund"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath(); |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = qianYunTongConfig.getAppkey();//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUIDUtil.getRandomCode(); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName()); |
| | | contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus()); |
| | | contentMap.put("content", new Gson().toJson(request)); |
| | | log.info("【订单退款】请求地址:" + url); |
| | | log.info("【订单退款】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【订单退款】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String resCode = jsonObject.getString("resCode"); |
| | | if (!"000000".equals(resCode)) { |
| | | log.error("【订单退款】失败:" + jsonObject.getString("resMsg")); |
| | | throw new RuntimeException("【订单退款】失败:" + jsonObject.getString("resMsg")); |
| | | } |
| | | JSONObject refundInfo = jsonObject.getJSONObject("busiResp").getJSONObject("refundInfo"); |
| | | String retCode = refundInfo.getString("retCode"); |
| | | if(!"".equals(retCode)){ |
| | | log.error("【订单退款】失败:" + refundInfo.getString("retMsg")); |
| | | throw new RuntimeException("【订单退款】失败:" + refundInfo.getString("retMsg")); |
| | | } |
| | | TradeOrderRefund tradeOrderRefund = refundInfo.getObject("data", TradeOrderRefund.class); |
| | | return tradeOrderRefund; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 订单退款通知 |
| | | * @param request |
| | | */ |
| | | public static void orderRefundNotice(OrderRefundNoticeRequest request) { |
| | | request.setScene("TRAFFIC"); |
| | | request.setMhltiCenterAppId("52270015"); |
| | | |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/orderRefundNotice"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath(); |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = qianYunTongConfig.getAppkey();//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUIDUtil.getRandomCode(); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName()); |
| | | contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus()); |
| | | contentMap.put("content", new Gson().toJson(request)); |
| | | log.info("【订单退款通知】请求地址:" + url); |
| | | log.info("【订单退款通知】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【订单退款通知】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String resCode = jsonObject.getString("resCode"); |
| | | if (!"000000".equals(resCode)) { |
| | | log.error("【订单退款通知】失败:" + jsonObject.getString("resMsg")); |
| | | throw new RuntimeException("【订单退款通知】失败:" + jsonObject.getString("resMsg")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单取消 |
| | | * @param orderId |
| | | */ |
| | | public static void tradeOrderCancel(String orderId) { |
| | | TradeOrderCancelRequest request = new TradeOrderCancelRequest(); |
| | | request.setScene("TRAFFIC"); |
| | | request.setMhltiCenterAppId("52270015"); |
| | | request.setOrderId(orderId); |
| | | |
| | | //请求路径 |
| | | String url = qianYunTongConfig.getApiUrl() + "/openapi/rest/1.0/tradeOrderCancel"; |
| | | //私钥文件 |
| | | String skprivateKeyFile = qianYunTongConfig.getPrivateKeyPath(); |
| | | //注意:私钥文件需要开发者手动新建.pem文件,将委办局提供的私钥串复制进文件里用于sign加密 |
| | | String appKey = qianYunTongConfig.getAppkey();//appkey |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Content-Type", "application/json"); |
| | | Map<String, Object> contentMap = new HashMap<String, Object>(); |
| | | Date nowdate = new Date(); |
| | | SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss"); |
| | | |
| | | String timeStamp = date.format(nowdate); |
| | | String messageId = UUIDUtil.getRandomCode(); |
| | | contentMap.put(SystemParameterNames.getAppKey(), appKey); |
| | | contentMap.put(SystemParameterNames.getMessage_id(), messageId); |
| | | contentMap.put(SystemParameterNames.getUserName(), qianYunTongConfig.getUserName()); |
| | | contentMap.put(SystemParameterNames.getStatus(), qianYunTongConfig.getStatus()); |
| | | contentMap.put("content", new Gson().toJson(request)); |
| | | log.info("【订单取消】请求地址:" + url); |
| | | log.info("【订单取消】请求参数:" + JSON.toJSONString(contentMap)); |
| | | String result = OpenApiClient.sendCommonHttpRequst(url, headers, "POST", skprivateKeyFile, timeStamp, contentMap); |
| | | log.info("【订单取消】请求结果:" + result); |
| | | JSONObject jsonObject = JSON.parseObject(result); |
| | | String resCode = jsonObject.getString("resCode"); |
| | | if (!"000000".equals(resCode)) { |
| | | log.error("【订单取消】失败:" + jsonObject.getString("resMsg")); |
| | | throw new RuntimeException("【订单取消】失败:" + jsonObject.getString("resMsg")); |
| | | } |
| | | } |
| | | } |