|
|
@@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* 转发中台接口
|
|
|
*
|
|
|
@@ -38,6 +40,27 @@ public class PayXwService {
|
|
|
log.info("{} 返回值->{}", payXwEnum.getDesc(), sync);
|
|
|
return sync;
|
|
|
}
|
|
|
+ private String jsonGetHttp(PayXwEnum payXwEnum, Object object) {
|
|
|
+ String para = object instanceof JSONObject jsonObject ? jsonObject.toJSONString() : JSONObject.toJSONString(object);
|
|
|
+ log.info("{} 入参->{}", payXwEnum.getDesc(), para);
|
|
|
+ OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(xwAddress + payXwEnum.getAddr());
|
|
|
+ JSONObject jsonObject = object instanceof JSONObject source ? source : JSONObject.from(object);
|
|
|
+ for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
|
|
+ if (entry.getValue() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ okHttpUtils.addPara(entry.getKey(), String.valueOf(entry.getValue()));
|
|
|
+ }
|
|
|
+ String sync;
|
|
|
+ try {
|
|
|
+ sync = okHttpUtils.get().sync();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新网服务异常", e.getCause());
|
|
|
+ throw new RuntimeException("支付服务异常!");
|
|
|
+ }
|
|
|
+ log.info("{} 返回值->{}", payXwEnum.getDesc(), sync);
|
|
|
+ return sync;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 创建用户
|
|
|
@@ -51,7 +74,7 @@ public class PayXwService {
|
|
|
}
|
|
|
|
|
|
public R<UserDetailDto> account(UserInfo userInfo) {
|
|
|
- String sync = jsonHttp(PayXwEnum.ACCOUNT, userInfo);
|
|
|
+ String sync = jsonGetHttp(PayXwEnum.ACCOUNT, userInfo);
|
|
|
return JSONObject.parseObject(sync, new TypeReference<>() {
|
|
|
});
|
|
|
}
|