Commit 68a06531 authored by Hsinli's avatar Hsinli

add

parents aef2e88c 3e87c77c
Pipeline #14131 passed with stage
in 35 seconds
...@@ -10,17 +10,32 @@ class LocationController extends Controller { ...@@ -10,17 +10,32 @@ class LocationController extends Controller {
async getAddress() { async getAddress() {
const { ctx } = this; const { ctx } = this;
const { lat, lng } = ctx.request.body; let { lat, lng } = ctx.request.body;
if (!lat || !lng) { let address = '';
ctx.failed('error lat lng'); if (lat && lng) {
const location_ret = await ctx.service.course.lbs.getLBSLocation({ lat, lng });
const loaction = location_ret.result;
if (loaction.formatted_addresses && loaction.formatted_addresses.recommend) {
address = loaction.formatted_addresses.recommend;
lat = loaction.location.lat;
lng = loaction.location.lng;
}
} }
const location_ret = await ctx.service.course.lbs.getLBSLocation({ lat, lng }); if (!address) {
let address = '获取位置信息失败'; const ip_ret = await ctx.service.course.lbs.getLBSIp();
if (location_ret.result.formatted_addresses && location_ret.result.formatted_addresses.recommend) { const ip = ip_ret.result;
address = location_ret.result.formatted_addresses.recommend; if (ip.location && ip.ad_info) {
const city = ip.ad_info.city ? ip.ad_info.city : '';
const district = ip.ad_info.district ? ip.ad_info.district : '';
address = ip.ad_info.province + city + district;
lat = ip.location.lat;
lng = ip.location.lng;
}
} }
if (!address) {
ctx.success({ result: address }); address = '获取地理位置信息失败';
}
ctx.success({ result: { address, lat, lng } });
} }
} }
......
...@@ -117,6 +117,54 @@ class LbsService extends Service { ...@@ -117,6 +117,54 @@ class LbsService extends Service {
return { result }; return { result };
} }
// 地址解析
async getLBSAddress(address) {
const { ctx } = this;
let result = {};
const params = {
address,
key: ctx.app.config.TX_LBS_KEY,
};
const resp = await ctx.helper.send_request(ctx.app.config.TX_LBS_ADDRESS_URL, params, { method: 'GET' });
// resp.data.status 状态码,0:正常,310:请求参数信息有误,311:Key格式错误,306:请求有护持信息请检查字符串,110:请求来源未被授权
ctx.logger.info('tx_lbs_location_resp: ' + JSON.stringify(resp));
if (resp.status === 200) {
// 判断响应是否正确
if (resp.data.status === 0) {
result = resp.data.result;
}
}
return { result };
}
// 逆地址解析
async getLBSIp() {
const { ctx } = this;
let result = {};
const ip = ctx.helper.getClientIP();
if (!ip) {
return result;
}
const params = {
ip: ip,
key: ctx.app.config.TX_LBS_KEY,
};
const resp = await ctx.helper.send_request(ctx.app.config.TX_LBS_URL + '/location/v1/ip ', params, { method: 'GET' });
// resp.data.status 状态码,0:正常,310:请求参数信息有误,311:Key格式错误,306:请求有护持信息请检查字符串,110:请求来源未被授权
ctx.logger.info('tx_lbs_ip_resp: ' + JSON.stringify(resp));
if (resp.status === 200) {
// 判断响应是否正确
if (resp.data.status === 0) {
result = resp.data.result;
}
}
return { result };
}
} }
......
...@@ -295,6 +295,11 @@ class OrderService extends Service { ...@@ -295,6 +295,11 @@ class OrderService extends Service {
if (order && order.pay_status === 1) { if (order && order.pay_status === 1) {
ctx.failed('订单已支付无需重复支付'); ctx.failed('订单已支付无需重复支付');
} }
const expire_time = moment(order.order_time).valueOf() + 24 * 3600 * 1000;
const now_time = moment().valueOf();
if (expire_time < now_time) {
ctx.failed('订单已失效');
}
ctx.logger.info('11111111111111111111111111111111111'); ctx.logger.info('11111111111111111111111111111111111');
const price = ((order.price - order.preferential_price) * 100).toFixed(); const price = ((order.price - order.preferential_price) * 100).toFixed();
......
...@@ -17,8 +17,13 @@ module.exports = appInfo => { ...@@ -17,8 +17,13 @@ module.exports = appInfo => {
domainWhiteList: [], domainWhiteList: [],
}; };
<<<<<<< HEAD
config.middleware = ['errorHandler', 'deviceLogin', 'deviceInit', 'responseSet']; config.middleware = ['errorHandler', 'deviceLogin', 'deviceInit', 'responseSet'];
// config.middleware = []; // config.middleware = [];
=======
// config.middleware = [ 'errorHandler', 'deviceLogin', 'deviceInit', 'responseSet' ];
config.middleware = [];
>>>>>>> 3e87c77c40fa53e79388f2de88910bcc217f5e6b
exports.multipart = { exports.multipart = {
// 不用steam用file // 不用steam用file
...@@ -131,6 +136,13 @@ module.exports = appInfo => { ...@@ -131,6 +136,13 @@ module.exports = appInfo => {
}, },
}; };
exports.session = {
key: 'SESSION_ID',
maxAge: 24 * 3600 * 1000, // 1 天
httpOnly: true,
encrypt: true,
};
config.PHP_URL = 'https://kaifa.jianbing.com'; config.PHP_URL = 'https://kaifa.jianbing.com';
config.NODE_URL = 'https://uat-nginx.jianbing.com/user_api/v1'; config.NODE_URL = 'https://uat-nginx.jianbing.com/user_api/v1';
config.NODE_BASE_URL = 'https://uat-nginx.jianbing.com'; config.NODE_BASE_URL = 'https://uat-nginx.jianbing.com';
...@@ -160,6 +172,7 @@ module.exports = appInfo => { ...@@ -160,6 +172,7 @@ module.exports = appInfo => {
config.TX_LBS_KEY = 'TNHBZ-A7C36-5DISQ-EM2JH-332V5-PGFW5'; config.TX_LBS_KEY = 'TNHBZ-A7C36-5DISQ-EM2JH-332V5-PGFW5';
config.TX_LBS_DISTANCE_URL = 'https://apis.map.qq.com/ws/distance/v1/'; // 距离计算(一对多) config.TX_LBS_DISTANCE_URL = 'https://apis.map.qq.com/ws/distance/v1/'; // 距离计算(一对多)
config.TX_LBS_ADDRESS_URL = 'https://apis.map.qq.com/ws/geocoder/v1/'; // 地址解析;逆地址解析 config.TX_LBS_ADDRESS_URL = 'https://apis.map.qq.com/ws/geocoder/v1/'; // 地址解析;逆地址解析
config.TX_LBS_URL = 'https://apis.map.qq.com/ws'; // 地址解析;逆地址解析
//我的信用-通化检测 //我的信用-通化检测
......
...@@ -146,6 +146,7 @@ module.exports = appInfo => { ...@@ -146,6 +146,7 @@ module.exports = appInfo => {
config.TX_LBS_KEY = process.env.TX_LBS_KEY; config.TX_LBS_KEY = process.env.TX_LBS_KEY;
config.TX_LBS_DISTANCE_URL = process.env.TX_LBS_DISTANCE_URL; // 距离计算(一对多) config.TX_LBS_DISTANCE_URL = process.env.TX_LBS_DISTANCE_URL; // 距离计算(一对多)
config.TX_LBS_ADDRESS_URL = process.env.TX_LBS_ADDRESS_URL; // 地址解析;逆地址解析 config.TX_LBS_ADDRESS_URL = process.env.TX_LBS_ADDRESS_URL; // 地址解析;逆地址解析
config.TX_LBS_URL = process.env.TX_LBS_URL; //腾讯MAP API
//我的信用-通化检测 //我的信用-通化检测
config.YYS_APP_KEY = process.env.YYS_APP_KEY; config.YYS_APP_KEY = process.env.YYS_APP_KEY;
......
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