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
02005eb9
Commit
02005eb9
authored
Apr 09, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rental house
parent
205fa107
Pipeline
#5776
passed with stage
in 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
193 additions
and
8 deletions
+193
-8
rental_house.js
app/service/house/rental_house.js
+136
-7
house_image.js
app/service/house_common/house_image.js
+2
-1
rental_house_type.js
app/service/house_common/rental_house_type.js
+55
-0
No files found.
app/service/house/rental_house.js
View file @
02005eb9
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
'use strict'
;
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
const
Service
=
require
(
'egg'
).
Service
;
const
R
=
require
(
'ramda'
);
const
PRICE_RANGE
=
{
const
PRICE_RANGE
=
{
1
:
{
name
:
'2000元以下'
,
min
:
0
,
max
:
2000
},
1
:
{
name
:
'2000元以下'
,
min
:
0
,
max
:
2000
},
...
@@ -33,6 +34,21 @@ class RentalHouseService extends Service {
...
@@ -33,6 +34,21 @@ class RentalHouseService extends Service {
if
(
condition
.
brand
)
{
if
(
condition
.
brand
)
{
queryConditions
.
push
();
queryConditions
.
push
();
}
}
if
(
condition
.
price
&&
condition
.
price
.
min
&&
condition
.
price
.
max
)
{
queryConditions
.
push
({
key
:
'price'
,
value
:
condition
.
price
.
min
,
operator
:
'greaterEqual'
,
});
queryConditions
.
push
({
key
:
'price'
,
value
:
condition
.
price
.
max
,
operator
:
'lessEqual'
,
});
}
if
(
condition
.
house_type
)
{
}
const
filter
=
{
const
filter
=
{
pageSize
:
30
,
pageSize
:
30
,
queryConditions
:
[{
queryConditions
:
[{
...
@@ -54,21 +70,43 @@ class RentalHouseService extends Service {
...
@@ -54,21 +70,43 @@ class RentalHouseService extends Service {
},],
},],
}
}
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
(
filter
);
const
rental_houses_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
all
(
filter
);
return
rental_houses_results
;
const
rental_houses
=
await
this
.
formatRentalHouseBasic
(
rental_houses_results
.
results
);
return
rental_houses
;
}
}
//房源详细信息
async
getRentalHouse
(
rental_house_id
)
{
async
getRentalHouse
(
rental_house_id
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
//获取房源基本信息
//获取房源基本信息
const
house_basic
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
one
(
rental_house_id
);
let
house_basic_result
=
await
ctx
.
service
.
houseCommon
.
rentalHouse
.
one
(
rental_house_id
);
if
(
!
house_basic
||
!
house_basic
.
id
)
{
if
(
!
house_basic_result
||
!
house_basic_result
.
id
)
{
ctx
.
failed
(
'house not found'
);
ctx
.
failed
(
'house not found'
);
}
}
rental_house_id
=
house_basic_result
.
id
;
//获取房源图片信息
//获取房源图片信息
const
house_images
=
await
this
.
getRentalHouseImages
(
rental_house_id
);
//获取房源类型
const
house_types
=
await
this
.
getRentalHouseTypes
(
rental_house_id
);
//处理房源基本信息格式
let
house_basic
=
await
this
.
formatRentalHouseBasic
([
house_basic_result
]);
house_basic
=
house_basic
[
0
];
return
{
house_basic
,
house_images
,
house_types
};
}
//获取房源画册
async
getRentalHouseImages
(
rental_house_id
)
{
const
{
ctx
}
=
this
;
const
house_image_filter
=
{
const
house_image_filter
=
{
pageSize
:
10000
,
queryConditions
:
[
queryConditions
:
[
{
{
key
:
'state'
,
key
:
'state'
,
...
@@ -82,16 +120,107 @@ class RentalHouseService extends Service {
...
@@ -82,16 +120,107 @@ class RentalHouseService extends Service {
},
},
{
{
key
:
'connectId'
,
key
:
'connectId'
,
value
:
house_basic
.
id
,
value
:
rental_house_
id
,
operator
:
'equal'
operator
:
'equal'
},
},
],
],
};
};
const
house_images_results
=
await
ctx
.
service
.
houseCommon
.
houseImage
.
all
(
house_image_filter
);
const
house_images_results
=
await
ctx
.
service
.
houseCommon
.
houseImage
.
all
(
house_image_filter
);
const
house_images
=
house_images_results
.
results
;
const
house_images
=
R
.
project
([
'id'
,
'path'
,
'description'
])(
house_images_results
.
results
);
return
{
house_basic
,
house_images
};
return
house_images
;
}
//获取房源类型
async
getRentalHouseTypes
(
rental_house_id
)
{
const
{
ctx
}
=
this
;
const
house_type_filter
=
{
pageSize
:
1000
,
queryConditions
:
[
{
key
:
'rentalHouseId'
,
value
:
rental_house_id
,
operator
:
'equal'
,
},
{
key
:
'state'
,
value
:
'1'
,
operator
:
'equal'
,
},
]
}
const
house_types_results
=
await
ctx
.
service
.
houseCommon
.
rentalHouseType
.
all
(
house_type_filter
);
const
house_types
=
house_types_results
.
results
;
let
house_type_image_filter
=
{
pageSize
:
10000
,
queryConditions
:
[
{
key
:
'state'
,
value
:
1
,
operator
:
'equal'
},
{
key
:
'type'
,
value
:
3
,
operator
:
'equal'
,
},
],
};
const
ret
=
[];
for
(
let
i
in
house_types
)
{
const
house_type
=
house_types
[
i
];
house_type_image_filter
.
queryConditions
.
push
({
key
:
'connectId'
,
value
:
house_type
.
id
,
operator
:
'equal'
,
});
const
house_type_images_results
=
await
ctx
.
service
.
houseCommon
.
houseImage
.
all
(
house_type_image_filter
);
ret
.
push
({
id
:
house_type
.
id
,
name
:
house_type
.
name
,
area
:
house_type
.
area
,
price
:
house_type
.
price
,
images
:
R
.
project
([
'id'
,
'path'
,
'description'
])(
house_type_images_results
.
results
)
});
}
return
ret
;
}
async
formatRentalHouseBasic
(
rental_houses
)
{
const
{
ctx
}
=
this
;
if
(
!
rental_houses
||
!
Array
.
isArray
(
rental_houses
)
||
rental_houses
.
length
===
0
)
{
return
[];
}
const
ret
=
[];
for
(
let
i
in
rental_houses
)
{
const
rental_house
=
rental_houses
[
i
];
const
temp_rental_house
=
{
id
:
rental_house
.
id
,
residential_id
:
rental_house
.
residentialId
,
//小区id
address
:
rental_house
.
address
,
//详细地址
price
:
rental_house
.
price
,
//价格
discount
:
rental_house
.
discount
,
//折扣
// business_license: rental_house.businessLicense,
tags
:
rental_house
.
tags
.
split
(
','
),
//房源特点
favourable_info
:
rental_house
.
favourableInfo
,
//优惠信息
introduce
:
rental_house
.
introduce
||
`该社区亮点:
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
2、房型说明:独门独户,拎包入住,满足各种需求,采光
3、社区配套:健身房、休憩区、小影院、娱乐室、商务区、无人商店、快递柜。
4、房间配套:空调、Wifi、洗衣机、热水器、冰箱、床、衣柜、电脑桌、沙发。`
,
room_configuration
:
JSON
.
parse
(
rental_house
.
roomConfiguration
),
//房间配置
notice
:
rental_house
.
notice
,
//入住须知
};
ret
.
push
(
temp_rental_house
);
}
return
ret
;
}
}
}
}
...
...
app/service/house_common/house_image.js
View file @
02005eb9
...
@@ -18,8 +18,9 @@ class HouseImageService extends Service {
...
@@ -18,8 +18,9 @@ class HouseImageService extends Service {
data
.
pageIndex
=
pageIndex
;
data
.
pageIndex
=
pageIndex
;
data
.
pageSize
=
pageSize
;
data
.
pageSize
=
pageSize
;
ctx
.
logger
.
info
(
'houseimage_list_
condition
s: '
+
JSON
.
stringify
(
data
));
ctx
.
logger
.
info
(
'houseimage_list_
param
s: '
+
JSON
.
stringify
(
data
));
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/houseimage/list'
,
data
,
{
method
:
'POST'
,
dataType
:
'json'
});
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/houseimage/list'
,
data
,
{
method
:
'POST'
,
dataType
:
'json'
});
ctx
.
logger
.
info
(
'houseimage_list_result: '
+
JSON
.
stringify
(
result
));
if
(
result
.
status
!==
200
)
{
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
...
...
app/service/house_common/rental_house_type.js
0 → 100644
View file @
02005eb9
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
RentalHouseTypeService
extends
Service
{
async
all
(
data
)
{
const
{
ctx
}
=
this
;
const
pageIndex
=
data
.
page
||
1
;
const
pageSize
=
data
.
pageSize
||
10
;
const
queryConditions
=
data
.
queryConditions
||
[];
const
orderConditions
=
data
.
orderConditions
||
[];
data
.
queryConditions
=
queryConditions
;
data
.
orderConditions
=
orderConditions
;
data
.
pageIndex
=
pageIndex
;
data
.
pageSize
=
pageSize
;
ctx
.
logger
.
info
(
'rentalhousetype_list_params: '
+
JSON
.
stringify
(
data
));
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/rentalhousetype/list'
,
data
,
{
method
:
'POST'
,
dataType
:
'json'
});
ctx
.
logger
.
info
(
'rentalhousetype_list_result: '
+
JSON
.
stringify
(
result
));
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
err
=
JSON
.
stringify
(
result
.
data
);
}
else
{
err
=
result
.
data
;
}
ctx
.
failed
(
err
);
}
return
result
.
data
;
}
async
one
(
id
)
{
const
{
ctx
}
=
this
;
const
result
=
await
ctx
.
helper
.
send_request
(
this
.
config
.
HOUSE_SERVICE_API
+
'/v1/rentalhousetype/'
+
id
,
{},
{
method
:
'GET'
,
dataType
:
'json'
});
ctx
.
logger
.
info
(
'rentalhousetype_result: '
+
JSON
.
stringify
(
result
));
if
(
result
.
status
!==
200
)
{
let
err
=
''
;
if
(
typeof
(
result
.
data
)
!==
'string'
)
{
err
=
JSON
.
stringify
(
result
.
data
);
}
else
{
err
=
result
.
data
;
}
ctx
.
failed
(
err
);
}
return
result
;
}
}
module
.
exports
=
RentalHouseTypeService
;
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