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
dea23b70
Commit
dea23b70
authored
Apr 28, 2020
by
姜登
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
product
parent
2ccd64bf
Pipeline
#22477
passed with stage
in 3 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
25 deletions
+37
-25
product.js
app/service/gjj/product.js
+37
-25
No files found.
app/service/gjj/product.js
View file @
dea23b70
...
...
@@ -34,21 +34,21 @@ class ProductService extends Service {
// const type = 'credit';
// keys = ['loan_organization', 'loan_filter', 'credit_bank', 'credit_theme', 'credit_filter'];
// console.info(keys);
let
classifies
=
await
ctx
.
blockModel
.
RecommendChannelClassify
.
findAll
({
where
:
{
type
,
valid
:
1
,
key
:
{
$in
:
keys
}
},
order
:
[[
'sort'
,
'asc'
]]
});
let
classifies
=
await
ctx
.
blockModel
.
RecommendChannelClassify
.
findAll
({
where
:
{
type
,
valid
:
1
,
key
:
{
$in
:
keys
}
},
order
:
[[
'sort'
,
'asc'
]]
});
// return classifies;
classifies
=
R
.
project
([
'id'
,
'key'
,
'title'
,
'description'
])(
classifies
);
classifies
=
R
.
project
([
'id'
,
'key'
,
'title'
,
'description'
])(
classifies
);
const
classify_ids
=
R
.
pluck
(
'id'
,
classifies
);
let
options
=
await
ctx
.
blockModel
.
RecommendChannelOption
.
all
({
where
:
{
classify_id
:
{
$in
:
classify_ids
},
status
:
'online'
,
valid
:
1
},
order
:
[[
'order'
,
'asc'
]]
});
options
=
R
.
project
([
'id'
,
'title'
,
'classify_id'
])(
options
);
let
options
=
await
ctx
.
blockModel
.
RecommendChannelOption
.
all
({
where
:
{
classify_id
:
{
$in
:
classify_ids
},
status
:
'online'
,
valid
:
1
},
order
:
[[
'order'
,
'asc'
]]
});
options
=
R
.
project
([
'id'
,
'title'
,
'classify_id'
])(
options
);
const
option_ids
=
R
.
pluck
(
'id'
,
options
);
let
option_products
=
await
ctx
.
blockModel
.
RecommendChannelProduct
.
all
({
where
:
{
option_id
:
{
$in
:
option_ids
},
valid
:
1
},
order
:
[[
'order'
,
'asc'
]]
});
option_products
=
R
.
project
([
'option_id'
,
'product_id'
,
'type'
])(
option_products
);
let
option_products
=
await
ctx
.
blockModel
.
RecommendChannelProduct
.
all
({
where
:
{
option_id
:
{
$in
:
option_ids
},
valid
:
1
},
order
:
[[
'order'
,
'asc'
]]
});
option_products
=
R
.
project
([
'option_id'
,
'product_id'
,
'type'
])(
option_products
);
const
ret
=
[];
for
(
const
i
in
classifies
)
{
const
classify
=
classifies
[
i
];
const
classify_id
=
classify
.
id
;
let
temp_options
=
options
.
filter
(
option
=>
parseInt
(
option
.
classify_id
)
===
parseInt
(
classify_id
));
temp_options
=
R
.
project
([
'id'
,
'title'
])(
temp_options
);
temp_options
=
R
.
project
([
'id'
,
'title'
])(
temp_options
);
for
(
const
j
in
temp_options
)
{
const
temp_option
=
temp_options
[
j
];
const
temp_option_id
=
temp_option
.
id
;
...
...
@@ -140,7 +140,7 @@ class ProductService extends Service {
}
products
=
products_results
.
data
.
ret
;
const
sort
=
function
(
a
,
b
)
{
const
sort
=
function
(
a
,
b
)
{
if
(
a
.
recommend_sorter
===
b
.
recommend_sorter
)
{
return
b
.
business_id
-
a
.
business_id
;
}
...
...
@@ -215,7 +215,7 @@ class ProductService extends Service {
const
{
ctx
}
=
this
;
const
userId
=
ctx
.
userId
;
const
R
=
require
(
'ramda'
);
const
recommendSort
=
function
(
a
,
b
)
{
const
recommendSort
=
function
(
a
,
b
)
{
if
(
a
.
recommend_sorter
===
b
.
recommend_sorter
)
{
return
b
.
business_id
-
a
.
business_id
;
}
...
...
@@ -247,7 +247,7 @@ class ProductService extends Service {
common_loan_list
:
''
,
page_type
:
location
===
'list'
?
2
:
1
,
is_run_pass_rate
:
0
,
created_time
:
moment
(
Date
()
).
format
(
'YYYY-MM-DD HH:mm:ss'
),
created_time
:
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
),
};
// 先获取分组
...
...
@@ -267,7 +267,7 @@ class ProductService extends Service {
break
;
case
2
:
isNeedCalc
=
false
;
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
e
.
class
=
'C'
;
e
.
rule
=
rule
;
e
.
hasPassRate
=
0
;
...
...
@@ -286,7 +286,7 @@ class ProductService extends Service {
if
(
!
ctx
.
isEmpty
(
userInfo
)
&&
!
ctx
.
isEmpty
(
userInfo
.
user
)
&&
!
ctx
.
isEmpty
(
userInfo
.
user
.
phone
)
&&
(
Number
(
userInfo
.
user
.
phone
)
%
2
===
0
))
{
isNeedCalc
=
true
;
}
else
{
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
e
.
class
=
'C'
;
e
.
rule
=
rule
;
e
.
hasPassRate
=
0
;
...
...
@@ -305,7 +305,7 @@ class ProductService extends Service {
// 先取A
if
(
classList
.
hasOwnProperty
(
'class_A'
)
&&
!
ctx
.
isEmpty
(
classList
.
class_A
))
{
result
=
R
.
take
(
limit
)(
R
.
sort
(
recommendSort
)(
classList
.
class_A
));
result
=
R
.
map
(
function
(
e
)
{
result
=
R
.
map
(
function
(
e
)
{
e
.
class
=
'A'
;
e
.
rule
=
2
;
return
e
;
...
...
@@ -314,7 +314,7 @@ class ProductService extends Service {
// 再取B
if
(
classList
.
hasOwnProperty
(
'class_B'
)
&&
!
ctx
.
isEmpty
(
classList
.
class_B
))
{
let
classB
=
R
.
take
(
limit
-
result
.
length
)(
R
.
sort
(
recommendSort
)(
classList
.
class_B
));
classB
=
R
.
map
(
function
(
e
)
{
classB
=
R
.
map
(
function
(
e
)
{
e
.
class
=
'B'
;
e
.
rule
=
2
;
return
e
;
...
...
@@ -330,7 +330,7 @@ class ProductService extends Service {
const
businessArr
=
R
.
pluck
(
'business_id'
)(
classList
.
class_C
);
const
passRateList
=
await
this
.
getBusinessPassRate
(
businessArr
);
if
(
!
ctx
.
isEmpty
(
passRateList
))
{
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
e
.
class
=
'C'
;
e
.
rule
=
rule
;
e
.
hasPassRate
=
0
;
...
...
@@ -348,7 +348,7 @@ class ProductService extends Service {
}
}
// 根据通过率降序排序
const
passRateSort
=
function
(
a
,
b
)
{
const
passRateSort
=
function
(
a
,
b
)
{
if
(
a
.
pass_rate
===
b
.
pass_rate
)
{
return
Number
(
a
.
recommend_sorter
)
-
Number
(
b
.
recommend_sorter
);
}
...
...
@@ -367,7 +367,7 @@ class ProductService extends Service {
}
else
{
// 模型计算参数不够,仍然采用手动推荐
classList
.
class_C
=
R
.
sort
(
recommendSort
)(
classList
.
class_C
);
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
classList
.
class_C
=
R
.
map
(
function
(
e
)
{
e
.
class
=
'C'
;
e
.
rule
=
rule
;
e
.
hasPassRate
=
0
;
...
...
@@ -443,10 +443,15 @@ class ProductService extends Service {
for
(
const
v
of
loanList
)
{
// 以下代码是为了处理渠道包下不展示特殊的4个业务
// start
const
sepecial_business_ids
=
[
95
,
7
,
130
,
51
,
99
,
111
];
const
place_cids
=
[
1210
,
1211
,
5492
,
5719
,
2420
];
if
(
ctx
.
helper
.
toInt
(
place_cid
)
>
0
&&
place_cids
.
includes
(
ctx
.
helper
.
toInt
(
place_cid
))
&&
sepecial_business_ids
.
includes
(
ctx
.
helper
.
toInt
(
v
.
business_id
)))
{
ctx
.
logger
.
info
(
'get_phone_by_user_place_business:'
+
place_cid
+
'--business_id--'
+
v
.
business_id
);
const
sepecial_business_ids
=
[
109
];
// const place_cids = [ 6046 ];
const
channelList
=
[
'n_1_10000_14038'
];
// if (ctx.helper.toInt(place_cid) > 0 && place_cids.includes(ctx.helper.toInt(place_cid)) && sepecial_business_ids.includes(ctx.helper.toInt(v.business_id))) {
// ctx.logger.info('get_phone_by_user_place_business:' + place_cid + '--business_id--' + v.business_id);
// continue;
// }
if
(
!
ctx
.
isEmpty
(
channel
)
&&
channelList
.
includes
(
channel
)
&&
sepecial_business_ids
.
includes
(
ctx
.
helper
.
toInt
(
v
.
business_id
)))
{
ctx
.
logger
.
info
(
'filter_channel_business: '
+
channel
+
'--business_id--'
+
v
.
business_id
);
continue
;
}
// end
...
...
@@ -552,10 +557,15 @@ class ProductService extends Service {
// 以下代码是为了处理渠道包下不展示特殊的4个业务
// start
const
sepecial_business_ids
=
[
95
,
7
,
130
,
51
,
99
,
111
];
const
place_cids
=
[
1210
,
1211
,
5492
,
5719
,
2420
];
if
(
ctx
.
helper
.
toInt
(
place_cid
)
>
0
&&
place_cids
.
includes
(
ctx
.
helper
.
toInt
(
place_cid
))
&&
sepecial_business_ids
.
includes
(
ctx
.
helper
.
toInt
(
v
.
business_id
)))
{
ctx
.
logger
.
info
(
'get_phone_by_user_place_business:'
+
place_cid
+
'--business_id--'
+
v
.
business_id
);
const
sepecial_business_ids
=
[
109
];
// const place_cids = [ 6046 ];
const
channelList
=
[
'n_1_10000_14038'
];
// if (ctx.helper.toInt(place_cid) > 0 && place_cids.includes(ctx.helper.toInt(place_cid)) && sepecial_business_ids.includes(ctx.helper.toInt(v.business_id))) {
// ctx.logger.info('get_phone_by_user_place_business:' + place_cid + '--business_id--' + v.business_id);
// continue;
// }
if
(
!
ctx
.
isEmpty
(
channel
)
&&
channelList
.
includes
(
channel
)
&&
sepecial_business_ids
.
includes
(
ctx
.
helper
.
toInt
(
v
.
business_id
)))
{
ctx
.
logger
.
info
(
'filter_channel_business: '
+
channel
+
'--business_id--'
+
v
.
business_id
);
continue
;
}
// end
...
...
@@ -606,6 +616,8 @@ class ProductService extends Service {
ret
.
push
(
tmp
);
}
}
else
if
(
city
===
''
&&
Number
(
v
.
type
)
===
4
&&
url
.
includes
(
'51yhdai'
))
{
}
else
{
const
tmp
=
{
type
:
v
.
type
,
...
...
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