Procházet zdrojové kódy

add 哈蜜瓜对接

GITZYY před 7 měsíci
rodič
revize
ef8266beee

+ 190 - 0
egress-gateway-service-infrastructure/src/main/java/com/hrsk/cloud/eg/infrastructure/business/GenerateCheckIntoHttpApiConfigService.java

@@ -3,6 +3,7 @@ package com.hrsk.cloud.eg.infrastructure.business;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
+import com.google.gson.JsonObject;
 import com.hrsk.cloud.eg.constant.BusinessPrefixEnum;
 import com.hrsk.cloud.eg.domain.api.*;
 import com.hrsk.cloud.eg.domain.api.common.ApiPayloadTypeEnum;
@@ -959,4 +960,193 @@ public class GenerateCheckIntoHttpApiConfigService {
         return httpApiConfig;
     }
 
+    /**
+     * @description:  易借 api生成配置
+     * @param:
+     * @return:
+     * @author zhangyy
+     * @date: 2024/9/9 15:16
+     */
+    public void generateYinJieConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":YiJie");
+        egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
+        egApiService.save(egApiDo);
+        JSONObject jsonObject = JSONObject.parseObject(openApiConfig);
+        EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
+        egApiEndpointDo.setApiCode(egApiDo.getApiCode());
+        egApiEndpointDo.setApiId(egApiDo.getId());
+        egApiEndpointDo.setApiName(jsonObject.getString("name"));
+        egApiEndpointDo.setApiConfig(HessianUtils.serialize(createYinJieCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createYinJieCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("url")+"api/third/check_loan?server=1");
+        httpApiConfig.setMethod("POST");
+        httpApiConfig.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
+        List<KeyValueObject> headers = Lists.newArrayList();
+        KeyValueObject head=new KeyValueObject();
+        head.setType(ValueObjectTypeEnum.BASIC.getType());
+        head.setKey("Content-Type");
+        head.setValue("application/json");
+        headers.add(head);
+        httpApiConfig.setHeader(headers);
+
+        JSONObject body=new  JSONObject();
+
+//        body.put("channelSource",jsonObject.getString("channelSource"));
+        body.put("channel",jsonObject.getString("channel"));
+        KeyValueObject attackPhone=new KeyValueObject();
+        attackPhone.setType("spel");
+        attackPhone.setValue("#param.user.phoneMd5");
+        JSONObject data=new  JSONObject();
+        data.put("type",102);
+        data.put("mobileMd5","#"+JSONObject.toJSONString(attackPhone));
+        body.put("data","#"+JSONObject.toJSONString(data));
+        //主体
+        httpApiConfig.setContent(JSONObject.toJSONString(body));
+        JSONObject resultObj=new  JSONObject();
+        KeyValueObject status=new KeyValueObject();
+        status.setType("spel");
+        status.setValue("#root[code]==0?0:1");
+//        List<FunctionObject> functionObjects = Lists.newArrayList();
+//        FunctionObject functionObject = new FunctionObject();
+//        functionObject.setCode("resultCodeConvertStatusInteger");
+//        functionObjects.add(functionObject);
+//        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("YinJie api {}",jsonString);
+        return httpApiConfig;
+    }
+
+    /**
+     * @description:  有融对接api
+     * @author zhangyy
+     * @date 2024/9/9 15:40
+     * @version 1.0
+     */
+    public void generateYouRonConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":Yourong");
+        egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
+        egApiService.save(egApiDo);
+        JSONObject jsonObject = JSONObject.parseObject(openApiConfig);
+        EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
+        egApiEndpointDo.setApiCode(egApiDo.getApiCode());
+        egApiEndpointDo.setApiId(egApiDo.getId());
+        egApiEndpointDo.setApiName(jsonObject.getString("name"));
+        egApiEndpointDo.setApiConfig(HessianUtils.serialize(createYouRonCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createYouRonCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("url")+"channel/openapi/checkuser");
+        httpApiConfig.setMethod("POST");
+        httpApiConfig.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
+        List<KeyValueObject> headers = Lists.newArrayList();
+        KeyValueObject head=new KeyValueObject();
+        head.setType(ValueObjectTypeEnum.BASIC.getType());
+        head.setKey("Content-Type");
+        head.setValue("application/json");
+        headers.add(head);
+        httpApiConfig.setHeader(headers);
+
+        JSONObject body=new  JSONObject();
+
+//        body.put("channelSource",jsonObject.getString("channelSource"));
+        body.put("channelCode",jsonObject.getString("channelCode"));
+        KeyValueObject attackPhone=new KeyValueObject();
+        attackPhone.setType("spel");
+        attackPhone.setValue("#param.user.phoneMd5");
+        body.put("phone","#"+JSONObject.toJSONString(attackPhone));
+        //主体
+        httpApiConfig.setContent(JSONObject.toJSONString(body));
+        JSONObject resultObj=new  JSONObject();
+        KeyValueObject status=new KeyValueObject();
+        status.setType("spel");
+        status.setValue("#root[code]==0?0:1");
+//        List<FunctionObject> functionObjects = Lists.newArrayList();
+//        FunctionObject functionObject = new FunctionObject();
+//        functionObject.setCode("resultCodeConvertStatusInteger");
+//        functionObjects.add(functionObject);
+//        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("YouRon api {}",jsonString);
+        return httpApiConfig;
+    }
+
+    /**
+     * @description:  哈蜜瓜 对接api 配置
+     * @author zhangyy
+     * @date 2024/9/9 16:05
+     * @version 1.0
+     */
+    public void generateHamiguaConfig(String openApiConfig) {
+        EgApiDo egApiDo=new EgApiDo();
+        egApiDo.setApiCode("EG:"+BusinessPrefixEnum.CHECK_INTO_PREFIX.getCode()+":Hamigua");
+        egApiDo.setApiName(BusinessPrefixEnum.CHECK_INTO_PREFIX.getMsg());
+        egApiService.save(egApiDo);
+        JSONObject jsonObject = JSONObject.parseObject(openApiConfig);
+        EgApiEndpointDo egApiEndpointDo=new EgApiEndpointDo();
+        egApiEndpointDo.setApiCode(egApiDo.getApiCode());
+        egApiEndpointDo.setApiId(egApiDo.getId());
+        egApiEndpointDo.setApiName(jsonObject.getString("name"));
+        egApiEndpointDo.setApiConfig(HessianUtils.serialize(createHamiguaCheckIntoBean(openApiConfig)));
+        egApiEndpointService.save(egApiEndpointDo);
+    }
+
+    private HttpApiConfig createHamiguaCheckIntoBean(String openApiConfig) {
+        JSONObject jsonObject=JSONObject.parseObject(openApiConfig);
+        HttpApiConfig httpApiConfig = new HttpApiConfig();
+        httpApiConfig.setUrl(jsonObject.getString("url")+"v1/api/customer/repeat/check");
+        httpApiConfig.setMethod("POST");
+        httpApiConfig.setContentType(ApiPayloadTypeEnum.APPLICATION_JSON.getCode());
+        List<KeyValueObject> headers = Lists.newArrayList();
+        KeyValueObject head=new KeyValueObject();
+        head.setType(ValueObjectTypeEnum.BASIC.getType());
+        head.setKey("Content-Type");
+        head.setValue("application/json");
+        headers.add(head);
+        httpApiConfig.setHeader(headers);
+
+        JSONObject body=new  JSONObject();
+
+//        body.put("channelSource",jsonObject.getString("channelSource"));
+//        body.put("channelCode",jsonObject.getString("channelCode"));
+        KeyValueObject attackPhone=new KeyValueObject();
+        attackPhone.setType("spel");
+        attackPhone.setValue("#param.user.phoneMd5");
+        body.put("mobile_md5","#"+JSONObject.toJSONString(attackPhone));
+
+        KeyValueObject city=new KeyValueObject();
+        attackPhone.setType("spel");
+        attackPhone.setValue("#param.user.companyCity");
+        body.put("city","#"+JSONObject.toJSONString(attackPhone));
+
+        //主体
+        httpApiConfig.setContent(JSONObject.toJSONString(body));
+        JSONObject resultObj=new  JSONObject();
+        KeyValueObject status=new KeyValueObject();
+        status.setType("spel");
+        status.setValue("#root[code]==10?0:1");
+//        List<FunctionObject> functionObjects = Lists.newArrayList();
+//        FunctionObject functionObject = new FunctionObject();
+//        functionObject.setCode("resultCodeConvertStatusInteger");
+//        functionObjects.add(functionObject);
+//        status.setFunctions(functionObjects);
+        resultObj.put("status","#"+JSONObject.toJSONString(status));
+        httpApiConfig.setResult(JSONObject.toJSONString(resultObj));
+        String jsonString = JSONObject.toJSONString(httpApiConfig);
+        log.info("Hamigua api {}",jsonString);
+        return httpApiConfig;
+    }
 }

