Просмотр исходного кода

Merge branch 'dev-xcq' into dev

# Conflicts:
#	sckw-modules-api/pom.xml
xucaiqin 2 лет назад
Родитель
Сommit
a5314aceea
17 измененных файлов с 696 добавлено и 2 удалено
  1. 4 0
      sckw-common/sckw-common-core/pom.xml
  2. 4 1
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/BusinessException.java
  3. 405 0
      sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/OkHttpUtils.java
  4. 25 0
      sckw-common/sckw-common-remote/src/main/java/com/sckw/remote/config/AllowClassList.java
  5. 32 0
      sckw-common/sckw-common-remote/src/main/java/com/sckw/remote/constant/DubboAllow.java
  6. 89 0
      sckw-common/sckw-common-remote/src/main/java/com/sckw/remote/filter/DubboExceptionFilter.java
  7. 1 0
      sckw-common/sckw-common-remote/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
  8. 1 0
      sckw-common/sckw-common-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  9. 1 0
      sckw-modules-api/pom.xml
  10. 22 0
      sckw-modules-api/sckw-payment-api/pom.xml
  11. 15 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PayCenterDubboService.java
  12. 14 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/ChannelEnum.java
  13. 16 0
      sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/MemberDetail.java
  14. 4 1
      sckw-modules/sckw-example/pom.xml
  15. 29 0
      sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java
  16. 5 0
      sckw-modules/sckw-payment/pom.xml
  17. 29 0
      sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PayCenterServiceImpl.java

+ 4 - 0
sckw-common/sckw-common-core/pom.xml

@@ -170,5 +170,9 @@
             <artifactId>mybatis-plus-extension</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+        </dependency>
     </dependencies>
 </project>

+ 4 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/exception/BusinessException.java

@@ -2,6 +2,8 @@ package com.sckw.core.exception;
 
 import lombok.Getter;
 
