Commit f68596c8 authored by 李尚科's avatar 李尚科

rental house fix

parent 7167a32c
Pipeline #6067 passed with stage
in 6 seconds
...@@ -34,18 +34,20 @@ class RentalHouseController extends Controller { ...@@ -34,18 +34,20 @@ class RentalHouseController extends Controller {
//租房列表 //租房列表
async getRentalHouses() { async getRentalHouses() {
const { ctx } = this; const { ctx } = this;
const query_params = ctx.query;
const input_params = ctx.request.body; const input_params = ctx.request.body;
const rule = { const rule = {
brand: { type: 'string', required: false },//品牌 brand: { type: 'string', required: false },//品牌
area_code: { type: 'string', required: false },//区域 area_code: { type: 'object', required: false },//区域
price: { type: 'object', required: false },//价格 price: { type: 'object', required: false },//价格
house_type: { type: 'string', required: false },//房型 house_type: { type: 'string', required: false },//房型
name: { 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({ query_params, input_params, results: ret, count: ret.length }); ctx.success({input_params, results: ret.results, count: ret.count });
} }
//租房详情 //租房详情
......
...@@ -46,12 +46,28 @@ class RentalHouseService extends Service { ...@@ -46,12 +46,28 @@ class RentalHouseService extends Service {
operator: 'equal', operator: 'equal',
}); });
} }
if (condition.area_code) { if (condition.area_code) {//城市\区域\商圈筛选
queryConditions.push({ if (condition.area_code.hasOwnProperty('city_code') && condition.area_code.city_code !== '') {
key: 'county', queryConditions.push({
value: condition.area_code, key: 'city',
operator: 'equal', value: condition.area_code.city_code,
}); operator: 'equal',
});
}
if (condition.area_code.hasOwnProperty('district_code') && condition.area_code.district_code !== '') {
queryConditions.push({
key: 'county',
value: condition.area_code.district_code,
operator: 'equal',
});
}
if (condition.area_code.hasOwnProperty('bizcircle_code') && condition.area_code.bizcircle_code !== '') {
queryConditions.push({
key: 'region',
value: condition.area_code.bizcircle_code,
operator: 'equal',
});
}
} }
if (condition.name) { if (condition.name) {
await ctx.service.house.searchHistory.addSearchHistory({ type: 2, key_word: condition.name });//增加搜索历史 await ctx.service.house.searchHistory.addSearchHistory({ type: 2, key_word: condition.name });//增加搜索历史
...@@ -77,7 +93,7 @@ class RentalHouseService extends Service { ...@@ -77,7 +93,7 @@ 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);
let rental_houses = await this.formatRentalHouseBasic(rental_houses_results.results); let rental_houses = await this.formatRentalHouseBasic(rental_houses_results.results);
rental_houses = R.project(['id', 'image', 'name', 'address', 'price', 'tags', 'favourable_info'])(rental_houses); rental_houses = R.project(['id', 'image', 'name', 'address', 'price', 'tags', 'favourable_info'])(rental_houses);
return rental_houses; return { results: rental_houses, count: rental_houses_results.rowCount };
} }
//房源详细信息 //房源详细信息
...@@ -111,10 +127,10 @@ class RentalHouseService extends Service { ...@@ -111,10 +127,10 @@ class RentalHouseService extends Service {
//处理房源基本信息格式 //处理房源基本信息格式
let house_basic = await this.formatRentalHouseBasic([house_basic_result]); let house_basic = await this.formatRentalHouseBasic([house_basic_result]);
house_basic = house_basic[0]; house_basic = house_basic[0];
//是否关注 //是否关注
const collectionFilter = { type: 2, id: rental_house_id } const collectionFilter = { type: 2, id: rental_house_id }
const collection = await service.house.collection.getCollection(collectionFilter); const collection = await ctx.service.house.collection.getCollection(collectionFilter);
ctx.service.house.footPrint.addFootPrint({ id: rental_house_id, type: 2 });//添加用户足迹记录 ctx.service.house.footPrint.addFootPrint({ id: rental_house_id, type: 2 });//添加用户足迹记录
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment