Commit 2c047410 authored by 李尚科's avatar 李尚科

add recommend new house

parent 541c0b71
Pipeline #8921 passed with stage
in 14 seconds
......@@ -47,6 +47,16 @@ class NewHouseController extends Controller {
const ret = await ctx.service.house.newHouse.getNewHouseType(inputParams.id);
ctx.success(ret);
}
//推荐楼盘
async getRecommendNewHouses() {
const { ctx } = this;
const input_params = ctx.query;
const results = await ctx.service.house.v2.newHouse.getRecommendNewHouses(input_params);
ctx.success({ results });
}
}
module.exports = NewHouseController;
......@@ -74,6 +74,7 @@ module.exports = app => {
router.post('/v2/new_house/list', 'house.v2.newHouse.getNewHouseList');//根据条件筛选列表
router.get('/v2/new_house/:id', 'house.v2.newHouse.getNewHouse');//新房具体信息
router.get('/v2/new_house/options/:city_code', 'house.v2.options.getNewHouseOptions');//筛选项信息
router.get('/v2/new_house/list/recommend/', 'house.v2.newHouse.getRecommendNewHouses');//推荐的新房楼盘 基本可通用
//关注
router.post('/v2/collection', loginAuth, 'house.v2.collection.addCollection');//关注
......
......@@ -432,6 +432,33 @@ class NewHouseService extends Service {
return ret;
}
//获取推荐楼盘 目前推荐逻辑条件少 后面扩展
async getRecommendNewHouses(condition) {
const { ctx } = this;
//推荐楼盘
let where = { corner: { $ne: '' } };
let { city_code, page, limit, } = condition;
page = page ? page : 1;
limit = limit ? limit : 3;
if (city_code) {
where.option_city_code = city_code;
}
let new_houses_rows = await ctx.realestateModel.NewHouse.list({ page: page, limit: limit, where: where, order: [['order_id', 'asc']] });
const similar_list = [];
for (let i in new_houses_rows.rows) {
const new_house = new_houses_rows.rows[i];
similar_list.push({
id: new_house.id,
name: new_house.name,
image: new_house.image,
corner: new_house.corner,
});
}
return similar_list;
}
}
module.exports = NewHouseService;
......@@ -17,6 +17,7 @@ const HOUSE_TYPE = [
class RentalHouseService extends Service {
//租房条件过滤
async getRentalHousesByFilter(condition) {
const { ctx } = this;
......@@ -50,7 +51,11 @@ class RentalHouseService extends Service {
if (house_type) {
const house_types = await ctx.realestateModel.RentalHouseType.all({ where: { type: house_type, status: 'online', valid: 1 } });
const rental_houses_ids = R.pluck('rental_house_id', house_types);
where.id = { $in: rental_houses_ids };
let match_ids = new Set(rental_houses_ids);
match_ids = [...match_ids];
if (Array.isArray(match_ids) && match_ids.length !== 0) {
where.id = { $in: match_ids };
}
}
const rental_houses_results = await ctx.realestateModel.RentalHouse.list({ page: page, limit: Number(limit), where: where, order: [['order_id', 'asc']] });
......@@ -87,7 +92,7 @@ class RentalHouseService extends Service {
let house_basic = await this.formatRentalHouseBasic([rental_house_info]);
house_basic = house_basic[0];
//TODO添加用户足迹,是否关注过房源
//添加用户足迹,是否关注过房源
await ctx.service.house.v2.footPrint.addFootPrint({ type: 2, id: rental_house_id });
//是否关注
let collectionTask = await ctx.service.house.collection.getCollection({ type: 2, id: rental_house_id });
......
......@@ -5,6 +5,7 @@ const Service = require('egg').Service;
class ToolService extends Service {
//新房地图点位
async getNewHouseMapPoint(area_code, level) {
const { ctx } = this;
......@@ -43,6 +44,7 @@ class ToolService extends Service {
return ret;
}
//二手房地图点位
async getUsedHouseMapPoint(area_code, level) {
const { ctx } = this;
......@@ -78,6 +80,7 @@ class ToolService extends Service {
return ret;
}
//存钱罐计算完毕后 生成购房计划
async generateHousePlan(input) {
const { ctx } = this;
......
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