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
3f75bcd5
Commit
3f75bcd5
authored
Feb 11, 2020
by
lishangke
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://t-git.51gjj.com/fangbin/51business
parents
7363d887
db283d39
Pipeline
#19302
passed with stage
in 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
3 deletions
+101
-3
duxiaoman_log.js
app/model/prometheus/duxiaoman_log.js
+36
-0
check.js
app/service/duxiaoman/check.js
+61
-3
config.prod.js
config/config.prod.js
+4
-0
No files found.
app/model/prometheus/duxiaoman_log.js
0 → 100644
View file @
3f75bcd5
'use strict'
;
const
moment
=
require
(
'moment'
);
module
.
exports
=
app
=>
{
const
{
INTEGER
,
STRING
,
DATE
}
=
app
.
Sequelize
;
const
DuxiaomanLog
=
app
.
prometheusModel
.
define
(
'duxiaoman_log'
,
{
id
:
{
type
:
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
user_id
:
STRING
,
app_user_id
:
STRING
,
app_id
:
STRING
,
app_type_id
:
STRING
,
user_sid
:
INTEGER
,
phone
:
STRING
,
is_target_user
:
INTEGER
,
request
:
STRING
,
response
:
STRING
,
created_at
:
{
type
:
DATE
,
get
()
{
const
date
=
this
.
getDataValue
(
'created_at'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
}
},
{
timestamps
:
false
,
tableName
:
'duxiaoman_log'
,
});
return
DuxiaomanLog
;
};
app/service/duxiaoman/check.js
View file @
3f75bcd5
...
@@ -12,7 +12,8 @@ class CheckService extends Service {
...
@@ -12,7 +12,8 @@ class CheckService extends Service {
async
getUserHidePhone
()
{
async
getUserHidePhone
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
let
ret
=
{
let
ret
=
{
hidePhone
:
''
hide_phone
:
''
,
is_reject
:
false
,
//30天之内是否有被拒记录
};
};
if
(
!
ctx
.
oldUserId
||
!
ctx
.
userId
)
{
if
(
!
ctx
.
oldUserId
||
!
ctx
.
userId
)
{
//如果没有登录就不做处理
//如果没有登录就不做处理
...
@@ -30,7 +31,20 @@ class CheckService extends Service {
...
@@ -30,7 +31,20 @@ class CheckService extends Service {
if
(
!
userInfo
)
{
if
(
!
userInfo
)
{
ctx
.
failed
(
'没有找到对应的手机号'
);
ctx
.
failed
(
'没有找到对应的手机号'
);
}
}
ret
.
hidePhone
=
userInfo
.
passport
.
replace
(
/
(\d{3})\d{4}(\d{4})
/
,
'$1****$2'
);
ret
.
hide_phone
=
userInfo
.
passport
.
replace
(
/
(\d{3})\d{4}(\d{4})
/
,
'$1****$2'
);
//最近30天是否有被拒记录
let
rejectFilter
=
{
attributes
:
[
'user_sid'
],
where
:
{
user_sid
:
userSid
,
created_at
:
{
$gt
:
moment
().
subtract
(
30
,
'days'
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
},
is_target_user
:
{
$ne
:
1
}
}
}
let
rejectRecord
=
await
ctx
.
prometheusModel
.
DuxiaomanLog
.
findOne
(
rejectFilter
);
ret
.
is_reject
=
!
rejectRecord
?
false
:
true
;
return
ret
;
return
ret
;
}
}
...
@@ -63,6 +77,10 @@ class CheckService extends Service {
...
@@ -63,6 +77,10 @@ class CheckService extends Service {
async
check
()
{
async
check
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
let
ret
=
{
is_target_user
:
0
,
//1 true 0 false -1 NOT_FOUND
url
:
''
}
if
(
!
ctx
.
oldUserId
||
!
ctx
.
userId
)
{
if
(
!
ctx
.
oldUserId
||
!
ctx
.
userId
)
{
//如果没有登录就不做处理
//如果没有登录就不做处理
ctx
.
failed
(
'登录异常'
);
ctx
.
failed
(
'登录异常'
);
...
@@ -95,10 +113,50 @@ class CheckService extends Service {
...
@@ -95,10 +113,50 @@ class CheckService extends Service {
ctx
.
logger
.
info
(
'dxmUrl:'
+
dxmUrl
);
ctx
.
logger
.
info
(
'dxmUrl:'
+
dxmUrl
);
let
result
=
await
ctx
.
helper
.
send_request
(
dxmUrl
,
{},
{
method
:
'GET'
});
let
result
=
await
ctx
.
helper
.
send_request
(
dxmUrl
,
{},
{
method
:
'GET'
});
ctx
.
logger
.
info
(
'result:'
+
JSON
.
stringify
(
result
));
ctx
.
logger
.
info
(
'result:'
+
JSON
.
stringify
(
result
));
return
result
;
if
(
result
.
status
===
200
)
{
if
(
result
.
data
.
retCode
===
0
)
{
ret
.
is_target_user
=
result
.
data
.
result
.
is_target_user
;
}
//数据库记录
let
addData
=
{
user_id
:
ctx
.
userId
,
app_user_id
:
ctx
.
appUserId
,
app_id
:
ctx
.
appId
,
app_type_id
:
ctx
.
appTypeId
,
user_sid
:
userSid
,
phone
:
userInfo
.
passport
,
is_target_user
:
result
.
data
.
result
.
is_target_user
,
request
:
JSON
.
stringify
(
params
),
response
:
JSON
.
stringify
(
result
.
data
),
}
await
ctx
.
prometheusModel
.
DuxiaomanLog
.
create
(
addData
);
}
else
{
ctx
.
failed
(
'服务异常,请稍后再试'
);
}
if
(
ret
.
is_target_user
===
1
)
{
let
businessId
=
this
.
config
.
CFG_ENV
===
'dev'
?
1
:
(
this
.
config
.
CFG_ENV
===
'uat'
?
174
:
3
);
let
businessInfo
=
await
this
.
getBusinessInfo
(
businessId
);
ret
.
url
=
businessInfo
.
url
;
}
return
ret
;
}
/**
* 获取业务信息,type=4表示普通贷款
* @param {integer|string} id 业务编号
* @returns {object} businessInfo 业务相关信息
*/
async
getBusinessInfo
(
id
)
{
const
{
ctx
}
=
this
;
let
url
=
this
.
config
.
CASSANDRA_API
+
'/huodong/bu_basic/'
+
id
+
'?type=4'
;
let
result
=
await
ctx
.
helper
.
send_request
(
url
,
{},
{
method
:
'GET'
,
});
ctx
.
logger
.
info
(
url
+
':'
+
JSON
.
stringify
(
result
));
let
businessInfo
=
(
result
.
status
===
200
&&
result
.
data
&&
result
.
data
.
ret
)
?
result
.
data
.
ret
:
{};
return
businessInfo
;
}
}
...
...
config/config.prod.js
View file @
3f75bcd5
...
@@ -164,6 +164,10 @@ module.exports = appInfo => {
...
@@ -164,6 +164,10 @@ module.exports = appInfo => {
config
.
DXM_SECRET
=
process
.
env
.
DXM_SECRET
;
config
.
DXM_SECRET
=
process
.
env
.
DXM_SECRET
;
config
.
DXM_URL
=
process
.
env
.
DXM_URL
;
config
.
DXM_URL
=
process
.
env
.
DXM_URL
;
config
.
CFG_ENV
=
process
.
env
.
CFG_ENV
;
config
.
CASSANDRA_API
=
process
.
env
.
CASSANDRA_API
;
return
config
;
return
config
;
};
};
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