快速调用企业工商数据

公司接了一个项目,客户想在他的CRM产品里加入客户公海功能,方便他的客户找到优质的客户资源。

客户指定了从白小秘读取数据,因为是付费接口,每次成功调到数据,虽然只需要3分钱,但有接近2亿条数据,如果每次都从接口读,可能还是要花不少钱。

所以客户要求缓存数据。联系白小秘官方,工程师说企业主体基本数据的更新频率大约是六个月,那么:新读取到的数据缓存6个月,6个月内从产品内部读,超过6个月则重新请求接口。


1. 前端小哥已经做好了页面,只等我的数据了。

2. 只需要两个接口,非常的简单,但基于最开始联系白小秘的时候,客服工程师竟然是个声音甜美的妹子,所以果断需要官方配合对接,哈哈

3. 开工

企业工商列表搜索接口:

http://data.baixiaomi.com/company/search/?token=11cecfe2de573a719a6b8b7ee04223b5&q=知识产权

curl:得到如下数据

{

         "code": 200,

         "data": [

                   {

                            "id": 39096373,

                            "title": "知识产权出版社有限责任公司",

                            "legal": "诸敏刚",

                            "capical": 0,

                            "register_date": "2010-12-14",

                            "contact": "te",

                            "province": "北京市",

                            "city": null,

                            "status": {

                                     "title": "存续",

                                     "theme": "info"

                            },

                            "type": "有限责任公司",

                            "industry": "文化、体育和娱乐业"

                   },

                   {

                            "id": 63533953,

                            "title": "知识产权出版社有限责任公司工会",

                            "legal": "唐学贵",

                            "capical": 0,

                            "register_date": "2018-05-25",

                            "contact": "",

                            "province": "北京市",

                            "city": null,

                            "status": {

                                     "title": "正常",

                                     "theme": "info"

                            },

                            "type": "未知",

                            "industry": null

                   },

                   {

                            "id": 16733052,

                            "title": "知识通(广州)知识产权有限公司",

                            "legal": "崔晓梅",

                            "capical": 0,

                            "register_date": "2018-03-09",

                            "contact": "m",

                            "province": "广东省",

                            "city": "广州市",

                            "status": {

                                     "title": "在业",

                                     "theme": "info"

                            },

                            "type": "有限责任公司",

                            "industry": "租赁和商务服务业"

                   },

                   {

                            "id": 37392023,

                            "title": "知识猫(武汉)知识产权服务有限公司",

                            "legal": "伍志军",

                            "capical": 0,

                            "register_date": "2018-08-02",

                            "contact": "me",

                            "province": "湖北省",

                            "city": "武汉市",

                            "status": {

                                     "title": "存续",

                                     "theme": "info"

                            },

                            "type": "有限责任公司",

                            "industry": "批发和零售业"

                   },

                   {

                            "id": 25269416,

                            "title": "贵宾知识产权股份有限公司",

                            "legal": "叶旭建",

                            "capical": 0,

                            "register_date": "2017-06-15",

                            "contact": "te",

                            "province": "江西省",

                            "city": "上饶市",

                            "status": {

                                     "title": "存续",

                                     "theme": "info"

                            },

                            "type": "股份有限公司",

                            "industry": "租赁和商务服务业"

                   }

         ],

         "msg": "ok",

         "page_index": 1,

         "page_size": 5,

         "total": 5000,

         "page_count": 1000,

         "is_more": 1,

         "all": 34586,

         "query": 1

}

 

官方的数据说明:

名称

必填

类型

说明

refresh

string

更新时间

contact

string

有无联系方式 m:手机号 t:座机号 e:邮箱

city

string

城市

province

string

省份

type

string

分类

title

string

企业名称

id

string

ID

 

 

企业工商信息详情

http://data.baixiaomi.com/company/detail/?token=2761e567df423a17dd8f8c7cfa056987&id=25269416

 

curl:得到:

{

         "code": 200,

         "data": {

                   "title": "知识猫(武汉)知识产权服务有限公司",

                   "status": "存续",

                   "legal": "伍志军",

                   "capital": "101.00",

                   "register_date": "2018-08-02",

                   "province": "湖北省",

                   "city": "武汉市",

                   "district": null,

                   "uni_code": "91420100MA4L0CWW11",

                   "register_no": "420100001037284",

                   "insurance": null,

                   "industry": "批发和零售业",

                   "check_date": "",

                   "contact": "15172508891,[email protected]",

                   "tax_no": null,

                   "agency_code": null,

                   "former_title": null,

                   "website": "",

                   "address": "武汉市东湖新技术开发区高新二路388号武汉光谷国际生物医药企业加速器一期工程一号厂房2单元280号",

                   "business": null

         },

         "msg": ""

}

 

官方的字段说明:

名称

必填

类型

说明

id

string

ID

address

string

注册地址

agency_code

string

组织机构代码证

capital

string

注册资本

business

string

经营范围

agency_code

string

组织机构代码证

address

string

注册地址

check_date

string

核准日期

province

string

省份

contact

string

联系方式

district

string

状态

insurance

string

参保人数

industry

string

所属行业

former_title

string

曾用名

district

string

状态

website

string

网址

tax_no

string

税号

status

string

经营状态

uni_code

string

统一社会信用代码

register_no

string

工商注册号

register_date

string

成立日期

legal

string

法定代表人

insurance

string

参保人数

 

因为可预见的数据量还是非常大,mysql端要分表存储,可以依赖ID做分区表,也可以做物理分表,1000万条数据,放一张表。

 

因为数据更新很快,搜索没办法做缓存,只能请求接口,搜索请求回来的数据:后端先在本地判断,是否有缓存的记录,如果有,则判断上次更新时间是否超过6个月,如果没有记录或超过6个月,则从接口请求,并更新本地缓存记录。

 

大功告成!


话说跟客服妹子聊的很投机,装作不懂,问了很多脑残问题,她会不会觉得我这样的也可以做程序员?哈哈。

Guess you like

Origin blog.csdn.net/tyanzhiqi/article/details/115214099