+import java.io.Serial;
+
 /**
  * @Author yzc
  * @Description 自定义业务异常
@@ -9,7 +11,8 @@ import lombok.Getter;
  */
 @Getter
 public class BusinessException extends RuntimeException {
-
+    @Serial
+    private static final long serialVersionUID = 4515565480123536390L;
     /**
      * 异常信息
      **/

+ 405 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/OkHttpUtils.java

@@ -0,0 +1,405 @@
+package com.sckw.core.utils;
+
+import com.alibaba.fastjson2.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.commons.lang3.StringUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.util.CollectionUtils;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author xcq
+ * @date 2023-02-21 10:42:20
+ **/
+@Slf4j
+public class OkHttpUtils {
+    private static volatile OkHttpClient okHttpClient = null;
+    private static volatile Semaphore semaphore = null;
+    private Map<String, String> headerMap;
+    private Map<String, String> paraMap;
+    private Map<String, String> bodyParaMap;
+    //json字符串
+    private String bodyParaString;
+    private String url;
+    private Request.Builder request;
+
+    /**
+     * 初始化okHttpClient,并且允许https访问
+     */
+    private OkHttpUtils() {
+        if (okHttpClient == null) {
+            synchronized (OkHttpUtils.class) {
+                if (okHttpClient == null) {
+                    TrustManager[] trustManagers = buildTrustManagers();
+                    okHttpClient = new OkHttpClient.Builder()
+                            .connectTimeout(15, TimeUnit.SECONDS)
+                            .writeTimeout(20, TimeUnit.SECONDS)
+                            .readTimeout(20, TimeUnit.SECONDS)
+                            .sslSocketFactory(createSSLSocketFactory(trustManagers), (X509TrustManager) trustManagers[0])
+                            .hostnameVerifier((hostName, session) -> true)
+                            .retryOnConnectionFailure(true)
+                            .build();
+                    addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36");
+                }
+            }
+        }
+    }
+
+    /**
+     * 用于异步请求时,控制访问线程数,返回结果
+     *
+     * @return
+     */
+    private static Semaphore getSemaphoreInstance() {
+        //只能1个线程同时访问
+        synchronized (OkHttpUtils.class) {
+            if (semaphore == null) {
+                semaphore = new Semaphore(0);
+            }
+        }
+        return semaphore;
+    }
+
+    /**
+     * 创建OkHttpUtils
+     *
+     * @return
+     */
+    public static OkHttpUtils builder() {
+        return new OkHttpUtils();
+    }
+
+    /**
+     * 添加url
+     *
+     * @param url
+     * @return
+     */
+    public OkHttpUtils url(String url) {
+        this.url = url;
+        return this;
+    }
+
+    /**
+     * 添加参数
+     *
+     * @param key   参数名
+     * @param value 参数值
+     * @return
+     */
+    public OkHttpUtils addPara(String key, String value) {
+        if (paraMap == null) {
+            paraMap = new LinkedHashMap<>(16);
+        }
+        paraMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * 添加参数
+     *
+     * @param key   参数名
+     * @param value 参数值
+     * @return
+     */
+    public OkHttpUtils addBodyPara(String key, String value) {
+        if (bodyParaMap == null) {
+            bodyParaMap = new LinkedHashMap<>(16);
+        }
+        bodyParaMap.put(key, value);
+        return this;
+    }
+
+    public OkHttpUtils addBodyJsonStr(String string) {
+        bodyParaString = string;
+        return this;
+    }
+
+    /**
+     * 添加请求头
+     *
+     * @param key   参数名
+     * @param value 参数值
+     * @return
+     */
+    public OkHttpUtils addHeader(String key, String value) {
+        if (headerMap == null) {
+            headerMap = new LinkedHashMap<>(16);
+        }
+        headerMap.put(key, value);
+        return this;
+    }
+
+    /**
+     * 初始化get方法
+     *
+     * @return
+     */
+    public OkHttpUtils get() {
+        request = new Request.Builder().get();
+        request.url(buildUrl());
+        return this;
+    }
+
+    /**
+     * 初始化post方法
+     */
+    public OkHttpUtils postForm(JSONObject object, byte[] file) {
+        MultipartBody.Builder formBody = new MultipartBody.Builder();
+        formBody.setType(MultipartBody.FORM);
+
+        for (String s : object.keySet()) {
+            formBody.addFormDataPart(s, StringUtils.isBlank(object.getString(s)) ? "" : object.getString(s));
+        }
+        String fileName = UUIDUtils.get32UUID() + ".zip";
+        log.info("文件名:{}", fileName);
+        formBody.addFormDataPart("file", fileName, RequestBody.create(file));
+
+        RequestBody requestBody = formBody.build();
+        // params参数
+        request = new Request.Builder().post(requestBody).url(buildUrl());
+        return this;
+    }
+
+    /**
+     * 初始化post方法
+     *
+     * @param isJsonPost true等于json的方式提交数据,类似postman里post方法的raw
+     *                   false等于普通的表单提交
+     * @return
+     */
+    public OkHttpUtils post(boolean isJsonPost) {
+        RequestBody requestBody;
+        if (isJsonPost) {
+            String json;
+            if (StringUtils.isNotBlank(bodyParaString)) {
+                json = bodyParaString;
+            } else if (!CollectionUtils.isEmpty(bodyParaMap)) {
+                json = JSONObject.toJSONString(bodyParaMap);
+            } else {
+                json = "{}";
+            }
+            requestBody = RequestBody.create(json, MediaType.parse("application/json; charset=utf-8"));
+        } else {
+            FormBody.Builder formBody = new FormBody.Builder();
+            if (bodyParaMap != null) {
+                bodyParaMap.forEach(formBody::add);
+            }
+            requestBody = formBody.build();
+        }
+        // params参数
+        request = new Request.Builder().post(requestBody).url(buildUrl());
+        return this;
+    }
+
+    private String buildUrl() {
+        StringBuilder urlBuilder = new StringBuilder(url);
+        if (paraMap != null) {
+            urlBuilder.append("?");
+            try {
+                for (Map.Entry<String, String> entry : paraMap.entrySet()) {
+                    urlBuilder.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8)).
+                            append("=").
+                            append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8)).
+                            append("&");
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            urlBuilder.deleteCharAt(urlBuilder.length() - 1);
+        }
+        return urlBuilder.toString();
+    }
+
+    /**
+     * 文件下载同步请求
+     *
+     * @return
+     */
+    public byte[] fileSync() {
+        setHeader(request);
+        try {
+            Response response = okHttpClient.newCall(request.build()).execute();
+            if (response.isSuccessful()) {
+                assert response.body() != null;
+                return response.body().bytes();
+            }
+            return new byte[0];
+        } catch (IOException e) {
+            e.printStackTrace();
+            return new byte[0];
+        }
+    }
+
+    /**
+     * 同步请求
+     *
+     * @return
+     */
+    public String sync() {
+        setHeader(request);
+        try {
+            Response response = okHttpClient.newCall(request.build()).execute();
+            assert response.body() != null;
+            return response.body().string();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return "请求失败:" + e.getMessage();
+        }
+    }
+
+    /**
+     * 异步请求,有返回值
+     */
+    public String async() {
+        StringBuilder buffer = new StringBuilder("");
+        setHeader(request);
+        okHttpClient.newCall(request.build()).enqueue(new Callback() {
+            @Override
+            public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+                assert response.body() != null;
+                buffer.append(response.body().string());
+                getSemaphoreInstance().release();
+            }
+            @Override
+            public void onFailure(@NotNull Call call, @NotNull IOException e) {
+                buffer.append("请求出错:").append(e.getMessage());
+
+            }
+        });
+        try {
+            getSemaphoreInstance().acquire();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        return buffer.toString();
+    }
+
+    /**
+     * 异步请求,带有接口回调
+     *
+     * @param callBack
+     */
+    public void async(ICallBack callBack) {
+        setHeader(request);
+        okHttpClient.newCall(request.build()).enqueue(new Callback() {
+
+            @Override
+            public void onFailure(@NotNull Call call,@NotNull  IOException e) {
+                callBack.onFailure(call, e.getMessage());
+            }
+
+            @Override
+            public void onResponse(Call call, Response response) throws IOException {
+                assert response.body() != null;
+                callBack.onSuccessful(call, response.body().string());
+            }
+        });
+    }
+
+    /**
+     * 为request添加请求头
+     *
+     * @param request
+     */
+    private void setHeader(Request.Builder request) {
+        if (headerMap != null) {
+            try {
+                for (Map.Entry<String, String> entry : headerMap.entrySet()) {
+                    request.addHeader(entry.getKey(), entry.getValue());
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    /**
+     * 生成安全套接字工厂,用于https请求的证书跳过
+     *
+     * @return
+     */
+    private static SSLSocketFactory createSSLSocketFactory(TrustManager[] trustAllCerts) {
+        SSLSocketFactory ssfFactory = null;
+        try {
+            SSLContext sc = SSLContext.getInstance("SSL");
+            sc.init(null, trustAllCerts, new SecureRandom());
+            ssfFactory = sc.getSocketFactory();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return ssfFactory;
+    }
+
+    private static TrustManager[] buildTrustManagers() {
+        return new TrustManager[]{
+                new X509TrustManager() {
+                    @Override
+                    public void checkClientTrusted(X509Certificate[] chain, String authType) {
+                    }
+
+                    @Override
+                    public void checkServerTrusted(X509Certificate[] chain, String authType) {
+                    }
+
+                    @Override
+                    public X509Certificate[] getAcceptedIssuers() {
+                        return new X509Certificate[]{};
+                    }
+                }
+        };
+    }
+
+    /**
+     * 自定义一个接口回调
+     */
+    public interface ICallBack {
+
+        void onSuccessful(Call call, String data);
+
+        void onFailure(Call call, String errorMsg);
+
+    }
+
+
+    /**
+     * 使用示例
+     *
+     * @param args
+     * @author xcq
+     * @date 2023-02-21 10:47:28
+     **/
+    public static void main(String[] args) {
+        String address = "https://file.cloudpnr.com/app-86820a0f-8b13-479b-a466-b261af7290d5%2Fsaturnfile%2F48cf909816b142e5beec68988c1982b1%2F39189ab6-fac3-11ed-9690-0242ac110002.zip?Expires=1685254390&OSSAccessKeyId=LTAI6Yzq9tIYS57h&Signature=oNyqey777CjDk0IH5ZaniwTAdfg%3D";
+        byte[] file = OkHttpUtils.builder().url(address)
+                .get()
+                .fileSync();
+        /*通知中台*/
+        JSONObject tmp = new JSONObject();
+        tmp.put("status", StringUtils.equals("00000000", "00000000") ? "true" : "false");
+        tmp.put("msg", "");
+        log.info("交易确认异步通知中台入参:{}", tmp.toJSONString());
+
+        String sync = OkHttpUtils.builder().url("http://10.10.10.241:9505/notice/huifu/signal_agent_pay/S520267896211968001/00dd5d5dd4682ea3fad88a37ab48223a")
+                .postForm(tmp, file)
+                .sync();
+        log.info("交易确认异步通知中台返回->{}", sync);
+
+
+    }
+}

+ 25 - 0
sckw-common/sckw-common-remote/src/main/java/com/sckw/remote/config/AllowClassList.java

@@ -0,0 +1,25 @@
+package com.sckw.remote.config;
+
+import com.sckw.remote.constant.DubboAllow;
+import jakarta.annotation.PostConstruct;
+import org.apache.dubbo.common.utils.SerializeSecurityManager;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+import org.springframework.stereotype.Component;
+
+/**
+ * dubbo接口放行处理
+ *
+ * @author xucaiqin
+ */
+@Component
+public class AllowClassList {
+    @PostConstruct
+    public void init() {
+        SerializeSecurityManager serializeSecurityManager = FrameworkModel.defaultModel().getBeanFactory().getBean(SerializeSecurityManager.class);
+        for (String s : DubboAllow.getPacks()) {
+            serializeSecurityManager.addToAllowed(s);
+        }
+
+    }
+
+}

+ 32 - 0
sckw-common/sckw-common-remote/src/main/java/com/sckw/remote/constant/DubboAllow.java

@@ -0,0 +1,32 @@
+package com.sckw.remote.constant;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author xucaiqin
+ */
+public enum DubboAllow {
+    EXCEPTION("com.sckw.core.exception", "异常放行包");
+    private final String pack;
+    private final String desc;
+
+    DubboAllow(String pack, String desc) {
+        this.pack = pack;
+        this.desc = desc;
+    }
+
+    public String getPack() {
+        return pack;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public static List<String> getPacks() {
+        return Arrays.stream(DubboAllow.values()).map(DubboAllow::getPack).toList();
+    }
+
+
+}

+ 89 - 0
sckw-common/sckw-common-remote/src/main/java/com/sckw/remote/filter/DubboExceptionFilter.java

@@ -0,0 +1,89 @@
+package com.sckw.remote.filter;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.ReflectUtils;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.rpc.*;
+import org.apache.dubbo.rpc.filter.ExceptionFilter;
+import org.apache.dubbo.rpc.service.GenericService;
+
+import java.lang.reflect.Method;
+
+import static org.apache.dubbo.common.constants.LoggerCodeConstants.CONFIG_FILTER_VALIDATION_EXCEPTION;
+
+@Activate(group = CommonConstants.PROVIDER)
+public class DubboExceptionFilter implements Filter, Filter.Listener {
+    private ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(ExceptionFilter.class);
+
+    @Override
+    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
+        return invoker.invoke(invocation);
+    }
+
+    @Override
+    public void onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation) {
+        if (appResponse.hasException() && GenericService.class != invoker.getInterface()) {
+            try {
+                Throwable exception = appResponse.getException();
+
+                // directly throw if it's checked exception
+                if (!(exception instanceof RuntimeException) && (exception instanceof Exception)) {
+                    return;
+                }
+                // directly throw if the exception appears in the signature
+                try {
+                    Method method = invoker.getInterface().getMethod(invocation.getMethodName(), invocation.getParameterTypes());
+                    Class<?>[] exceptionClasses = method.getExceptionTypes();
+                    for (Class<?> exceptionClass : exceptionClasses) {
+                        if (exception.getClass().equals(exceptionClass)) {
+                            return;
+                        }
+                    }
+                } catch (NoSuchMethodException e) {
+                    return;
+                }
+
+                // for the exception not found in method's signature, print ERROR message in server's log.
+                logger.error(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", "Got unchecked and undeclared exception which called by " + RpcContext.getServiceContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + exception.getClass().getName() + ": " + exception.getMessage(), exception);
+
+                // directly throw if exception class and interface class are in the same jar file.
+                String serviceFile = ReflectUtils.getCodeBase(invoker.getInterface());
+                String exceptionFile = ReflectUtils.getCodeBase(exception.getClass());
+                if (serviceFile == null || exceptionFile == null || serviceFile.equals(exceptionFile)) {
+                    return;
+                }
+                // directly throw if it's JDK exception
+                String className = exception.getClass().getName();
+                if (className.startsWith("java.") || className.startsWith("javax.")) {
+                    return;
+                }
+                //自定义异常处理
+                if (className.startsWith("com.sckw.core.exception")) {
+                    return;
+                }
+                // directly throw if it's dubbo exception
+                if (exception instanceof RpcException) {
+                    return;
+                }
+
+                // otherwise, wrap with RuntimeException and throw back to the client
+                appResponse.setException(new RuntimeException(StringUtils.toString(exception)));
+            } catch (Throwable e) {
+                logger.warn(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", "Fail to ExceptionFilter when called by " + RpcContext.getServiceContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e);
+            }
+        }
+    }
+
+    @Override
+    public void onError(Throwable e, Invoker<?> invoker, Invocation invocation) {
+        logger.error(CONFIG_FILTER_VALIDATION_EXCEPTION, "", "", "Got unchecked and undeclared exception which called by " + RpcContext.getServiceContext().getRemoteHost() + ". service: " + invoker.getInterface().getName() + ", method: " + invocation.getMethodName() + ", exception: " + e.getClass().getName() + ": " + e.getMessage(), e);
+    }
+
+    // For test purpose
+    public void setLogger(ErrorTypeAwareLogger logger) {
+        this.logger = logger;
+    }
+}

+ 1 - 0
sckw-common/sckw-common-remote/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter

@@ -0,0 +1 @@
+dubboExceptionFilter=com.sckw.remote.filter.DubboExceptionFilter

+ 1 - 0
sckw-common/sckw-common-remote/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1 @@
+com.sckw.remote.config.AllowClassList

+ 1 - 0
sckw-modules-api/pom.xml

@@ -27,6 +27,7 @@
         <module>sckw-order-api</module>
         <module>sckw-fleet-api</module>
         <module>sckw-contract-api</module>
+        <module>sckw-payment-api</module>
     </modules>
 
     <properties>

+ 22 - 0
sckw-modules-api/sckw-payment-api/pom.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.sckw</groupId>
+        <artifactId>sckw-modules-api</artifactId>
+        <version>1.0.0</version>
+    </parent>
+
+    <artifactId>sckw-payment-api</artifactId>
+    <description>结算api</description>
+
+    <properties>
+        <maven.compiler.source>17</maven.compiler.source>
+        <maven.compiler.target>17</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+
+</project>

+ 15 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/dubbo/PayCenterDubboService.java

@@ -0,0 +1,15 @@
+package com.sckw.payment.api.dubbo;
+
+import com.sckw.payment.api.model.constant.ChannelEnum;
+import com.sckw.payment.api.model.dto.MemberDetail;
+
+public interface PayCenterDubboService {
+    /**
+     * 获取会员详情
+     *
+     * @param uid     中台用户id
+     * @param channel 渠道
+     * @return
+     */
+    MemberDetail memberDetail(String uid, ChannelEnum channel);
+}

+ 14 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/constant/ChannelEnum.java

@@ -0,0 +1,14 @@
+package com.sckw.payment.api.model.constant;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum ChannelEnum {
+    HF("huifu", "汇付渠道"),
+    XS("newpay", "新生渠道"),
+    ZX("citic", "中信渠道");
+    private String channel;
+    private String desc;
+}

+ 16 - 0
sckw-modules-api/sckw-payment-api/src/main/java/com/sckw/payment/api/model/dto/MemberDetail.java

@@ -0,0 +1,16 @@
+package com.sckw.payment.api.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 会员详情
+ */
+@Getter
+@Setter
+public class MemberDetail {
+    private Boolean register;
+    private String uid;
+    private String channel;
+    private Integer status;
+}

+ 4 - 1
sckw-modules/sckw-example/pom.xml

@@ -92,7 +92,10 @@
             <groupId>com.sckw</groupId>
             <artifactId>sckw-order-api</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-payment-api</artifactId>
+        </dependency>
         <!--junit-->
         <dependency>
             <groupId>junit</groupId>

+ 29 - 0
sckw-modules/sckw-example/src/main/java/com/sckw/example/controller/TestController.java

@@ -0,0 +1,29 @@
+package com.sckw.example.controller;
+
+import com.sckw.payment.api.dubbo.PayCenterDubboService;
+import com.sckw.payment.api.model.constant.ChannelEnum;
+import com.sckw.payment.api.model.dto.MemberDetail;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@AllArgsConstructor
+@RestController
+@RequestMapping("/test")
+public class TestController {
+    @DubboReference(version = "2.0.0", group = "design", check = false)
+    PayCenterDubboService payCenterDubboService;
+
+    @GetMapping("/detail")
+    public MemberDetail download(@RequestParam("type") String uid, String channel) {
+        MemberDetail memberDetail = payCenterDubboService.memberDetail(uid, ChannelEnum.HF);
+        return memberDetail;
+    }
+
+
+}

+ 5 - 0
sckw-modules/sckw-payment/pom.xml

@@ -66,6 +66,11 @@
             <groupId>com.sckw</groupId>
             <artifactId>sckw-order-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-payment-api</artifactId>
+        </dependency>
+
     </dependencies>
     <build>
         <plugins>

+ 29 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/dubbo/PayCenterServiceImpl.java

@@ -0,0 +1,29 @@
+package com.sckw.payment.service.dubbo;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.utils.OkHttpUtils;
+import com.sckw.payment.api.dubbo.PayCenterDubboService;
+import com.sckw.payment.api.model.constant.ChannelEnum;
+import com.sckw.payment.api.model.dto.MemberDetail;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+@DubboService(group = "design", version = "1.0.0")
+@Slf4j
+public class PayCenterServiceImpl implements PayCenterDubboService {
+    @Value("${payCenter.address}")
+    private String payCenterAddr;
+
+    @Override
+    public MemberDetail memberDetail(String uid, ChannelEnum channel) {
+        log.info("会员详情入参->uid:{} channel:{}", uid, channel);
+        String sync = OkHttpUtils.builder().url(payCenterAddr + "/member/detail").addPara("", "").get().sync();
+        log.info("返回值:{}", sync);
+        return JSONObject.parseObject(sync, MemberDetail.class);
+    }
+
+
+}