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

house v2 tool fix

parent 4f821694
Pipeline #10232 passed with stage
in 4 seconds
...@@ -362,12 +362,38 @@ class ToolController extends Controller { ...@@ -362,12 +362,38 @@ class ToolController extends Controller {
const { ctx } = this; const { ctx } = this;
const input_parmas = ctx.request.body; const input_parmas = ctx.request.body;
const keyword = input_parmas.keyword; const keyword = input_parmas.keyword;
const city_code = input_parmas.city_code; let city_code = input_parmas.city_code;
const zhixiaqu_map = { 110000: 110100, 500000: 500100, 120000: 120100, 310000: 310100 };
let results = []; let results = [];
if (keyword && city_code) { if (keyword && city_code) {
const month = moment(new Date()).format('MM'); const month = moment(new Date()).format('MM');
const house_price_map_results = await ctx.blockModel.HousePriceMap.all({ where: { pid: city_code, name: { $like: `%${keyword}%` } } }); if (['110000', '500000', '120000', '310000'].includes(city_code)) {
results = house_price_map_results.map(item => { return { name: item.name, description: `${month}月参考价`, price: item.price, unit: '元/平' } }); city_code = zhixiaqu_map[city_code];
}
const city_result = await ctx.blockModel.City.one({ where: { code: city_code } });
const area_results = await ctx.blockModel.City.all({ where: { name: { $like: `%${keyword}%` }, level: 3, parent: city_result.id } });
const area_results_codes = R.pluck('code', area_results);
if (area_results_codes && area_results_codes.length > 0) {
//城市房价
const house_price_map_results = await ctx.blockModel.HousePriceMap.all({ where: { id: { $in: area_results_codes } } });
const price_map_results = house_price_map_results.map(item => { return { name: item.name, code: item.id, description: `${month}月参考价`, price: item.price, unit: '元/平' } });
//房价走势
let out_codes = R.pluck('code', price_map_results);//去重
const house_price_trend_results = await ctx.blockModel.HousePriceTrend2.all({ where: { id: { $in: area_results_codes, $notIn: out_codes } } });
const price_trend_results = house_price_trend_results.map(item => { return { name: item.name, code: item.id, description: `${month}月参考价`, price: '-----', unit: '元/平' } });
//房价供需趋势
out_codes = out_codes.concat(R.pluck('code', price_trend_results));//去重
const house_supply_demand_results = await ctx.blockModel.HouseSupplyDemand2.all({ where: { id: { $in: area_results_codes, $notIn: out_codes } } });
const supply_demand_results = house_supply_demand_results.map(item => { return { name: item.name, code: item.id, description: `${month}月参考价`, price: '-----', unit: '元/平' } });
results = [...price_map_results, ...price_trend_results, ...supply_demand_results];
}
} }
ctx.success({ results }); ctx.success({ results });
......
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