Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
kaopu-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a6fcca99
authored
Dec 10, 2019
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of
http://119.23.72.7/sunlong_v5/kaopu-server
into dev
parents
59904a31
96eb56fd
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
176 additions
and
48 deletions
cmd/main.go
internal/dao/com_basicinfos.go
internal/dao/com_credits.go
internal/dao/dao.go
internal/logic/common.go
internal/logic/tianyancha.go
internal/model/com_basicinfos.go
cmd/main.go
View file @
a6fcca99
package
main
import
"fmt"
func
main
()
{
fmt
.
Print
(
1
)
;
fmt
.
Print
(
1
)
}
...
...
internal/dao/com_basicinfos.go
View file @
a6fcca99
...
...
@@ -5,6 +5,8 @@ import (
"fmt"
"github.com/pkg/errors"
"github.com/bilibili/kratos/pkg/database/sql"
"kaopu-server/internal/logic"
"github.com/bilibili/kratos/pkg/log"
)
...
...
@@ -19,7 +21,7 @@ func (d *dao) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (res m
return
}
defer
d
.
db
.
Close
()
defer
rows
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
...
...
@@ -33,5 +35,28 @@ func (d *dao) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (res m
break
}
//只有没查找过才查找
if
logic
.
StringTurnInt64
(
res
[
"tyc_select_num"
])
==
0
{
tycInfo
:=
logic
.
HttpGet
(
res
[
"com_name"
])
tycInfo
[
"com_credits_id"
]
=
res
[
"com_credits_id"
]
tycInfo
[
"tyc_select_num"
]
=
"1"
d
.
UpdateCompanyBaseInfoForTyc
(
c
,
tycInfo
)
}
return
}
func
(
d
*
dao
)
UpdateCompanyBaseInfoForTyc
(
c
context
.
Context
,
updateInfo
map
[
string
]
string
)
(
res
int64
)
{
var
(
execSql
string
)
execSql
=
"update `lie_com_basicinfos` set `customer_property` = ?, `establishment_time` = ?, `five_legal_change` = ?, `registered_capital` = ?, `social_security_participants` = ?, `two_years_no_lawsuit` = ? , `tyc_select_num` = ? , `tianyancha_json` = ? where com_credits_id = ? "
row
,
err
:=
d
.
db
.
Exec
(
c
,
execSql
,
updateInfo
[
"customer_property"
],
updateInfo
[
"establishment_time"
],
updateInfo
[
"five_legal_change"
],
updateInfo
[
"registered_capital"
],
updateInfo
[
"social_security_participants"
],
updateInfo
[
"two_years_no_lawsuit"
],
updateInfo
[
"tyc_select_num"
],
updateInfo
[
"tianyancha_json"
],
updateInfo
[
"com_credits_id"
])
if
err
!=
nil
{
log
.
Error
(
"updateScoresdb.DemoExec.Exec(%s) error(%v)"
,
execSql
,
err
)
}
affectNum
,
err
:=
row
.
RowsAffected
()
return
affectNum
}
internal/dao/com_credits.go
View file @
a6fcca99
...
...
@@ -15,7 +15,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]strin
var
(
rows
*
sql
.
Rows
)
if
rows
,
err
=
d
.
db
.
Query
(
ctx
,
"SELECT "
+
SqlField
+
" FROM lie_com_credits "
);
err
!=
nil
{
if
rows
,
err
=
d
.
db
.
Query
(
ctx
,
"SELECT "
+
SqlField
+
" FROM lie_com_credits
where status = 5 or status = 10
"
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
...
...
internal/dao/dao.go
View file @
a6fcca99
...
...
@@ -38,6 +38,7 @@ type (
GetCompanyModelItemsByProjectid
(
c
context
.
Context
,
project_id
int64
,
score
float64
)
(
res
map
[
string
]
string
,
err
error
)
GetCompanyModelItemsByProjectidWitchString
(
c
context
.
Context
,
project_id
int64
,
stringVal
string
)
(
res
map
[
string
]
string
,
err
error
)
UpdateMoveSumScores
(
c
context
.
Context
,
com_credits
model
.
ComCredits
)
(
resId
int64
,
err
error
)
UpdateCompanyBaseInfoForTyc
(
c
context
.
Context
,
updateInfo
map
[
string
]
string
)
(
res
int64
)
//---静态结束
//---动态开始
...
...
internal/logic/common.go
View file @
a6fcca99
...
...
@@ -2266,3 +2266,12 @@ func StringTurnFloat64(val string)(float64) {
floatval
,
_
:=
strconv
.
ParseFloat
(
val
,
64
)
return
floatval
}
func
StringIndex
(
stringDemo
,
stringKey
string
)
int
{
return
strings
.
Index
(
stringDemo
,
stringKey
)
}
func
Int64TurnString
(
intval
int64
)(
stringval
string
)
{
return
strconv
.
FormatInt
(
intval
,
10
)
}
\ No newline at end of file
internal/logic/tianyancha.go
View file @
a6fcca99
package
logic
import
(
"
fmt
"
"
encoding/json
"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
)
type
TianYanChaCompanyInfo
struct
{
EstiblishTime
float64
`json:"estiblishTime"`
CompanyOrgType
string
`json:"companyOrgType"`
SocialStaffNum
float64
`json:"socialStaffNum"`
RegCapital
string
`json:"regCapital"`
}
type
ResultStruct
struct
{
Result
TianYanChaCompanyInfo
`json:"result"`
}
type
TotalResultStruct
struct
{
Result
TotalNumResultStruct
`json:"result"`
}
type
TotalNumResultStruct
struct
{
Total
int64
`json:"total"`
}
const
TIANYANCHATOKEN
=
"ba7fd1d1-8ebd-4d4a-844a-d44d75815ad3"
//公司信息
const
NAMEURL
=
"http://open.api.tianyancha.com/services/open/ic/baseinfoV2/2.0?name=
"
const
COMPANYINFOURL
=
"http://open.api.tianyancha.com/services/open/ic/baseinfoV2/2.0
"
//法律诉讼
const
LAWSUIT
=
"http://open.api.tianyancha.com/services/open/jr/lawSuit/2.0
?pageNum=1&name=
"
const
LAWSUIT
=
"http://open.api.tianyancha.com/services/open/jr/lawSuit/2.0"
//法人变更次数
const
CHANGEINFO
=
"http://open.api.tianyancha.com/services/open/ic/changeinfo/2.0?pageNum=1&name="
const
CHANGEINFO
=
"http://open.api.tianyancha.com/services/open/ic/changeinfo/2.0"
func
HttpGet
(
companyName
string
)(
returnDatas
map
[
string
]
string
)
{
var
companyTycInfo
ResultStruct
respBody
:=
BasicHttpGet
(
COMPANYINFOURL
,
companyName
)
json
.
Unmarshal
(
respBody
,
&
companyTycInfo
)
returnData
:=
make
(
map
[
string
]
string
)
//成立时间
returnData
[
"establishment_time"
]
=
strconv
.
FormatFloat
((
companyTycInfo
.
Result
.
EstiblishTime
/
1000
),
'f'
,
-
1
,
64
)
returnData
[
"tianyancha_json"
]
=
string
(
respBody
)
//公司性质
var
companyOrgType
string
if
strings
.
Contains
(
companyTycInfo
.
Result
.
CompanyOrgType
,
"上市"
)
{
companyOrgType
=
"1"
}
else
if
strings
.
Contains
(
companyTycInfo
.
Result
.
CompanyOrgType
,
"国企"
){
companyOrgType
=
"2"
}
else
if
strings
.
Contains
(
companyTycInfo
.
Result
.
CompanyOrgType
,
"央企"
){
companyOrgType
=
"3"
}
else
{
companyOrgType
=
"0"
}
returnData
[
"customer_property"
]
=
companyOrgType
//参保人数
returnData
[
"social_security_participants"
]
=
strconv
.
FormatFloat
(
companyTycInfo
.
Result
.
SocialStaffNum
,
'f'
,
-
1
,
64
)
//注册资本
var
capitalNum
float64
if
strings
.
Contains
(
companyTycInfo
.
Result
.
RegCapital
,
"万"
)
{
capitalNum
=
StringTurnFloat64
(
companyTycInfo
.
Result
.
RegCapital
[
:
StringIndex
(
companyTycInfo
.
Result
.
RegCapital
,
"万"
)])
*
10000
}
else
if
strings
.
Contains
(
companyTycInfo
.
Result
.
RegCapital
,
"亿"
){
capitalNum
=
StringTurnFloat64
(
companyTycInfo
.
Result
.
RegCapital
[
:
StringIndex
(
companyTycInfo
.
Result
.
RegCapital
,
"亿"
)])
*
100000000
}
else
{
capitalNum
=
StringTurnFloat64
(
companyTycInfo
.
Result
.
RegCapital
)
}
returnData
[
"registered_capital"
]
=
strconv
.
FormatFloat
(
capitalNum
,
'f'
,
-
1
,
64
)
var
totalNum
TotalResultStruct
respBody
=
BasicHttpGet
(
LAWSUIT
,
companyName
)
json
.
Unmarshal
(
respBody
,
&
totalNum
)
returnData
[
"tianyancha_json"
]
+=
"||||"
+
string
(
respBody
)
if
totalNum
.
Result
.
Total
>
0
{
returnData
[
"two_years_no_lawsuit"
]
=
"1"
}
else
{
returnData
[
"two_years_no_lawsuit"
]
=
"0"
}
respBody
=
BasicHttpGet
(
CHANGEINFO
,
companyName
)
json
.
Unmarshal
(
respBody
,
&
totalNum
)
returnData
[
"tianyancha_json"
]
+=
"||||"
+
string
(
respBody
)
returnData
[
"five_legal_change"
]
=
strconv
.
FormatInt
(
totalNum
.
Result
.
Total
,
10
)
return
returnData
}
func
BasicHttpGet
(
url
,
name
string
)(
respBody
[]
byte
)
{
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
func
HttpGet
(
url
string
)
{
q
:=
req
.
URL
.
Query
()
q
.
Add
(
"pageNum"
,
"1"
)
q
.
Add
(
"name"
,
name
)
req
.
URL
.
RawQuery
=
q
.
Encode
()
request
,
_
:=
http
.
NewRequest
(
"GET"
,
url
,
nil
)
request
.
Header
.
Add
(
"Authorization"
,
TIANYANCHATOKEN
)
req
.
Header
.
Set
(
"Authorization"
,
TIANYANCHATOKEN
)
//get数据并接收http响应
resp
,
err
:=
http
.
DefaultClient
.
Do
(
request
)
if
err
!=
nil
{
fmt
.
Printf
(
"post data error:%v
\n
"
,
err
)
}
else
{
fmt
.
Println
(
"post a data successful."
)
respBody
,
_
:=
ioutil
.
ReadAll
(
resp
.
Body
)
fmt
.
Printf
(
"response data:%v
\n
"
,
string
(
respBody
))
var
resp
*
http
.
Response
resp
,
err
=
http
.
DefaultClient
.
Do
(
req
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
log
.
Print
(
err
)
}
defer
resp
.
Body
.
Close
()
return
body
}
\ No newline at end of file
internal/model/com_basicinfos.go
View file @
a6fcca99
...
...
@@ -24,6 +24,11 @@ type ComCreditsBasicInfos struct {
YearTaxPayable
float64
`json:"year_tax_payable"`
TwoYearsnoLawsuit
int8
`json:"two_years_no_lawsuit"`
SocialSecurityParticiPant
int16
`json:"social_security_participants"`
IdCardFront
string
`json:"id_card_front"`
IdCardBack
string
`json:"id_card_back"`
PayDutyPic
string
`json:"pay_duty_pic"`
TianyanchaJson
string
`json:"tianyancha_json"`
TycSelectNum
int64
`json:"tyc_select_num"`
CreateTime
int64
`json:"create_time"`
//'创建时间'
UpdateTime
int64
`json:"update_time"`
//'更新时间'
}
...
...
@@ -31,31 +36,36 @@ type ComCreditsBasicInfos struct {
/*CREATE TABLE `lie_com_basicinfos` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`com_credits_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联信用分id',
`com_name` varchar(80) NOT NULL DEFAULT '' COMMENT '公司名称',
`com_organization` varchar(30) NOT NULL DEFAULT '' COMMENT '组织结构代码',
`establishment_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '公司成立时间',
`com_leader` varchar(60) NOT NULL DEFAULT '' COMMENT '公司负责人',
`registered_capital` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000' COMMENT '注册资本',
`customer_property` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '客户性质 0 其它 1上市 2国企 3央企',
`score_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '评分时间',
`com_address` varchar(100) NOT NULL DEFAULT '' COMMENT '公司地址',
`legal_representative` varchar(50) NOT NULL DEFAULT '' COMMENT '法定代表人',
`legal_fixed_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '法定代表人固定电话',
`legal_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '法定代表人移动电话',
`actual_controller` varchar(50) NOT NULL DEFAULT '' COMMENT '实控人',
`actual_fix_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '企业实控人固定电话',
`actual_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '企业实控人移动电话',
`com_contact` varchar(50) NOT NULL DEFAULT '' COMMENT '企业联系人',
`contact_fix_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '企业联系人',
`contact_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '企业联系人移动电话',
`five_legal_change` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '5年内法人变更次数',
`year_tax_payable` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000' COMMENT '年纳税额',
`two_years_no_lawsuit` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '近两年内有无诉讼 1有 ',
`social_security_participants` smallint(10) unsigned NOT NULL DEFAULT '0' COMMENT '社保参保人数',
`create_time` int(11) unsigned NOT NULL DEFAULT '0',
`update_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `company_code` (`com_credits_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='公司基础信息';*/
\ No newline at end of file
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`com_credits_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联信用分id',
`com_name` varchar(80) NOT NULL DEFAULT '' COMMENT '公司名称',
`com_organization` varchar(30) NOT NULL DEFAULT '' COMMENT '组织结构代码',
`establishment_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '公司成立时间',
`com_leader` varchar(60) NOT NULL DEFAULT '' COMMENT '公司负责人',
`registered_capital` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000' COMMENT '注册资本',
`customer_property` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '客户性质 0 其它 1上市 2国企 3央企',
`score_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '评分时间',
`com_address` varchar(100) NOT NULL DEFAULT '' COMMENT '公司地址',
`legal_representative` varchar(50) NOT NULL DEFAULT '' COMMENT '法定代表人',
`legal_fixed_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '法定代表人固定电话',
`legal_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '法定代表人移动电话',
`actual_controller` varchar(50) NOT NULL DEFAULT '' COMMENT '实控人',
`actual_fix_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '企业实控人固定电话',
`actual_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '企业实控人移动电话',
`com_contact` varchar(50) NOT NULL DEFAULT '' COMMENT '企业联系人',
`contact_fix_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '企业联系人固定电话',
`contact_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '企业联系人移动电话',
`five_legal_change` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '5年内法人变更次数',
`year_tax_payable` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000' COMMENT '年纳税额',
`two_years_no_lawsuit` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '近两年内有无诉讼 1有 ',
`social_security_participants` smallint(10) unsigned NOT NULL DEFAULT '0' COMMENT '社保参保人数',
`id_card_front` varchar(100) NOT NULL DEFAULT '' COMMENT '身份证正面照',
`id_card_back` varchar(100) NOT NULL DEFAULT '' COMMENT '身份证反面照',
`pay_duty_pic` varchar(100) NOT NULL DEFAULT '' COMMENT '纳税凭证照片',
`tianyancha_json` varchar(500) NOT NULL DEFAULT '' COMMENT '天眼查返回的json',
`tyc_select_num` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '查询次数',
`create_time` int(11) unsigned NOT NULL DEFAULT '0',
`update_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `company_code` (`com_credits_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='公司基础信息';*/
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment