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
fb2a35ec
Commit
fb2a35ec
authored
Apr 11, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
89ab9771
Pipeline
#5861
passed with stage
in 2 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
305 additions
and
60 deletions
+305
-60
rental_house.js
app/controller/house/rental_house.js
+36
-5
tool.js
app/controller/house/tool.js
+51
-0
house_price_map.js
app/model/block/house_price_map.js
+84
-0
house.js
app/router/house.js
+9
-3
option.js
app/service/house/option.js
+39
-29
rental_house.js
app/service/house/rental_house.js
+29
-21
tool.js
app/service/house/tool.js
+56
-0
rental_house_type.js
app/service/house_common/rental_house_type.js
+1
-1
config.default.js
config/config.default.js
+0
-1
No files found.
app/controller/house/rental_house.js
View file @
fb2a35ec
...
@@ -4,20 +4,51 @@ const Controller = require('egg').Controller;
...
@@ -4,20 +4,51 @@ const Controller = require('egg').Controller;
class
RentalHouseController
extends
Controller
{
class
RentalHouseController
extends
Controller
{
//租房首页信息
async
home
()
{
const
{
ctx
}
=
this
;
//banners
const
app_user_id
=
ctx
.
appUserId
;
const
user_id
=
ctx
.
userId
;
const
token
=
ctx
.
token
;
const
device_id
=
ctx
.
device_id
;
const
device_login_id
=
ctx
.
device_login_id
;
const
headers
=
{
app_user_id
:
app_user_id
,
device_id
:
device_id
||
'610d1ed6-b140-4edd-9f50-f4a7aee525b8'
,
device_login_id
:
device_login_id
,
token
:
token
,
uid
:
user_id
,
}
// house_h5_rental_home_banners
const
banners_result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
NODE_URL
+
'/51app/api/block/all'
,
{
alias
:
'cnd_app_discovery_audit_banners'
},
{
method
:
'GET'
,
dataType
:
'json'
,
headers
:
headers
});
let
banners
=
[];
if
(
banners_result
.
status
===
200
)
{
banners
=
banners_result
.
data
.
results
;
}
const
developers
=
await
ctx
.
service
.
house
.
option
.
getDevelopers
();
//品牌信息
ctx
.
success
({
banners
,
developers
});
}
//租房列表
async
getRentalHouses
()
{
async
getRentalHouses
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
query
;
const
query_params
=
ctx
.
query
;
const
input_params
=
ctx
.
request
.
body
;
const
rule
=
{
const
rule
=
{
brand
:
{
type
:
'string'
,
required
:
false
},
//品牌
brand
:
{
type
:
'string'
,
required
:
false
},
//品牌
district
:
{
type
:
'string'
,
required
:
false
},
//区域
area_code
:
{
type
:
'string'
,
required
:
false
},
//区域
// price: { type: 'enum', required: false, values: ['1', '2', '4', '5', '6', '7', '8', '9']
},//价格
price
:
{
type
:
'object'
,
required
:
false
},
//价格
house_type
:
{
type
:
'
enum'
,
required
:
false
,
values
:
[
'1'
,
'2'
,
'4'
,
'5'
,
'6'
]
},
//房型
house_type
:
{
type
:
'
string'
,
required
:
false
},
//房型
};
};
ctx
.
validate
(
rule
,
input_params
);
ctx
.
validate
(
rule
,
input_params
);
const
ret
=
await
ctx
.
service
.
house
.
rentalHouse
.
getRentalHousesByFilter
(
input_params
);
const
ret
=
await
ctx
.
service
.
house
.
rentalHouse
.
getRentalHousesByFilter
(
input_params
);
ctx
.
success
(
ret
);
ctx
.
success
(
{
query_params
,
input_params
,
results
:
ret
,
count
:
ret
.
length
}
);
}
}
//租房详情
async
getRentalHouse
()
{
async
getRentalHouse
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
params
;
const
input_params
=
ctx
.
params
;
...
...
app/controller/house/tool.js
0 → 100644
View file @
fb2a35ec
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
ToolController
extends
Controller
{
async
getMapPoint
()
{
const
{
ctx
}
=
this
;
const
input_parmas
=
ctx
.
params
;
const
rule
=
{
city_code
:
{
type
:
'string'
,
required
:
true
},
}
ctx
.
validate
(
rule
,
input_parmas
);
const
city_code
=
input_parmas
.
city_code
;
const
ret
=
await
ctx
.
service
.
house
.
tool
.
getMapPoint
(
city_code
);
ctx
.
success
({
results
:
ret
});
}
async
generateBuyHousePlan
()
{
const
{
ctx
}
=
this
;
const
input_parmas
=
ctx
.
request
.
body
;
const
rule
=
{
city_code
:
{
type
:
'string'
,
required
:
true
},
down_payment
:
{
type
:
'string'
,
required
:
true
},
invest_payment
:
{
type
:
'string'
,
required
:
true
}
}
ctx
.
validate
(
rule
,
input_parmas
);
const
target_house
=
await
ctx
.
blockModel
.
HousePriceMap
.
one
({
where
:
{
id
:
input_parmas
.
city_code
}
});
let
target_price
=
0
;
if
(
target_house
&&
target_house
.
price
)
{
target_price
=
target_house
.
price
;
}
const
filter
=
{
price
:
{
min
:
target_price
-
300000
,
max
:
target_price
+
300000
},
}
const
recommend_houses
=
await
ctx
.
service
.
house
.
rentalHouse
.
getRentalHousesByFilter
(
filter
);
//推荐房源
// const recommend_houses = [];//推荐房源
const
house_plan
=
await
ctx
.
service
.
house
.
tool
.
generateHousePlan
(
input_parmas
);
//计算购房能力 生成购房计划
const
ret
=
{
house_plan
,
recommend_houses
,
}
ctx
.
success
({
results
:
ret
});
}
}
module
.
exports
=
ToolController
;
app/model/block/house_price_map.js
0 → 100644
View file @
fb2a35ec
'use strict'
;
module
.
exports
=
app
=>
{
const
{
STRING
,
INTEGER
}
=
app
.
Sequelize
;
const
HousePriceMap
=
app
.
blockModel
.
define
(
'house_price_map'
,
{
id
:
{
type
:
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
,
},
pid
:
INTEGER
,
name
:
STRING
,
spell
:
STRING
,
longitude
:
STRING
,
latitude
:
STRING
,
price
:
INTEGER
,
is_top
:
INTEGER
,
},
{
timestamps
:
false
,
tableName
:
'house_price_map'
,
freezeTableName
:
true
,
});
HousePriceMap
.
one
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
HousePriceMap
.
findOne
({
attributes
:
attributes
,
where
:
where
,
});
}
HousePriceMap
.
all
=
async
(
data
)
=>
{
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
return
await
HousePriceMap
.
findAll
({
attributes
:
attributes
,
where
:
where
,
});
}
HousePriceMap
.
list
=
async
(
data
=
{})
=>
{
const
limit
=
data
.
limit
?
data
.
limit
:
10
;
const
page
=
data
.
page
?
data
.
page
:
1
;
const
order
=
data
.
order
?
data
.
order
:
[];
const
attributes
=
data
.
attributes
?
data
.
attributes
:
{};
const
where
=
data
.
where
?
data
.
where
:
{};
const
condition
=
{
offset
:
(
page
-
1
)
*
limit
,
limit
,
where
:
where
,
order
:
order
,
attributes
:
attributes
,
};
const
{
count
,
rows
}
=
await
HousePriceMap
.
findAndCountAll
(
condition
);
return
{
page
,
count
,
rows
};
}
HousePriceMap
.
add
=
async
(
data
)
=>
{
try
{
//返回promise对象实力 instance
const
res
=
await
HousePriceMap
.
create
(
data
);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return
res
.
id
;
}
catch
(
error
)
{
ctx
.
status
=
500
;
throw
(
error
);
}
}
HousePriceMap
.
edit
=
async
(
data
)
=>
{
const
where
=
data
.
where
;
const
params
=
data
.
params
;
HousePriceMap
.
update
(
params
,
{
where
:
where
}).
catch
(
e
=>
res
.
json
({
status
:
500
,
error
:
e
}));
}
return
HousePriceMap
;
};
app/router/house.js
View file @
fb2a35ec
...
@@ -4,9 +4,15 @@ module.exports = app => {
...
@@ -4,9 +4,15 @@ module.exports = app => {
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/house'
);
const
router
=
app
.
router
.
namespace
(
app
.
config
.
projectRootPath
+
'/house'
);
const
loginAuth
=
app
.
middleware
.
loginAuth
({
type
:
'new'
});
//登录中间件
const
loginAuth
=
app
.
middleware
.
loginAuth
({
type
:
'new'
});
//登录中间件
router
.
get
(
'/options/:city_code'
,
'house.options.getOptions'
);
//筛选项信息
router
.
get
(
'/tool/:city_code'
,
'house.tool.getMapPoint'
);
//购房计划地图点位
router
.
get
(
'/rental_house'
,
'house.rentalHouse.getRentalHouses'
);
//租房列表
router
.
post
(
'/tool/plan'
,
'house.tool.generateBuyHousePlan'
);
//生成购房计划
router
.
get
(
'/rental_house/:rental_house_id'
,
'house.rentalHouse.getRentalHouse'
);
//租房列表
router
.
get
(
'/rental_house/home'
,
'house.rentalHouse.home'
);
//租房首页信息
router
.
get
(
'/options/:city_code'
,
'house.options.getOptions'
);
//筛选项信息
router
.
get
(
'/rental_house/list'
,
'house.rentalHouse.getRentalHouses'
);
//租房列表
router
.
post
(
'/rental_house/list'
,
'house.rentalHouse.getRentalHouses'
);
//租房列表
router
.
get
(
'/rental_house/info/:rental_house_id'
,
'house.rentalHouse.getRentalHouse'
);
//租房列表
//新房
//新房
router
.
get
(
'/new_house/list/:type'
,
'house.newHouse.getNewHouseList'
);
//列表
router
.
get
(
'/new_house/list/:type'
,
'house.newHouse.getNewHouseList'
);
//列表
...
...
app/service/house/option.js
View file @
fb2a35ec
...
@@ -3,50 +3,60 @@
...
@@ -3,50 +3,60 @@
const
Service
=
require
(
'egg'
).
Service
;
const
Service
=
require
(
'egg'
).
Service
;
const
PRICE_RANGE
=
{
const
PRICE_RANGE
=
[
1
:
{
name
:
'2000元以下'
,
min
:
0
,
max
:
2000
},
{
name
:
'2000元以下'
,
min
:
0
,
max
:
2000
},
2
:
{
name
:
'2000元-3000元'
,
min
:
2000
,
max
:
3000
},
{
name
:
'2000元-3000元'
,
min
:
2000
,
max
:
3000
},
3
:
{
name
:
'3000元-4000元'
,
min
:
3000
,
max
:
4000
},
{
name
:
'3000元-4000元'
,
min
:
3000
,
max
:
4000
},
4
:
{
name
:
'4000元-5000元'
,
min
:
4000
,
max
:
5000
},
{
name
:
'4000元-5000元'
,
min
:
4000
,
max
:
5000
},
5
:
{
name
:
'5000元-6000元'
,
min
:
5000
,
max
:
6000
},
{
name
:
'5000元-6000元'
,
min
:
5000
,
max
:
6000
},
6
:
{
name
:
'6000元-7000元'
,
min
:
6000
,
max
:
7000
},
{
name
:
'6000元-7000元'
,
min
:
6000
,
max
:
7000
},
7
:
{
name
:
'7000元-8000元'
,
min
:
7000
,
max
:
8000
},
{
name
:
'7000元-8000元'
,
min
:
7000
,
max
:
8000
},
8
:
{
name
:
'8000元-10000元'
,
min
:
8000
,
max
:
10000
},
{
name
:
'8000元-10000元'
,
min
:
8000
,
max
:
10000
},
9
:
{
name
:
'10000元以上'
,
min
:
10000
,
max
:
10000000000000
},
{
name
:
'10000元以上'
,
min
:
10000
,
max
:
10000000000000
},
}
]
const
HOUSE_TYPE
=
{
const
HOUSE_TYPE
=
[
1
:
{
name
:
'1室'
,
min
:
1
,
max
:
1
},
{
name
:
'1室'
,
min
:
1
,
max
:
1
,
value
:
1
,
},
2
:
{
name
:
'2室'
,
min
:
2
,
max
:
2
},
{
name
:
'2室'
,
min
:
2
,
max
:
2
,
value
:
2
,
},
3
:
{
name
:
'3室'
,
min
:
3
,
max
:
3
},
{
name
:
'3室'
,
min
:
3
,
max
:
3
,
value
:
3
,
},
4
:
{
name
:
'4室'
,
min
:
4
,
max
:
4
},
{
name
:
'4室'
,
min
:
4
,
max
:
4
,
value
:
4
,
},
5
:
{
name
:
'5室以上'
,
min
:
5
,
max
:
10000
},
{
name
:
'5室以上'
,
min
:
5
,
max
:
10000
,
value
:
5
,
},
6
:
{
name
:
'别墅'
,
min
:
10000
,
max
:
10000000
},
{
name
:
'别墅'
,
min
:
10000
,
max
:
10000000
,
value
:
6
,
},
}
]
class
OptionService
extends
Service
{
class
OptionService
extends
Service
{
//获取筛选项
async
getOptions
(
city_code
)
{
async
getOptions
(
city_code
)
{
const
brands
=
await
this
.
getDevelopers
();
const
house_types
=
HOUSE_TYPE
;
const
prices
=
PRICE_RANGE
;
const
areas
=
await
this
.
getAreaOptions
(
city_code
);
return
{
result
:
{
brands
,
prices
,
house_types
,
areas
}
};
}
//获取开发商列表
async
getDevelopers
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
developers_results
=
await
ctx
.
service
.
houseCommon
.
developer
.
all
({});
const
developers_results
=
await
ctx
.
service
.
houseCommon
.
developer
.
all
({});
const
developers
=
developers_results
.
results
;
const
developers
=
developers_results
.
results
;
const
brands
=
[];
const
ret
=
[];
for
(
let
i
in
developers
)
{
for
(
let
i
in
developers
)
{
const
developer
=
developers
[
i
];
const
developer
=
developers
[
i
];
brands
.
push
({
ret
.
push
({
id
:
developer
.
id
,
id
:
developer
.
id
,
name
:
developer
.
name
,
name
:
developer
.
name
,
image
:
developer
.
logo
,
image
:
developer
.
logo
,
});
});
}
}
const
house_types
=
HOUSE_TYPE
;
const
prices
=
PRICE_RANGE
;
const
areas
=
await
this
.
getAreaOptions
(
city_code
);
return
{
brands
,
prices
,
house_types
,
areas
}
;
return
ret
;
}
}
//获取区域商圈
async
getAreaOptions
(
city_code
)
{
async
getAreaOptions
(
city_code
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
city_code
}
});
const
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
city_code
}
});
...
@@ -70,14 +80,14 @@ class OptionService extends Service {
...
@@ -70,14 +80,14 @@ class OptionService extends Service {
const
bizcircle
=
bizcircles
[
i
];
const
bizcircle
=
bizcircles
[
i
];
_children
.
push
({
_children
.
push
({
id
:
bizcircle
.
id
,
id
:
bizcircle
.
id
,
name
:
bizcircle
.
name
,
area_
name
:
bizcircle
.
name
,
district_id
:
bizcircle
.
district_id
,
//
district_id: bizcircle.district_id,
});
});
}
}
ret
.
push
({
ret
.
push
({
id
:
district
.
id
,
id
:
district
.
id
,
name
:
district
.
name
,
area_
name
:
district
.
name
,
city_id
:
district
.
city_id
,
//
city_id: district.city_id,
_children
:
_children
,
_children
:
_children
,
})
})
...
...
app/service/house/rental_house.js
View file @
fb2a35ec
...
@@ -30,11 +30,16 @@ class RentalHouseService extends Service {
...
@@ -30,11 +30,16 @@ class RentalHouseService extends Service {
async
getRentalHousesByFilter
(
condition
)
{
async
getRentalHousesByFilter
(
condition
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
queryConditions
=
[];
const
queryConditions
=
[];
if
(
condition
.
brand
)
{
if
(
condition
.
brand
)
{
queryConditions
.
push
();
queryConditions
.
push
({
key
:
'developerId'
,
value
:
condition
.
brand
,
operator
:
'equal'
,
});
}
}
if
(
condition
.
price
&&
condition
.
price
.
m
in
&&
condition
.
price
.
m
ax
)
{
if
(
condition
.
price
&&
condition
.
price
.
max
)
{
queryConditions
.
push
({
queryConditions
.
push
({
key
:
'price'
,
key
:
'price'
,
value
:
condition
.
price
.
min
,
value
:
condition
.
price
.
min
,
...
@@ -47,31 +52,28 @@ class RentalHouseService extends Service {
...
@@ -47,31 +52,28 @@ class RentalHouseService extends Service {
});
});
}
}
if
(
condition
.
house_type
)
{
if
(
condition
.
house_type
)
{
queryConditions
.
push
({
key
:
'rentalHouseType'
,
value
:
condition
.
house_type
,
operator
:
'equal'
,
});
}
}
queryConditions
.
push
({
key
:
"state"
,
value
:
1
,
operator
:
"equal"
});
const
filter
=
{
const
filter
=
{
pageSize
:
30
,
pageSize
:
30
,
queryConditions
:
[{
queryConditions
:
queryConditions
,
key
:
"state"
,
value
:
1
,
operator
:
"equal"
},
{
key
:
"price"
,
value
:
19000
,
operator
:
"greater"
},
{
key
:
"price"
,
value
:
29000
,
operator
:
"less"
},],
orderConditions
:
[{
orderConditions
:
[{
key
:
'price'
,
key
:
'price'
,
orderSequence
:
'asc'
,
orderSequence
:
'asc'
,
},],
},],
}
}
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
(
filter
);
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
(
filter
);
cons
t
rental_houses
=
await
this
.
formatRentalHouseBasic
(
rental_houses_results
.
results
);
le
t
rental_houses
=
await
this
.
formatRentalHouseBasic
(
rental_houses_results
.
results
);
rental_houses
=
R
.
project
([
'id'
,
'image'
,
'name'
,
'address'
,
'price'
,
'tags'
,
'favourable_info'
])(
rental_houses
);
return
rental_houses
;
return
rental_houses
;
}
}
...
@@ -170,7 +172,7 @@ class RentalHouseService extends Service {
...
@@ -170,7 +172,7 @@ class RentalHouseService extends Service {
],
],
};
};
const
ret
=
[]
;
const
ret
=
{}
;
for
(
let
i
in
house_types
)
{
for
(
let
i
in
house_types
)
{
const
house_type
=
house_types
[
i
];
const
house_type
=
house_types
[
i
];
house_type_image_filter
.
queryConditions
.
push
({
house_type_image_filter
.
queryConditions
.
push
({
...
@@ -179,7 +181,10 @@ class RentalHouseService extends Service {
...
@@ -179,7 +181,10 @@ class RentalHouseService extends Service {
operator
:
'equal'
,
operator
:
'equal'
,
});
});
const
house_type_images_results
=
await
ctx
.
service
.
houseCommon
.
houseImage
.
all
(
house_type_image_filter
);
const
house_type_images_results
=
await
ctx
.
service
.
houseCommon
.
houseImage
.
all
(
house_type_image_filter
);
ret
.
push
({
if
(
!
ret
[
house_type
.
name
]
||
ret
[
house_type
.
name
].
length
===
0
)
{
ret
[
house_type
.
name
]
=
[];
}
ret
[
house_type
.
name
].
push
({
id
:
house_type
.
id
,
id
:
house_type
.
id
,
name
:
house_type
.
name
,
name
:
house_type
.
name
,
area
:
house_type
.
area
,
area
:
house_type
.
area
,
...
@@ -191,6 +196,7 @@ class RentalHouseService extends Service {
...
@@ -191,6 +196,7 @@ class RentalHouseService extends Service {
return
ret
;
return
ret
;
}
}
async
formatRentalHouseBasic
(
rental_houses
)
{
async
formatRentalHouseBasic
(
rental_houses
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
...
@@ -202,6 +208,8 @@ class RentalHouseService extends Service {
...
@@ -202,6 +208,8 @@ class RentalHouseService extends Service {
const
rental_house
=
rental_houses
[
i
];
const
rental_house
=
rental_houses
[
i
];
const
temp_rental_house
=
{
const
temp_rental_house
=
{
id
:
rental_house
.
id
,
id
:
rental_house
.
id
,
name
:
rental_house
.
name
,
//房源名称
image
:
rental_house
.
imgae
,
//列表展示图片
residential_id
:
rental_house
.
residentialId
,
//小区id
residential_id
:
rental_house
.
residentialId
,
//小区id
address
:
rental_house
.
address
,
//详细地址
address
:
rental_house
.
address
,
//详细地址
price
:
rental_house
.
price
,
//价格
price
:
rental_house
.
price
,
//价格
...
@@ -209,7 +217,7 @@ class RentalHouseService extends Service {
...
@@ -209,7 +217,7 @@ class RentalHouseService extends Service {
// business_license: rental_house.businessLicense,
// business_license: rental_house.businessLicense,
tags
:
rental_house
.
tags
.
split
(
','
),
//房源特点
tags
:
rental_house
.
tags
.
split
(
','
),
//房源特点
favourable_info
:
rental_house
.
favourableInfo
,
//优惠信息
favourable_info
:
rental_house
.
favourableInfo
,
//优惠信息
introduce
:
rental_house
.
introduce
||
`该社区亮点:
introduce
:
rental_house
.
description
||
`该社区亮点:
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
2、房型说明:独门独户,拎包入住,满足各种需求,采光
2、房型说明:独门独户,拎包入住,满足各种需求,采光
3、社区配套:健身房、休憩区、小影院、娱乐室、商务区、无人商店、快递柜。
3、社区配套:健身房、休憩区、小影院、娱乐室、商务区、无人商店、快递柜。
...
...
app/service/house/tool.js
0 → 100644
View file @
fb2a35ec
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
ToolService
extends
Service
{
async
getMapPoint
(
city_code
)
{
const
{
ctx
}
=
this
;
const
first_tops
=
await
ctx
.
blockModel
.
HousePriceMap
.
all
({
where
:
{
pid
:
city_code
}
});
if
(
!
first_tops
||
first_tops
.
length
===
0
)
{
return
[];
}
const
ret
=
[];
for
(
let
i
in
first_tops
)
{
const
item
=
first_tops
[
i
];
ret
.
push
({
id
:
item
.
id
,
name
:
item
.
name
,
longitude
:
item
.
longitude
,
latitude
:
item
.
latitude
,
price
:
item
.
price
,
});
}
return
ret
;
}
async
generateHousePlan
(
input
)
{
const
{
ctx
}
=
this
;
const
down_payment
=
input
.
down_payment
||
0
;
//首付金额
const
invest_payment
=
input
.
invest_payment
||
0
;
//投资金额
const
balance
=
down_payment
-
invest_payment
;
let
notice
=
''
;
let
status
=
0
;
let
plan
=
[];
if
(
balance
<
0
)
{
status
=
2
;
//完全有能力买到房
notice
=
'您的资金已满足本项目首付条件,还有更多项目在您预算范围内。一键预约,轻松看房!'
;
return
{
status
,
notice
,
plan
};
}
const
rate
=
balance
/
invest_payment
;
if
(
rate
>=
0.5
)
{
status
=
0
;
//完全没有希望能买到房
notice
=
'非常遗憾,您的首付预算距离购买该项目尚有较大差距,您可以选择以下方案:'
;
}
else
{
status
=
1
;
//j加把劲还是有希望买到房
notice
=
'恭喜您!依据以上计划,您即将完成XXX项目首付款准备。您现阶段首付预算可以购买以下项目房源:'
;
}
return
{
status
,
notice
,
plan
};
}
}
module
.
exports
=
ToolService
;
app/service/house_common/rental_house_type.js
View file @
fb2a35ec
...
@@ -7,7 +7,7 @@ class RentalHouseTypeService extends Service {
...
@@ -7,7 +7,7 @@ class RentalHouseTypeService extends Service {
async
all
(
data
)
{
async
all
(
data
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
pageIndex
=
data
.
page
||
1
;
const
pageIndex
=
data
.
page
||
0
;
const
pageSize
=
data
.
pageSize
||
10
;
const
pageSize
=
data
.
pageSize
||
10
;
const
queryConditions
=
data
.
queryConditions
||
[];
const
queryConditions
=
data
.
queryConditions
||
[];
const
orderConditions
=
data
.
orderConditions
||
[];
const
orderConditions
=
data
.
orderConditions
||
[];
...
...
config/config.default.js
View file @
fb2a35ec
...
@@ -16,7 +16,6 @@ module.exports = appInfo => {
...
@@ -16,7 +16,6 @@ module.exports = appInfo => {
config
.
keys
=
appInfo
.
name
+
'_1554705194320_9697'
;
config
.
keys
=
appInfo
.
name
+
'_1554705194320_9697'
;
config
.
projectRootPath
=
'/51business/api'
;
config
.
projectRootPath
=
'/51business/api'
;
config
.
projectRootPath
=
'/51business/api'
;
// add your middleware config here
// add your middleware config here
config
.
middleware
=
[
'errorHandler'
];
config
.
middleware
=
[
'errorHandler'
];
...
...
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