From 2b919980a8c70554a64cb3d03cc95679af4d817f Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期一, 03 七月 2023 00:22:16 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity
---
service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatRentingToNotifyAdapt.java | 76 +++++++++++++++++++++-----------------
1 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatRentingToNotifyAdapt.java b/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatRentingToNotifyAdapt.java
index e49bff8..6556cbb 100644
--- a/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatRentingToNotifyAdapt.java
+++ b/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatRentingToNotifyAdapt.java
@@ -16,22 +16,21 @@
package com.java110.api.smo.payment.adapt.wechatPay;
import com.alibaba.fastjson.JSONObject;
-import com.java110.dto.rentingPool.RentingPoolDto;
-import com.java110.dto.smallWeChat.SmallWeChatDto;
+import com.java110.api.smo.DefaultAbstractComponentSMO;
+import com.java110.dto.renting.RentingPoolDto;
+import com.java110.dto.wechat.SmallWeChatDto;
import com.java110.api.properties.WechatAuthProperties;
import com.java110.api.smo.payment.adapt.IPayNotifyAdapt;
import com.java110.utils.cache.CommonCache;
import com.java110.utils.constant.CommonConstant;
-import com.java110.utils.constant.ServiceConstant;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.PayUtil;
import com.java110.utils.util.StringUtil;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
-import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import java.util.*;
@@ -44,7 +43,7 @@
*/
@Component(value = "wechatRentingToNotifyAdapt")
-public class WechatRentingToNotifyAdapt implements IPayNotifyAdapt {
+public class WechatRentingToNotifyAdapt extends DefaultAbstractComponentSMO implements IPayNotifyAdapt {
private static final Logger logger = LoggerFactory.getLogger(WechatRentingToNotifyAdapt.class);
@@ -133,7 +132,7 @@
JSONObject paramIn = JSONObject.parseObject(order);
paramIn.put("oId", orderId);
String url = "fee.rentingPayFeeConfirm";
- responseEntity = this.callCenterService(restTemplate, "-1", paramIn.toJSONString(), url, HttpMethod.POST);
+ responseEntity = this.callCenterService(getHeaders("-1"), paramIn.toJSONString(), url, HttpMethod.POST);
if (responseEntity.getStatusCode() != HttpStatus.OK) {
return 0;
@@ -141,33 +140,42 @@
return 1;
}
-
- /**
- * 璋冪敤涓績鏈嶅姟
- *
- * @return
- */
- protected ResponseEntity<String> callCenterService(RestTemplate restTemplate, String userId, String param, String url, HttpMethod httpMethod) {
-
- ResponseEntity<String> responseEntity = null;
- HttpHeaders header = new HttpHeaders();
- header.add(CommonConstant.HTTP_APP_ID.toLowerCase(), APP_ID);
- header.add(CommonConstant.HTTP_USER_ID.toLowerCase(), userId);
- header.add(CommonConstant.HTTP_TRANSACTION_ID.toLowerCase(), UUID.randomUUID().toString());
- header.add(CommonConstant.HTTP_REQ_TIME.toLowerCase(), DateUtil.getDefaultFormateTimeString(new Date()));
- header.add(CommonConstant.HTTP_SIGN.toLowerCase(), "");
- HttpEntity<String> httpEntity = new HttpEntity<String>(param, header);
- //logger.debug("璇锋眰涓績鏈嶅姟淇℃伅锛寋}", httpEntity);
- try {
- responseEntity = restTemplate.exchange(url, httpMethod, httpEntity, String.class);
- } catch (HttpStatusCodeException e) { //杩欓噷spring 妗嗘灦 鍦�4XX 鎴� 5XX 鏃舵姏鍑� HttpServerErrorException 寮傚父锛岄渶瑕侀噸鏂板皝瑁呬竴涓�
- responseEntity = new ResponseEntity<String>(e.getResponseBodyAsString(), e.getStatusCode());
- } catch (Exception e) {
- responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
- } finally {
- logger.debug("璇锋眰鍦板潃涓�,{} 璇锋眰涓績鏈嶅姟淇℃伅锛寋},涓績鏈嶅姟杩斿洖淇℃伅锛寋}", url, httpEntity, responseEntity);
- }
- return responseEntity;
+ private Map<String, String> getHeaders(String userId) {
+ Map<String, String> headers = new HashMap<>();
+ headers.put(CommonConstant.HTTP_APP_ID.toLowerCase(), APP_ID);
+ headers.put(CommonConstant.HTTP_USER_ID.toLowerCase(), userId);
+ headers.put(CommonConstant.HTTP_TRANSACTION_ID.toLowerCase(), UUID.randomUUID().toString());
+ headers.put(CommonConstant.HTTP_REQ_TIME.toLowerCase(), DateUtil.getDefaultFormateTimeString(new Date()));
+ headers.put(CommonConstant.HTTP_SIGN.toLowerCase(), "");
+ return headers;
}
+// /**
+// * 璋冪敤涓績鏈嶅姟
+// *
+// * @return
+// */
+// protected ResponseEntity<String> callCenterService(RestTemplate restTemplate, String userId, String param, String url, HttpMethod httpMethod) {
+//
+// ResponseEntity<String> responseEntity = null;
+// HttpHeaders header = new HttpHeaders();
+// header.add(CommonConstant.HTTP_APP_ID.toLowerCase(), APP_ID);
+// header.add(CommonConstant.HTTP_USER_ID.toLowerCase(), userId);
+// header.add(CommonConstant.HTTP_TRANSACTION_ID.toLowerCase(), UUID.randomUUID().toString());
+// header.add(CommonConstant.HTTP_REQ_TIME.toLowerCase(), DateUtil.getDefaultFormateTimeString(new Date()));
+// header.add(CommonConstant.HTTP_SIGN.toLowerCase(), "");
+// HttpEntity<String> httpEntity = new HttpEntity<String>(param, header);
+// //logger.debug("璇锋眰涓績鏈嶅姟淇℃伅锛寋}", httpEntity);
+// try {
+// responseEntity = restTemplate.exchange(url, httpMethod, httpEntity, String.class);
+// } catch (HttpStatusCodeException e) { //杩欓噷spring 妗嗘灦 鍦�4XX 鎴� 5XX 鏃舵姏鍑� HttpServerErrorException 寮傚父锛岄渶瑕侀噸鏂板皝瑁呬竴涓�
+// responseEntity = new ResponseEntity<String>(e.getResponseBodyAsString(), e.getStatusCode());
+// } catch (Exception e) {
+// responseEntity = new ResponseEntity<String>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+// } finally {
+// logger.debug("璇锋眰鍦板潃涓�,{} 璇锋眰涓績鏈嶅姟淇℃伅锛寋},涓績鏈嶅姟杩斿洖淇℃伅锛寋}", url, httpEntity, responseEntity);
+// }
+// return responseEntity;
+// }
+
}
--
Gitblit v1.8.0