Commit 146b9f3e authored by Hsinli's avatar Hsinli

Merge branch 'master' of t-git.51gjj.com:fangbin/51business

parents 874bbb2c 626e6144
'use strict'; 'use strict';
const Controller = require('egg').Controller; const Controller = require('egg').Controller;
const moment = require('moment');
class Export20190425 extends Controller { class Export20190425 extends Controller {
//新房 包含了对应的新房户型和小区信息 //新房 包含了对应的新房户型和小区信息
...@@ -342,6 +342,118 @@ class Export20190425 extends Controller { ...@@ -342,6 +342,118 @@ class Export20190425 extends Controller {
ctx.success(ret); ctx.success(ret);
} }
async moveRentalHouse() {
const { ctx } = this;
let data = {
pageIndex: 1,
pageSize: 999,
orderConditions: [{
key: 'id',
orderSequence: 'asc',
}]
}
const result = await ctx.helper.send_request(this.config.HOUSE_SERVICE_API + '/v1/rentalHouse/list', data, { method: 'POST' });
if (result.status !== 200) {
ctx.failed('error');
}
const now_time = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
const rental_houses = result.data.results;
const residential_developers = { 568: 1, 569: 1, 570: 2, 571: 2, 572: 2, 573: 3, 574: 3, 575: 4, 576: 5, 577: 2, 578: 2, 579: 2, 580: 2, 581: 2, 582: 2, 583: 2, 584: 2, 585: 2, 586: 2, 587: 3, 588: 3, 589: 3, 590: 6, 591: 7, 592: 8, 593: 8, 594: 9, 595: 9, 596: 9, 597: 9, 598: 9, 599: 9 };
const rental_house_type_data = [];
const rental_house_data = [];
for (const i in rental_houses) {
const rental_house = rental_houses[i];
const residential = rental_house.residential;
const rental_house_types = rental_house.rentalHouseType;
for (const j in rental_house_types) {
const rental_house_type = rental_house_types[j];
rental_house_type_data.push({
name: rental_house_type.name,
rental_house_id: rental_house_type.rentalHouseId,
type: rental_house_type.type,
price: rental_house_type.price,
discount: rental_house_type.discount,
area: rental_house_type.area,
remark: rental_house_type.remark,
status: rental_house_type.state ? 'online' : 'offline',
created_at: rental_house_type.createdAt,
updated_at: now_time,
});
}
const tmp = {
id: rental_house.id,
name: rental_house.name,
province: residential.province,
city: residential.city,
area: residential.county,
option_city_code: residential.city,
option_district_code: residential.county,
option_bizicircle_code: residential.region,
developer_id: residential_developers[residential.id],
rental_type: 1,
address: rental_house.address,
price: rental_house.price,
discount: rental_house.discount,
image: rental_house.image,
business_license: rental_house.businessLicense,
notice: rental_house.notice,
tags: rental_house.tags,
favourable_info: rental_house.favourableInfo,
limit_cities: rental_house.limitCities,
room_configuration: rental_house.roomConfiguration,
description: rental_house.description,
order_id: 0,
status: 'online',
valid: 1,
created_at: rental_house.createdAt,
updated_at: now_time,
}
rental_house_data.push(tmp);
}
const rental_house_count = await ctx.realestateModel.RentalHouse.bulkCreate(rental_house_data);
const rental_house_type_count = await ctx.realestateModel.RentalHouseType.bulkCreate(rental_house_type_data);
ctx.success({ rental_house_count, rental_house_type_count });
}
async moveDeveloper() {
const { ctx } = this;
let data = {
pageIndex: 1,
pageSize: 999,
orderConditions: [{
key: 'id',
orderSequence: 'asc',
}]
}
const result = await ctx.helper.send_request(this.config.HOUSE_SERVICE_API + '/v1/developer/list', data, { method: 'POST' });
if (result.status !== 200) {
ctx.failed('error');
}
const now_time = moment(new Date()).format('YYYY-MM-DD HH:mm:ss');
const developers = result.data.results;
const developer_data = [];
for (let i in developers) {
const developer = developers[i];
developer_data.push({
id: developer.id,
short_name: developer.shortName,
name: developer.name,
logo: developer.logo,
order_id: developer.orderNum,
description: developer.description,
status: 'online',
valid: 1,
created_at: developer.createdAt,
updated_at: now_time,
});
}
const developer_count = await ctx.realestateModel.Developer.bulkCreate(developer_data);
ctx.success({ developer_count });
}
} }
module.exports = Export20190425; module.exports = Export20190425;
...@@ -16,7 +16,35 @@ module.exports = app => { ...@@ -16,7 +16,35 @@ module.exports = app => {
type: STRING, type: STRING,
allowNull: false 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, type: INTEGER,
allowNull: true allowNull: true
}, },
...@@ -46,7 +74,19 @@ module.exports = app => { ...@@ -46,7 +74,19 @@ module.exports = app => {
}, },
tags: { tags: {
type: STRING, 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: { favourable_info: {
type: STRING, type: STRING,
...@@ -58,7 +98,19 @@ module.exports = app => { ...@@ -58,7 +98,19 @@ module.exports = app => {
}, },
room_configuration: { room_configuration: {
type: STRING, 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: { description: {
type: STRING, type: STRING,
......
...@@ -17,6 +17,8 @@ module.exports = app => { ...@@ -17,6 +17,8 @@ module.exports = app => {
router.get('third', '/order', 'house.v2.export190619.moveOrder'); router.get('third', '/order', 'house.v2.export190619.moveOrder');
router.get('third', '/history', 'house.v2.export190619.moveHistory'); router.get('third', '/history', 'house.v2.export190619.moveHistory');
router.get('third', '/foot', 'house.v2.export190619.moveFoot'); 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');
......
...@@ -164,19 +164,19 @@ class RentalHouseService extends Service { ...@@ -164,19 +164,19 @@ class RentalHouseService extends Service {
id: rental_house.id, id: rental_house.id,
name: rental_house.name,//房源名称 name: rental_house.name,//房源名称
image: rental_house.image,//列表展示图片 image: rental_house.image,//列表展示图片
residential_id: rental_house.residentialId,//小区id // residential_id: rental_house.residentialId,//小区id
address: rental_house.address,//详细地址 address: rental_house.address,//详细地址
price: rental_house.price,//价格 price: rental_house.price,//价格
discount: rental_house.discount,//折扣 discount: rental_house.discount,//折扣
// business_license: rental_house.businessLicense, // business_license: rental_house.businessLicense,
tags: rental_house.tags ? eval(rental_house.tags) : [],//房源特点 tags: rental_house.tags,//房源特点
favourable_info: rental_house.favourableInfo,//优惠信息 favourable_info: rental_house.favourable_info,//优惠信息
introduce: rental_house.description || `该社区亮点: introduce: rental_house.description || `该社区亮点:
1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。 1、房源介绍:精装公寓,家电齐全,独立卫生间,南通北透,独门独户。
2、房型说明:独门独户,拎包入住,满足各种需求,采光 2、房型说明:独门独户,拎包入住,满足各种需求,采光
3、社区配套:健身房、休憩区、小影院、娱乐室、商务区、无人商店、快递柜。 3、社区配套:健身房、休憩区、小影院、娱乐室、商务区、无人商店、快递柜。
4、房间配套:空调、Wifi、洗衣机、热水器、冰箱、床、衣柜、电脑桌、沙发。`, 4、房间配套:空调、Wifi、洗衣机、热水器、冰箱、床、衣柜、电脑桌、沙发。`,
room_configuration: ctx.helper.JsonParse(rental_house.roomConfiguration),//房间配置 room_configuration: rental_house.room_configuration,//房间配置
// room_configuration: rental_house.roomConfiguration,//房间配置 // room_configuration: rental_house.roomConfiguration,//房间配置
notice: rental_house.notice,//入住须知 notice: rental_house.notice,//入住须知
}; };
......
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