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
cd29e663
Commit
cd29e663
authored
Jul 04, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
house v2 tool fix
parent
4f821694
Pipeline
#10232
passed with stage
in 4 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
+29
-3
tool.js
app/controller/house/v2/tool.js
+29
-3
No files found.
app/controller/house/v2/tool.js
View file @
cd29e663
...
@@ -362,12 +362,38 @@ class ToolController extends Controller {
...
@@ -362,12 +362,38 @@ class ToolController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_parmas
=
ctx
.
request
.
body
;
const
input_parmas
=
ctx
.
request
.
body
;
const
keyword
=
input_parmas
.
keyword
;
const
keyword
=
input_parmas
.
keyword
;
const
city_code
=
input_parmas
.
city_code
;
let
city_code
=
input_parmas
.
city_code
;
const
zhixiaqu_map
=
{
110000
:
110100
,
500000
:
500100
,
120000
:
120100
,
310000
:
310100
};
let
results
=
[];
let
results
=
[];
if
(
keyword
&&
city_code
)
{
if
(
keyword
&&
city_code
)
{
const
month
=
moment
(
new
Date
()).
format
(
'MM'
);
const
month
=
moment
(
new
Date
()).
format
(
'MM'
);
const
house_price_map_results
=
await
ctx
.
blockModel
.
HousePriceMap
.
all
({
where
:
{
pid
:
city_code
,
name
:
{
$like
:
`%
${
keyword
}
%`
}
}
});
if
([
'110000'
,
'500000'
,
'120000'
,
'310000'
].
includes
(
city_code
))
{
results
=
house_price_map_results
.
map
(
item
=>
{
return
{
name
:
item
.
name
,
description
:
`
${
month
}
月参考价`
,
price
:
item
.
price
,
unit
:
'元/平'
}
});
city_code
=
zhixiaqu_map
[
city_code
];
}
const
city_result
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
city_code
}
});
const
area_results
=
await
ctx
.
blockModel
.
City
.
all
({
where
:
{
name
:
{
$like
:
`%
${
keyword
}
%`
},
level
:
3
,
parent
:
city_result
.
id
}
});
const
area_results_codes
=
R
.
pluck
(
'code'
,
area_results
);
if
(
area_results_codes
&&
area_results_codes
.
length
>
0
)
{
//城市房价
const
house_price_map_results
=
await
ctx
.
blockModel
.
HousePriceMap
.
all
({
where
:
{
id
:
{
$in
:
area_results_codes
}
}
});
const
price_map_results
=
house_price_map_results
.
map
(
item
=>
{
return
{
name
:
item
.
name
,
code
:
item
.
id
,
description
:
`
${
month
}
月参考价`
,
price
:
item
.
price
,
unit
:
'元/平'
}
});
//房价走势
let
out_codes
=
R
.
pluck
(
'code'
,
price_map_results
);
//去重
const
house_price_trend_results
=
await
ctx
.
blockModel
.
HousePriceTrend2
.
all
({
where
:
{
id
:
{
$in
:
area_results_codes
,
$notIn
:
out_codes
}
}
});
const
price_trend_results
=
house_price_trend_results
.
map
(
item
=>
{
return
{
name
:
item
.
name
,
code
:
item
.
id
,
description
:
`
${
month
}
月参考价`
,
price
:
'-----'
,
unit
:
'元/平'
}
});
//房价供需趋势
out_codes
=
out_codes
.
concat
(
R
.
pluck
(
'code'
,
price_trend_results
));
//去重
const
house_supply_demand_results
=
await
ctx
.
blockModel
.
HouseSupplyDemand2
.
all
({
where
:
{
id
:
{
$in
:
area_results_codes
,
$notIn
:
out_codes
}
}
});
const
supply_demand_results
=
house_supply_demand_results
.
map
(
item
=>
{
return
{
name
:
item
.
name
,
code
:
item
.
id
,
description
:
`
${
month
}
月参考价`
,
price
:
'-----'
,
unit
:
'元/平'
}
});
results
=
[...
price_map_results
,
...
price_trend_results
,
...
supply_demand_results
];
}
}
}
ctx
.
success
({
results
});
ctx
.
success
({
results
});
...
...
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