+ 20 - 0
start/src/test/java/GenerateConfigTest.java

@@ -101,4 +101,24 @@ public class GenerateConfigTest {
         generateCHeckIntoHttpApiConfigService.generateYuKuaiHuaConfig(productBusinessApiInfoDos.get(0).getThreeSystemConfig());
     }
 
+
+    @Test
+    public void createYinJieHuaApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointJonintTypeForList("YiJie");
+        generateCHeckIntoHttpApiConfigService.generateYinJieConfig(productBusinessApiInfoDos.get(0).getThreeSystemConfig());
+    }
+
+
+    @Test
+    public void createYouRonApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointJonintTypeForList("Yourong");
+        generateCHeckIntoHttpApiConfigService.generateYouRonConfig(productBusinessApiInfoDos.get(0).getThreeSystemConfig());
+    }
+
+    @Test
+    public void createHamiguaApiTest(){
+        List<ProductBusinessApiInfoDo> productBusinessApiInfoDos = productBusinessApiInfoService.selectByJointJonintTypeForList("Hamigua");
+        generateCHeckIntoHttpApiConfigService.generateHamiguaConfig(productBusinessApiInfoDos.get(0).getThreeSystemConfig());
+    }
+
 }

+ 30 - 0
start/src/test/java/StartApiTest.java

