Commit 3250a3ff authored by Hsinli's avatar Hsinli

add gps

parent 7c91519e
Pipeline #10968 passed with stage
in 50 seconds
......@@ -36,6 +36,14 @@ module.exports = app => {
type: STRING,
allowNull: true
},
gps: {
type: STRING,
allowNull: true
},
sale_gps: {
type: STRING,
allowNull: true
},
sale_province: {
type: INTEGER,
allowNull: true
......
......@@ -157,19 +157,31 @@ class NewHouseService extends Service {
let area = typeArea.min === typeArea.max ? Number(typeArea.min) : Number(typeArea.min) + '-' + Number(typeArea.max);
//经纬度
let addressDecode = await this.addressDecode({ city: data.option_city_code, district: data.option_district_code, bizicircle: data.option_bizicircle_code });
let address = addressDecode.city + addressDecode.county + addressDecode.region + data.address;
let gps_result = await ctx.helper.getGPS(address, addressDecode.city);
if (!gps_result.lat || !gps_result.lng) {
gps_result = await ctx.helper.getGPS(addressDecode, addressDecode.city);
}
let longitude = 0;
let latitude = 0;
if (gps_result) {
longitude = gps_result.lng;
latitude = gps_result.lat;
if (data.gps.length > 0) {
let gpsInfo = data.gps.split(',').slice(0, 2);
longitude = gpsInfo[1];
latitude = gpsInfo[0];
} else {
let addressDecode = await this.addressDecode({ city: data.option_city_code, district: data.option_district_code, bizicircle: data.option_bizicircle_code });
let address = addressDecode.city + addressDecode.county + addressDecode.region + data.address;
let gps_result = await ctx.helper.getGPS(address, addressDecode.city);
if (!gps_result.lat || !gps_result.lng) {
gps_result = await ctx.helper.getGPS(addressDecode, addressDecode.city);
}
if (gps_result) {
longitude = gps_result.lng;
latitude = gps_result.lat;
}
let gpsFilter = {
params: { gps: latitude + ',' + longitude },
where: { id: data.id }
}
await ctx.realestateModel.NewHouse.edit(gpsFilter);
}
ret.basic = {
id: data.id,
name: data.name,//标题
......
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