From 7b0e7c62dab0061d2aa167b46f8a838f363f579a Mon Sep 17 00:00:00 2001
From: 1098226878@qq.com <1098226878@qq.com>
Date: 星期一, 17 一月 2022 17:02:55 +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/WechatOweFeeToNotifyAdapt.java | 45 +++++++++++++--------------------------------
1 files changed, 13 insertions(+), 32 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatOweFeeToNotifyAdapt.java b/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatOweFeeToNotifyAdapt.java
index d4bccae..d4317a2 100644
--- a/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatOweFeeToNotifyAdapt.java
+++ b/service-api/src/main/java/com/java110/api/smo/payment/adapt/wechatPay/WechatOweFeeToNotifyAdapt.java
@@ -17,6 +17,7 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.java110.api.smo.DefaultAbstractComponentSMO;
import com.java110.core.factory.WechatFactory;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.smallWeChat.SmallWeChatDto;
@@ -30,7 +31,7 @@
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;
@@ -47,7 +48,7 @@
*/
@Component(value = "wechatOweFeeToNotifyAdapt")
-public class WechatOweFeeToNotifyAdapt implements IOweFeeToNotifyAdapt {
+public class WechatOweFeeToNotifyAdapt extends DefaultAbstractComponentSMO implements IOweFeeToNotifyAdapt {
private static final Logger logger = LoggerFactory.getLogger(WechatOweFeeToNotifyAdapt.class);
@@ -141,7 +142,7 @@
paramIn.put("oId", orderId);
freshFees(paramIn);
String url = "fee.payOweFee";
- 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;
@@ -168,42 +169,22 @@
}
- /**
- * 璋冪敤涓績鏈嶅姟
- *
- * @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(), "");
- header.add("Content-Type", "application/json");
- 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;
}
-
private SmallWeChatDto getSmallWechat(String appId) {
ResponseEntity responseEntity = null;
- responseEntity = this.callCenterService(restTemplate, "-1", "",
+ responseEntity = this.callCenterService(getHeaders("-1"), "",
"smallWeChat.listSmallWeChats?appId="
+ appId + "&page=1&row=1", HttpMethod.GET);
--
Gitblit v1.8.0