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
10249826
Commit
10249826
authored
Nov 09, 2019
by
方斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
z
parent
05a9ea11
Pipeline
#16070
passed with stage
in 6 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
3 deletions
+50
-3
product.js
app/controller/gjj/product.js
+1
-0
helper.js
app/extend/helper.js
+25
-0
product.js
app/service/gjj/product.js
+24
-3
No files found.
app/controller/gjj/product.js
View file @
10249826
...
@@ -16,6 +16,7 @@ class ProductController extends Controller {
...
@@ -16,6 +16,7 @@ class ProductController extends Controller {
let
common_loans
=
[];
let
common_loans
=
[];
let
common_credits
=
[];
let
common_credits
=
[];
let
credit_cards
=
[];
let
credit_cards
=
[];
if
(
type
===
'loan'
)
{
if
(
type
===
'loan'
)
{
suit_options
=
await
ctx
.
service
.
gjj
.
product
.
getLoanChannelSuitOptions
();
suit_options
=
await
ctx
.
service
.
gjj
.
product
.
getLoanChannelSuitOptions
();
if
(
suit_options
)
{
if
(
suit_options
)
{
...
...
app/extend/helper.js
View file @
10249826
...
@@ -181,6 +181,31 @@ module.exports = {
...
@@ -181,6 +181,31 @@ module.exports = {
return
{
lng
:
0
,
lat
:
0
};
return
{
lng
:
0
,
lat
:
0
};
},
},
//根据IP地址来处理业务的展示与否
async
parseIp
()
{
let
ip
=
this
.
getClientIP
();
//
ip
=
'122.224.130.226'
;
if
(
!
ip
)
{
return
''
;
}
let
data
=
{
ak
:
'3TBenWOhPygtFFazaR5kSibU'
,
output
:
'json'
,
ip
,
};
const
{
ctx
}
=
this
;
const
resp
=
await
ctx
.
curl
(
'https://api.map.baidu.com/location/ip'
,
{
timeout
:
3000
,
dataType
:
'json'
,
method
:
'GET'
,
data
:
data
});
const
ret
=
resp
.
data
;
if
(
ret
.
status
!=
0
)
{
return
{};
}
return
ret
;
},
async
check_submit_frequent
(
redis_key
,
expire
=
5
)
{
async
check_submit_frequent
(
redis_key
,
expire
=
5
)
{
const
{
ctx
,
app
}
=
this
;
const
{
ctx
,
app
}
=
this
;
const
redis_value
=
await
app
.
memcache
.
get
(
redis_key
);
const
redis_value
=
await
app
.
memcache
.
get
(
redis_key
);
...
...
app/service/gjj/product.js
View file @
10249826
...
@@ -131,12 +131,15 @@ class ProductService extends Service {
...
@@ -131,12 +131,15 @@ class ProductService extends Service {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
url
=
this
.
config
.
NODE_BASE_URL
+
'/cassandra-server/bu_basic/list'
;
const
url
=
this
.
config
.
NODE_BASE_URL
+
'/cassandra-server/bu_basic/list'
;
const
products_results
=
await
ctx
.
helper
.
send_request
(
url
,
{
type
,
app_id
:
ctx
.
appId
},
{
method
:
'GET'
});
const
products_results
=
await
ctx
.
helper
.
send_request
(
url
,
{
type
,
app_id
:
'DE78A9AC-0407-4998-AE4D-B7F5A64EAC19'
},
{
method
:
'GET'
});
// ctx.logger.info(JSON.stringify({ url, products_results }));
// ctx.logger.info(JSON.stringify({ url, products_results }));
let
products
=
[];
let
products
=
[];
console
.
log
(
products_results
)
if
(
products_results
.
status
!==
200
||
!
products_results
.
data
||
!
products_results
.
data
.
ret
)
{
if
(
products_results
.
status
!==
200
||
!
products_results
.
data
||
!
products_results
.
data
.
ret
)
{
return
products
;
return
products
;
}
}
products
=
products_results
.
data
.
ret
;
products
=
products_results
.
data
.
ret
;
const
sort
=
function
(
a
,
b
)
{
const
sort
=
function
(
a
,
b
)
{
if
(
a
.
recommend_sorter
===
b
.
recommend_sorter
)
{
if
(
a
.
recommend_sorter
===
b
.
recommend_sorter
)
{
...
@@ -145,7 +148,7 @@ class ProductService extends Service {
...
@@ -145,7 +148,7 @@ class ProductService extends Service {
return
a
.
recommend_sorter
-
b
.
recommend_sorter
;
return
a
.
recommend_sorter
-
b
.
recommend_sorter
;
};
};
products
=
R
.
sort
(
sort
)(
products
);
products
=
R
.
sort
(
sort
)(
products
);
products
=
await
this
.
formatProducts
(
products
);
products
=
await
this
.
formatProducts
(
products
,
type
);
return
products
;
return
products
;
}
}
...
@@ -470,12 +473,23 @@ class ProductService extends Service {
...
@@ -470,12 +473,23 @@ class ProductService extends Service {
return
ret
;
return
ret
;
}
}
async
formatProducts
(
products
)
{
async
formatProducts
(
products
,
type
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
ret
=
[];
const
ret
=
[];
const
channel
=
ctx
.
channel
;
const
channel
=
ctx
.
channel
;
let
location
=
'loan_channel'
;
let
location
=
'loan_channel'
;
let
city
=
''
;
if
(
type
==
4
)
{
let
city_res
=
await
ctx
.
helper
.
parseIp
();
if
(
city_res
&&
city_res
.
content
&&
city_res
.
content
.
address_detail
&&
city_res
.
content
.
address_detail
.
city
)
{
city
=
city_res
.
content
.
address_detail
.
city
.
replace
(
'市'
,
''
);
}
}
var
in_city
=
false
;
for
(
const
v
of
products
)
{
for
(
const
v
of
products
)
{
in_city
=
false
;
if
(
Number
(
v
.
type
)
===
2
||
Number
(
v
.
type
)
===
3
)
{
if
(
Number
(
v
.
type
)
===
2
||
Number
(
v
.
type
)
===
3
)
{
v
.
rate
=
''
;
v
.
rate
=
''
;
v
.
rate_title
=
''
;
v
.
rate_title
=
''
;
...
@@ -490,6 +504,13 @@ class ProductService extends Service {
...
@@ -490,6 +504,13 @@ class ProductService extends Service {
url
=
url
.
includes
(
'?'
)
?
url
+
'&from=51gjj_loan_channel'
:
url
+
'?from=51gjj_loan_channel'
;
url
=
url
.
includes
(
'?'
)
?
url
+
'&from=51gjj_loan_channel'
:
url
+
'?from=51gjj_loan_channel'
;
}
}
url
=
this
.
config
.
PHP_URL
+
'/app/track/url?url='
+
encodeURI
(
url
)
+
'&source=51gjj&location='
+
location
;
url
=
this
.
config
.
PHP_URL
+
'/app/track/url?url='
+
encodeURI
(
url
)
+
'&source=51gjj&location='
+
location
;
if
(
v
.
cities
&&
v
.
cities
.
length
>
0
&&
city
!=
''
&&
v
.
cities
.
indexOf
(
city
))
{
in_city
=
true
;
}
if
(
!
in_city
)
continue
;
//如果不在该城市,继续循环
const
tmp
=
{
const
tmp
=
{
type
:
v
.
type
,
type
:
v
.
type
,
business_id
:
v
.
business_id
,
business_id
:
v
.
business_id
,
...
...
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