Commit 412fe50f authored by 李尚科's avatar 李尚科

二期 rental_house residential fix

parent e2dfced7
Pipeline #8506 passed with stage
in 11 seconds
......@@ -3,6 +3,7 @@
const Service = require('egg').Service;
const R = require('ramda');
const HOUSE_TYPE = [
{ name: '不限', min: 0, max: 0, value: 0, },
{ name: '1室', min: 1, max: 1, value: 1, },
......@@ -15,6 +16,28 @@ const HOUSE_TYPE = [
]
class RentalHouseService extends Service {
async getRentalHouseByFilter_V2(condition) {
const { ctx } = this;
const { brand, price, house_type, area_code, name, } = condition;
let where = {};
if (brand) {
const residentials = await ctx.service.house.residential.getResidentialByDeveloper({ developer_id: brand });
const residentials_ids = R.pluck('id', residentials);
}
if (area_code) {
}
if (house_type) {
}
if (name) {
where.name = { $like: `%${name}%` };
}
}
async getRentalHousesByFilter(condition) {
const { ctx } = this;
......
......@@ -12,6 +12,29 @@ class ResidentialService extends Service {
return residentialInfo;
}
//通过开发商id获取小区列表
async getResidentialByDeveloper(condition, elements = []) {
const { ctx } = this;
const { developer_id } = condition;
if (!developer_id) {
return [];
}
const residential_developer = await ctx.realestateModel.ResidentialDeveloper.all({ where: { developer_id: developer_id, status: 'online', valid: 1 } });
const residential_ids = R.pluck('residential_id', residential_developer);
if (residential_ids.length === 0) {
return [];
}
let residentials = await ctx.realestateModel.Residential.all({ where: { id: { $in: residential_ids }, status: 'online', valid: 1 } });
if (Array.isArray(elements) && elements.length !== 0) {
residentials = R.project(elements)(residentials);
}
return residentials;
}
}
......
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