中扬CRM客户关系管理系统
LSH
2023-09-11 17580e07751d7abaac48071a8ec0e743fdfb35fc
src/main/java/com/zy/crm/manager/utils/CompanySearchUtils.java
@@ -2,6 +2,8 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.core.common.Cools;
import com.core.exception.CoolException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -22,7 +24,11 @@
        List<Map<String, Object>> list = new ArrayList<>();
        switch (api) {
            case 1:
                list.addAll(aliyun_1(company));
                List<Map<String, Object>> maps = aliyun_1(company);
                if (Cools.isEmpty(maps)){
                    break;
                }
                list.addAll(maps);
                break;
        }
        return list;
@@ -32,6 +38,9 @@
     * 阿里云市场API
     */
    private static List<Map<String, Object>> aliyun_1(String company) {
        if (Cools.isEmpty(company) || company.length()<=3){
            return null;
        }
        ArrayList<Map<String, Object>> list = new ArrayList<>();
        try {
            HashMap<String, Object> headers = new HashMap<>();
@@ -51,6 +60,9 @@
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            if (Cools.isEmpty(jsonObject)){
                throw new CoolException("无返回结果");
            }
            if (Integer.parseInt(jsonObject.get("error_code").toString()) == 0) {
                JSONObject result = JSON.parseObject(jsonObject.get("result").toString());
                List<JSONObject> data = JSON.parseArray(result.get("data").toString(), JSONObject.class);
@@ -72,6 +84,9 @@
                }
            }
        } catch (Exception e) {
            if (e.getMessage().equals("无返回结果")){
                throw new CoolException("无返回结果");
            }
            e.printStackTrace();
        }
        return list;