From e75b54b2db44d0096fc8afddc39f6fc8c40e6786 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期六, 19 十一月 2022 14:54:35 +0800
Subject: [PATCH] 优化 支付
---
service-api/src/main/java/com/java110/api/smo/payment/adapt/fuiouPay/FuiouOweFeeToNotifyAdapt.java | 56 ++++++++++++++++++++++----------------------------------
1 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/smo/payment/adapt/fuiouPay/FuiouOweFeeToNotifyAdapt.java b/service-api/src/main/java/com/java110/api/smo/payment/adapt/fuiouPay/FuiouOweFeeToNotifyAdapt.java
index 49958a6..9d5f559 100644
--- a/service-api/src/main/java/com/java110/api/smo/payment/adapt/fuiouPay/FuiouOweFeeToNotifyAdapt.java
+++ b/service-api/src/main/java/com/java110/api/smo/payment/adapt/fuiouPay/FuiouOweFeeToNotifyAdapt.java
@@ -17,6 +17,8 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.java110.api.smo.DefaultAbstractComponentSMO;
+import com.java110.core.factory.CommunitySettingFactory;
import com.java110.core.factory.WechatFactory;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.smallWeChat.SmallWeChatDto;
@@ -30,7 +32,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;
@@ -38,6 +40,8 @@
import org.springframework.web.client.RestTemplate;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
/**
@@ -58,7 +62,7 @@
*/
@Component(value = "fuiouOweFeeToNotifyAdapt")
-public class FuiouOweFeeToNotifyAdapt implements IOweFeeToNotifyAdapt {
+public class FuiouOweFeeToNotifyAdapt extends DefaultAbstractComponentSMO implements IOweFeeToNotifyAdapt {
private static final Logger logger = LoggerFactory.getLogger(FuiouOweFeeToNotifyAdapt.class);
@@ -123,18 +127,22 @@
}
String orderId = map.get("out_trade_no").toString();
+ String orderPre = CommunitySettingFactory.getValue(smallWeChatDto.getObjId(), "FUIOU_ORDER_PRE");
+ orderId = orderId.substring(orderPre.length());
String order = CommonCache.getAndRemoveValue(FeeDto.REDIS_PAY_OWE_FEE + orderId);
if (StringUtil.isEmpty(order)) {
return 1;// 璇存槑宸茬粡澶勭悊杩囦簡 鍐嶄笉澶勭悊
}
+
+
//鏌ヨ鐢ㄦ埛ID
JSONObject paramIn = JSONObject.parseObject(order);
paramIn.put("oId", orderId);
freshFees(paramIn);
- String url = ServiceConstant.SERVICE_API_URL + "/api/fee.payOweFee";
- responseEntity = this.callCenterService(restTemplate, "-1", paramIn.toJSONString(), url, HttpMethod.POST);
+ String url = "fee.payOweFee";
+ responseEntity = this.callCenterService(getHeaders("-1"), paramIn.toJSONString(), url, HttpMethod.POST);
if (responseEntity.getStatusCode() != HttpStatus.OK) {
return 0;
@@ -162,42 +170,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", "",
- ServiceConstant.SERVICE_API_URL + "/api/smallWeChat.listSmallWeChats?appId="
+ responseEntity = this.callCenterService(getHeaders("-1"), "",
+ "smallWeChat.listSmallWeChats?appId="
+ appId + "&page=1&row=1", HttpMethod.GET);
if (responseEntity.getStatusCode() != HttpStatus.OK) {
--
Gitblit v1.8.0