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
7cd7f1b4
Commit
7cd7f1b4
authored
Jul 26, 2019
by
任国军
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://t-git.51gjj.com/fangbin/51business
parents
4e4c6a2f
9570278f
Pipeline
#11610
passed with stage
in 48 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
248 additions
and
43 deletions
+248
-43
house_analysis.js
app/controller/house/v2/house_analysis.js
+26
-5
tool.js
app/controller/house/v2/tool.js
+69
-0
response.js
app/controller/response.js
+2
-2
device_init.js
app/middleware/device_init.js
+7
-4
house_analysis.js
app/model/realestate/house_analysis.js
+3
-0
new_house.js
app/model/realestate/new_house.js
+8
-0
rental_house.js
app/model/realestate/rental_house.js
+10
-1
house.js
app/router/house.js
+2
-0
house_analysis.js
app/service/house/v2/house_analysis.js
+22
-7
new_house.js
app/service/house/v2/new_house.js
+34
-16
option.js
app/service/house/v2/option.js
+8
-2
rental_house.js
app/service/house/v2/rental_house.js
+21
-6
tool.js
app/service/house/v2/tool.js
+36
-0
No files found.
app/controller/house/v2/house_analysis.js
View file @
7cd7f1b4
...
@@ -9,9 +9,7 @@ class HouseAnalysisController extends Controller {
...
@@ -9,9 +9,7 @@ class HouseAnalysisController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
input_params
=
ctx
.
request
.
body
;
if
(
!
input_params
.
city_code
)
{
ctx
.
failed
(
'city_code error'
);
}
let
results
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
getHouseAnalysisByFilter
(
input_params
);
let
results
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
getHouseAnalysisByFilter
(
input_params
);
const
format_rows
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
formatHouseAnalysis
(
results
.
results
);
const
format_rows
=
await
ctx
.
service
.
house
.
v2
.
houseAnalysis
.
formatHouseAnalysis
(
results
.
results
);
results
.
results
=
format_rows
;
results
.
results
=
format_rows
;
...
@@ -52,9 +50,12 @@ class HouseAnalysisController extends Controller {
...
@@ -52,9 +50,12 @@ class HouseAnalysisController extends Controller {
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
request
.
body
;
const
input_params
=
ctx
.
request
.
body
;
const
rule
=
{
const
rule
=
{
name
:
{
type
:
'string'
,
required
:
true
},
name
:
{
type
:
'string'
,
required
:
false
},
//2.1版本改动 废弃
city_code
:
{
type
:
'string'
,
required
:
true
},
city_code
:
{
type
:
'string'
,
required
:
true
},
house_type
:
{
type
:
'string'
,
required
:
true
},
house_type
:
{
type
:
'string'
,
required
:
false
},
//2.1版本改动 废弃
room_num
:
{
type
:
'string'
,
required
:
true
},
//2.1 版本新增
hall_num
:
{
type
:
'string'
,
required
:
true
},
//2.1 版本新增
toilet_num
:
{
type
:
'string'
,
required
:
true
},
//2.1 版本新增
area
:
{
type
:
'string'
,
required
:
true
},
area
:
{
type
:
'string'
,
required
:
true
},
image
:
{
type
:
'string'
,
required
:
true
},
image
:
{
type
:
'string'
,
required
:
true
},
}
}
...
@@ -64,6 +65,26 @@ class HouseAnalysisController extends Controller {
...
@@ -64,6 +65,26 @@ class HouseAnalysisController extends Controller {
ctx
.
success
({
result
});
ctx
.
success
({
result
});
}
}
// async uploadHouseAnalysis_2_1() {
// const { ctx } = this;
// const input_params = ctx.request.body;
// const rule = {
// name: { type: 'string', required: false },
// city_code: { type: 'string', required: true },
// house_type: { type: 'string', required: false },
// room_num: { type: 'string', required: false },
// hall_num: { type: 'string', required: false },
// toilet_num: { type: 'string', required: false },
// area: { type: 'string', required: true },
// image: { type: 'string', required: true },
// }
// ctx.validate(rule, input_params);
// const result = await ctx.service.house.v2.houseAnalysis.addHouseAnalysis(input_params);
// ctx.success({ result });
// }
async
getUserHouseAnalysis
()
{
async
getUserHouseAnalysis
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
...
...
app/controller/house/v2/tool.js
View file @
7cd7f1b4
...
@@ -148,6 +148,7 @@ class ToolController extends Controller {
...
@@ -148,6 +148,7 @@ class ToolController extends Controller {
const
gps_info
=
await
ctx
.
helper
.
getGPS
(
address
,
city
);
const
gps_info
=
await
ctx
.
helper
.
getGPS
(
address
,
city
);
if
(
gps_info
.
lng
&&
gps_info
.
lat
)
{
if
(
gps_info
.
lng
&&
gps_info
.
lat
)
{
result
=
{
result
=
{
house_id
,
name
:
new_house_name
,
name
:
new_house_name
,
longitude
:
gps_info
.
lng
,
longitude
:
gps_info
.
lng
,
latitude
:
gps_info
.
lat
,
latitude
:
gps_info
.
lat
,
...
@@ -237,6 +238,74 @@ class ToolController extends Controller {
...
@@ -237,6 +238,74 @@ class ToolController extends Controller {
ctx
.
success
({
results
:
ret
});
ctx
.
success
({
results
:
ret
});
}
}
//生成购房计划
async
generateBuyHousePlan_2_1
()
{
const
{
ctx
}
=
this
;
const
input_parmas
=
ctx
.
request
.
body
;
const
rule
=
{
city_code
:
{
type
:
'string'
,
required
:
true
},
total_price
:
{
type
:
'object'
,
required
:
true
},
down_payment_rate
:
{
type
:
'string'
,
required
:
true
},
//首付成数
down_payment
:
{
type
:
'string'
,
required
:
true
},
//首付
invest_payment
:
{
type
:
'string'
,
required
:
true
},
//现有现金
prepare_time
:
{
type
:
'string'
,
required
:
true
},
house_style
:
{
type
:
'string'
,
required
:
false
},
}
ctx
.
validate
(
rule
,
input_parmas
);
if
(
!
parseFloat
(
input_parmas
.
invest_payment
))
{
ctx
.
failed
(
'现有金额不能为0'
);
}
const
city_code
=
input_parmas
.
city_code
;
const
total_price
=
input_parmas
.
total_price
;
// const down_payment = parseFloat(input_parmas.down_payment);
const
invest_payment
=
parseFloat
(
input_parmas
.
invest_payment
);
const
down_payment_rate
=
parseFloat
(
input_parmas
.
down_payment_rate
);
if
(
!
parseFloat
(
total_price
.
max
)
||
!
parseFloat
(
total_price
.
min
))
{
ctx
.
failed
(
'总价区间不能为0'
);
}
const
house_plan
=
await
ctx
.
service
.
house
.
v2
.
tool
.
generateHousePlan_2_1
(
input_parmas
);
//计算购房能力 生成购房计划
if
(
house_plan
!==
2
)
{
total_price
.
max
=
invest_payment
*
2
/
down_payment_rate
+
30
;
total_price
.
min
=
invest_payment
*
2
/
down_payment_rate
-
30
;
}
let
where
=
{
reference_total_price
:
{
$between
:
[
parseFloat
(
total_price
.
min
),
parseFloat
(
total_price
.
max
)]
},
option_city_code
:
city_code
,
status
:
'online'
,
valid
:
1
,
}
const
recommend_houses_formats
=
[];
let
recommend_houses
=
await
ctx
.
realestateModel
.
NewHouse
.
list
({
limit
:
6
,
page
:
1
,
where
:
where
,
order
:
[[
'order_id'
,
'desc'
]]
});
//推荐房源
for
(
let
i
in
recommend_houses
.
rows
)
{
const
recommend_house
=
recommend_houses
.
rows
[
i
];
recommend_houses_formats
.
push
(
await
ctx
.
service
.
house
.
v2
.
newHouse
.
formatNewHouseBasic
(
recommend_house
));
}
recommend_houses
=
recommend_houses_formats
.
splice
(
0
,
6
);
const
headers
=
{
cookie
:
ctx
.
request
.
headers
.
cookie
}
const
banners_result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_BASE_URL
+
'/51app/api/block/all'
,
{
alias
:
'51fangc_tool_plan_banners'
},
{
method
:
'GET'
,
dataType
:
'json'
,
headers
:
headers
});
let
banners
=
[];
if
(
banners_result
.
status
===
200
)
{
banners
=
banners_result
.
data
.
results
;
}
const
ret
=
{
house_plan
,
banners
,
recommend_houses
,
}
ctx
.
success
({
results
:
ret
});
}
//购房计划城市区域列表
//购房计划城市区域列表
async
planAreaList
()
{
async
planAreaList
()
{
...
...
app/controller/response.js
View file @
7cd7f1b4
...
@@ -64,7 +64,7 @@ class ResponseController extends Controller {
...
@@ -64,7 +64,7 @@ class ResponseController extends Controller {
delete
(
node_user_center_login_ret
.
device_login_logs_id
);
delete
(
node_user_center_login_ret
.
device_login_logs_id
);
}
}
if
(
!
phone
||
!
channel_id
||
!
app_id
||
!
node_user_center_login_ret
.
token
)
{
//
没有手机号
或渠道错误 或直接注册新用户中心失败时 使用设备登录
if
(
!
phone
||
!
channel_id
||
!
app_id
||
!
node_user_center_login_ret
.
token
)
{
//
或渠道错误 或直接注册新用户中心失败时 使用设备登录
const
user_agent
=
header
.
user_agent
?
header
.
user_agent
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
;
const
user_agent
=
header
.
user_agent
?
header
.
user_agent
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
;
const
ip
=
ctx
.
helper
.
getClientIP
();
const
ip
=
ctx
.
helper
.
getClientIP
();
const
device_no
=
ctx
.
helper
.
md5
(
user_agent
+
ip
);
const
device_no
=
ctx
.
helper
.
md5
(
user_agent
+
ip
);
...
@@ -101,7 +101,7 @@ class ResponseController extends Controller {
...
@@ -101,7 +101,7 @@ class ResponseController extends Controller {
const
value
=
node_user_center_login_ret
[
key
];
const
value
=
node_user_center_login_ret
[
key
];
const
exist_value
=
ctx
.
cookies
.
get
(
key
,
{
signed
:
false
});
const
exist_value
=
ctx
.
cookies
.
get
(
key
,
{
signed
:
false
});
if
(
!
exist_value
){
if
(
!
exist_value
){
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
maxAge
:
expire
,
expires
:
date
,
path
:
'/'
});
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
path
:
'/'
,
overwrite
:
true
});
}
}
}
}
...
...
app/middleware/device_init.js
View file @
7cd7f1b4
...
@@ -19,6 +19,8 @@ module.exports = () => {
...
@@ -19,6 +19,8 @@ module.exports = () => {
break
;
break
;
}
}
ctx
.
logger
.
info
(
JSON
.
stringify
({
url
:
ctx
.
request
.
url
,
params
:
input_params
,
cookies
:
ctx
.
header
.
cookie
}));
const
stack
=
ctx
.
app
.
router
.
stack
;
const
stack
=
ctx
.
app
.
router
.
stack
;
const
current_path_list
=
ctx
.
request
.
url
.
split
(
'?'
);
const
current_path_list
=
ctx
.
request
.
url
.
split
(
'?'
);
const
current_path
=
current_path_list
[
0
];
const
current_path
=
current_path_list
[
0
];
...
@@ -110,9 +112,10 @@ module.exports = () => {
...
@@ -110,9 +112,10 @@ module.exports = () => {
method
:
'POST'
,
method
:
'POST'
,
});
});
// ctx.logger.info('appUserId: ' + appUserId);
// ctx.logger.info('appUserId: ' + appUserId);
ctx
.
logger
.
info
(
'request_header: '
+
JSON
.
stringify
(
ctx
.
request
.
header
));
// ctx.logger.info('request_header: ' + JSON.stringify(ctx.request.header));
ctx
.
logger
.
info
(
'user_auth_params: '
+
JSON
.
stringify
(
params
));
// ctx.logger.info('user_auth_params: ' + JSON.stringify(params));
ctx
.
logger
.
info
(
'user_auth_result: '
+
JSON
.
stringify
(
result
));
// ctx.logger.info('user_auth_result: ' + JSON.stringify(result));
ctx
.
logger
.
info
(
JSON
.
stringify
({
url
:
ctx
.
app
.
config
.
NODE_URL
+
'/user/auth'
,
request_header
:
ctx
.
request
.
header
,
user_auth_params
:
params
,
user_auth_result
:
result
}));
console
.
log
(
result
);
console
.
log
(
result
);
if
(
result
.
status
!==
201
)
{
if
(
result
.
status
!==
201
)
{
ctx
.
failed
(
'token 已失效'
);
ctx
.
failed
(
'token 已失效'
);
...
@@ -198,7 +201,7 @@ module.exports = () => {
...
@@ -198,7 +201,7 @@ module.exports = () => {
const
value
=
user_login_info
[
key
];
const
value
=
user_login_info
[
key
];
const
exist_value
=
ctx
.
cookies
.
get
(
key
,
{
signed
:
false
});
const
exist_value
=
ctx
.
cookies
.
get
(
key
,
{
signed
:
false
});
if
(
!
exist_value
)
{
if
(
!
exist_value
)
{
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
maxAge
:
expire
,
expires
:
date
,
path
:
'/'
});
ctx
.
cookies
.
set
(
key
,
value
,
{
httpOnly
:
false
,
signed
:
false
,
path
:
'/'
,
overwrite
:
true
});
}
}
}
}
return
user_login_info
;
return
user_login_info
;
...
...
app/model/realestate/house_analysis.js
View file @
7cd7f1b4
...
@@ -18,6 +18,9 @@ module.exports = app => {
...
@@ -18,6 +18,9 @@ module.exports = app => {
residential
:
STRING
,
residential
:
STRING
,
city
:
STRING
,
city
:
STRING
,
house_type
:
STRING
,
house_type
:
STRING
,
room_num
:
INTEGER
,
hall_num
:
INTEGER
,
toilet_num
:
INTEGER
,
house_area
:
STRING
,
house_area
:
STRING
,
image
:
STRING
,
image
:
STRING
,
text
:
STRING
,
text
:
STRING
,
...
...
app/model/realestate/new_house.js
View file @
7cd7f1b4
...
@@ -36,6 +36,14 @@ module.exports = app => {
...
@@ -36,6 +36,14 @@ module.exports = app => {
type
:
STRING
,
type
:
STRING
,
allowNull
:
true
allowNull
:
true
},
},
gps
:
{
type
:
STRING
,
allowNull
:
true
},
sale_gps
:
{
type
:
STRING
,
allowNull
:
true
},
sale_province
:
{
sale_province
:
{
type
:
INTEGER
,
type
:
INTEGER
,
allowNull
:
true
allowNull
:
true
...
...
app/model/realestate/rental_house.js
View file @
7cd7f1b4
...
@@ -48,10 +48,18 @@ module.exports = app => {
...
@@ -48,10 +48,18 @@ module.exports = app => {
type
:
INTEGER
,
type
:
INTEGER
,
allowNull
:
true
allowNull
:
true
},
},
surplus_amount
:
{
type
:
INTEGER
,
allowNull
:
true
},
address
:
{
address
:
{
type
:
STRING
,
type
:
STRING
,
allowNull
:
true
allowNull
:
true
},
},
gps
:
{
type
:
STRING
,
allowNull
:
true
},
price
:
{
price
:
{
type
:
DECIMAL
,
type
:
DECIMAL
,
allowNull
:
true
allowNull
:
true
...
@@ -205,7 +213,8 @@ module.exports = app => {
...
@@ -205,7 +213,8 @@ module.exports = app => {
const
where
=
data
.
where
;
const
where
=
data
.
where
;
const
params
=
data
.
params
;
const
params
=
data
.
params
;
try
{
try
{
return
res
=
await
RentalHouse
.
update
(
params
,
{
where
:
where
})
const
res
=
await
RentalHouse
.
update
(
params
,
{
where
:
where
})
return
res
;
}
catch
(
error
)
{
}
catch
(
error
)
{
throw
(
error
);
throw
(
error
);
}
}
...
...
app/router/house.js
View file @
7cd7f1b4
...
@@ -51,6 +51,7 @@ module.exports = app => {
...
@@ -51,6 +51,7 @@ module.exports = app => {
//房产v2
//房产v2
router
.
get
(
'/v2/tool/:house_style/:area_code/:level'
,
'house.v2.tool.getMapPoint'
);
//购房计划地图点位(存钱罐地图)(房价地图)
router
.
get
(
'/v2/tool/:house_style/:area_code/:level'
,
'house.v2.tool.getMapPoint'
);
//购房计划地图点位(存钱罐地图)(房价地图)
router
.
post
(
'/v2/tool/plan'
,
'house.v2.tool.generateBuyHousePlan'
);
//生成购房计划
router
.
post
(
'/v2/tool/plan'
,
'house.v2.tool.generateBuyHousePlan'
);
//生成购房计划
router
.
post
(
'/v2.1/tool/plan'
,
'house.v2.tool.generateBuyHousePlan_2_1'
);
//生成购房计划
router
.
get
(
'/v2/tool/plan_area_list'
,
'house.v2.tool.planAreaList'
);
//购房计划页面 区域列表接口
router
.
get
(
'/v2/tool/plan_area_list'
,
'house.v2.tool.planAreaList'
);
//购房计划页面 区域列表接口
router
.
get
(
'/v2/tool/:type/:city_code'
,
'house.v2.tool.getHousePriceFeature'
);
//房价走势图 房价涨跌图 购房资格图、贷款额度问答、供需趋势图
router
.
get
(
'/v2/tool/:type/:city_code'
,
'house.v2.tool.getHousePriceFeature'
);
//房价走势图 房价涨跌图 购房资格图、贷款额度问答、供需趋势图
router
.
post
(
'/v2/tool/calculate_price'
,
'house.tool.calculateHousePrice'
);
//房产估价
router
.
post
(
'/v2/tool/calculate_price'
,
'house.tool.calculateHousePrice'
);
//房产估价
...
@@ -106,6 +107,7 @@ module.exports = app => {
...
@@ -106,6 +107,7 @@ module.exports = app => {
router
.
post
(
'/v2/house_analysis/list'
,
'house.v2.houseAnalysis.getHouseAnalysisList'
);
//户型解析列表
router
.
post
(
'/v2/house_analysis/list'
,
'house.v2.houseAnalysis.getHouseAnalysisList'
);
//户型解析列表
router
.
get
(
'/v2/house_analysis/info/:house_analysis_id'
,
'house.v2.houseAnalysis.getHouseAnalysisInfo'
);
//户型解析列表
router
.
get
(
'/v2/house_analysis/info/:house_analysis_id'
,
'house.v2.houseAnalysis.getHouseAnalysisInfo'
);
//户型解析列表
router
.
post
(
'/v2/house_analysis/'
,
loginAuth
,
'house.v2.houseAnalysis.uploadHouseAnalysis'
);
//上传户型信息
router
.
post
(
'/v2/house_analysis/'
,
loginAuth
,
'house.v2.houseAnalysis.uploadHouseAnalysis'
);
//上传户型信息
// router.post('/v2.1/house_analysis/', loginAuth, 'house.v2.houseAnalysis.uploadHouseAnalysis_2_1');//上传户型信息
router
.
get
(
'/v2/house_analysis/mine'
,
loginAuth
,
'house.v2.houseAnalysis.getUserHouseAnalysis'
);
//我的户型
router
.
get
(
'/v2/house_analysis/mine'
,
loginAuth
,
'house.v2.houseAnalysis.getUserHouseAnalysis'
);
//我的户型
router
.
get
(
'/v2/house_analysis/city_list'
,
'house.v2.houseAnalysis.getHouseAnalysisSupportCity'
);
//上传户型解析的城市列表
router
.
get
(
'/v2/house_analysis/city_list'
,
'house.v2.houseAnalysis.getHouseAnalysisSupportCity'
);
//上传户型解析的城市列表
...
...
app/service/house/v2/house_analysis.js
View file @
7cd7f1b4
...
@@ -11,13 +11,22 @@ class HouseAnalysisService extends Service {
...
@@ -11,13 +11,22 @@ class HouseAnalysisService extends Service {
async
getHouseAnalysisByFilter
(
condition
)
{
async
getHouseAnalysisByFilter
(
condition
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
let
{
city_code
,
keyword
,
page
,
page_size
}
=
condition
;
let
{
city_code
,
keyword
,
page
,
page_size
,
room_num
,
hall_num
,
toilet_num
}
=
condition
;
page
=
page
?
page
:
1
;
page
=
page
?
page
:
1
;
page_size
=
page_size
?
page_size
:
10
;
page_size
=
page_size
?
page_size
:
10
;
let
where
=
{
status
:
'pass'
};
let
where
=
{
status
:
'pass'
};
if
(
city_code
)
{
if
(
city_code
)
{
where
.
city
=
city_code
;
where
.
city
=
city_code
;
}
}
if
(
room_num
)
{
where
.
room_num
=
room_num
;
}
if
(
hall_num
)
{
where
.
hall_num
=
hall_num
;
}
if
(
toilet_num
)
{
where
.
toilet_num
=
toilet_num
;
}
if
(
keyword
&&
keyword
.
length
!==
0
)
{
if
(
keyword
&&
keyword
.
length
!==
0
)
{
where
.
residential
=
{
$like
:
`%
${
keyword
}
%`
}
where
.
residential
=
{
$like
:
`%
${
keyword
}
%`
}
}
}
...
@@ -58,17 +67,23 @@ class HouseAnalysisService extends Service {
...
@@ -58,17 +67,23 @@ class HouseAnalysisService extends Service {
if
(
!
user_id
||
!
app_user_id
||
!
app_id
||
!
app_type_id
)
{
if
(
!
user_id
||
!
app_user_id
||
!
app_id
||
!
app_type_id
)
{
ctx
.
failed
(
'login error'
);
ctx
.
failed
(
'login error'
);
}
}
let
{
name
,
house_type
,
room_num
,
hall_num
,
toilet_num
,
city_code
,
area
,
image
}
=
params
;
if
(
!
house_type
)
{
house_type
=
`
${
room_num
}
室
${
hall_num
}
厅
${
toilet_num
}
卫`
;
}
const
data
=
{
const
data
=
{
user_id
,
user_id
,
app_user_id
,
app_user_id
,
app_id
,
app_id
,
app_type_id
,
app_type_id
,
residential
:
params
.
name
,
residential
:
name
,
house_type
:
params
.
house_type
,
house_type
:
house_type
,
city
:
params
.
city_code
,
room_num
,
house_area
:
params
.
area
,
hall_num
,
image
:
params
.
image
,
toilet_num
,
city
:
city_code
,
house_area
:
area
,
image
:
image
,
created_at
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD HH:mm:ss'
),
created_at
:
moment
(
new
Date
()).
format
(
'YYYY-MM-DD HH:mm:ss'
),
}
}
...
...
app/service/house/v2/new_house.js
View file @
7cd7f1b4
...
@@ -14,6 +14,7 @@ const HOUSE_TYPE = [
...
@@ -14,6 +14,7 @@ const HOUSE_TYPE = [
{
name
:
'5室以上'
,
min
:
5
,
max
:
10000
,
value
:
6
,
},
{
name
:
'5室以上'
,
min
:
5
,
max
:
10000
,
value
:
6
,
},
{
name
:
'别墅'
,
min
:
10000
,
max
:
10000000
,
value
:
7
,
},
{
name
:
'别墅'
,
min
:
10000
,
max
:
10000000
,
value
:
7
,
},
]
]
const
SaleType
=
{
0
:
'未开售'
,
1
:
'售罄'
,
2
:
'预售'
,
3
:
'在售'
};
class
NewHouseService
extends
Service
{
class
NewHouseService
extends
Service
{
/**
/**
...
@@ -121,7 +122,6 @@ class NewHouseService extends Service {
...
@@ -121,7 +122,6 @@ class NewHouseService extends Service {
*/
*/
async
formatNewHouse
(
data
)
{
async
formatNewHouse
(
data
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
saleType
=
{
0
:
'未开售'
,
1
:
'售罄'
,
2
:
'预售'
,
3
:
'在售'
};
const
decorationType
=
{
1
:
'毛坯'
,
2
:
'简装'
,
3
:
'精装'
}
const
decorationType
=
{
1
:
'毛坯'
,
2
:
'简装'
,
3
:
'精装'
}
const
archType
=
{
1
:
'板楼'
,
2
:
'塔楼'
};
const
archType
=
{
1
:
'板楼'
,
2
:
'塔楼'
};
let
ret
=
{};
let
ret
=
{};
...
@@ -157,19 +157,31 @@ class NewHouseService extends Service {
...
@@ -157,19 +157,31 @@ class NewHouseService extends Service {
let
area
=
typeArea
.
min
===
typeArea
.
max
?
Number
(
typeArea
.
min
)
:
Number
(
typeArea
.
min
)
+
'-'
+
Number
(
typeArea
.
max
);
let
area
=
typeArea
.
min
===
typeArea
.
max
?
Number
(
typeArea
.
min
)
:
Number
(
typeArea
.
min
)
+
'-'
+
Number
(
typeArea
.
max
);
//经纬度
//经纬度
let
addressDecode
=
await
this
.
addressDecode
({
city
:
data
.
option_city_code
,
district
:
data
.
option_district_code
,
bizicircle
:
data
.
option_bizicircle_code
});
let
address
=
addressDecode
.
city
+
addressDecode
.
county
+
addressDecode
.
region
+
data
.
address
;
let
gps_result
=
await
ctx
.
helper
.
getGPS
(
address
,
addressDecode
.
city
);
if
(
!
gps_result
.
lat
||
!
gps_result
.
lng
)
{
gps_result
=
await
ctx
.
helper
.
getGPS
(
addressDecode
,
addressDecode
.
city
);
}
let
longitude
=
0
;
let
longitude
=
0
;
let
latitude
=
0
;
let
latitude
=
0
;
if
(
gps_result
)
{
if
(
data
.
gps
.
length
>
0
)
{
longitude
=
gps_result
.
lng
;
let
gpsInfo
=
data
.
gps
.
split
(
','
).
slice
(
0
,
2
);
latitude
=
gps_result
.
lat
;
longitude
=
gpsInfo
[
1
];
latitude
=
gpsInfo
[
0
];
}
else
{
let
addressDecode
=
await
this
.
addressDecode
({
city
:
data
.
option_city_code
,
district
:
data
.
option_district_code
,
bizicircle
:
data
.
option_bizicircle_code
});
let
address
=
addressDecode
.
city
+
addressDecode
.
county
+
addressDecode
.
region
+
data
.
address
;
let
gps_result
=
await
ctx
.
helper
.
getGPS
(
address
,
addressDecode
.
city
);
if
(
!
gps_result
.
lat
||
!
gps_result
.
lng
)
{
gps_result
=
await
ctx
.
helper
.
getGPS
(
addressDecode
,
addressDecode
.
city
);
}
if
(
gps_result
)
{
longitude
=
gps_result
.
lng
;
latitude
=
gps_result
.
lat
;
}
let
gpsFilter
=
{
params
:
{
gps
:
latitude
+
','
+
longitude
},
where
:
{
id
:
data
.
id
}
}
await
ctx
.
realestateModel
.
NewHouse
.
edit
(
gpsFilter
);
}
}
ret
.
basic
=
{
ret
.
basic
=
{
id
:
data
.
id
,
id
:
data
.
id
,
name
:
data
.
name
,
//标题
name
:
data
.
name
,
//标题
...
@@ -202,7 +214,7 @@ class NewHouseService extends Service {
...
@@ -202,7 +214,7 @@ class NewHouseService extends Service {
decoration
:
decorationType
[
data
.
decoration_type
]
||
''
,
//装修情况,1 毛坯,2简装,3精装
decoration
:
decorationType
[
data
.
decoration_type
]
||
''
,
//装修情况,1 毛坯,2简装,3精装
},
},
sale
:
{
sale
:
{
sale_type
:
saleType
[
data
.
sale_type
]
||
''
,
//销售状态 0未开售,1售罄,2预售,3在售
sale_type
:
SaleType
[
data
.
sale_type
]
||
SaleType
[
3
]
,
//销售状态 0未开售,1售罄,2预售,3在售
address
:
data
.
address
,
//地址
address
:
data
.
address
,
//地址
sale_address
:
data
.
sale_address
,
//售楼地址
sale_address
:
data
.
sale_address
,
//售楼地址
developer
:
data
.
developer
?
data
.
developer
.
name
:
''
,
//开发商
developer
:
data
.
developer
?
data
.
developer
.
name
:
''
,
//开发商
...
@@ -291,7 +303,6 @@ class NewHouseService extends Service {
...
@@ -291,7 +303,6 @@ class NewHouseService extends Service {
*/
*/
async
formatNewHouseType
(
data
)
{
async
formatNewHouseType
(
data
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
saleType
=
{
0
:
'未开售'
,
1
:
'售罄'
,
2
:
'预售'
,
3
:
'在售'
};
let
ret
=
{};
let
ret
=
{};
if
(
Object
.
keys
(
data
).
length
>
0
)
{
if
(
Object
.
keys
(
data
).
length
>
0
)
{
ret
=
{
ret
=
{
...
@@ -301,7 +312,7 @@ class NewHouseService extends Service {
...
@@ -301,7 +312,7 @@ class NewHouseService extends Service {
house_type
:
data
.
house_type
.
split
(
','
).
slice
(
0
,
2
),
house_type
:
data
.
house_type
.
split
(
','
).
slice
(
0
,
2
),
image
:
data
.
image
,
image
:
data
.
image
,
apartment
:
data
.
apartment
,
//户型,如4室2厅3卫
apartment
:
data
.
apartment
,
//户型,如4室2厅3卫
sale_type
:
s
aleType
[
data
.
sale_type
]
||
''
,
sale_type
:
S
aleType
[
data
.
sale_type
]
||
''
,
area
:
Number
(
data
.
area
),
//面积
area
:
Number
(
data
.
area
),
//面积
orientation
:
data
.
orientation
,
//朝向
orientation
:
data
.
orientation
,
//朝向
num
:
data
.
num
,
//房源数量
num
:
data
.
num
,
//房源数量
...
@@ -374,9 +385,10 @@ class NewHouseService extends Service {
...
@@ -374,9 +385,10 @@ class NewHouseService extends Service {
valid
:
1
valid
:
1
}
}
}
}
if
(
condition
.
house_type
)
{
//v2.1去掉户型筛选,替换为贷款方式
newHouseTypeFilter
.
where
.
type
=
condition
.
house_type
;
// if (condition.house_type) {
}
// newHouseTypeFilter.where.type = condition.house_type;
// }
if
((
condition
.
area
&&
condition
.
area
.
hasOwnProperty
(
'min'
)
&&
condition
.
area
.
hasOwnProperty
(
'max'
)))
{
if
((
condition
.
area
&&
condition
.
area
.
hasOwnProperty
(
'min'
)
&&
condition
.
area
.
hasOwnProperty
(
'max'
)))
{
newHouseTypeFilter
.
where
.
area
=
{
$between
:
[
condition
.
area
.
min
,
condition
.
area
.
max
]
};
newHouseTypeFilter
.
where
.
area
=
{
$between
:
[
condition
.
area
.
min
,
condition
.
area
.
max
]
};
}
}
...
@@ -385,6 +397,11 @@ class NewHouseService extends Service {
...
@@ -385,6 +397,11 @@ class NewHouseService extends Service {
filter
.
where
.
id
=
{
$in
:
matchIds
};
filter
.
where
.
id
=
{
$in
:
matchIds
};
}
}
//贷款方式
if
(
condition
.
loan_type
&&
Number
(
condition
.
loan_type
)
!==
0
)
{
filter
.
where
.
loan_type
=
Number
(
condition
.
loan_type
);
}
if
(
condition
.
name
)
{
//关键词搜索 模糊查询
if
(
condition
.
name
)
{
//关键词搜索 模糊查询
//增加搜索历史
//增加搜索历史
let
addHistory
=
{
let
addHistory
=
{
...
@@ -432,6 +449,7 @@ class NewHouseService extends Service {
...
@@ -432,6 +449,7 @@ class NewHouseService extends Service {
image
:
newHouseInfo
.
image
,
image
:
newHouseInfo
.
image
,
price
:
Number
(
newHouseInfo
.
reference_avg_price
)
===
0
?
'--'
:
Number
(
newHouseInfo
.
reference_avg_price
),
price
:
Number
(
newHouseInfo
.
reference_avg_price
)
===
0
?
'--'
:
Number
(
newHouseInfo
.
reference_avg_price
),
corner
:
newHouseInfo
.
corner
||
''
,
corner
:
newHouseInfo
.
corner
||
''
,
sale_type
:
SaleType
[
newHouseInfo
.
sale_type
]
||
SaleType
[
3
],
//销售状态 0未开售,1售罄,2预售,3在售
}
}
return
ret
;
return
ret
;
}
}
...
...
app/service/house/v2/option.js
View file @
7cd7f1b4
...
@@ -63,6 +63,11 @@ const NEW_HOUSE_AREA = [
...
@@ -63,6 +63,11 @@ const NEW_HOUSE_AREA = [
{
name
:
'200平米以上'
,
id
:
-
144
,
min
:
200
,
max
:
999
}
{
name
:
'200平米以上'
,
id
:
-
144
,
min
:
200
,
max
:
999
}
]
]
const
NEW_HOUSE_LOAN_TYPE
=
[
{
name
:
'全部'
,
id
:
-
146
,
values
:
0
},
{
name
:
'可公积金贷款'
,
id
:
-
147
,
values
:
1
},
];
class
OptionService
extends
Service
{
class
OptionService
extends
Service
{
//获取筛选项
//获取筛选项
...
@@ -91,9 +96,9 @@ class OptionService extends Service {
...
@@ -91,9 +96,9 @@ class OptionService extends Service {
const
total_price
=
NEW_HOUSE_TOTAL_PRICE
;
const
total_price
=
NEW_HOUSE_TOTAL_PRICE
;
const
house_types
=
HOUSE_TYPE
;
const
house_types
=
HOUSE_TYPE
;
const
house_area
=
NEW_HOUSE_AREA
;
const
house_area
=
NEW_HOUSE_AREA
;
const
loan_type
=
NEW_HOUSE_LOAN_TYPE
;
const
areas
=
await
this
.
getAreaOptions
(
city_code
);
const
areas
=
await
this
.
getAreaOptions
(
city_code
);
return
{
return
{
result
:
[
result
:
[
{
name
:
'区域'
,
id
:
-
1
,
path
:
[],
nameShow
:
''
,
_children
:
areas
},
{
name
:
'区域'
,
id
:
-
1
,
path
:
[],
nameShow
:
''
,
_children
:
areas
},
...
@@ -103,7 +108,8 @@ class OptionService extends Service {
...
@@ -103,7 +108,8 @@ class OptionService extends Service {
{
name
:
'单价'
,
id
:
-
4
,
_children
:
unit_price
}]
{
name
:
'单价'
,
id
:
-
4
,
_children
:
unit_price
}]
},
},
{
name
:
'面积'
,
id
:
-
5
,
path
:
[],
nameShow
:
''
,
_children
:
house_area
},
{
name
:
'面积'
,
id
:
-
5
,
path
:
[],
nameShow
:
''
,
_children
:
house_area
},
{
name
:
'户型'
,
id
:
-
6
,
path
:
[],
nameShow
:
''
,
_children
:
house_types
},
// { name: '户型', id: -6, path: [], nameShow: '', _children: house_types },
{
name
:
'贷款方式'
,
id
:
-
6
,
path
:
[],
nameShow
:
''
,
_children
:
loan_type
},
]
]
};
};
}
}
...
...
app/service/house/v2/rental_house.js
View file @
7cd7f1b4
...
@@ -63,7 +63,7 @@ class RentalHouseService extends Service {
...
@@ -63,7 +63,7 @@ class RentalHouseService extends Service {
const
rental_houses_results
=
await
ctx
.
realestateModel
.
RentalHouse
.
list
({
page
:
page
,
limit
:
Number
(
limit
),
where
:
where
,
order
:
[[
'order_id'
,
'desc'
],
[
'id'
,
'desc'
]]
});
const
rental_houses_results
=
await
ctx
.
realestateModel
.
RentalHouse
.
list
({
page
:
page
,
limit
:
Number
(
limit
),
where
:
where
,
order
:
[[
'order_id'
,
'desc'
],
[
'id'
,
'desc'
]]
});
let
rental_houses
=
await
this
.
formatRentalHouseBasic
(
rental_houses_results
.
rows
);
let
rental_houses
=
await
this
.
formatRentalHouseBasic
(
rental_houses_results
.
rows
);
rental_houses
=
R
.
project
([
'id'
,
'image'
,
'name'
,
'address'
,
'price'
,
'tags'
,
'favourable_info'
])(
rental_houses
);
rental_houses
=
R
.
project
([
'id'
,
'image'
,
'name'
,
'address'
,
'price'
,
'
surplus_amount'
,
'
tags'
,
'favourable_info'
])(
rental_houses
);
return
{
page
:
page
,
count
:
rental_houses_results
.
count
,
results
:
rental_houses
};
return
{
page
:
page
,
count
:
rental_houses_results
.
count
,
results
:
rental_houses
};
...
@@ -100,11 +100,24 @@ class RentalHouseService extends Service {
...
@@ -100,11 +100,24 @@ class RentalHouseService extends Service {
//添加用户足迹
//添加用户足迹
ctx
.
service
.
house
.
v2
.
footPrint
.
addFootPrint
({
type
:
2
,
id
:
rental_house_id
});
ctx
.
service
.
house
.
v2
.
footPrint
.
addFootPrint
({
type
:
2
,
id
:
rental_house_id
});
const
city_codes
=
[
rental_house_info
.
province
,
rental_house_info
.
city
,
rental_house_info
.
area
];
let
gps_info
=
{};
const
cities
=
await
ctx
.
blockModel
.
City
.
all
({
where
:
{
code
:
{
$in
:
city_codes
}
}
});
if
(
!
rental_house_info
.
gps
)
{
const
city
=
(
cities
&&
cities
[
1
]
&&
cities
[
1
].
name
)
?
cities
[
1
].
name
:
''
;
const
city_codes
=
[
rental_house_info
.
province
,
rental_house_info
.
city
,
rental_house_info
.
area
];
const
address
=
R
.
pluck
(
'name'
,
cities
).
join
(
''
)
+
rental_house_info
.
address
;
const
cities
=
await
ctx
.
blockModel
.
City
.
all
({
where
:
{
code
:
{
$in
:
city_codes
}
}
});
const
gps_info
=
await
ctx
.
helper
.
getGPS
(
address
,
city
);
const
city
=
(
cities
&&
cities
[
1
]
&&
cities
[
1
].
name
)
?
cities
[
1
].
name
:
''
;
const
address
=
R
.
pluck
(
'name'
,
cities
).
join
(
''
)
+
rental_house_info
.
address
;
console
.
info
(
address
);
gps_info
=
await
ctx
.
helper
.
getGPS
(
address
,
city
);
ctx
.
realestateModel
.
RentalHouse
.
edit
({
where
:
{
id
:
rental_house_id
},
params
:
{
gps
:
`
${
gps_info
.
lat
}
,
${
gps_info
.
lng
}
`
}
});
}
else
{
const
gps_str
=
ctx
.
helper
.
checkGps
(
rental_house_info
.
gps
);
const
gps_array
=
gps_str
.
split
(
','
);
gps_info
=
{
lng
:
gps_array
[
1
],
lat
:
gps_array
[
0
],
}
}
house_basic
.
longitude
=
gps_info
.
lng
;
house_basic
.
longitude
=
gps_info
.
lng
;
house_basic
.
latitude
=
gps_info
.
lat
;
house_basic
.
latitude
=
gps_info
.
lat
;
...
@@ -169,11 +182,13 @@ class RentalHouseService extends Service {
...
@@ -169,11 +182,13 @@ class RentalHouseService extends Service {
image
:
rental_house
.
image
,
//列表展示图片
image
:
rental_house
.
image
,
//列表展示图片
// residential_id: rental_house.residentialId,//小区id
// residential_id: rental_house.residentialId,//小区id
address
:
rental_house
.
address
,
//详细地址
address
:
rental_house
.
address
,
//详细地址
gps
:
rental_house
.
gps
,
//项目地址经纬度
price
:
rental_house
.
price
,
//价格
price
:
rental_house
.
price
,
//价格
discount
:
rental_house
.
discount
,
//折扣
discount
:
rental_house
.
discount
,
//折扣
// business_license: rental_house.businessLicense,
// business_license: rental_house.businessLicense,
tags
:
rental_house
.
tags
,
//房源特点
tags
:
rental_house
.
tags
,
//房源特点
rental_type
:
rental_house
.
rental_type
,
//租房类型 1整租 2合租 3独栋公寓
rental_type
:
rental_house
.
rental_type
,
//租房类型 1整租 2合租 3独栋公寓
surplus_amount
:
rental_house
.
surplus_amount
,
//剩余数量 目前如果为0则展示 "满租",其他情况不展示
favourable_info
:
rental_house
.
favourable_info
,
//优惠信息
favourable_info
:
rental_house
.
favourable_info
,
//优惠信息
introduce
:
rental_house
.
description
||
`该社区亮点:
introduce
:
rental_house
.
description
||
`该社区亮点:
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
...
...
app/service/house/v2/tool.js
View file @
7cd7f1b4
...
@@ -111,6 +111,42 @@ class ToolService extends Service {
...
@@ -111,6 +111,42 @@ class ToolService extends Service {
return
{
status
,
notice
,
invest_items
};
return
{
status
,
notice
,
invest_items
};
}
}
//存钱罐计算完毕后 生成购房计划
async
generateHousePlan_2_1
(
input
)
{
const
{
ctx
}
=
this
;
const
down_payment
=
input
.
down_payment
||
0
;
//首付金额
const
invest_payment
=
input
.
invest_payment
||
0
;
//投资金额
const
prepare_time
=
input
.
prepare_time
||
6
;
const
balance
=
down_payment
-
invest_payment
;
let
notice
=
''
;
let
status
=
0
;
let
invest_items
=
[];
if
(
balance
<=
0
)
{
status
=
2
;
//完全有能力买到房
notice
=
'您的资金已满足本项目首付条件,还有更多项目在您预算范围内。一键预约,轻松看房!'
;
return
{
status
,
notice
,
invest_items
};
}
const
rate
=
balance
/
invest_payment
;
if
(
rate
>
10
)
{
status
=
0
;
//完全没有希望能买到房
notice
=
'非常遗憾,您的首付预算距离购买该项目尚有较大差距,请修改购房计划,重新尝试!'
;
}
else
{
status
=
1
;
//加把劲还是有希望买到房
notice
=
'恭喜您!依据以上计划,您即将完成此项目首付款准备。您现阶段首付预算可以购买以下项目房源:'
;
const
invest_plans
=
await
ctx
.
blockModel
.
HouseInvestPlan
.
one
({
where
:
{
condition_min
:
{
$lt
:
rate
},
condition_max
:
{
$gte
:
rate
},
status
:
'online'
,
valid
:
1
,
period
:
prepare_time
}
});
if
(
Object
.
keys
(
invest_plans
).
length
!==
0
&&
invest_plans
.
items
)
{
invest_items
=
invest_plans
.
items
;
if
(
invest_items
.
length
===
0
)
{
//差距还是太大 投资期限过长 不宜买房
status
=
0
;
notice
=
'非常遗憾,您的首付预算距离购买该项目尚有较大差距,请修改购房计划,重新尝试!'
;
}
}
}
return
{
status
,
notice
,
invest_items
};
}
}
}
module
.
exports
=
ToolService
;
module
.
exports
=
ToolService
;
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