@@ -288,6 +288,36 @@ public class StartApiTest {
         apiGateway.checkIntoRequest(checkin);
     }
 
+    @Test
+    public void youRonApiTest(){
+        Long apiId= 441426447379776L;
+        UserInBaseInfoDto user =new UserInBaseInfoDto();
+        user.setPhoneMd5("b5500dfab55f42b340d31326561e16cb");
+        user.setCompanyCity("重庆");
+        PlanDto  plan =new PlanDto();
+        plan.setApiId(apiId);
+        plan.setBid("aff1c7b30d8b240826030235business");
+        CheckIntoParamDto checkin =new CheckIntoParamDto();
+        checkin.setPlan(plan);
+        checkin.setUser(user);
+        apiGateway.checkIntoRequest(checkin);
+    }
+
+    @Test
+    public void HamiguaApiTest(){
+        Long apiId= 441426784657728L;
+        UserInBaseInfoDto user =new UserInBaseInfoDto();
+        user.setPhoneMd5("b5500dfab55f42b340d31326561e16cb");
+        user.setCompanyCity("重庆");
+        PlanDto  plan =new PlanDto();
+        plan.setApiId(apiId);
+        plan.setBid("aff1c7b30d8b240826030235business");
+        CheckIntoParamDto checkin =new CheckIntoParamDto();
+        checkin.setPlan(plan);
+        checkin.setUser(user);
+        apiGateway.checkIntoRequest(checkin);
+    }
+
     @Test
     public void spel(){
         Map<String,Object> map =new HashMap<>();