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
e62be838
Commit
e62be838
authored
Jun 13, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addd
parent
02a2bfed
Pipeline
#8897
passed with stage
in 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
31 deletions
+68
-31
new_house.js
app/service/house/v2/new_house.js
+22
-8
search_history.js
app/service/house/v2/search_history.js
+45
-22
config.local.js
config/config.local.js
+1
-1
No files found.
app/service/house/v2/new_house.js
View file @
e62be838
...
...
@@ -3,6 +3,7 @@
const
Service
=
require
(
'egg'
).
Service
;
const
moment
=
require
(
'moment'
);
const
_
=
require
(
'lodash'
);
const
HOUSE_TYPE
=
[
{
name
:
'不限'
,
min
:
0
,
max
:
0
,
value
:
0
,
},
{
name
:
'1室'
,
min
:
1
,
max
:
1
,
value
:
1
,
},
...
...
@@ -367,14 +368,27 @@ class NewHouseService extends Service {
if
(
condition
.
total_price
&&
condition
.
total_price
.
hasOwnProperty
(
'min'
)
&&
condition
.
total_price
.
hasOwnProperty
(
'max'
))
{
//总价
filter
.
where
.
reference_total_price
=
{
$between
:
[
condition
.
total_price
.
min
,
condition
.
total_price
.
max
]
};
}
//根据户型的面积筛选 TODO
// if (condition.area && condition.area.hasOwnProperty('min') && condition.area.hasOwnProperty('max')) {
// filter.where.area = { $between: [condition.area.min, condition.area.max] };
// }
//户型 TODO
// if (condition.house_type) {
// filter.where.type = condition.house_type;
// }
//根据户型的面积筛选
//根据户型筛选
if
((
condition
.
area
&&
condition
.
area
.
hasOwnProperty
(
'min'
)
&&
condition
.
area
.
hasOwnProperty
(
'max'
))
||
condition
.
house_type
)
{
let
newHouseTypeFilter
=
{
attributes
:
[
'new_house_id'
],
where
:
{
status
:
'online'
,
valid
:
1
}
}
if
(
condition
.
house_type
)
{
newHouseTypeFilter
.
where
.
type
=
condition
.
house_type
;
}
if
((
condition
.
area
&&
condition
.
area
.
hasOwnProperty
(
'min'
)
&&
condition
.
area
.
hasOwnProperty
(
'max'
)))
{
newHouseTypeFilter
.
where
.
area
=
{
$between
:
[
condition
.
area
.
min
,
condition
.
area
.
max
]
};
}
let
newHouseIds
=
await
ctx
.
realestateModel
.
NewHouseType
.
all
(
newHouseTypeFilter
);
let
matchIds
=
_
.
uniq
(
_
.
map
(
newHouseIds
,
'new_house_id'
));
filter
.
where
.
id
=
{
$in
:
matchIds
};
}
if
(
condition
.
name
)
{
//关键词搜索 模糊查询
//增加搜索历史
let
addHistory
=
{
...
...
app/service/house/v2/search_history.js
View file @
e62be838
...
...
@@ -68,27 +68,7 @@ class searchHistoryService extends Service {
return
ret
;
}
//用户的搜索记录
let
endDate
=
moment
().
subtract
(
6
,
'months'
).
format
(
'YYYY-MM-DD HH:mm:ss'
);
let
filter
=
{
limit
:
50
,
attributes
:
[
'key_word'
],
where
:
{
state
:
1
,
user_id
:
ctx
.
userId
,
house_style
:
type
,
created_at
:
{
$gt
:
endDate
}
},
order
:
[[
'created_at'
,
'desc'
]],
}
let
searchHistoryList
=
await
ctx
.
realestateModel
.
SearchHistory
.
findAll
(
filter
);
let
list
=
[];
if
(
searchHistoryList
.
length
>
0
)
{
for
(
let
i
in
searchHistoryList
)
{
if
(
list
.
indexOf
(
searchHistoryList
[
i
].
key_word
)
===
-
1
)
{
list
.
push
(
searchHistoryList
[
i
].
key_word
);
}
}
}
let
list
=
await
this
.
getSearchHistory
(
type
);
ret
.
search_history
=
{
results
:
list
,
count
:
list
.
length
...
...
@@ -127,8 +107,51 @@ class searchHistoryService extends Service {
await
ctx
.
realestateModel
.
SearchHistory
.
edit
(
updateFilter
);
}
return
ret
;
}
/**
* 搜索历史
* 历史记录取用户最近6个月的搜索记录,去重处理,条数不超过50条
* 排序根据搜索时间逆序排列,距离当前时间近的排在前面,重复搜索的关键词取最近一次的搜索时间进行排序
* @param {*} type
*/
async
getSearchHistory
(
type
)
{
const
{
ctx
}
=
this
;
let
ret
=
{
results
:
[],
count
:
0
};
if
(
!
ctx
.
userId
)
{
//如果没有登录就返回
return
ret
;
}
//用户的搜索记录
let
endDate
=
moment
().
subtract
(
6
,
'months'
).
format
(
'YYYY-MM-DD HH:mm:ss'
);
let
filter
=
{
limit
:
50
,
attributes
:
[
'key_word'
],
where
:
{
state
:
1
,
user_id
:
ctx
.
userId
,
house_style
:
type
,
created_at
:
{
$gt
:
endDate
}
},
order
:
[[
'created_at'
,
'desc'
]],
}
let
searchHistoryList
=
await
ctx
.
realestateModel
.
SearchHistory
.
findAll
(
filter
);
let
list
=
[];
if
(
searchHistoryList
.
length
>
0
)
{
for
(
let
i
in
searchHistoryList
)
{
if
(
list
.
indexOf
(
searchHistoryList
[
i
].
key_word
)
===
-
1
)
{
list
.
push
(
searchHistoryList
[
i
].
key_word
);
}
}
}
ret
=
{
results
:
list
,
count
:
list
.
length
};
return
ret
;
}
}
...
...
config/config.local.js
View file @
e62be838
...
...
@@ -17,7 +17,7 @@ module.exports = appInfo => {
domainWhiteList
:
[],
};
config
.
middleware
=
[
'errorHandler'
,
'deviceLogin'
,
'deviceInit'
,
'responseSet'
];
//
config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
exports
.
multipart
=
{
// 不用steam用file
...
...
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