Commit b54b4109 authored by 任国军's avatar 任国军
parents 9032db35 d5250a12
Pipeline #12733 passed with stage
in 4 seconds
......@@ -25,7 +25,7 @@ class HouseAnalysisController extends Controller {
const results = await ctx.service.house.v2.houseAnalysis.getHouseAnalysis(house_analysis_id);
//推荐楼盘
let where = { corner: { $ne: '' } };
let where = { corner: { $ne: '' }, status: 'online', valid: 1 };
if (city_code) {
where.option_city_code = city_code;
}
......
......@@ -66,6 +66,14 @@ class NewHouseController extends Controller {
const ret = await ctx.service.house.v2.newHouse.getNewHouseCity();
ctx.success(ret);
}
/**
* 新房城市对应的价格
*/
async getNewHouseCityPrice() {
const { ctx } = this;
const ret = await ctx.service.house.v2.newHouse.getNewHouseCityPrice();
ctx.success(ret);
}
}
module.exports = NewHouseController;
......@@ -58,6 +58,16 @@ class RentalHouseController extends Controller {
ctx.success(ret);
}
//推荐楼盘
async getRecommendRentalHouses() {
const { ctx } = this;
const input_params = ctx.query;
const results = await ctx.service.house.v2.rentalHouse.getRecommendRentalHouses(input_params);
ctx.success({ results });
}
}
module.exports = RentalHouseController;
......@@ -276,7 +276,7 @@ module.exports = app => {
}
NewHouse.list = async (data = {}) => {
const limit = data.limit ? data.limit : 10;
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
......
......@@ -182,7 +182,7 @@ module.exports = app => {
}
RentalHouse.list = async (data = {}) => {
const limit = data.limit ? data.limit : 10;
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
......
......@@ -72,6 +72,7 @@ module.exports = app => {
router.post('/v2/rental_house/list', 'house.v2.rentalHouse.getRentalHouses');//租房列表
router.get('/v2/rental_house/info/:rental_house_id', 'house.v2.rentalHouse.getRentalHouse');//住房详情
router.get('/v2/options/:city_code', 'house.v2.options.getOptions');//筛选项信息
router.get('/v2/rental_house/list/recommend', 'house.v2.rentalHouse.getRecommendRentalHouses');//推荐的租房楼盘 基本可通用
//足迹
router.get('/v2/foot_print/list', 'house.v2.footPrint.getFootPrintList');//用户浏览记录列表
......@@ -83,6 +84,7 @@ module.exports = app => {
router.get('/v2/new_house/options/:city_code', 'house.v2.options.getNewHouseOptions');//筛选项信息
router.get('/v2/new_house/list/recommend/', 'house.v2.newHouse.getRecommendNewHouses');//推荐的新房楼盘 基本可通用
router.get('/v2/new_house/city/list', 'house.v2.newHouse.getNewHouseCity');//新房支持的城市
router.get('/v2/new_house/city/price', 'house.v2.newHouse.getNewHouseCityPrice');//新房支持的城市
//关注
......
......@@ -459,24 +459,28 @@ class NewHouseService extends Service {
const { ctx } = this;
//推荐楼盘
let where = { corner: { $ne: '' } };
let { city_code, page, limit, } = condition;
let { city_code, page, limit, total_price } = condition;
page = page ? page : 1;
limit = limit ? limit : 3;
let where = { corner: { $ne: '' }, status: 'online', valid: 1 };
let order = [];
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', 'desc']] });
if (total_price) {
where.reference_total_price = { $ne: 0 };
order.push(['reference_total_price', total_price]);
}
order.push(['order_id', 'desc']);
let new_houses_rows = await ctx.realestateModel.NewHouse.list({ page: page, limit: limit, where: where, order: order });
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,
can_gjj_loan: new_house.corner ? 1 : 0,
});
const temp_house = await this.formatNewHouseBasic(new_house);
temp_house.can_gjj_loan = new_house.corner ? 1 : 0;
similar_list.push(temp_house);
}
return similar_list;
......@@ -506,7 +510,9 @@ class NewHouseService extends Service {
return { city, county, region };
}
//新房支持的城市
/**
* 新房支持的城市
*/
async getNewHouseCity() {
const { ctx } = this;
//所有支持的城市编码
......@@ -528,6 +534,28 @@ class NewHouseService extends Service {
}
return ret;
}
/**
* 新房城市对应的价格显示
*/
async getNewHouseCityPrice() {
const { ctx } = this;
//所有支持的城市编码
let filter = {
where: {
valid: 1
}
}
let cityPrice = await ctx.realestateModel.NewHouseCityPrice.findAll(filter);
let ret = {};
if (cityPrice !== undefined && cityPrice.length > 0) {
for (let i in cityPrice) {
ret[cityPrice[i].code] = cityPrice[i];
}
}
return ret;
}
......
......@@ -205,6 +205,34 @@ class RentalHouseService extends Service {
return ret;
}
//获取推荐楼盘 目前推荐逻辑条件少 后面扩展
async getRecommendRentalHouses(condition) {
const { ctx } = this;
//推荐楼盘
let { city_code, page, limit, price } = condition;
page = page ? page : 1;
limit = limit ? limit : 3;
let where = { status: 'online', valid: 1 };
let order = [];
if (city_code) {
where.option_city_code = city_code;
}
if (price) {
where.price = { $ne: 0 };
order.push(['price', price]);
}
order.push(['order_id', 'desc']);
let rental_houses_rows = await ctx.realestateModel.RentalHouse.list({ page, limit, where, order });
const recommend_list = await this.formatRentalHouseBasic(rental_houses_rows.rows);
const recommend_result = R.project(['id', 'image', 'name', 'address', 'price', 'surplus_amount', 'tags', 'favourable_info'])(recommend_list);
return recommend_result;
}
}
module.exports = RentalHouseService;
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