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
ccaa41c6
Commit
ccaa41c6
authored
Jun 13, 2019
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add loan_home recommend
parent
beb64607
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
23 deletions
+57
-23
product.js
app/controller/gjj/product.js
+8
-0
product.js
app/router/product.js
+2
-1
product.js
app/service/gjj/product.js
+31
-19
config.local.js
config/config.local.js
+16
-3
No files found.
app/controller/gjj/product.js
View file @
ccaa41c6
...
...
@@ -30,5 +30,13 @@ class ProductController extends Controller {
ctx
.
success
({
results
,
credit_loans
,
common_loans
,
common_credits
,
credit_cards
});
}
// 贷款频道首页热门推荐
async
getLoanHomeRecommendList
()
{
const
{
ctx
}
=
this
;
const
ret
=
await
ctx
.
service
.
gjj
.
product
.
getLoanHomeList
();
ctx
.
success
({
results
:
ret
,
count
:
ret
.
length
});
}
}
module
.
exports
=
ProductController
;
app/router/product.js
View file @
ccaa41c6
...
...
@@ -4,6 +4,7 @@ module.exports = app => {
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/product'
);
router
.
get
(
'third_options'
,
'/recommend/channel/options/:type'
,
'gjj.product.getOptionProducts'
);
//
router
.
get
(
'third_options'
,
'/recommend/channel/options/:type'
,
'gjj.product.getOptionProducts'
);
// 筛选项
router
.
get
(
'third_options'
,
'/recommend/channel/home'
,
'gjj.product.getLoanHomeRecommendList'
);
// 贷款频道首页
};
app/service/gjj/product.js
View file @
ccaa41c6
...
...
@@ -88,7 +88,7 @@ class ProductService extends Service {
children
.
push
({
id
:
-
3
,
title
:
'最适合您的'
,
quality
:
[
7
,
8
,
29
],
// TODO
quality
:
await
this
.
getSuitLoans
(),
normal
:
[],
});
...
...
@@ -117,30 +117,37 @@ class ProductService extends Service {
const
{
ctx
}
=
this
;
const
url
=
this
.
config
.
NODE_BASE_URL
+
'/cassandra-server/bu_basic/list?type='
+
type
;
const
products_results
=
await
ctx
.
helper
.
send_request
(
url
,
{},
{
method
:
'GET'
});
//ctx.logger.info(JSON.stringify({ url, products_results }));
if
(
type
!==
1
)
{
console
.
log
(
products_results
.
data
.
ret
);
}
// ctx.logger.info(JSON.stringify({ url, products_results }));
let
products
=
[];
if
(
products_results
.
status
!==
200
||
!
products_results
.
data
||
!
products_results
.
data
.
ret
)
{
return
products
;
}
products
=
products_results
.
data
.
ret
;
products
=
await
this
.
formatProducts
(
products_results
.
data
.
ret
)
;
return
products
;
}
// 最适合您的(推荐)贷款
async
getSuitLoans
()
{
const
ret
=
await
this
.
getBusinessRecommendList
();
const
ret
=
await
this
.
getBusinessRecommendList
(
9999
);
return
ret
;
}
// 贷款频道首页热门推荐
async
getLoanHomeList
()
{
let
ret
=
await
this
.
getBusinessRecommendList
(
6
,
'home'
);
if
(
ret
.
length
<
6
)
{
const
creditLoan
=
R
.
take
(
6
-
ret
.
length
)(
await
this
.
getAllProductsByType
(
1
));
ret
=
R
.
insertAll
(
ret
.
length
,
creditLoan
)(
ret
);
}
return
ret
;
}
// 获取用户贷款分组
async
getBusinessClassList
()
{
const
{
ctx
}
=
this
;
const
userId
=
'58f1af6b-9018-4d69-b839-a26aaa368445'
;
const
appUserId
=
'9CEB848A-2F87-4C5F-A50A-D65882C04CA6'
;
const
userId
=
ctx
.
userId
;
const
appUserId
=
ctx
.
appUserId
;
const
url
=
ctx
.
app
.
config
.
NODE_BASE_URL
+
'/cassandra-server/loan_list/bu_class/list'
;
const
param
=
{
uid
:
userId
,
app_uid
:
appUserId
};
const
resp
=
await
ctx
.
helper
.
send_request
(
url
,
param
,
{
method
:
'GET'
});
...
...
@@ -153,8 +160,8 @@ class ProductService extends Service {
// 获取用户贷款通过率
async
getBusinessPassRate
(
businessList
)
{
const
{
ctx
}
=
this
;
const
userId
=
'58f1af6b-9018-4d69-b839-a26aaa368445'
;
const
appUserId
=
'9CEB848A-2F87-4C5F-A50A-D65882C04CA6'
;
const
userId
=
ctx
.
userId
;
const
appUserId
=
ctx
.
appUserId
;
const
url
=
ctx
.
app
.
config
.
NODE_BASE_URL
+
'/cassandra-server/loan_list/recommend_sort/list'
;
const
param
=
{
uid
:
userId
,
app_uid
:
appUserId
,
business_arr
:
businessList
};
...
...
@@ -185,11 +192,10 @@ class ProductService extends Service {
}
// 获取推荐列表,按照ABC分组顺序推荐
async
getBusinessRecommendList
()
{
async
getBusinessRecommendList
(
limit
,
location
=
'list'
)
{
const
{
ctx
,
service
}
=
this
;
const
userId
=
ctx
.
userId
;
const
R
=
require
(
'ramda'
);
const
limit
=
10
;
const
recommendSort
=
function
(
a
,
b
)
{
return
a
.
recommend_sorter
-
b
.
recommend_sorter
;
};
...
...
@@ -226,7 +232,10 @@ class ProductService extends Service {
// 判断C组是否有值
if
(
classList
.
hasOwnProperty
(
'class_C'
)
&&
!
ctx
.
isEmpty
(
classList
.
class_C
))
{
// 获取开关状态,判断是自动推荐or手动推荐orABTest
const
rule
=
1
;
const
keyword
=
location
===
'list'
?
'config_list_smart_recommend'
:
'config_loan_smart_recommend'
;
const
ruleSetting
=
await
this
.
app
.
huodongModel
.
Setting
.
findOne
({
where
:
{
keyword
}
});
const
rule
=
Number
(
ruleSetting
.
value
);
console
.
log
(
'rule: '
+
String
(
rule
));
// 是否需要计算模型
let
isNeedCalc
=
false
;
let
userInfo
=
{};
...
...
@@ -265,7 +274,7 @@ class ProductService extends Service {
break
;
}
if
(
isNeedCalc
)
{
if
(
isNeedCalc
||
rule
)
{
const
businessArr
=
R
.
pluck
(
'business_id'
)(
classList
.
class_C
);
const
passRateList
=
await
this
.
getBusinessPassRate
(
businessArr
);
if
(
!
ctx
.
isEmpty
(
passRateList
))
{
...
...
@@ -357,10 +366,13 @@ class ProductService extends Service {
}
async
formatProducts
(
products
)
{
const
{
ctx
}
=
this
;
const
ret
=
[];
const
channel
=
ctx
.
channel
;
for
(
const
v
of
products
)
{
const
rate
=
v
.
rate
.
includes
(
'元'
)
?
v
.
rate
:
v
.
rate
+
'%'
;
const
channel_rate
=
v
.
channel_rate
.
includes
(
'元'
)
?
v
.
channel_rate
:
v
.
channel_rate
+
'%'
;
const
channels
=
ctx
.
isEmpty
(
v
.
channel_rate_id
)
?
[]
:
v
.
channel_rate_id
.
split
(
','
);
const
rate
=
channels
.
includes
(
channel
)
?
(
v
.
channel_rate
.
includes
(
'元'
)
?
v
.
channel_rate
:
v
.
channel_rate
+
'%'
)
:
(
v
.
rate
.
includes
(
'元'
)
?
v
.
rate
:
v
.
rate
+
'%'
);
const
rateTitle
=
channels
.
includes
(
channel
)
?
v
.
channel_rate_title
:
v
.
rate_title
;
let
url
=
v
.
url
;
if
(
Number
(
v
.
type
)
===
4
)
{
url
=
url
.
includes
(
'?'
)
?
url
+
'&from=51gjj_loan_channel'
:
url
+
'?from=51gjj_loan_channel'
;
...
...
@@ -372,8 +384,8 @@ class ProductService extends Service {
name
:
v
.
name
,
logo
:
v
.
logo
,
alias
:
v
.
alias
,
rate_title
:
v
.
rate_t
itle
,
rate
:
v
.
rate
,
rate_title
:
rateT
itle
,
rate
,
min_amount
:
v
.
min_amount
,
max_amount
:
v
.
max_amount
,
sort
:
v
.
recommend_sorter
,
...
...
config/config.local.js
View file @
ccaa41c6
...
...
@@ -66,6 +66,19 @@ module.exports = appInfo => {
password
:
'ppD1sDSutHG83T2s1Ue3k'
,
port
:
3306
,
},
{
// 东八时区
timezone
:
'+08:00'
,
delegate
:
'huodongModel'
,
baseDir
:
'model/huodong'
,
// other sequelize configurations
dialect
:
'mysql'
,
host
:
'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com'
,
database
:
'devhuodong'
,
username
:
'devhuodong'
,
password
:
'jianbing2014GG'
,
port
:
3306
,
},
],
};
...
...
@@ -90,13 +103,13 @@ module.exports = appInfo => {
};
config
.
PHP_URL
=
'https://kaifa.jianbing.com'
;
config
.
NODE_URL
=
'https://
uat
-nginx.jianbing.com/user_api/v1'
;
config
.
NODE_BASE_URL
=
'https://
uat
-nginx.jianbing.com'
;
config
.
NODE_URL
=
'https://
dev
-nginx.jianbing.com/user_api/v1'
;
config
.
NODE_BASE_URL
=
'https://
dev
-nginx.jianbing.com'
;
config
.
HOUSE_SERVICE_API
=
'https://uat-nginx.jianbing.com/house-service'
;
config
.
CDN_BASE_URL
=
'https://r.51gjj.com/image/'
;
config
.
USER_CENTER_API_URI
=
'https://
uat
-nginx.jianbing.com/usercenter-service'
;
config
.
USER_CENTER_API_URI
=
'https://
dev
-nginx.jianbing.com/usercenter-service'
;
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