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
8ea8be48
Commit
8ea8be48
authored
Jun 18, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add buy house plan
parent
bf7a0b0c
Pipeline
#9053
passed with stage
in 15 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
58 deletions
+76
-58
home.js
app/controller/home.js
+3
-3
tool.js
app/controller/house/v2/tool.js
+60
-52
router.js
app/router.js
+1
-1
house.js
app/router/house.js
+3
-2
rental_house.js
app/service/house/v2/rental_house.js
+9
-0
No files found.
app/controller/home.js
View file @
8ea8be48
...
...
@@ -13,9 +13,9 @@ class HomeController extends Controller {
const
{
ctx
}
=
this
;
const
expire
=
7200
*
1000
;
const
date
=
new
Date
();
ctx
.
cookies
.
set
(
'auth_token'
,
'0f42a68d19ef161a7c7665488e625ba8'
,
{
httpOnly
:
false
,
signed
:
false
,
maxAge
:
expire
,
expires
:
date
,
path
:
'/'
});
ctx
.
cookies
.
set
(
'jianbing_customer_id'
,
'815209'
,
{
httpOnly
:
false
,
signed
:
false
,
maxAge
:
expire
,
expires
:
date
,
path
:
'/'
});
ctx
.
success
(
ctx
.
cookies
);
//
ctx.cookies.set('auth_token', '0f42a68d19ef161a7c7665488e625ba8', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
//
ctx.cookies.set('jianbing_customer_id', '815209', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
ctx
.
success
(
ctx
.
header
.
cookie
);
}
}
...
...
app/controller/house/v2/tool.js
View file @
8ea8be48
...
...
@@ -177,11 +177,11 @@ class ToolController extends Controller {
const
{
ctx
}
=
this
;
const
input_parmas
=
ctx
.
request
.
body
;
const
rule
=
{
city_code
:
{
type
:
'string'
,
required
:
true
},
area_code
:
{
type
:
'string'
,
required
:
true
},
area_name
:
{
type
:
'string
'
,
required
:
true
},
total_price
:
{
type
:
'object
'
,
required
:
true
},
down_payment
:
{
type
:
'string'
,
required
:
true
},
invest_payment
:
{
type
:
'string'
,
required
:
true
},
total_price
:
{
type
:
'string'
,
required
:
true
},
prepare_time
:
{
type
:
'string'
,
required
:
true
},
house_style
:
{
type
:
'string'
,
required
:
false
},
}
...
...
@@ -189,72 +189,80 @@ class ToolController extends Controller {
if
(
!
parseFloat
(
input_parmas
.
invest_payment
))
{
ctx
.
failed
(
'现有金额不能为0'
);
}
if
(
!
parseFloat
(
input_parmas
.
total_price
))
{
ctx
.
failed
(
'面积不能为0'
);
}
// const target_house = await ctx.blockModel.HousePriceMap.one({ where: { id: input_parmas.area_code } });
const
area_code
=
input_parmas
.
area_code
;
const
total_price
=
parseFloat
(
input_parmas
.
total_price
);
const
area_name
=
input_parmas
.
area_name
;
const
house_style
=
input_parmas
.
house_style
?
input_parmas
.
house_style
:
'new_house'
;
let
filter
=
{
total_price
:
{
min
:
total_price
-
30
,
max
:
total_price
+
30
},
area_code
:
{
bizcircle_code
:
area_code
},
const
city_code
=
input_parmas
.
city_code
;
const
total_price
=
input_parmas
.
total_price
;
if
(
!
parseFloat
(
total_price
.
max
)
||
!
parseFloat
(
total_price
.
min
))
{
ctx
.
failed
(
'总价区间不能为0'
);
}
let
recommend_houses
=
await
ctx
.
service
.
house
.
v2
.
newHouse
.
getNewHouseList
(
filter
);
//推荐房源
let
house_map
;
let
district_code
;
if
(
recommend_houses
.
count
===
0
)
{
// const house_style = input_parmas.house_style ? input_parmas.house_style : 'new_house';
if
(
house_style
===
'new_house'
)
{
house_map
=
await
ctx
.
blockModel
.
HouseNewHousePriceMap2
.
one
({
where
:
{
id
:
area_code
}
});
}
else
if
(
house_style
===
'used_house'
)
{
house_map
=
await
ctx
.
blockModel
.
HousePriceMap3
.
one
({
where
:
{
id
:
area_code
}
});
}
district_code
=
(
house_map
&&
house_map
.
pid
)
?
house_map
.
pid
:
''
;
filter
.
area_code
=
{
district_code
:
district_code
}
recommend_houses
=
await
ctx
.
service
.
house
.
newHouse
.
getNewHouseList
(
filter
);
//推荐房源
let
where
=
{
reference_total_price
:
{
$between
:
[
parseFloat
(
total_price
.
min
),
parseFloat
(
total_price
.
max
)]
},
option_city_code
:
city_code
,
option_district_code
:
area_code
,
status
:
'online'
,
valid
:
1
,
}
if
(
recommend_houses
.
count
===
0
)
{
let
city_code
;
if
(
house_style
===
'new_house'
)
{
house_map
=
await
ctx
.
blockModel
.
HouseNewHousePriceMap
.
one
({
where
:
{
id
:
district_code
}
});
}
else
if
(
house_style
===
'used_house'
)
{
house_map
=
await
ctx
.
blockModel
.
HousePriceMap2
.
one
({
where
:
{
id
:
district_code
}
});
house_map
=
await
ctx
.
blockModel
.
HousePriceMap
.
one
({
where
:
{
id
:
house_map
.
pid
}
});
}
city_code
=
(
house_map
&&
house_map
.
pid
)
?
house_map
.
pid
:
''
;
filter
.
area_code
=
{
city_code
:
city_code
};
recommend_houses
=
await
ctx
.
service
.
house
.
v2
.
newHouse
.
getNewHouseList
(
filter
);
//推荐房源
let
recommend_houses
=
await
ctx
.
realestateModel
.
NewHouse
.
list
({
limit
:
6
,
page
:
1
,
where
:
where
,
order
:
[[
'order_id'
,
'desc'
]]
});
//推荐房源
if
(
recommend_houses
.
count
<
6
)
{
delete
where
.
option_district_code
;
const
recommend_houses_supplement
=
await
ctx
.
realestateModel
.
NewHouse
.
list
({
limit
:
6
,
page
:
1
,
where
:
where
,
order
:
[[
'order_id'
,
'desc'
]]
});
//推荐房源
recommend_houses
=
[...
recommend_houses
.
rows
,
...
recommend_houses_supplement
.
rows
];
}
recommend_houses
=
recommend_houses
.
results
.
splice
(
0
,
4
);
// const recommend_houses = [];//推荐房源
recommend_houses
=
recommend_houses
.
splice
(
0
,
6
);
const
recommend_houses_formats
=
[];
for
(
let
i
in
recommend_houses
)
{
const
recommend_house
=
recommend_houses
[
i
];
recommend_houses_formats
.
push
(
await
ctx
.
service
.
house
.
v2
.
newHouse
.
formatNewHouseBasic
(
recommend_house
));
}
recommend_houses
=
recommend_houses_formats
;
// recommend_houses = await ctx.service.house.v2.newHouse.formatNewHouseTypeList(recommend_houses);
const
house_plan
=
await
ctx
.
service
.
house
.
v2
.
tool
.
generateHousePlan
(
input_parmas
);
//计算购房能力 生成购房计划
let
fine_houses
=
[];
if
(
house_plan
.
status
!==
0
)
{
filter
=
{
name
:
area_name
,
}
fine_houses
=
await
ctx
.
service
.
house
.
v2
.
newHouse
.
getNewHouseList
(
filter
);
//推荐房源
fine_houses
=
fine_houses
.
results
.
splice
(
0
,
1
);
}
const
ret
=
{
house_plan
,
fine_houses
,
recommend_houses
,
}
ctx
.
success
({
results
:
ret
});
}
async
planAreaList
()
{
const
{
ctx
}
=
this
;
const
city_list_ret
=
await
ctx
.
blockModel
.
City
.
all
({
where
:
{
level
:
2
}
});
const
city_list
=
[];
for
(
let
i
in
city_list_ret
)
{
let
city
=
city_list_ret
[
i
];
if
(
city
.
name
.
indexOf
(
'市辖区'
)
!==
-
1
)
{
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
id
:
city
.
parent
}
});
if
(
!
city
||
!
city
.
id
)
{
continue
;
}
}
city_list
.
push
({
id
:
city
.
id
,
name
:
city
.
name
,
code
:
city
.
code
,
letter
:
city
.
fword
.
toUpperCase
(),
});
}
const
cities_ids
=
R
.
pluck
(
'code'
,
city_list
);
const
districts
=
await
ctx
.
blockModel
.
HouseDistrict
.
all
({
where
:
{
city_id
:
{
$in
:
cities_ids
}
}
});
const
results
=
[];
for
(
let
i
in
city_list
)
{
const
city
=
city_list
[
i
];
const
children
=
districts
.
filter
(
item
=>
{
return
(
parseInt
(
item
.
city_id
)
===
parseInt
(
city
.
code
))
?
true
:
false
});
city
.
_children
=
children
.
map
(
item
=>
{
return
{
id
:
item
.
id
,
name
:
item
.
name
,
code
:
item
.
name
}
});
results
.
push
(
city
);
}
ctx
.
success
({
results
});
}
//type类型;trend:房价走势图;increase:房价涨跌 ;question: 购房问题;supply:供需趋势图
async
getHousePriceFeature
()
{
...
...
app/router.js
View file @
8ea8be48
...
...
@@ -7,7 +7,7 @@ module.exports = app => {
const
{
controller
}
=
app
;
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
);
router
.
get
(
'/'
,
controller
.
home
.
index
);
//
router.get('/home/setCookie', controller.home.setCookie);
router
.
get
(
'/home/setCookie'
,
controller
.
home
.
setCookie
);
require
(
'./router/gjj'
)(
app
);
...
...
app/router/house.js
View file @
8ea8be48
...
...
@@ -49,7 +49,8 @@ module.exports = app => {
//房产v2
router
.
get
(
'/v2/tool/:house_style/:area_code/:level'
,
'house.v2.tool.getMapPoint'
);
//购房计划地图点位(存钱罐地图)(房价地图)
router
.
post
(
'/v2/tool/plan'
,
'house.tool.generateBuyHousePlan'
);
//生成购房计划
router
.
post
(
'/v2/tool/plan'
,
'house.v2.tool.generateBuyHousePlan'
);
//生成购房计划
router
.
get
(
'/v2/tool/plan_area_list'
,
'house.v2.tool.planAreaList'
);
//购房计划页面 区域列表接口
router
.
get
(
'/v2/tool/:type/:area_code'
,
'house.v2.tool.getHousePriceFeature'
);
//房价走势图 房价涨跌图 购房资格图、贷款额度问答、供需趋势图
router
.
post
(
'/v2/tool/calculate_price'
,
'house.tool.calculateHousePrice'
);
//房产估价
router
.
get
(
'/v2/tool/qfang_area_list'
,
'house.tool.getQFangAreaList'
);
//房产估价模糊匹配到的小区列表
...
...
@@ -78,7 +79,7 @@ module.exports = app => {
router
.
get
(
'/v2/new_house/list/recommend/'
,
'house.v2.newHouse.getRecommendNewHouses'
);
//推荐的新房楼盘 基本可通用
//关注
router
.
post
(
'/v2/collection'
,
loginAuth
,
'house.v2.collection.addCollection'
);
//关注
router
.
post
(
'/v2/collection'
,
'house.v2.collection.addCollection'
);
//关注
router
.
get
(
'/v2/collection/list'
,
loginAuth
,
'house.v2.collection.getCollectionList'
);
//关注列表
router
.
put
(
'/v2/collection'
,
loginAuth
,
'house.v2.collection.unCollection'
);
//取消关注
...
...
app/service/house/v2/rental_house.js
View file @
8ea8be48
...
...
@@ -97,6 +97,15 @@ class RentalHouseService extends Service {
//是否关注
let
collectionTask
=
await
ctx
.
service
.
house
.
collection
.
getCollection
({
type
:
2
,
id
:
rental_house_id
});
const
city_codes
=
[
rental_house_info
.
province
,
rental_house_info
.
city
,
rental_house_info
.
area
];
const
cities
=
await
ctx
.
blockModel
.
City
.
all
({
where
:
{
code
:
{
$in
:
city_codes
}
}
});
const
city
=
(
cities
&&
cities
[
1
]
&&
cities
[
1
].
name
)
?
cities
[
1
].
name
:
''
;
const
address
=
R
.
pluck
(
'name'
,
cities
).
join
(
''
)
+
rental_house_info
.
address
;
const
gps_info
=
await
ctx
.
helper
.
getGPS
(
address
,
city
);
house_basic
.
longitude
=
gps_info
.
lng
;
house_basic
.
latitude
=
gps_info
.
lat
;
return
{
house_basic
,
house_images
,
house_types
,
collection
:
collectionTask
,
};
}
...
...
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