Commit b484e465 authored by 任国军's avatar 任国军
parents 60584193 c6b105ba
Pipeline #10180 passed with stage
in 5 seconds
......@@ -13,9 +13,9 @@ class HomeController extends Controller {
const {ctx} = this;
const expire = 7200 * 1000;
const date = new Date();
ctx.cookies.set('auth_token', '0f42a68d19ef161a7c7665488e625ba8', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
ctx.cookies.set('jianbing_customer_id', '815209', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
ctx.success(ctx.cookies);
// ctx.cookies.set('auth_token', '0f42a68d19ef161a7c7665488e625ba8', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
// ctx.cookies.set('jianbing_customer_id', '815209', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
ctx.success(ctx.header.cookie);
}
}
......
This diff is collapsed.
'use strict';
const Controller = require('egg').Controller;
const R = require('ramda');
class HouseAnalysisController extends Controller {
//购房解析列表
......@@ -40,6 +40,7 @@ class HouseAnalysisController extends Controller {
name: new_house.name,
image: new_house.image,
corner: new_house.corner,
can_gjj_loan: new_house.corner ? 1 : 0,
});
}
......@@ -74,6 +75,16 @@ class HouseAnalysisController extends Controller {
}
//上传户型解析的城市列表
async getHouseAnalysisSupportCity() {
const { ctx } = this;
const results = await ctx.blockModel.City.all({ where: { code: { $in: [110000, 310000, 330100, 440100, 440300, 500000] } } });
ctx.success({ results: R.project(['code', 'name'])(results) });
}
}
module.exports = HouseAnalysisController;
This diff is collapsed.
......@@ -115,7 +115,7 @@ module.exports = () => {
ctx.logger.info('user_auth_result: ' + JSON.stringify(result));
console.log(result);
if (result.status !== 201) {
ctx.failed('无效用户');
ctx.failed('token 已失效');
return;
}
......
......@@ -19,6 +19,14 @@ module.exports = app => {
type: STRING,
allowNull: true
},
app_id: {
type: STRING,
allowNull: true
},
app_type_id: {
type: STRING,
allowNull: true
},
connect_id: {
type: INTEGER,
allowNull: true
......
......@@ -11,10 +11,6 @@ module.exports = app => {
primaryKey: true,
autoIncrement: true,
},
app_type_id: {
type: STRING,
allowNull: true,
},
user_id: {
type: STRING,
allowNull: true
......@@ -23,6 +19,14 @@ module.exports = app => {
type: STRING,
allowNull: true
},
app_id: {
type: STRING,
allowNull: true
},
app_type_id: {
type: STRING,
allowNull: true
},
connect_id: {
type: INTEGER,
allowNull: true
......
......@@ -16,11 +16,19 @@ module.exports = app => {
type: STRING,
allowNull: false
},
residential_id: {
developer_id: {
type: INTEGER,
allowNull: true
},
developer_id: {
province: {
type: INTEGER,
allowNull: true
},
city: {
type: INTEGER,
allowNull: true
},
area: {
type: INTEGER,
allowNull: true
},
......@@ -28,6 +36,18 @@ module.exports = app => {
type: STRING,
allowNull: true
},
sale_province: {
type: INTEGER,
allowNull: true
},
sale_city: {
type: INTEGER,
allowNull: true
},
sale_area: {
type: INTEGER,
allowNull: true
},
sale_address: {
type: INTEGER,
allowNull: true
......@@ -92,22 +112,6 @@ module.exports = app => {
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
land_area: {
type: DECIMAL,
allowNull: true
},
house_area: {
type: DECIMAL,
allowNull: true
},
area_ratio: {
type: DECIMAL,
allowNull: true
},
green_ratio: {
type: DECIMAL,
allowNull: true
},
plan_rooms: {
type: INTEGER,
allowNull: true
......@@ -164,18 +168,6 @@ module.exports = app => {
type: INTEGER,
allowNull: true
},
province: {
type: INTEGER,
allowNull: true
},
city: {
type: INTEGER,
allowNull: true
},
area: {
type: INTEGER,
allowNull: true
},
residential_property_right_years: {
type: INTEGER,
allowNull: true
......@@ -224,18 +216,6 @@ module.exports = app => {
type: TEXT,
allowNull: true
},
sale_province: {
type: INTEGER,
allowNull: true
},
sale_city: {
type: INTEGER,
allowNull: true
},
sale_area: {
type: INTEGER,
allowNull: true
},
deleted_at: {
type: DATE,
allowNull: true,
......
......@@ -19,6 +19,14 @@ module.exports = app => {
type: STRING,
allowNull: true
},
app_id: {
type: STRING,
allowNull: true
},
app_type_id: {
type: STRING,
allowNull: true
},
connect_id: {
type: INTEGER,
allowNull: true
......
......@@ -16,7 +16,35 @@ module.exports = app => {
type: STRING,
allowNull: false
},
residential_id: {
developer_id: {
type: INTEGER,
allowNull: true
},
province: {
type: INTEGER,
allowNull: true
},
city: {
type: INTEGER,
allowNull: true
},
area: {
type: INTEGER,
allowNull: true
},
option_city_code: {
type: INTEGER,
allowNull: true
},
option_district_code: {
type: INTEGER,
allowNull: true
},
option_bizicircle_code: {
type: INTEGER,
allowNull: true
},
rental_type: {
type: INTEGER,
allowNull: true
},
......@@ -46,7 +74,19 @@ module.exports = app => {
},
tags: {
type: STRING,
allowNull: true
allowNull: true,
field: 'tags',
get() {
const tags = this.getDataValue('tags');
if (tags) {
try {
return JSON.parse(tags);
} catch (error) {
return [];
}
}
return [];
},
},
favourable_info: {
type: STRING,
......@@ -58,7 +98,19 @@ module.exports = app => {
},
room_configuration: {
type: STRING,
allowNull: true
allowNull: true,
field: 'room_configuration',
get() {
const room_configuration = this.getDataValue('room_configuration');
if (room_configuration) {
try {
return JSON.parse(room_configuration);
} catch (error) {
return {};
}
}
return {};
},
},
description: {
type: STRING,
......
......@@ -19,6 +19,14 @@ module.exports = app => {
type: STRING,
allowNull: true
},
app_id: {
type: STRING,
allowNull: true
},
app_type_id: {
type: STRING,
allowNull: true
},
key_word: {
type: STRING,
allowNull: true
......
......@@ -7,7 +7,7 @@ module.exports = app => {
const { controller } = app;
const router = app.router.namespace(app.config.projectRootPath);
router.get('/', controller.home.index);
// router.get('/home/setCookie', controller.home.setCookie);
router.get('/home/setCookie', controller.home.setCookie);
require('./router/gjj')(app);
......
'use strict';
module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/house/export');
// router.get('add', '/house_image', 'house.export20190425.exportHouseImages');//用户浏览记录列表
// router.get('add', '/residential', 'house.export20190425.exportResidential');//用户浏览记录列表
// router.get('/new_house', 'house.export20190425.moveNewHouse');
// router.get('/new_house_type', 'house.export20190425.moveNewHouseType');
//sqlserver迁移数据
router.get('third', '/new_house_related', 'house.v2.export190619.moveNewHouse');
router.get('third', '/collection', 'house.v2.export190619.moveCollection');
router.get('third', '/order', 'house.v2.export190619.moveOrder');
router.get('third', '/history', 'house.v2.export190619.moveHistory');
router.get('third', '/foot', 'house.v2.export190619.moveFoot');
router.get('third', '/rental_house_related', 'house.v2.export190619.moveRentalHouse');
router.get('third', '/developer', 'house.v2.export190619.moveDeveloper');
router.get('third', '/house_image', 'house.v2.export190619.moveHouseImage');
};
'use strict';
module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/house/export20190425');
router.get('add', '/house_image', 'house.export20190425.exportHouseImages');//用户浏览记录列表
router.get('add', '/residential', 'house.export20190425.exportResidential');//用户浏览记录列表
router.get('/new_house', 'house.export20190425.moveNewHouse');
router.get('/new_house_type', 'house.export20190425.moveNewHouseType');
};
......@@ -4,6 +4,7 @@ module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/house');
const loginAuth = app.middleware.loginAuth({ type: 'new' });//登录中间件
/***********1.0接口关闭
router.get('/tool/:house_style/:area_code/:level', 'house.tool.getMapPoint');//购房计划地图点位
router.post('/tool/plan', 'house.tool.generateBuyHousePlan');//生成购房计划
router.get('/tool/:type/:area_code', 'house.tool.getHousePriceFeature');//房价指数 房价涨跌 购房资格、贷款额度问答
......@@ -43,21 +44,24 @@ module.exports = app => {
//我的
router.get('/mine', 'house.mine.getMineInfo');//获取用户的头像昵称和关注等信息
***********关闭1.0接口****************/
//房产v2
router.get('/v2/tool/:house_style/:area_code/:level', 'house.v2.tool.getMapPoint');//购房计划地图点位(存钱罐地图)(房价地图)
router.post('/v2/tool/plan', 'house.tool.generateBuyHousePlan');//生成购房计划
router.post('/v2/tool/plan', 'house.v2.tool.generateBuyHousePlan');//生成购房计划
router.get('/v2/tool/plan_area_list', 'house.v2.tool.planAreaList');//购房计划页面 区域列表接口
router.get('/v2/tool/:type/:area_code', 'house.v2.tool.getHousePriceFeature');//房价走势图 房价涨跌图 购房资格图、贷款额度问答、供需趋势图
router.post('/v2/tool/calculate_price', 'house.tool.calculateHousePrice');//房产估价
router.get('/v2/tool/qfang_area_list', 'house.tool.getQFangAreaList');//房产估价模糊匹配到的小区列表
router.get('/v2/tool/map_houses', 'house.tool.getMapHouses');//房产估价模糊匹配到的小区列表
router.get('/v2/tool/house_price_feature_city', 'house.v2.tool.getHousePriceFeatureCity');//房价指数 城市月参考价支持的城市
router.get('/v2/tool/house_price_city', 'house.v2.tool.getHousePriceCity');//房价指数 城市月参考价
router.post('/v2/tool/house_price_search', 'house.v2.tool.getHousePriceFeatureSearch');//房价指数 搜索结果
router.get('/v2/tool/house_point', 'house.v2.tool.getHousePoint');//点击房源信息跳到地图页 需要的经纬度信息。
router.post('/v2/tool/nearby_house_points', 'house.v2.tool.getHouseNearbyPoint');//点击房源信息跳到地图页 此房源周边信息。
router.get('/v2/tool/oss_signature', 'house.v2.tool.getBusinessSignature');//点击房源信息跳到地图页 此房源周边信息。
//租房列表
......@@ -103,6 +107,7 @@ module.exports = app => {
router.get('/v2/house_analysis/info/:house_analysis_id', 'house.v2.houseAnalysis.getHouseAnalysisInfo');//户型解析列表
router.post('/v2/house_analysis/', loginAuth, 'house.v2.houseAnalysis.uploadHouseAnalysis');//上传户型信息
router.get('/v2/house_analysis/mine', loginAuth, 'house.v2.houseAnalysis.getUserHouseAnalysis');//我的户型
router.get('/v2/house_analysis/city_list', 'house.v2.houseAnalysis.getHouseAnalysisSupportCity');//上传户型解析的城市列表
//提问
router.post('/v2/question', loginAuth, 'house.v2.question.addQuestion');//提问
......
......@@ -139,7 +139,9 @@ class ProductService extends Service {
if (products_results.status !== 200 || !products_results.data || !products_results.data.ret) {
return products;
}
products = await this.formatProducts(products_results.data.ret);
products = products_results.data.ret;
products.sort(function (x, y) { return x['recommend_sorter'] - y['recommend_sorter'] });
products = await this.formatProducts(products);
return products;
}
......
......@@ -12,6 +12,10 @@ class AnswerLikeService extends Service {
*/
async like(id) {
const { ctx } = this;
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就不做处理
return false;
}
let filter = {
where: {
answer_id: id,
......
......@@ -12,6 +12,10 @@ class CollectionService extends Service {
*/
async addCollection(inputParams) {
const { ctx } = this;
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就不做处理
return false;
}
let filter = {
where: {
......@@ -28,6 +32,8 @@ class CollectionService extends Service {
let data = {
user_id: ctx.userId,
app_user_id: ctx.appUserId,
app_id: ctx.appId,
app_type_id: ctx.appTypeId,
house_style: inputParams.type,
connect_id: inputParams.id,
state: 1,
......@@ -109,7 +115,7 @@ class CollectionService extends Service {
user_id: ctx.userId,
created_at: { $gt: endDate },
},
order: [['created_at', 'desc']]
order: [['id', 'desc']]
}
let list = [];
let collectionList = await ctx.realestateModel.Collection.all(filter);
......@@ -130,6 +136,9 @@ class CollectionService extends Service {
});
//数据整理
for (let j in retList) {
if (retList[j].status === 'offline' || Number(retList[j].valid) === 0) {
continue;
}
let type = collectionList[j].house_style;
let tmp = {
id: retList[j].id,
......@@ -137,7 +146,7 @@ class CollectionService extends Service {
address: retList[j].address,
tags: retList[j].tags ? eval(retList[j].tags) : [],
image: retList[j].image,
area: type === 1 ? Number(retList[j].house_area) : '',
area: type === 1 ? Number(retList[j].residential_house_area) : '',
price: type === 1 ? (['', 0].includes(Number(retList[j].reference_avg_price)) ? '--' : Number(retList[j].reference_avg_price)) : Number(retList[j].price),
type: type === 1 ? 'new_house' : 'rental_house',
corner: type === 1 ? retList[j].corner : '',
......@@ -165,16 +174,52 @@ class CollectionService extends Service {
let filter = {
page: 1,
limit: 50,
attributes: ['connect_id', 'house_style'],
where: {
state: 1,
user_id: ctx.userId,
created_at: { $gt: endDate },
},
order: [['created_at', 'desc']]
order: [['id', 'desc']]
}
let list = await ctx.realestateModel.Collection.all(filter);
let count = 0;
if (list.length > 0) {
let newHouseId = [];
let rentalHouseId = [];
for (let i in list) {
if (Number(list[i].house_style) === 1) {
newHouseId.push(list[i].connect_id);
}
if (Number(list[i].house_style) === 2) {
rentalHouseId.push(list[i].connect_id);
}
}
let newHousefilter = {
where: {
status: 'online',
valid: 1,
id: { $in: newHouseId },
},
}
let newHouseCountTask = ctx.realestateModel.NewHouse.count(newHousefilter);
let rentalHousefilter = {
where: {
status: 'online',
valid: 1,
id: { $in: rentalHouseId },
},
}
let rentalHouseCountTask = ctx.realestateModel.RentalHouse.count(rentalHousefilter);
const retList = await Promise.all([newHouseCountTask, rentalHouseCountTask]).then(result => {
return result;
}).catch(error => {
ctx.failed(error);
});
count = Number(retList[0]) + Number(retList[1]);
}
let collectionList = await ctx.realestateModel.Collection.all(filter);
let ret = {
count: collectionList.length
count: count
};
return ret;
}
......
......@@ -15,15 +15,15 @@ class FootPrintService extends Service {
const { ctx } = this;
const user_id = ctx.userId;
const app_user_id = ctx.appUserId;
const app_type_id = ctx.appTypeId;
if (!user_id || !app_user_id) {
return false;
}
const data = {
user_id: user_id,
app_type_id: app_type_id,
app_user_id: app_user_id,
app_id: ctx.appId,
app_type_id: ctx.appTypeId,
house_style: inputParams.type,
connect_id: inputParams.id,
state: 1,
......@@ -51,8 +51,19 @@ class FootPrintService extends Service {
count: 0
};
}
const foot_prints_rows = await ctx.realestateModel.FootPrint.list({ page: 1, limit: 50, where: { user_id: user_id, app_type_id: app_type_id, state: 1 }, order: [['id', 'desc']] });
let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss');
const filter = {
page: 1,
limit: 50,
where: {
user_id: user_id,
app_type_id: app_type_id,
state: 1,
created_at: { $gt: endDate },
},
order: [['id', 'desc']]
};
const foot_prints_rows = await ctx.realestateModel.FootPrint.list(filter);
const foot_prints = foot_prints_rows.rows;
const p_houses = [];
for (let i in foot_prints) {
......@@ -73,6 +84,9 @@ class FootPrintService extends Service {
//处理足迹数据
const foot_print_records = [];
for (let j in houses) {
if (houses[j].status === 'offline' || Number(houses[j].valid) === 0) {
continue;
}
const house = houses[j];
const foot_print = foot_prints[j];
const type = foot_print.house_style === 1 ? 'new_house' : 'rental_house';
......@@ -106,19 +120,56 @@ class FootPrintService extends Service {
if (!ctx.userId) {
return { count: 0 };
}
let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss');
const filter = {
page: 1,
limit: 50,
attributes: ['connect_id', 'house_style'],
where: {
state: 1,
user_id: ctx.userId,
created_at: { $gt: endDate },
},
order: [['created_at', 'desc']]
}
const footPrintsResults = await ctx.realestateModel.FootPrint.all(filter);
const list = await ctx.realestateModel.FootPrint.all(filter);
let count = 0;
if (list.length > 0) {
let newHouseId = [];
let rentalHouseId = [];
for (let i in list) {
if (Number(list[i].house_style) === 1) {
newHouseId.push(list[i].connect_id);
}
if (Number(list[i].house_style) === 2) {
rentalHouseId.push(list[i].connect_id);
}
}
let newHousefilter = {
where: {
status: 'online',
valid: 1,
id: { $in: newHouseId },
},
}
let newHouseCountTask = ctx.realestateModel.NewHouse.count(newHousefilter);
let rentalHousefilter = {
where: {
status: 'online',
valid: 1,
id: { $in: rentalHouseId },
},
}
let rentalHouseCountTask = ctx.realestateModel.RentalHouse.count(rentalHousefilter);
const retList = await Promise.all([newHouseCountTask, rentalHouseCountTask]).then(result => {
return result;
}).catch(error => {
ctx.failed(error);
});
count = Number(retList[0]) + Number(retList[1]);
}
let ret = {
count: footPrintsResults.length
count: count
};
return ret;
}
......
......@@ -12,6 +12,10 @@ class HotQuestionAnswerService extends Service {
*/
async addAnswer(inputParams) {
const { ctx } = this;
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就不做处理
return false;
}
let data = {
user_id: ctx.userId,
app_user_id: ctx.appUserId,
......
......@@ -12,6 +12,10 @@ class HotQuestionPutService extends Service {
*/
async addQuestion(inputParams) {
const { ctx } = this;
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就不做处理
return false;
}
let data = {
user_id: ctx.userId,
app_user_id: ctx.appUserId,
......@@ -67,15 +71,22 @@ class HotQuestionPutService extends Service {
*/
async questionDetail(condition) {
const { ctx } = this;
let ret = {
question: '--',
time: '--',
answerList: []
};
//问题内容
let filter = {
attributes: ['question', 'created_at'],
where: {
id: Number(condition.id),
status: "pass"
id: Number(condition.id)
}
}
let question = await ctx.realestateModel.HotQuestionPut.one(filter);
if (question === null || !question) {
return ret;
}
//回答的列表
let answerFliter = {
page: Number(condition.page) || 1,
......@@ -83,9 +94,9 @@ class HotQuestionPutService extends Service {
question_id: Number(condition.id),
}
let answerLsit = await ctx.service.house.v2.hotQuestionAnswer.answerList(answerFliter);
let ret = {
ret = {
question: question.question || '',
time: question.created_at ? moment().format("YYYY-MM-DD") : '',
time: question.created_at ? moment(question.created_at).format("YYYY-MM-DD") : '',
answerList: answerLsit
}
return ret;
......
......@@ -11,8 +11,9 @@ class HouseAnalysisService extends Service {
async getHouseAnalysisByFilter(condition) {
const { ctx } = this;
let { city_code, keyword, page } = condition;
let { city_code, keyword, page, page_size } = condition;
page = page ? page : 1;
page_size = page_size ? page_size : 10;
let where = { status: 'pass' };
if (city_code) {
where.city = city_code;
......@@ -20,7 +21,7 @@ class HouseAnalysisService extends Service {
if (keyword && keyword.length !== 0) {
where.residential = { $like: `%${keyword}%` }
}
const house_analysis_rows = await ctx.realestateModel.HouseAnalysis.list({ page: page, where: where, order: [['id', 'desc']] });
const house_analysis_rows = await ctx.realestateModel.HouseAnalysis.list({ page: page, limit: Number(page_size), where: where, order: [['id', 'desc']] });
const house_analysis = R.project(['id', 'image', 'residential', 'house_type', 'house_area', 'text'])(house_analysis_rows.rows);
return { page: page, count: house_analysis_rows.count, results: house_analysis };
......@@ -83,7 +84,7 @@ class HouseAnalysisService extends Service {
if (!user_id || !app_type_id) {
ctx.failed('login error');
}
const results = await ctx.realestateModel.HouseAnalysis.list({ page: page, limit: limit, where: { user_id: user_id, app_type_id: app_type_id }, order: [['id', 'desc']] });
const results = await ctx.realestateModel.HouseAnalysis.list({ page: page, limit: Number(limit), where: { user_id: user_id, app_type_id: app_type_id }, order: [['id', 'desc']] });
return results;
}
......
This diff is collapsed.
......@@ -112,9 +112,9 @@ class OptionService extends Service {
async getDevelopers(city_code) {
const { ctx } = this;
const rental_house_developers = await ctx.realestateModel.RentalHouse.findAll({ attributes: ['developer_id'], group: 'developer_id', where: { option_city_code: city_code } });
const developers_ids = rental_house_developers.map(item => { return item.dataValues.developer_id });
const developers = await ctx.realestateModel.Developer.all({ where: { id: { $in: developers_ids } } });
const rental_house_developers = await ctx.realestateModel.RentalHouse.findAll({ attributes: ['developer_id'], group: 'developer_id', where: { option_city_code: city_code, status: 'online', valid: 1 } });
const developers_ids = rental_house_developers.map(item => { return item.developer_id });
const developers = await ctx.realestateModel.Developer.all({ where: { id: { $in: developers_ids }, status: 'online', valid: 1 } });
const ret = developers.map(item => { return { id: item.id, name: item.name, image: item.logo, value: item.id } });
return ret;
}
......
......@@ -11,8 +11,11 @@ class OrderService extends Service {
* @param {object} inputParams
*/
async addOrder(inputParams) {
const { ctx, service } = this;
const { ctx } = this;
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就不做处理
return false;
}
let filter = {
where: {
state: 1,
......@@ -33,6 +36,8 @@ class OrderService extends Service {
let data = {
user_id: ctx.userId,
app_user_id: ctx.appUserId,
app_id: ctx.appId,
app_type_id: ctx.appTypeId,
house_style: inputParams.type,
connect_id: inputParams.id,
name: inputParams.name,
......@@ -64,7 +69,7 @@ class OrderService extends Service {
user_id: ctx.userId,
created_at: { $gt: endDate }
},
order: [['created_at', 'desc']]
order: [['id', 'desc']]
}
let list = [];
let orderList = await ctx.realestateModel.Order.all(filter);
......@@ -85,6 +90,9 @@ class OrderService extends Service {
});
//数据整理
for (let j in retList) {
if (retList[j].status === 'offline' || Number(retList[j].valid) === 0) {
continue;
}
let type = orderList[j].house_style;
let tmp = {
id: retList[j].id,
......@@ -92,7 +100,7 @@ class OrderService extends Service {
address: retList[j].address,
tags: retList[j].tags ? eval(retList[j].tags) : [],
image: retList[j].image,
area: type === 1 ? Number(retList[j].house_area) : '',
area: type === 1 ? Number(retList[j].residential_house_area) : '',
price: type === 1 ? (Number(retList[j].reference_avg_price) === 0 ? '--' : Number(retList[j].reference_avg_price)) : Number(retList[j].price),
time: moment().format('YYYY-MM-DD') === moment(orderList[j].order_at).format('YYYY-MM-DD') ? '今天' : moment(orderList[j].order_at).format('YYYY-MM-DD'),
type: type === 1 ? 'new_house' : 'rental_house',
......@@ -120,17 +128,52 @@ class OrderService extends Service {
let filter = {
page: 1,
limit: 50,
attributes: ['connect_id', 'house_style'],
where: {
state: 1,
user_id: ctx.userId,
created_at: { $gt: endDate }
created_at: { $gt: endDate },
},
order: [['created_at', 'desc']]
order: [['id', 'desc']]
}
let list = await ctx.realestateModel.Order.all(filter);
let count = 0;
if (list.length > 0) {
let newHouseId = [];
let rentalHouseId = [];
for (let i in list) {
if (Number(list[i].house_style) === 1) {
newHouseId.push(list[i].connect_id);
}
if (Number(list[i].house_style) === 2) {
rentalHouseId.push(list[i].connect_id);
}
}
let newHousefilter = {
where: {
status: 'online',
valid: 1,
id: { $in: newHouseId },
},
}
let newHouseCountTask = ctx.realestateModel.NewHouse.count(newHousefilter);
let rentalHousefilter = {
where: {
status: 'online',
valid: 1,
id: { $in: rentalHouseId },
},
}
let rentalHouseCountTask = ctx.realestateModel.RentalHouse.count(rentalHousefilter);
const retList = await Promise.all([newHouseCountTask, rentalHouseCountTask]).then(result => {
return result;
}).catch(error => {
ctx.failed(error);
});
count = Number(retList[0]) + Number(retList[1]);
}
let orderList = await ctx.realestateModel.Order.all(filter);
let ret = {
count: orderList.length
count: count
};
return ret;
}
......
......@@ -31,6 +31,8 @@ class RentalHouseService extends Service {
where.developer_id = brand;
}
if (name) {
//增加搜索历史
ctx.service.house.v2.searchHistory.addSearchHistory({ type: 2, key_word: name });
where.name = { $like: `%${name}%` };
}
if (price && price.max) {
......@@ -45,7 +47,7 @@ class RentalHouseService extends Service {
where.option_district_code = area_code.district_code;
}
if (area_code.bizcircle_code && area_code.bizcircle_code !== '') {
where.option_bizcircle_code = area_code.bizcircle_code;
where.option_bizicircle_code = area_code.bizcircle_code;
}
}
if (house_type) {
......@@ -53,12 +55,13 @@ class RentalHouseService extends Service {
const rental_houses_ids = R.pluck('rental_house_id', house_types);
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 };
}
// if (Array.isArray(match_ids) && match_ids.length !== 0) {
// where.id = { $in: match_ids };
// }
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']] });
const rental_houses_results = await ctx.realestateModel.RentalHouse.list({ page: page, limit: Number(limit), where: where, order: [['order_id', 'desc'], ['id', 'desc']] });
let rental_houses = await this.formatRentalHouseBasic(rental_houses_results.rows);
rental_houses = R.project(['id', 'image', 'name', 'address', 'price', 'tags', 'favourable_info'])(rental_houses);
......@@ -78,26 +81,34 @@ class RentalHouseService extends Service {
//楼盘图片信息和房型信息
const house_types_rets = await ctx.realestateModel.RentalHouseType.all({ where: { rental_house_id: rental_house_id, status: 'online', valid: 1 } });
const p_house_images = ctx.service.house.v2.houseImage.getAll({ type: 1, connect_id: rental_house_id }, ['id', 'path', 'description']);
const p_house_images = ctx.service.house.v2.houseImage.getAll({ type: 0, connect_id: rental_house_id }, ['id', 'path', 'description']);
const p_house_types = this.formatRentHouseTypes(house_types_rets);
const p_ret = await Promise.all([p_house_images, p_house_types]).then(result => {//等待所有异步内容获取完成
const p_collection = await ctx.service.house.v2.collection.getCollection({ type: 2, id: rental_house_id });
const p_ret = await Promise.all([p_house_images, p_house_types, p_collection]).then(result => {//等待所有异步内容获取完成
return result;
}).catch(error => {
ctx.failed(error);
});
const house_images = p_ret[0];
const house_types = p_ret[1];
const collection = p_ret[2];//是否关注
//处理房源基本信息格式
let house_basic = await this.formatRentalHouseBasic([rental_house_info]);
house_basic = house_basic[0];
//添加用户足迹,是否关注过房源
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 });
//添加用户足迹
ctx.service.house.v2.footPrint.addFootPrint({ type: 2, id: rental_house_id });
const city_codes = [rental_house_info.province, rental_house_info.city, rental_house_info.area];
const cities = await ctx.blockModel.City.all({ where: { code: { $in: city_codes } } });
const city = (cities && cities[1] && cities[1].name) ? cities[1].name : '';
const address = R.pluck('name', cities).join('') + rental_house_info.address;
const gps_info = await ctx.helper.getGPS(address, city);
house_basic.longitude = gps_info.lng;
house_basic.latitude = gps_info.lat;
return { house_basic, house_images, house_types, collection: collectionTask, };
return { house_basic, house_images, house_types, collection: collection.length > 0 ? true : false, };
}
//格式化户型数据
......@@ -156,19 +167,20 @@ class RentalHouseService extends Service {
id: rental_house.id,
name: rental_house.name,//房源名称
image: rental_house.image,//列表展示图片
residential_id: rental_house.residentialId,//小区id
// residential_id: rental_house.residentialId,//小区id
address: rental_house.address,//详细地址
price: rental_house.price,//价格
discount: rental_house.discount,//折扣
// business_license: rental_house.businessLicense,
tags: rental_house.tags ? eval(rental_house.tags) : [],//房源特点
favourable_info: rental_house.favourableInfo,//优惠信息
tags: rental_house.tags,//房源特点
rental_type: rental_house.rental_type,//租房类型 1整租 2合租 3独栋公寓
favourable_info: rental_house.favourable_info,//优惠信息
introduce: rental_house.description || `该社区亮点:
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
2、房型说明:独门独户,拎包入住,满足各种需求,采光
3、社区配套:健身房、休憩区、小影院、娱乐室、商务区、无人商店、快递柜。
4、房间配套:空调、Wifi、洗衣机、热水器、冰箱、床、衣柜、电脑桌、沙发。`,
room_configuration: ctx.helper.JsonParse(rental_house.roomConfiguration),//房间配置
room_configuration: rental_house.room_configuration,//房间配置
// room_configuration: rental_house.roomConfiguration,//房间配置
notice: rental_house.notice,//入住须知
};
......
......@@ -12,12 +12,15 @@ class searchHistoryService extends Service {
*/
async addSearchHistory(inputParams) {
const { ctx } = this;
if (!ctx.userId) {
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就不做处理
return false;
}
let data = {
user_id: ctx.userId,
app_user_id: ctx.appUserId,
app_id: ctx.appId,
app_type_id: ctx.appTypeId,
key_word: inputParams.key_word,
house_style: inputParams.type,
state: 1,
......@@ -36,8 +39,10 @@ class searchHistoryService extends Service {
const { ctx } = this;
let ret = {
hot_search: {
results: [],
count: 0
results: {
results: [],
count: 0
}
},
search_history: {
results: [],
......@@ -45,21 +50,14 @@ class searchHistoryService extends Service {
}
};
//不管有没有登录获取城市相关的热门搜索
let hotList = await ctx.service.house.v2.hotSearch.getHotSearch(condition);
ret.hot_search = {
results: hotList,
count: hotList.length
}
ret.hot_search.results = await ctx.service.house.v2.hotSearch.getHotSearch(condition);
if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就返回
return ret;
}
//用户的搜索记录
let list = await this.getSearchHistory(condition.type);
ret.search_history = {
results: list,
count: list.length
};
ret.search_history = await this.getSearchHistory(condition.type);
return ret;
}
......
......@@ -91,7 +91,7 @@ class ToolService extends Service {
let notice = '';
let status = 0;
let invest_items = [];
if (balance < 0) {
if (balance <= 0) {
status = 2;//完全有能力买到房
notice = '您的资金已满足本项目首付条件,还有更多项目在您预算范围内。一键预约,轻松看房!';
return { status, notice, invest_items };
......
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