Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
6229da14
Commit
6229da14
authored
Oct 18, 2019
by
任国军
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://t-git.51gjj.com/fangbin/51business
parents
202b066b
d65e6c79
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
213 additions
and
12 deletions
+213
-12
home.js
app/controller/credit/home.js
+4
-2
wechat.js
app/controller/gjj/wechat.js
+133
-3
abroad_house.js
app/controller/house/v2/abroad_house.js
+3
-1
search_history.js
app/controller/house/v2/search_history.js
+1
-0
abroad_house.js
app/model/realestate/abroad_house.js
+60
-0
credit.js
app/router/credit.js
+1
-0
HuaYunPaas.js
app/schedule/HuaYunPaas.js
+1
-1
callrisk.js
app/service/credit/callrisk.js
+1
-1
abroad_house.js
app/service/house/v2/abroad_house.js
+7
-2
foot_print.js
app/service/house/v2/foot_print.js
+1
-1
config.local.js
config/config.local.js
+1
-1
No files found.
app/controller/credit/home.js
View file @
6229da14
...
...
@@ -15,9 +15,11 @@ class HomeController extends Controller {
async
test
()
{
const
{
ctx
}
=
this
;
const
stream1
=
await
ctx
.
getFileStream
();
const
orderSn
=
await
ctx
.
query
.
sn
;
const
yys_report_data
=
await
ctx
.
service
.
credit
.
yys
.
getData
(
orderSn
);
//拉取报告数据
// const stream1 = await ctx.getFileStream();
// await pump(stream, writeStream);
ctx
.
success
(
stream1
);
ctx
.
success
(
yys_report_data
);
}
}
...
...
app/controller/gjj/wechat.js
View file @
6229da14
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
const
WECHAT_CODE_URL
=
'https://open.weixin.qq.com/connect/oauth2/authorize'
;
const
WECHAT_AUTH
=
'https://api.weixin.qq.com/sns/oauth2/access_token'
;
const
WECHAT_APPID
=
''
;
const
WECHAT_SECRET
=
''
;
const
NO_GJJ_PAGE
=
'https://www.baidu.com'
;
const
GJJ_DETAIL_PAGE
=
'https:www.jianbing.com'
;
class
WechatController
extends
Controller
{
async
oauthLogin
()
{
const
{
ctx
}
=
this
;
const
result
=
{};
ctx
.
success
(
result
);
const
code
=
ctx
.
query
.
code
;
const
channel_id
=
ctx
.
query
.
channel_id
;
if
(
!
code
||
code
.
length
===
0
)
{
const
target_url
=
WECHAT_CODE_URL
+
`?appid=
${
WECHAT_APPID
}
&redirect_uri=
${
encodeURIComponent
(
`https://p.jianbing.com/51ucenter/api/user/oauth?&channel_id=
${
channel_id
}
`
)}
&response_type=code&scope=snsapi_base&state=gjjquery#wechat_redirect`
;
ctx
.
redirect
(
target_url
);
}
const
url
=
`
${
WECHAT_AUTH
}
?appid=
${
WECHAT_APPID
}
&secret=
${
WECHAT_SECRET
}
&code=
${
code
}
&grant_type=authorization_code`
const
result
=
await
ctx
.
helper
.
send_request
(
url
,
{},
{
method
:
'GET'
});
if
(
result
.
status
!==
200
)
{
ctx
.
failed
(
'获取openid失败'
);
}
const
wx_ret
=
result
.
data
;
if
(
!
wx_ret
.
openid
)
{
ctx
.
failed
(
'获取openid失败'
);
}
const
openid
=
wx_ret
.
openid
;
//判断是否已绑定手机号
const
user_exist_url
=
`
${
this
.
app
.
config
.
NODE_BASE_URL
}
/user_api/v1/user/is_exist/
${
openid
}
`
;
const
bind_phone_result
=
await
ctx
.
helper
.
send_request
(
user_exist_url
,
{},
{
method
:
'GET'
});
if
(
bind_phone_result
.
status
!==
200
)
{
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
user_exist_ret
=
bind_phone_result
.
data
;
if
(
user_exist_ret
.
result
!=
'true'
)
{
//未绑定的手机号时
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
user_id
=
user_exist_ret
.
uid
;
//判断是否有导入公积金
const
gjj_exist_url
=
`
${
this
.
app
.
config
.
NODE_BASE_URL
}
/cassandra-server/gjj/list/
${
user_id
}
`
;
const
gjj_exist_result
=
await
ctx
.
helper
.
send_request
(
gjj_exist_url
,
{},
{
method
:
'GET'
});
if
(
gjj_exist_result
.
status
!==
200
)
{
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
const
gjj_exist_ret
=
gjj_exist_result
.
data
;
if
(
!
gjj_exist_ret
.
ret
||
gjj_exist_ret
.
ret
.
length
===
0
)
{
//没有导入公积金时
ctx
.
redirect
(
NO_GJJ_PAGE
);
return
;
}
await
this
.
user_login
({
code
,
openid
,
channel_id
});
//用户直接登录
ctx
.
redirect
(
GJJ_DETAIL_PAGE
);
return
;
}
async
checkLogin
()
{
...
...
@@ -20,9 +65,94 @@ class WechatController extends Controller {
if
(
user_id
)
{
is_login
=
true
;
}
const
phone
=
await
ctx
.
helper
.
getPhoneCity
(
'15968762898'
);
ctx
.
success
({
result
:
is_login
,
phone
});
}
ctx
.
success
({
result
:
is_login
});
async
user_login
(
params
){
const
{
ctx
}
=
this
;
const
{
code
,
openid
,
channel_id
}
=
params
;
const
user_agent
=
ctx
.
request
.
header
.
user_agent
?
ctx
.
request
.
header
.
user_agent
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
;
const
ip
=
ctx
.
helper
.
getClientIP
();
const
past_deviceno
=
ctx
.
helper
.
md5
(
user_agent
+
ip
);
const
app_channel_info
=
await
ctx
.
poseidonModel
.
AppChannel
.
one
({
where
:
{
alias
:
channel_id
}
});
if
(
!
app_channel_info
||
Object
.
keys
(
app_channel_info
).
length
===
0
)
{
ctx
.
failed
(
'渠道未配置'
);
}
if
(
!
app_channel_info
.
app_id
)
{
ctx
.
failed
(
'渠道未关联APPID'
);
}
const
device_login_params
=
{
past_deviceno
:
past_deviceno
,
channel_id
:
app_channel_info
.
channel_id
,
app_id
:
app_channel_info
.
app_id
,
device_info
:
{},
}
const
result_device_login
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_URL
+
'/login/device'
,
device_login_params
,
{
method
:
'POST'
});
//设备登录
const
device_login_data
=
result_device_login
.
data
;
//设备登录返回结果
if
(
!
device_login_data
||
Object
.
keys
(
device_login_data
).
length
===
0
)
{
ctx
.
failed
(
'device login error, device_login_data empty'
);
}
if
(
!
device_login_data
.
past_deviceno
)
{
//使用设备码+时间+随机数产生的一个尽量避免重复的字符串,类似游客版h5
ctx
.
failed
(
'device login error, past_deviceno empty'
);
}
if
(
!
device_login_data
.
device_id
)
{
//Devices字段表主键ID
ctx
.
failed
(
'device login error, device_id empty'
);
}
if
(
!
device_login_data
.
device_login_logs_id
)
{
//DeviceLoginLogs字段表主键ID
ctx
.
failed
(
'device login error, device_login_logs_id empty'
);
}
const
user_login_params
=
{
//用户登录传递的参数
past_deviceno
:
past_deviceno
,
//使用设备码+时间+随机数产生的一个尽量避免重复的字符串,类似游客版h5登
// device_no: device_login_data.device_no,//使用新的sdk生成的设备指纹
login_type
:
'5'
,
//登录类型:1 验证码手机登录, 2 password手机登录,4 token登录,5 微信登录,
passport
:
code
,
//登录账号:手机登录值为手机
password
:
code
,
//类型对应的值
app_user_id
:
input_params
.
app_user_id
||
''
,
//app用户ID token登陆时传的参数 可空
code
:
code
||
''
,
//第三方授权登录时的code 可空
device_info
:
{},
//设备信息
openid
:
openid
||
''
//例如微信公众号的appid(不传默认是51查个税)
};
const
result_user_login
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_URL
+
'/login/user'
,
user_login_params
,
{
method
:
'POST'
});
//用户登录
const
user_login_data
=
result_user_login
.
data
;
//用户登录返回结果
if
(
!
user_login_data
||
Object
.
keys
(
user_login_data
).
length
===
0
)
{
ctx
.
failed
(
'用户的登录失败'
);
}
if
(
!
user_login_data
.
token
||
!
user_login_data
.
uid
)
{
const
error_msg
=
user_login_data
.
error
?
user_login_data
.
error
:
'用户的登录失败'
;
ctx
.
failed
(
error_msg
);
}
//获取用户信息
const
login_token
=
user_login_data
.
token
;
const
app_user_id
=
user_login_data
.
app_user_id
;
const
user_id
=
user_login_data
.
uid
;
const
device_id
=
device_login_data
.
device_id
;
const
device_login_id
=
device_login_data
.
device_login_logs_id
;
const
env
=
this
.
app
.
config
.
env
;
let
host
=
this
.
config
.
NODE_BASE_URL
;
if
(
env
===
'prod'
)
host
=
host
.
replace
(
'lan-nginx.jianbing.com'
,
'p.jianbing.com'
);
const
user_info
=
{
token
:
login_token
,
app_user_id
:
app_user_id
,
user_id
:
user_id
,
device_id
:
device_id
,
device_login_id
:
device_login_id
,
android_url
:
`
${
host
}
/frontendh5/lp/wc/index?down=
${
encodeURIComponent
(
app_channel_info
.
android_url
)}
`
,
ios_url
:
app_channel_info
.
ios_url
,
}
for
(
let
key
in
user_info
)
{
const
value
=
user_info
[
key
];
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
path
:
'/'
,
overwrite
:
true
});
}
return
user_info
;
}
}
module
.
exports
=
WechatController
;
app/controller/house/v2/abroad_house.js
View file @
6229da14
...
...
@@ -5,12 +5,14 @@ const Controller = require('egg').Controller;
class
AbroadHouseController
extends
Controller
{
/**
*
获取
海外房列表
* 海外房列表
*/
async
list
()
{
const
{
ctx
}
=
this
;
let
inputParams
=
ctx
.
request
.
body
;
const
rule
=
{
page
:
{
type
:
'int'
,
required
:
false
},
page_size
:
{
type
:
'int'
,
required
:
false
},
name
:
{
type
:
'string'
,
required
:
false
},
};
ctx
.
validate
(
rule
,
inputParams
);
...
...
app/controller/house/v2/search_history.js
View file @
6229da14
...
...
@@ -44,6 +44,7 @@ class searchHistoryController extends Controller {
new_house
:
1
,
rental_house
:
2
,
hot_question
:
3
,
abroad_house
:
4
,
}
const
rule
=
{
type
:
{
...
...
app/model/realestate/abroad_house.js
View file @
6229da14
...
...
@@ -71,6 +71,66 @@ module.exports = app => {
});
AbroadHouse
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
AbroadHouse
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
AbroadHouse
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
order
=
data
.
order
?
data
.
order
:
[];
return
await
AbroadHouse
.
findAll
({
attributes
:
attributes
,
where
:
where
,
order
,
});
}
AbroadHouse
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
Number
(
data
.
limit
)
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
AbroadHouse
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
AbroadHouse
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
AbroadHouse
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
throw
(
error
);
}
}
AbroadHouse
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
try
{
return
await
AbroadHouse
.
update
(
params
,
{
where
:
where
})
}
catch
(
error
)
{
throw
(
error
);
}
}
return
AbroadHouse
;
};
app/router/credit.js
View file @
6229da14
...
...
@@ -13,6 +13,7 @@ module.exports = app => {
router
.
get
(
'/home'
,
'credit.home.home'
);
//首页
router
.
get
(
'/test'
,
'credit.home.test'
);
//首页
//我的信用-黑名单报告
...
...
app/schedule/HuaYunPaas.js
View file @
6229da14
...
...
@@ -8,7 +8,7 @@ class HuaYunPaas extends Subscription {
// 通过 schedule 属性来设置定时任务的执行间隔等配置
static
get
schedule
()
{
return
{
cron
:
'0
50 4 * * *'
,
//每天4:5
0点执行
cron
:
'0
0 0 * * *'
,
//每天00:0
0点执行
// cron: '*/1 * * * *',//每1分钟执行一次脚本
type
:
'worker'
,
env
:
[
'prod'
],
...
...
app/service/credit/callrisk.js
View file @
6229da14
...
...
@@ -71,7 +71,7 @@ class CallriskService extends Service {
const
{
ctx
}
=
this
;
let
basics
=
await
ctx
.
prometheusModel
.
CreditCallriskReport
.
one
({
where
:
{
id
:
report_id
}
});
let
basics
=
await
ctx
.
prometheusModel
.
CreditCallriskReport
.
one
({
where
:
{
id
:
report_id
,
user_id
:
ctx
.
userId
}
});
if
(
!
basics
||
!
basics
.
id
)
{
ctx
.
failed
(
'error report_id'
);
}
...
...
app/service/house/v2/abroad_house.js
View file @
6229da14
...
...
@@ -12,7 +12,11 @@ class AbroadHouseService extends Service {
*/
async
abroadHouseList
(
condition
)
{
const
{
ctx
}
=
this
;
let
page
=
Number
(
condition
.
page
)
||
1
;
let
pageSize
=
Number
(
condition
.
page_size
)
||
10
;
let
filter
=
{
page
:
page
,
limit
:
pageSize
,
where
:
{
valid
:
1
,
status
:
'online'
,
...
...
@@ -28,7 +32,8 @@ class AbroadHouseService extends Service {
await
ctx
.
service
.
house
.
v2
.
searchHistory
.
addSearchHistory
(
addHistory
);
filter
.
where
.
name
=
{
$like
:
'%'
+
condition
.
name
+
'%'
}
}
let
list
=
await
ctx
.
realestateModel
.
AbroadHouse
.
findAll
(
filter
);
let
abroadList
=
await
ctx
.
realestateModel
.
AbroadHouse
.
list
(
filter
);
let
list
=
abroadList
.
rows
;
let
data
=
[];
for
(
let
i
in
list
)
{
data
[
i
]
=
{
...
...
@@ -42,7 +47,7 @@ class AbroadHouseService extends Service {
}
let
ret
=
{
results
:
data
,
count
:
data
.
length
count
:
abroadList
.
count
};
return
ret
;
}
...
...
app/service/house/v2/foot_print.js
View file @
6229da14
...
...
@@ -91,7 +91,7 @@ class FootPrintService extends Service {
//处理足迹数据
const
foot_print_records
=
[];
for
(
let
j
in
houses
)
{
if
(
houses
[
j
].
status
===
'offline'
||
Number
(
houses
[
j
].
valid
)
===
0
)
{
if
(
houses
[
j
]
===
null
||
houses
[
j
]
.
status
===
'offline'
||
Number
(
houses
[
j
].
valid
)
===
0
)
{
continue
;
}
const
house
=
houses
[
j
];
...
...
config/config.local.js
View file @
6229da14
...
...
@@ -90,7 +90,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'prometheus_
dev
'
,
database
:
'prometheus_
uat
'
,
username
:
'prometheus'
,
password
:
'q9t8Ay4qIUW4sw3s25K28'
,
port
:
3306
,
...
...
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