Commit ede5c571 authored by 方斌's avatar 方斌
parents f2c11b29 cbeecb20
Pipeline #15700 passed with stage
in 1 minute 16 seconds
...@@ -6,7 +6,7 @@ class TestController extends Controller { ...@@ -6,7 +6,7 @@ class TestController extends Controller {
const { service, ctx } = this; const { service, ctx } = this;
const from = { lng: 120.069206, lat: 30.291121 }; const from = { lng: 120.069206, lat: 30.291121 };
const to = { lng: 120.212997, lat: 30.29133 }; const to = { lng: 120.212997, lat: 30.29133 };
const ret = await service.course.lbs.getLBSDistance('driving', from, [ to ]); const ret = await service.course.lbs.getLBSDistance('walking', from, [ to, to ]);
ctx.success(ret); ctx.success(ret);
} }
} }
......
'use strict';
const Controller = require('egg').Controller;
const crypto = require('crypto');
const fs = require('fs');
const request = require('request');
class WechatController extends Controller {
async test() {
const { ctx, service } = this;
const data = {MsgType: 'miniprogrampage'};
await service.course.wechat.sendMsg(data);
ctx.success();
}
async callbackAction() {
const { ctx, service } = this;
await service.course.wechat.callbackAction();
ctx.success('success');
}
async check() {
const { ctx } = this;
const params = ctx.request.query;
const {
signature,
timestamp,
nonce,
echostr,
} = params;
const array = [ '51gjj', timestamp, nonce ];
array.sort();
// 3.将三个参数字符串拼接成一个字符串进行sha1加密
const tempStr = array.join('');
const hashCode = crypto.createHash('sha1'); // 创建加密类型
const resultCode = hashCode.update(tempStr, 'utf8').digest('hex');
console.log(resultCode);
// 4.开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
if (resultCode === signature) {
ctx.success(echostr);
} else {
ctx.success();
}
}
}
module.exports = WechatController;
...@@ -39,7 +39,8 @@ class CallriskController extends Controller { ...@@ -39,7 +39,8 @@ class CallriskController extends Controller {
name: { type: 'string', required: true }, name: { type: 'string', required: true },
phone: { type: 'string', required: true }, phone: { type: 'string', required: true },
id_card: { type: 'string', required: true }, id_card: { type: 'string', required: true },
password: { type: 'string', required: true } password: { type: 'string', required: true },
net: { type: 'number', required: true },
} }
ctx.validate(rule, input_params); ctx.validate(rule, input_params);
const result = await ctx.service.credit.apply.applyCallrisk(input_params); const result = await ctx.service.credit.apply.applyCallrisk(input_params);
......
...@@ -13,6 +13,15 @@ class HomeController extends Controller { ...@@ -13,6 +13,15 @@ class HomeController extends Controller {
ctx.success(ret); ctx.success(ret);
} }
async test() {
const { ctx } = this;
const orderSn = await ctx.query.sn;
const yys_report_data = await ctx.service.credit.yys.getData(orderSn);//拉取报告数据
// const stream1 = await ctx.getFileStream();
// await pump(stream, writeStream);
ctx.success(yys_report_data);
}
} }
module.exports = HomeController; module.exports = HomeController;
...@@ -34,7 +34,7 @@ class OrderController extends Controller { ...@@ -34,7 +34,7 @@ class OrderController extends Controller {
const { method, order_id, reject_url } = input_params; const { method, order_id, reject_url } = input_params;
let result = await ctx.service.credit.order.unifiedOrder(method, order_id); let result = await ctx.service.credit.order.unifiedOrder(method, order_id);
// result.reject_url = reject_url; // result.reject_url = reject_url;
result.url = `${result.url}&py=#shanp.com&redirect_url=${reject_url}`; result.url = `${result.url}&redirect_url=${reject_url}`;
ctx.success({ result }); ctx.success({ result });
} }
......
'use strict';
const Controller = require('egg').Controller;
const WECHAT_CODE_URL = 'https://open.weixin.qq.com/connect/oauth2/authorize';
const WECHAT_AUTH = 'https://api.weixin.qq.com/sns/oauth2/access_token';
const WECHAT_APPID = 'wx3c772df2d8d78da3';
const WECHAT_APPID_TEST = 'wxa9df2d60730b25d9';
const WECHAT_SECRET = 'b369fd28a9f9320ebe4e35dfaa00b194';
const WECHAT_SECRET_TEST = 'dfede7a3b543149a88b07b46bcc28e00';
const REDIRECT_PAGE = '/webserve/accumulation/index';
class WechatController extends Controller {
//公众号公积金查询H5授权跳转
async oauthLogin() {
const { ctx } = this;
const code = ctx.query.code;
const channel_id = ctx.query.channel_id;
const app_id = ['https://lan-nginx.jianbing.com', 'https://pro-nginx.jianbing.com'].includes(this.config.NODE_BASE_URL) ? WECHAT_APPID : WECHAT_APPID_TEST;
const appsecret = ['https://lan-nginx.jianbing.com', 'https://pro-nginx.jianbing.com'].includes(this.config.NODE_BASE_URL) ? WECHAT_SECRET : WECHAT_SECRET_TEST;
if (!code || code.length === 0) {
const target_url = WECHAT_CODE_URL + `?appid=${app_id}&redirect_uri=${encodeURIComponent(`${this.app.config.OUT_P_NODE_URL}/51business/api/gjj/wechat/oauth_login?&channel_id=${channel_id}`)}&response_type=code&scope=snsapi_base&state=gjjquery#wechat_redirect`;
ctx.redirect(target_url); return;
}
const url = `${WECHAT_AUTH}?appid=${app_id}&secret=${appsecret}&code=${code}&grant_type=authorization_code`
const result = await ctx.helper.send_request(url, {}, { method: 'GET' });
ctx.logger.info(JSON.stringify({ wx_gjj_query: result }));
if (result.status !== 200) {
ctx.failed('获取openid失败1');
}
const wx_ret = result.data;
if (!wx_ret.openid) {
ctx.failed('获取openid失败2');
}
const openid = wx_ret.openid;
ctx.cookies.set('openid', openid, { httpOnly: false, signed: false, path: '/', overwrite: true });
const redirect_url = this.app.config.OUT_P_NODE_URL + REDIRECT_PAGE;
//判断是否已绑定手机号
const user_exist_url = `${this.app.config.NODE_BASE_URL}/user_api/v1/user/is_exist/${openid}`;
const bind_phone_result = await ctx.helper.send_request(user_exist_url, { type: 5 }, { method: 'GET' });
ctx.logger.info(JSON.stringify({ bind_phone_result: bind_phone_result }));
if (bind_phone_result.status !== 200) {
ctx.redirect(redirect_url + `?channel_id=${channel_id}&type=noLogin&openid=${openid}`); return;
}
const user_exist_ret = bind_phone_result.data;
if (user_exist_ret.result != 'true') {//未绑定的手机号时
ctx.redirect(redirect_url + `?channel_id=${channel_id}&type=noLogin&openid=${openid}`); return;
}
const user_id = user_exist_ret.uid;
//已绑定手机的 继续 判断是否有导入公积金
await this.user_login({ code, openid, channel_id });//已绑定的用户 直接登录
const gjj_exist_url = `${this.app.config.NODE_BASE_URL}/cassandra-server/gjj/list/${user_id}`;
const gjj_exist_result = await ctx.helper.send_request(gjj_exist_url, {}, { method: 'GET' });
ctx.logger.info(JSON.stringify({ gjj_exist_result: gjj_exist_result }));
if (gjj_exist_result.status !== 200) {//调用公积金接口出错
ctx.redirect(redirect_url + `?channel_id=${channel_id}&type=noLogin`); return;
}
const gjj_exist_ret = gjj_exist_result.data;
if (!gjj_exist_ret.ret || gjj_exist_ret.ret.length === 0) {//没有导入公积金时
ctx.redirect(redirect_url + `?channel_id=${channel_id}&type=noLogin`); return;
}
ctx.redirect(redirect_url + `?channel_id=${channel_id}&type=hasLogin`); return;//已导入公积金
}
//判断是否有公积金导入并跳转
// async checkGjj() {
// const { ctx } = this;
// const user_id = ctx.userId;
// //判断是否有导入公积金
// console.info(user_id);
// const gjj_exist_url = `${this.app.config.NODE_BASE_URL}/cassandra-server/gjj/list/${user_id}`;
// const gjj_exist_result = await ctx.helper.send_request(gjj_exist_url, {}, { method: 'GET' });
// ctx.logger.info(JSON.stringify({ gjj_exist_result: gjj_exist_result }));
// if (gjj_exist_result.status !== 200) {
// ctx.redirect(NO_GJJ_PAGE); return;
// }
// ctx.redirect(GJJ_DETAIL_PAGE); return;
// }
async checkLogin() {
const { ctx } = this;
const user_id = ctx.userId;
let is_login = false;
if (user_id) {
is_login = true;
}
// const phone = await ctx.helper.getPhoneCity('15968762898');
ctx.success({ result: is_login });
}
async user_login(params) {
const { ctx } = this;
const { code, openid, channel_id } = params;
const user_agent = ctx.request.header.user_agent ? ctx.request.header.user_agent : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36';
const ip = ctx.helper.getClientIP();
const past_deviceno = ctx.helper.md5(user_agent + ip);
const app_channel_info = await ctx.blockModel.AppChannel.one({ where: { alias: channel_id } });
if (!app_channel_info || Object.keys(app_channel_info).length === 0) {
ctx.failed('渠道未配置');
}
if (!app_channel_info.app_id) {
ctx.failed('渠道未关联APPID');
}
const device_login_params = {
past_deviceno: past_deviceno,
channel_id: app_channel_info.channel_id,
app_id: app_channel_info.app_id,
device_info: {},
}
const result_device_login = await ctx.helper.send_request(this.config.NODE_URL + '/login/device', device_login_params, { method: 'POST' });//设备登录
const device_login_data = result_device_login.data;//设备登录返回结果
if (!device_login_data || Object.keys(device_login_data).length === 0) {
ctx.failed('device login error, device_login_data empty');
}
if (!device_login_data.past_deviceno) {//使用设备码+时间+随机数产生的一个尽量避免重复的字符串,类似游客版h5
ctx.failed('device login error, past_deviceno empty');
}
if (!device_login_data.device_id) {//Devices字段表主键ID
ctx.failed('device login error, device_id empty');
}
if (!device_login_data.device_login_logs_id) {//DeviceLoginLogs字段表主键ID
ctx.failed('device login error, device_login_logs_id empty');
}
const user_login_params = {//用户登录传递的参数
past_deviceno: past_deviceno,//使用设备码+时间+随机数产生的一个尽量避免重复的字符串,类似游客版h5登
// device_no: device_login_data.device_no,//使用新的sdk生成的设备指纹
login_type: '5',//登录类型:1 验证码手机登录, 2 password手机登录,4 token登录,5 微信登录,
passport: code,//登录账号:手机登录值为手机
password: code,//类型对应的值
app_user_id: params.app_user_id || '',//app用户ID token登陆时传的参数 可空
code: code || '',//第三方授权登录时的code 可空
device_info: {},//设备信息
openid: openid || '' //例如微信公众号的openid(不传默认是51查个税)
};
const result_user_login = await ctx.helper.send_request(this.config.NODE_URL + '/login/user', user_login_params, { method: 'POST' });//用户登录
ctx.logger.info(JSON.stringify({ user_login_params: user_login_params, result_user_login: result_user_login }));
const user_login_data = result_user_login.data;//用户登录返回结果
if (!user_login_data || Object.keys(user_login_data).length === 0) {
ctx.failed('用户的登录失败');
}
if (!user_login_data.token || !user_login_data.uid) {
const error_msg = user_login_data.error ? user_login_data.error : '用户的登录失败';
ctx.failed(error_msg);
}
//获取用户信息
const login_token = user_login_data.token;
const app_user_id = user_login_data.app_user_id;
const user_id = user_login_data.uid;
const device_id = device_login_data.device_id;
const device_login_id = device_login_data.device_login_logs_id;
const env = this.app.config.env;
let host = this.config.NODE_BASE_URL;
if (env === 'prod') host = host.replace('lan-nginx.jianbing.com', 'p.jianbing.com');
const user_info = {
token: login_token,
app_user_id: app_user_id,
user_id: user_id,
device_id: device_id,
device_login_id: device_login_id,
android_url: `${host}/frontendh5/lp/wc/index?down=${encodeURIComponent(app_channel_info.android_url)}`,
ios_url: app_channel_info.ios_url,
}
for (let key in user_info) {
const value = user_info[key];
ctx.cookies.set(key, value, { httpOnly: false, signed: false, path: '/', overwrite: true });
}
return user_info;
}
}
module.exports = WechatController;
'use strict';
const Controller = require('egg').Controller;
class AbroadHouseController extends Controller {
/**
* 海外房列表
*/
async list() {
const { ctx } = this;
let inputParams = ctx.request.body;
const rule = {
page: { type: 'int', required: false },
page_size: { type: 'int', required: false },
name: { type: 'string', required: false },
};
ctx.validate(rule, inputParams);
let ret = await ctx.service.house.v2.abroadHouse.abroadHouseList(inputParams);
ctx.success(ret);
}
}
module.exports = AbroadHouseController;
...@@ -13,6 +13,22 @@ class FootPrintController extends Controller { ...@@ -13,6 +13,22 @@ class FootPrintController extends Controller {
ctx.success(ret); ctx.success(ret);
} }
/**
* 海外房的足迹记录需要额外记录
*/
async addAbroadFootPrint() {
const { ctx } = this;
let inputParams = ctx.request.body;
const rule = {
id: { type: 'int', required: true },
};
ctx.validate(rule, inputParams);
inputParams.type = 4;
let ret = await ctx.service.house.v2.footPrint.addFootPrint(inputParams);
ctx.success(ret);
}
} }
module.exports = FootPrintController; module.exports = FootPrintController;
'use strict'; 'use strict';
const Controller = require('egg').Controller; const Controller = require('egg').Controller;
const ConfigType = {
1: 'new_house',
2: 'rental_house',
4: 'abroad_house',
}
class searchHistoryController extends Controller { class searchHistoryController extends Controller {
...@@ -19,9 +24,9 @@ class searchHistoryController extends Controller { ...@@ -19,9 +24,9 @@ class searchHistoryController extends Controller {
}; };
ctx.validate(rule, inputParams); ctx.validate(rule, inputParams);
let ret = {}; let ret = {};
let type = [1, 2]; let type = [1, 2, 4];
for (let i in type) { for (let i in type) {
let tag = type[i] === 1 ? 'new_house' : 'rental_house'; let tag = ConfigType[type[i]];
ret[tag] = await ctx.service.house.v2.searchHistory.getSearchHistoryList({ type: type[i], city_code: Number(inputParams.city_code) }); ret[tag] = await ctx.service.house.v2.searchHistory.getSearchHistoryList({ type: type[i], city_code: Number(inputParams.city_code) });
} }
...@@ -39,6 +44,7 @@ class searchHistoryController extends Controller { ...@@ -39,6 +44,7 @@ class searchHistoryController extends Controller {
new_house: 1, new_house: 1,
rental_house: 2, rental_house: 2,
hot_question: 3, hot_question: 3,
abroad_house: 4,
} }
const rule = { const rule = {
type: { type: {
......
...@@ -38,13 +38,13 @@ class ResponseController extends Controller { ...@@ -38,13 +38,13 @@ class ResponseController extends Controller {
const user_sid = ctx.cookies.get('jianbing_customer_id', { signed: false }); const user_sid = ctx.cookies.get('jianbing_customer_id', { signed: false });
const auth_token = ctx.cookies.get('auth_token', { signed: false }); const auth_token = ctx.cookies.get('auth_token', { signed: false });
ctx.logger.info('target_user--' + new Date().getTime() + JSON.stringify({ target_old_user: { auth_token, user_sid } })); // ctx.logger.info('target_user--' + new Date().getTime() + JSON.stringify({ target_old_user: { auth_token, user_sid } }));
const phone_info = await ctx.service.user.get_phone_by_user_sid({ user_sid: user_sid, token: auth_token });//获取用户手机号码 const phone_info = await ctx.service.user.get_phone_by_user_sid({ user_sid: user_sid, token: auth_token });//获取用户手机号码
ctx.logger.info('phone_info: ' + JSON.stringify(phone_info)); // ctx.logger.info('phone_info: ' + JSON.stringify(phone_info));
const phone = phone_info.phone; const phone = phone_info.phone;
// const phone = '15968762898'; // const phone = '15968762898';
const app_channel_info = await ctx.blockModel.AppChannel.one({ where: { alias: channel_alias } });// const app_channel_info = await ctx.blockModel.AppChannel.one({ where: { alias: channel_alias } });//
ctx.logger.info('app_channel_info: ' + JSON.stringify(app_channel_info)); // ctx.logger.info('app_channel_info: ' + JSON.stringify(app_channel_info));
const channel_id = (app_channel_info && app_channel_info.channel_id) ? app_channel_info.channel_id : false; const channel_id = (app_channel_info && app_channel_info.channel_id) ? app_channel_info.channel_id : false;
const app_id = (app_channel_info && app_channel_info.app_id) ? app_channel_info.app_id : false; const app_id = (app_channel_info && app_channel_info.app_id) ? app_channel_info.app_id : false;
...@@ -59,15 +59,16 @@ class ResponseController extends Controller { ...@@ -59,15 +59,16 @@ class ResponseController extends Controller {
// console.info(this.config.NODE_URL + '/login/go_register'); // console.info(this.config.NODE_URL + '/login/go_register');
const result_go_register = await ctx.helper.send_request(this.config.NODE_URL + '/login/go_register', go_register_params, { method: 'POST' });//通过手机号直接注册新用户中心 const result_go_register = await ctx.helper.send_request(this.config.NODE_URL + '/login/go_register', go_register_params, { method: 'POST' });//通过手机号直接注册新用户中心
node_user_center_login_ret = result_go_register.data; node_user_center_login_ret = result_go_register.data;
ctx.logger.info('target_user--' + new Date().getTime() + JSON.stringify({ target_old_user: { go_register_params, node_user_center_login_ret } })); // ctx.logger.info('target_user--' + new Date().getTime() + JSON.stringify({ target_old_user: { go_register_params, node_user_center_login_ret } }));
// ctx.logger.info('go_register_result: ' + JSON.stringify(node_user_center_login_ret)); // ctx.logger.info('go_register_result: ' + JSON.stringify(node_user_center_login_ret));
ctx.logger.info(JSON.stringify({ url: ctx.app.config.NODE_URL + '/login/go_register', go_register_params: go_register_params, go_register_result: node_user_center_login_ret }));
node_user_center_login_ret.user_id = node_user_center_login_ret.uid; node_user_center_login_ret.user_id = node_user_center_login_ret.uid;
node_user_center_login_ret.device_login_id = node_user_center_login_ret.device_login_logs_id; node_user_center_login_ret.device_login_id = node_user_center_login_ret.device_login_logs_id;
delete (node_user_center_login_ret.uid); delete (node_user_center_login_ret.uid);
delete (node_user_center_login_ret.device_login_logs_id); delete (node_user_center_login_ret.device_login_logs_id);
} }
ctx.logger.info('target_user--' + new Date().getTime() + JSON.stringify({ target_old_user: { channel_id, app_id } })); // ctx.logger.info('target_user--' + new Date().getTime() + JSON.stringify({ target_old_user: { channel_id, app_id } }));
if (!phone || !channel_id || !app_id || !node_user_center_login_ret.token) {// 或渠道错误 或直接注册新用户中心失败时 使用设备登录 if (!phone || !channel_id || !app_id || !node_user_center_login_ret.token) {// 或渠道错误 或直接注册新用户中心失败时 使用设备登录
const user_agent = header.user_agent ? header.user_agent : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'; const user_agent = header.user_agent ? header.user_agent : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36';
const ip = ctx.helper.getClientIP(); const ip = ctx.helper.getClientIP();
......
...@@ -13,6 +13,7 @@ const OLDUSERID = Symbol('Context#oldUserId'); ...@@ -13,6 +13,7 @@ const OLDUSERID = Symbol('Context#oldUserId');
const USERID = Symbol('Context#userId'); const USERID = Symbol('Context#userId');
const OLDCOOKIE = Symbol('Context#oldCookie'); const OLDCOOKIE = Symbol('Context#oldCookie');
const USERUUID = Symbol('Context#userUuid'); const USERUUID = Symbol('Context#userUuid');
const OPENID = Symbol('Context#openId');
module.exports = { module.exports = {
failed(message) { failed(message) {
...@@ -177,6 +178,10 @@ module.exports = { ...@@ -177,6 +178,10 @@ module.exports = {
return this[USERUUID]; return this[USERUUID];
}, },
get openId() {
return this[OPENID];
},
setAppUserId(app_user_id) { setAppUserId(app_user_id) {
this[APPUSERID] = app_user_id; this[APPUSERID] = app_user_id;
}, },
...@@ -212,4 +217,8 @@ module.exports = { ...@@ -212,4 +217,8 @@ module.exports = {
setUserUuid(user_uuid) { setUserUuid(user_uuid) {
this[USERUUID] = user_uuid; this[USERUUID] = user_uuid;
}, },
setOpenId(openId) {
this[OPENID] = openId;
},
}; };
...@@ -316,7 +316,7 @@ module.exports = { ...@@ -316,7 +316,7 @@ module.exports = {
//固定位数前补充 0 操作 //固定位数前补充 0 操作
PrefixInteger(num, length) { PrefixInteger(num, length) {
return (Array(length).join('0') + num).slice(-length); return (Array(length).join('0') + num).slice(-length);
}, },
async xmlTojson(data) { async xmlTojson(data) {
const ret_p = new Promise((resolve, reject) => { const ret_p = new Promise((resolve, reject) => {
XML2JS.parseString(data, (err, result) => { XML2JS.parseString(data, (err, result) => {
...@@ -337,6 +337,33 @@ module.exports = { ...@@ -337,6 +337,33 @@ module.exports = {
const bulider = new XML2JS.Builder(); const bulider = new XML2JS.Builder();
const xml_params = bulider.buildObject(data); const xml_params = bulider.buildObject(data);
return xml_params; return xml_params;
},
//获取手机号码归属地
async getPhoneCity(phone) {
const { ctx } = this;
const url = 'https://mobsec-dianhua.baidu.com/dianhua_api/open/location';
let location = '--';
const result = await ctx.helper.send_request(url, { tel: phone }, { method: 'GET', timeout: 6000 });
if (result.status !== 200) {
return location;
}
const ret = result.data;
let city = '';
if (ret.response && ret.response[phone] && ret.response[phone].detail && ret.response[phone].detail.area) {
city = ret.response[phone].detail.area[0].city;
}
let provinece = '';
if (ret.response && ret.response[phone] && ret.response[phone].detail && ret.response[phone].detail.province) {
provinece = ret.response[phone].detail.province;
}
if (city == provinece) {
city = '';
}
location = provinece + city;
return location;
} }
}; };
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module.exports = (options, app) => { module.exports = (options, app) => {
return async function (ctx, next) { return async function(ctx, next) {
const uuid = ctx.headers.uuid; const uuid = ctx.headers.uuid;
const key = 'course_user_session_' + uuid; const key = 'course_user_session_' + uuid;
...@@ -21,6 +21,7 @@ module.exports = (options, app) => { ...@@ -21,6 +21,7 @@ module.exports = (options, app) => {
// console.info('11111111111111111111111111111111'); // console.info('11111111111111111111111111111111');
// console.info(auth_info); // console.info(auth_info);
ctx.setUserUuid(user_uuid); ctx.setUserUuid(user_uuid);
ctx.setOpenId(openid);
await next(); await next();
}; };
......
...@@ -37,7 +37,7 @@ module.exports = app => { ...@@ -37,7 +37,7 @@ module.exports = app => {
allowNull: false, allowNull: false,
}, },
silence_time_rate_3day: { silence_time_rate_3day: {
type: INTEGER, type: STRING,
allowNull: false, allowNull: false,
}, },
maximum_active_call_count: { maximum_active_call_count: {
...@@ -45,7 +45,7 @@ module.exports = app => { ...@@ -45,7 +45,7 @@ module.exports = app => {
allowNull: false, allowNull: false,
}, },
maximum_active_call_number: { maximum_active_call_number: {
type: INTEGER, type: STRING,
allowNull: false, allowNull: false,
}, },
maximum_active_call_city: { maximum_active_call_city: {
...@@ -57,7 +57,7 @@ module.exports = app => { ...@@ -57,7 +57,7 @@ module.exports = app => {
allowNull: false, allowNull: false,
}, },
maximum_passive_call_number: { maximum_passive_call_number: {
type: INTEGER, type: STRING,
allowNull: false, allowNull: false,
}, },
maximum_passive_call_city: { maximum_passive_call_city: {
...@@ -69,7 +69,7 @@ module.exports = app => { ...@@ -69,7 +69,7 @@ module.exports = app => {
allowNull: false, allowNull: false,
}, },
maximum_call_time_number: { maximum_call_time_number: {
type: INTEGER, type: STRING,
allowNull: false, allowNull: false,
}, },
maximum_call_time_city: { maximum_call_time_city: {
......
...@@ -64,14 +64,14 @@ module.exports = app => { ...@@ -64,14 +64,14 @@ module.exports = app => {
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined; // return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// }, // },
// }, // },
// created_at: { created_at: {
// type: DATE, type: DATE,
// allowNull: false, allowNull: true,
// get() { get() {
// const date = this.getDataValue('created_at'); const date = this.getDataValue('created_at');
// return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined; return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
// }, },
// } }
}, { }, {
timestamps: false, timestamps: false,
tableName: 'credit_callrisk_report', tableName: 'credit_callrisk_report',
......
...@@ -21,12 +21,20 @@ module.exports = app => { ...@@ -21,12 +21,20 @@ module.exports = app => {
allowNull: false, allowNull: false,
}, },
silence_begin_time: { silence_begin_time: {
type: INTEGER, type: DATE,
allowNull: false, allowNull: true,
get() {
const date = this.getDataValue('silence_begin_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
}, },
silence_end_time: { silence_end_time: {
type: INTEGER, type: DATE,
allowNull: false, allowNull: true,
get() {
const date = this.getDataValue('silence_end_time');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
}, },
// is_deleted: { // is_deleted: {
// type: INTEGER, // type: INTEGER,
......
'use strict';
const moment = require('moment');
module.exports = app => {
const { STRING, INTEGER, DATE, TEXT, DECIMAL } = app.Sequelize;
const AbroadHouse = app.realestateModel.define('abroad_house', {
id: {
type: INTEGER,
allowNull: false,
primaryKey: true,
autoIncrement: true,
},
name: {
type: STRING,
allowNull: true
},
images: {
type: TEXT,
allowNull: true
},
tags: {
type: STRING,
allowNull: true
},
total_price: {
type: DECIMAL,
allowNull: true
},
url: {
type: STRING,
allowNull: true
},
order: {
type: INTEGER,
allowNull: true
},
valid: {
type: INTEGER,
allowNull: true
},
status: {
type: STRING,
allowNull: true
},
created_at: {
type: DATE,
get() {
const date = this.getDataValue('created_at');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
updated_at: {
type: DATE,
get() {
const date = this.getDataValue('updated_at');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
deleted_at: {
type: DATE,
get() {
const date = this.getDataValue('deleted_at');
return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : undefined;
},
},
}, {
timestamps: false,
tableName: 'abroad_house',
});
AbroadHouse.one = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
return await AbroadHouse.findOne({
attributes: attributes,
where: where,
});
}
AbroadHouse.all = async (data) => {
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const order = data.order ? data.order : [];
return await AbroadHouse.findAll({
attributes: attributes,
where: where,
order,
});
}
AbroadHouse.list = async (data = {}) => {
const limit = data.limit ? Number(data.limit) : 10;
const page = data.page ? data.page : 1;
const order = data.order ? data.order : [];
const attributes = data.attributes ? data.attributes : {};
const where = data.where ? data.where : {};
const condition = {
offset: (page - 1) * limit,
limit,
where: where,
order: order,
attributes: attributes,
};
const { count, rows } = await AbroadHouse.findAndCountAll(condition);
return { page, count, rows };
}
AbroadHouse.add = async (data) => {
try {
//返回promise对象实力 instance
const res = await AbroadHouse.create(data);
//从promise 实例中中获得需要的id号,id 必须是自增长,而且必须主键,否则返回null
return res.id;
} catch (error) {
throw (error);
}
}
AbroadHouse.edit = async (data) => {
const where = data.where;
const params = data.params;
try {
return await AbroadHouse.update(params, { where: where })
} catch (error) {
throw (error);
}
}
return AbroadHouse;
};
...@@ -2,30 +2,33 @@ ...@@ -2,30 +2,33 @@
module.exports = app => { module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/course'); const router = app.router.namespace(app.config.projectRootPath + '/course');
const loginAuth = app.middleware.loginAuth({ type: 'new' });//登录中间件 const loginAuth = app.middleware.loginAuth({ type: 'new' });// 登录中间件
const miniAuth = app.middleware.miniAuth();//因为不跟现有的用户中心系统,所以使用单独的登录中间件 const miniAuth = app.middleware.miniAuth();// 因为不跟现有的用户中心系统,所以使用单独的登录中间件
router.get('third', '/options', 'course.option.getOptions');//筛选项 router.get('third', '/options', 'course.option.getOptions');// 筛选项
router.post('third', '/address', miniAuth, 'course.location.getAddress');//根据经纬度或ip获取地理位置信息 router.post('third', '/address', miniAuth, 'course.location.getAddress');// 根据经纬度或ip获取地理位置信息
router.post('third', '/institutions', miniAuth, 'course.institution.institutionList');//机构列表 router.post('third', '/institutions', miniAuth, 'course.institution.institutionList');// 机构列表
router.get('third', '/institutions', miniAuth, 'course.institution.institutionList');//机构列表 router.get('third', '/institutions', miniAuth, 'course.institution.institutionList');// 机构列表
router.get('third', '/institution/:institution_id/:area_id', miniAuth, 'course.institution.institutionInfo');//机构详情 router.get('third', '/institution/:institution_id/:area_id', miniAuth, 'course.institution.institutionInfo');// 机构详情
router.post('third', '/classes', miniAuth, 'course.institution.classList');//课程列表 router.post('third', '/classes', miniAuth, 'course.institution.classList');// 课程列表
router.get('third', '/classes', miniAuth, 'course.institution.classList');//课程列表 router.get('third', '/classes', miniAuth, 'course.institution.classList');// 课程列表
router.get('third', '/class/:class_id', miniAuth, 'course.institution.classInfo');//课程详情 router.get('third', '/class/:class_id', miniAuth, 'course.institution.classInfo');// 课程详情
router.post('third', '/teachers', miniAuth, 'course.institution.teacherList');//老师列表 router.post('third', '/teachers', miniAuth, 'course.institution.teacherList');// 老师列表
router.get('third', '/teachers', miniAuth, 'course.institution.teacherList');//老师详情 router.get('third', '/teachers', miniAuth, 'course.institution.teacherList');// 老师详情
router.get('third', '/teacher/:teacher_id', miniAuth, 'course.institution.teacherInfo');//老师详情 router.get('third', '/teacher/:teacher_id', miniAuth, 'course.institution.teacherInfo');// 老师详情
router.post('third', '/user/auth', 'course.user.auth');//微信授权登录 router.post('third', '/user/auth', 'course.user.auth');// 微信授权登录
router.post('third', '/user/register_user', miniAuth, 'course.user.registerUserInfo');//授权后注册用户 router.post('third', '/user/register_user', miniAuth, 'course.user.registerUserInfo');// 授权后注册用户
router.get('third', '/user/baby', miniAuth, 'course.user.getBabyInfo');//获取baby信息 router.get('third', '/user/baby', miniAuth, 'course.user.getBabyInfo');// 获取baby信息
router.post('third', '/user/baby', miniAuth, 'course.user.saveBabyInfo');//保存baby信息 router.post('third', '/user/baby', miniAuth, 'course.user.saveBabyInfo');// 保存baby信息
router.delete('third', '/user/baby', miniAuth, 'course.user.delBabyInfo');//删除baby信息 router.delete('third', '/user/baby', miniAuth, 'course.user.delBabyInfo');// 删除baby信息
router.get('third', '/user/collection/institution', miniAuth, 'course.user.getCollectInstitutions');//收藏的机构列表 router.get('third', '/user/collection/institution', miniAuth, 'course.user.getCollectInstitutions');// 收藏的机构列表
router.post('third', '/user/collection/institution', miniAuth, 'course.user.collectInstitution');//收藏机构 router.post('third', '/user/collection/institution', miniAuth, 'course.user.collectInstitution');// 收藏机构
router.delete('third', '/user/collection/institution', miniAuth, 'course.user.delCollectInstitution');//取消收藏机构 router.delete('third', '/user/collection/institution', miniAuth, 'course.user.delCollectInstitution');// 取消收藏机构
router.get('third', '/wechat/callbackAction', 'course.wechat.check');
router.post('third', '/wechat/callbackAction', 'course.wechat.callbackAction');
router.post('third', '/wechat/test', 'course.wechat.test');
}; };
...@@ -13,6 +13,7 @@ module.exports = app => { ...@@ -13,6 +13,7 @@ module.exports = app => {
router.get('/home', 'credit.home.home');//首页 router.get('/home', 'credit.home.home');//首页
router.get('/test', 'credit.home.test');//首页
//我的信用-黑名单报告 //我的信用-黑名单报告
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
module.exports = app => { module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/gjj'); const router = app.router.namespace(app.config.projectRootPath + '/gjj');
router.get('/mine/loans', 'gjj.mine.getMyLoans');// 我的贷款 router.get('/mine/loans', 'gjj.mine.getMyLoans');// 我的贷款
router.get('/mine/creditcards', 'gjj.mine.getMyCreditCards');// 我的信用卡 router.get('/mine/creditcards', 'gjj.mine.getMyCreditCards');// 我的信用卡
router.get('/wechat/check_login', 'gjj.wechat.checkLogin');// 公积金公众号检查用户是否登录
router.get('third', '/wechat/oauth_login', 'gjj.wechat.oauthLogin');// 公积金公众号授权登录
// router.get('/wechat/check_gjj', 'gjj.wechat.checkGjj');// 公积金公众号授权登录
}; };
...@@ -129,6 +129,12 @@ module.exports = app => { ...@@ -129,6 +129,12 @@ module.exports = app => {
router.post('/v2/answer/like/:id', loginAuth, 'house.v2.like.like');//点赞 router.post('/v2/answer/like/:id', loginAuth, 'house.v2.like.like');//点赞
router.put('/v2/answer/like/:id', loginAuth, 'house.v2.like.unLike');//取消点赞 router.put('/v2/answer/like/:id', loginAuth, 'house.v2.like.unLike');//取消点赞
//海外房列表
router.post('/v2/abroad_house/list', 'house.v2.abroadHouse.list');
//海外房足迹记录
router.post('/v2/foot_print/abroad_house', 'house.v2.footPrint.addAbroadFootPrint');
}; };
\ No newline at end of file
...@@ -8,7 +8,7 @@ class HuaYunPaas extends Subscription { ...@@ -8,7 +8,7 @@ class HuaYunPaas extends Subscription {
// 通过 schedule 属性来设置定时任务的执行间隔等配置 // 通过 schedule 属性来设置定时任务的执行间隔等配置
static get schedule() { static get schedule() {
return { return {
cron: '0 50 4 * * *',//每天4:50点执行 cron: '0 0 0 * * *',//每天00:00点执行
// cron: '*/1 * * * *',//每1分钟执行一次脚本 // cron: '*/1 * * * *',//每1分钟执行一次脚本
type: 'worker', type: 'worker',
env: ['prod'], env: ['prod'],
......
...@@ -33,7 +33,7 @@ class SmsService extends Service { ...@@ -33,7 +33,7 @@ class SmsService extends Service {
if (!(/【51公积金】/.test(params.params.content))) { if (!(/【51公积金】/.test(params.params.content))) {
params.params.content = '【51公积金】' + params.params.content; params.params.content = '【51公积金】' + params.params.content;
} }
ctx.logger.info(params); ctx.logger.info(JSON.stringify(params));
let result = await ctx.helper.send_request(url, params, { method: 'POST' }); let result = await ctx.helper.send_request(url, params, { method: 'POST' });
return result; return result;
} }
......
This diff is collapsed.
...@@ -23,6 +23,15 @@ const INSTITUTION_TYPE = [ ...@@ -23,6 +23,15 @@ const INSTITUTION_TYPE = [
{ id: -15, name: '品牌', value: '品牌' }, { id: -15, name: '品牌', value: '品牌' },
]; ];
const DISTANCES = [
{ id: -16, name: '全部', value: 0 },
{ id: -17, name: '500米以内', value: 500 },
{ id: -18, name: '1公里以内', value: 1000 },
{ id: -19, name: '2公里以内', value: 2000 },
{ id: -20, name: '3公里以内', value: 3000 },
{ id: -21, name: '5公里以内', value: 5000 },
];
class OptionService extends Service { class OptionService extends Service {
...@@ -39,7 +48,8 @@ class OptionService extends Service { ...@@ -39,7 +48,8 @@ class OptionService extends Service {
cats: tree_cats, cats: tree_cats,
ages: AGE_CATS, ages: AGE_CATS,
institutions: INSTITUTION_TYPE, institutions: INSTITUTION_TYPE,
} distances: DISTANCES,
};
return options; return options;
} }
...@@ -58,7 +68,7 @@ class OptionService extends Service { ...@@ -58,7 +68,7 @@ class OptionService extends Service {
newNode.level = node.level; newNode.level = node.level;
newNode.value = node.id; newNode.value = node.id;
newNode._child = this.getTrees(data, node.id); newNode._child = this.getTrees(data, node.id);
if (newNode._child.length !== 0) newNode._child.unshift({ id: 0, name: '全部', value: 0 }); if (newNode._child.length !== 0) newNode._child.unshift({ id: 0, name: '全部', value: node.id });
ret.push(newNode); ret.push(newNode);
} }
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -58,20 +58,29 @@ class ApplyService extends Service { ...@@ -58,20 +58,29 @@ class ApplyService extends Service {
return ret; return ret;
} }
/**
* 进入个人通话查询页面
*/
async callriskInit() { async callriskInit() {
const { ctx } = this; const { ctx } = this;
if (!ctx.userId) {
ctx.failed('登录异常');
}
let ret = { let ret = {
have_be_pay_order: false, have_be_pay_order: false,
order_id: null, order_id: null,
phone: '',
placeholder: { placeholder: {
name: '', name: '',
id_card: '' id_card: '',
} }
} }
let bePayOrder = await ctx.service.credit.order.getBePayOrder('callrisk'); let bePayOrder = await ctx.service.credit.order.getBePayOrder('callrisk');
if (bePayOrder.length !== 0) { if (bePayOrder.length !== 0) {
ret.have_be_pay_order = true; ret.have_be_pay_order = true;
ret.order_id = bePayOrder[0].id; ret.order_id = bePayOrder[0].id;
ret.phone = bePayOrder[0].phone.substring(0, 3) + '****' + bePayOrder[0].phone.substring(7, 11)
} }
//第一次查询成功的订单,反显姓名和身份证 //第一次查询成功的订单,反显姓名和身份证
...@@ -159,7 +168,7 @@ class ApplyService extends Service { ...@@ -159,7 +168,7 @@ class ApplyService extends Service {
} }
times++; times++;
if (times >= 11) { if (times >= 11) {
ctx.failed('今日获取验证码次数过多,请明日再试'); // ctx.failed('今日获取验证码次数过多,请明日再试');
} }
let pexpire = new Date(moment().add(1, 'days').format('YYYY-MM-DD 00:00:00')).getTime(); let pexpire = new Date(moment().add(1, 'days').format('YYYY-MM-DD 00:00:00')).getTime();
let validTime = Number(pexpire) - Number(moment().format('x')); let validTime = Number(pexpire) - Number(moment().format('x'));
...@@ -171,6 +180,7 @@ class ApplyService extends Service { ...@@ -171,6 +180,7 @@ class ApplyService extends Service {
code = Math.round(Math.random() * 9999).toString(); code = Math.round(Math.random() * 9999).toString();
let len = code.length; let len = code.length;
if ((4 - len) > 0) { if ((4 - len) > 0) {
ß
for (var i = 0; i < 4 - len; i++) { for (var i = 0; i < 4 - len; i++) {
code = '0' + code; code = '0' + code;
} }
...@@ -276,10 +286,7 @@ class ApplyService extends Service { ...@@ -276,10 +286,7 @@ class ApplyService extends Service {
ctx.logger.info(params); ctx.logger.info(params);
let url = this.config.BLACKLIST_APPLY_URL; let url = this.config.BLACKLIST_APPLY_URL;
let result = await ctx.helper.send_request(url, params, { method: 'POST' }); let result = await ctx.helper.send_request(url, params, { method: 'POST' });
ctx.logger.info(result); ctx.logger.info('blacklist:apply:result:' + JSON.stringify(result));
ctx.logger.info(result.data);
ctx.logger.info(result.data.data.blackList);
if (result.status != 200) { if (result.status != 200) {
ctx.failed('数据获取接口异常'); ctx.failed('数据获取接口异常');
} }
...@@ -332,7 +339,7 @@ class ApplyService extends Service { ...@@ -332,7 +339,7 @@ class ApplyService extends Service {
async applyCallrisk(input) { async applyCallrisk(input) {
const { ctx } = this; const { ctx } = this;
const { name, phone, id_card, password } = input; const { name, phone, id_card, password, net } = input;
const user_id = ctx.userId; const user_id = ctx.userId;
const app_type_id = ctx.appTypeId; const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId; const app_user_id = ctx.appUserId;
...@@ -340,7 +347,7 @@ class ApplyService extends Service { ...@@ -340,7 +347,7 @@ class ApplyService extends Service {
const type = TypeConfig['callrisk'];//个人通话类型 const type = TypeConfig['callrisk'];//个人通话类型
let report_id = null; let report_id = null;
//数盒魔方三要素校验 //数盒魔方三要素校验
// await ctx.service.credit.callrisk.checkThreeElements(input); await ctx.service.credit.callrisk.checkThreeElements(input);
// await ctx.service.credit.common.shuhemofangCheck('callrisk', input); // await ctx.service.credit.common.shuhemofangCheck('callrisk', input);
//判断用户当前三要素是否是二次查询未支付订单 //判断用户当前三要素是否是二次查询未支付订单
...@@ -355,12 +362,12 @@ class ApplyService extends Service { ...@@ -355,12 +362,12 @@ class ApplyService extends Service {
const order_id = order.id; const order_id = order.id;
//创建yys-order apply 记录 //创建yys-order apply 记录
const apply = await this.createYysApply({ name, phone, id_card, password, order_id }); const apply = await this.createYysApply({ name, phone, id_card, password, net, order_id });
const order_sn = apply.r_order_id; const order_sn = apply.r_order_id;
//第一次调用运营商获取验证码接口 //第一次调用运营商获取验证码接口
const input_params = { const input_params = {
phone,name, phone, name,
ID: id_card, ID: id_card,
password: apply.service_code, password: apply.service_code,
}; };
...@@ -376,7 +383,7 @@ class ApplyService extends Service { ...@@ -376,7 +383,7 @@ class ApplyService extends Service {
// get_code_params.data.phoneCode = ''; // get_code_params.data.phoneCode = '';
const yys_get_code = await ctx.service.credit.yys.getCode(get_code_params); const yys_get_code = await ctx.service.credit.yys.getCode(get_code_params);
if (yys_get_code.code !== 0) { if (yys_get_code.code !== 0) {
ctx.failed('getCode error msg:' + yys_get_code.msg); ctx.failed(yys_get_code.msg);
} }
const order_no = await ctx.service.credit.common.getOrdertNo('callrisk', order_id); const order_no = await ctx.service.credit.common.getOrdertNo('callrisk', order_id);
await ctx.prometheusModel.CreditOrder.update({ order_no, apply_id: apply.id }, { where: { id: order_id } }); await ctx.prometheusModel.CreditOrder.update({ order_no, apply_id: apply.id }, { where: { id: order_id } });
...@@ -394,10 +401,10 @@ class ApplyService extends Service { ...@@ -394,10 +401,10 @@ class ApplyService extends Service {
const app_type_id = ctx.appTypeId; const app_type_id = ctx.appTypeId;
const app_user_id = ctx.appUserId; const app_user_id = ctx.appUserId;
const app_id = ctx.appId; const app_id = ctx.appId;
const { name, phone, id_card, password, order_id } = input; const { name, phone, id_card, password, net, order_id } = input;
//运营商API.创建订单号 //运营商API.创建订单号
const order_sn_info = await ctx.service.credit.yys.getOrderSn(phone); const order_sn_info = await ctx.service.credit.yys.getOrderSn({ phone, net });
if (order_sn_info.code !== 0) { if (order_sn_info.code !== 0) {
ctx.failed('getOrderSn error msg:' + order_sn_info.msg); ctx.failed('getOrderSn error msg:' + order_sn_info.msg);
} }
...@@ -432,14 +439,14 @@ class ApplyService extends Service { ...@@ -432,14 +439,14 @@ class ApplyService extends Service {
let orderFilter = { let orderFilter = {
arrtibutes: ['id', 'name', 'id_card'], arrtibutes: ['id', 'name', 'id_card'],
where: { where: {
user_id: ctx.userId, user_id: user_id,
state: '已支付', state: '已支付',
type: 2, type: type,
valid: 1 valid: 1
} }
} }
let orderInfo = await ctx.prometheusModel.CreditOrder.findOne(orderFilter); let orderInfo = await ctx.prometheusModel.CreditOrder.findOne(orderFilter);
if (orderInfo !== null && (inputParams.name !== orderInfo.name || inputParams.id_card !== orderInfo.id_card)) { if (orderInfo !== null && (name !== orderInfo.name || id_card !== orderInfo.id_card)) {
ctx.failed('仅供本人查询使用,无法查询其他人信息'); ctx.failed('仅供本人查询使用,无法查询其他人信息');
} }
......
...@@ -372,7 +372,8 @@ class BlacklistService extends Service { ...@@ -372,7 +372,8 @@ class BlacklistService extends Service {
let birth = parseInt(inputParams.id_card.substring(6, 10)); let birth = parseInt(inputParams.id_card.substring(6, 10));
let age = parseInt(moment().format('YYYY')) - birth; let age = parseInt(moment().format('YYYY')) - birth;
let city = await ctx.service.credit.common.getIdCardCity(inputParams.id_card); // let city = await ctx.service.credit.common.getIdCardCity(inputParams.id_card);
let city = await ctx.helper.getPhoneCity(inputParams.phone);//2019-10-14 20:36:00 lisk 改为获取手机号归属地
let reportData = { let reportData = {
name: inputParams.name, name: inputParams.name,
......
This diff is collapsed.
...@@ -214,6 +214,7 @@ class CommonService extends Service { ...@@ -214,6 +214,7 @@ class CommonService extends Service {
await ctx.prometheusModel.CreditPay.edit({ where: { id: pay_info.id }, params: { pay_result: JSON.stringify(result), transaction_id: sign_data.transaction_id, status: 1 } }); await ctx.prometheusModel.CreditPay.edit({ where: { id: pay_info.id }, params: { pay_result: JSON.stringify(result), transaction_id: sign_data.transaction_id, status: 1 } });
await ctx.service.credit.order.logOrder(order.id); await ctx.service.credit.order.logOrder(order.id);
await ctx.prometheusModel.CreditOrder.update({ state: '已支付', state_time: state_time, pay_status: 1 }, { where: { id: order.id } }); await ctx.prometheusModel.CreditOrder.update({ state: '已支付', state_time: state_time, pay_status: 1 }, { where: { id: order.id } });
await ctx.service.credit.order.updateOrderStateToCancel(order);//更新其他同姓名和身份证号的订单状态
return true; return true;
} }
} }
...@@ -314,13 +315,13 @@ class CommonService extends Service { ...@@ -314,13 +315,13 @@ class CommonService extends Service {
async noticeShuhemofang(status) { async noticeShuhemofang(status) {
const { ctx } = this; const { ctx } = this;
//异常情况 //异常情况
if (status === '2') { if (status == '2') {
ctx.failed('手机号已实名,身份证姓名均不匹配,请重新输入'); ctx.failed('手机号已实名,身份证姓名均不匹配,请重新输入');
} }
if (status === '3') { if (status == '3') {
ctx.failed('手机号已实名,姓名不匹配,请重新输入'); ctx.failed('手机号已实名,姓名不匹配,请重新输入');
} }
if (status === '4') { if (status == '4') {
ctx.failed('手机号已实名,身份证不匹配,请重新输入'); ctx.failed('手机号已实名,身份证不匹配,请重新输入');
} }
//未知情况 //未知情况
...@@ -361,7 +362,7 @@ class CommonService extends Service { ...@@ -361,7 +362,7 @@ class CommonService extends Service {
} }
} }
if (history.in) { if (history.in) {
await this.noticeShuhemofang(Number(history.detail.status)); await this.noticeShuhemofang(history.detail.status);
} else { } else {
if (shmfList.length >= 5) { if (shmfList.length >= 5) {
ctx.failed('您输入的想要检测人数已超过最大限制,仅可检测输入过的检测信息'); ctx.failed('您输入的想要检测人数已超过最大限制,仅可检测输入过的检测信息');
......
...@@ -122,12 +122,14 @@ class OrderService extends Service { ...@@ -122,12 +122,14 @@ class OrderService extends Service {
const slag = TypeConfigFlip[type]; const slag = TypeConfigFlip[type];
const preferential = await ctx.service.credit.preferential.getPreferential(slag); const preferential = await ctx.service.credit.preferential.getPreferential(slag);
let preferential_price = 0; let preferential_price = 0;
let preferential_id = 0;
if (preferential && preferential.id) { if (preferential && preferential.id) {
preferential_price = preferential.price; preferential_price = preferential.price;
preferential_id = preferential.id;
} }
const price = (order.price - preferential_price).toFixed(2); const price = (order.price - preferential_price).toFixed(2);
await ctx.prometheusModel.CreditOrder.update({ final_price: price, preferential_price, preferential_id: preferential.id }, { where: { id, pay_status: 0 } }); await ctx.prometheusModel.CreditOrder.update({ final_price: price, preferential_price, preferential_id: preferential_id }, { where: { id, pay_status: 0 } });
return price; return price;
...@@ -253,6 +255,7 @@ class OrderService extends Service { ...@@ -253,6 +255,7 @@ class OrderService extends Service {
const state_time = moment().format('YYYY-MM-DD HH:mm:ss'); const state_time = moment().format('YYYY-MM-DD HH:mm:ss');
await this.logOrder(order.id); await this.logOrder(order.id);
await ctx.prometheusModel.CreditOrder.update({ state: '已支付', state_time, pay_status: 1 }, { where: { id: order.id, pay_status: 0 } }) await ctx.prometheusModel.CreditOrder.update({ state: '已支付', state_time, pay_status: 1 }, { where: { id: order.id, pay_status: 0 } })
await this.updateOrderStateToCancel(order);//更新其他同姓名和身份证号的订单状态
return true; return true;
} }
} }
...@@ -335,7 +338,7 @@ class OrderService extends Service { ...@@ -335,7 +338,7 @@ class OrderService extends Service {
client_ip: ctx.helper.getClientIP(), client_ip: ctx.helper.getClientIP(),
}; };
await this.addCreditPay(pay_data);//添加下单记录 await this.addCreditPay(pay_data);//添加下单记录
await this.updateOrderStateToCancel(order);//更新其他同姓名和身份证号的订单状态 // await this.updateOrderStateToCancel(order);//更新其他同姓名和身份证号的订单状态//2019-10-14 14:52:23 移动到支付完成时通知那里
await this.updateOrderPrice(order);//更新金额 await this.updateOrderPrice(order);//更新金额
await this.logOrder(order.id);//订单状态变化日志记录 await this.logOrder(order.id);//订单状态变化日志记录
const state_time = moment().format('YYYY-MM-DD HH:mm:ss'); const state_time = moment().format('YYYY-MM-DD HH:mm:ss');
......
...@@ -12,16 +12,17 @@ class YysService extends Service { ...@@ -12,16 +12,17 @@ class YysService extends Service {
* 创建订单号 * 创建订单号
* @param {*} * @param {*}
*/ */
async getOrderSn(phone) { async getOrderSn({ phone, net }) {
const { ctx } = this; const { ctx } = this;
let params = { let params = {
phone: phone phone: phone,
net: Number(net),
} }
let url = this.config.NODE_BASE_URL + '/yys_api/getorderSn' + '?appKey=' + this.config.YYS_APP_KEY; let url = this.config.NODE_BASE_URL + '/yys_api/getorderSn' + '?appKey=' + this.config.YYS_APP_KEY;
let resp = await ctx.helper.send_request(url, params, { method: 'POST' }); let resp = await ctx.helper.send_request(url, params, { method: 'POST', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp })); ctx.logger.info(JSON.stringify({ yys_getorderSn_params: params, yys_getorderSn_result: resp }));
if (resp.data.code === undefined || resp.data.code !== 0) { if (resp.data.code === undefined || resp.data.code !== 0) {
ctx.failed('getorderSn error:' + resp.data.msg); ctx.failed(resp.data.msg);
} }
let order_sn = resp.data.data.orderSn; let order_sn = resp.data.data.orderSn;
await this.addCreditLogYys(order_sn, '/yys_api/getorderSn', params, resp.data); await this.addCreditLogYys(order_sn, '/yys_api/getorderSn', params, resp.data);
...@@ -43,7 +44,7 @@ class YysService extends Service { ...@@ -43,7 +44,7 @@ class YysService extends Service {
// } // }
// } // }
let url = this.config.NODE_BASE_URL + '/yys_api/getCode' + '?appKey=' + this.config.YYS_APP_KEY; let url = this.config.NODE_BASE_URL + '/yys_api/getCode' + '?appKey=' + this.config.YYS_APP_KEY;
let resp = await ctx.helper.send_request(url, params, { method: 'POST' }); let resp = await ctx.helper.send_request(url, params, { method: 'POST', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_getCode_params: params, yys_getCode_result: resp })); ctx.logger.info(JSON.stringify({ yys_getCode_params: params, yys_getCode_result: resp }));
await this.addCreditLogYys(params.orderSn, '/yys_api/getCode', params, resp.data); await this.addCreditLogYys(params.orderSn, '/yys_api/getCode', params, resp.data);
// console.info(resp); // console.info(resp);
...@@ -65,7 +66,7 @@ class YysService extends Service { ...@@ -65,7 +66,7 @@ class YysService extends Service {
// } // }
// } // }
const url = this.config.NODE_BASE_URL + '/yys_api/commit' + '?appKey=' + this.config.YYS_APP_KEY; const url = this.config.NODE_BASE_URL + '/yys_api/commit' + '?appKey=' + this.config.YYS_APP_KEY;
const resp = await ctx.helper.send_request(url, params, { method: 'POST' }); const resp = await ctx.helper.send_request(url, params, { method: 'POST', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_commit_params: params, yys_commit_result: resp })); ctx.logger.info(JSON.stringify({ yys_commit_params: params, yys_commit_result: resp }));
await this.addCreditLogYys(params.orderSn, '/yys_api/commit', params, resp.data); await this.addCreditLogYys(params.orderSn, '/yys_api/commit', params, resp.data);
return resp.data; return resp.data;
...@@ -81,7 +82,7 @@ class YysService extends Service { ...@@ -81,7 +82,7 @@ class YysService extends Service {
orderSn: orderSn, orderSn: orderSn,
} }
let url = this.config.NODE_BASE_URL + '/yys_api/query' + '?appKey=' + this.config.YYS_APP_KEY; let url = this.config.NODE_BASE_URL + '/yys_api/query' + '?appKey=' + this.config.YYS_APP_KEY;
let resp = await ctx.helper.send_request(url, params, { method: 'POST' }); let resp = await ctx.helper.send_request(url, params, { method: 'POST', timeout: 30000 });
ctx.logger.info(JSON.stringify({ yys_query_params: params, yys_query_result: resp })); ctx.logger.info(JSON.stringify({ yys_query_params: params, yys_query_result: resp }));
await this.addCreditLogYys(orderSn, '/yys_api/query', params, resp.data); await this.addCreditLogYys(orderSn, '/yys_api/query', params, resp.data);
return resp.data; return resp.data;
...@@ -106,7 +107,7 @@ class YysService extends Service { ...@@ -106,7 +107,7 @@ class YysService extends Service {
} }
params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_REPORT_APPSECRET); params.sign = await ctx.service.credit.common.sign(params.signParams, this.config.YYS_REPORT_APPSECRET);
const url = this.config.YYS_REPORT_URL; const url = this.config.YYS_REPORT_URL;
const result = await ctx.helper.send_request(url, params, { method: 'POST' }); const result = await ctx.helper.send_request(url, params, { method: 'POST', timeout: 30000 });
ctx.logger.info(JSON.stringify({ thxdReport_parmas: params, thxdReport_result: result })); ctx.logger.info(JSON.stringify({ thxdReport_parmas: params, thxdReport_result: result }));
return result.data; return result.data;
......
'use strict';
const Service = require('egg').Service;
class WechatService extends Service {
async oauthLogin() {
const { ctx } = this;
const result = {};
ctx.success(result);
}
}
module.exports = WechatService;
'use strict';
const Service = require('egg').Service;
const moment = require('moment');
const _ = require('lodash');
class AbroadHouseService extends Service {
/**
* 海外房列表
*/
async abroadHouseList(condition) {
const { ctx } = this;
let page = Number(condition.page) || 1;
let pageSize = Number(condition.page_size) || 10;
let filter = {
page: page,
limit: pageSize,
where: {
valid: 1,
status: 'online',
},
order: [['order', 'asc']]
}
if (condition.name) {//关键词搜索 模糊查询
//增加搜索历史
let addHistory = {
type: 4,
key_word: condition.name
};
await ctx.service.house.v2.searchHistory.addSearchHistory(addHistory);
filter.where.name = { $like: '%' + condition.name + '%' }
}
let abroadList = await ctx.realestateModel.AbroadHouse.list(filter);
let list = abroadList.rows;
let data = [];
for (let i in list) {
data[i] = {
id: list[i].id,
name: list[i].name || '',
images: list[i].images ? JSON.parse(list[i].images) : [],
tags: list[i].tags ? JSON.parse(list[i].tags) : [],
total_price: list[i].total_price === '0.00' ? '--' : list[i].total_price,
url: list[i].url || '',
}
}
let ret = {
results: data,
count: abroadList.count
};
return ret;
}
}
module.exports = AbroadHouseService;
...@@ -2,7 +2,13 @@ ...@@ -2,7 +2,13 @@
'use strict'; 'use strict';
const Service = require('egg').Service; const Service = require('egg').Service;
const _ = require('lodash');
const moment = require('moment'); const moment = require('moment');
const ConfigType = {
1: 'new_house',
2: 'rental_house',
4: 'abroad_house',
}
class FootPrintService extends Service { class FootPrintService extends Service {
...@@ -29,8 +35,7 @@ class FootPrintService extends Service { ...@@ -29,8 +35,7 @@ class FootPrintService extends Service {
state: 1, state: 1,
remark: inputParams.remark || '', remark: inputParams.remark || '',
} }
let ret = await ctx.realestateModel.FootPrint.add(data); let ret = await ctx.realestateModel.FootPrint.create(data);
return { id: ret.id }; return { id: ret.id };
} }
...@@ -57,7 +62,6 @@ class FootPrintService extends Service { ...@@ -57,7 +62,6 @@ class FootPrintService extends Service {
limit: 50, limit: 50,
where: { where: {
user_id: user_id, user_id: user_id,
// app_type_id: app_type_id,
state: 1, state: 1,
created_at: { $gt: endDate }, created_at: { $gt: endDate },
}, },
...@@ -69,10 +73,13 @@ class FootPrintService extends Service { ...@@ -69,10 +73,13 @@ class FootPrintService extends Service {
for (let i in foot_prints) { for (let i in foot_prints) {
let foot_print = foot_prints[i]; let foot_print = foot_prints[i];
if (foot_print.house_style === 1) {//获取房源信息 if (foot_print.house_style === 1) {//获取房源信息
p_houses[i] = ctx.realestateModel.NewHouse.one({ where: { id: foot_print.connect_id } }); p_houses[i] = ctx.realestateModel.NewHouse.one({ attributes: ['id', 'name', 'status', 'valid'], where: { id: foot_print.connect_id } });
} else if (foot_print.house_style === 2) { } else if (foot_print.house_style === 2) {
p_houses[i] = ctx.realestateModel.RentalHouse.one({ where: { id: foot_print.connect_id } }); p_houses[i] = ctx.realestateModel.RentalHouse.one({ attributes: ['id', 'name', 'status', 'valid'], where: { id: foot_print.connect_id } });
} else if (foot_print.house_style === 4) {
p_houses[i] = ctx.realestateModel.AbroadHouse.findOne({ attributes: ['id', 'name', 'url', 'status', 'valid'], where: { id: foot_print.connect_id } });
} }
} }
const houses = await Promise.all(p_houses).then(result => {//等待所有异步内容获取完成 const houses = await Promise.all(p_houses).then(result => {//等待所有异步内容获取完成
return result; return result;
...@@ -84,12 +91,12 @@ class FootPrintService extends Service { ...@@ -84,12 +91,12 @@ class FootPrintService extends Service {
//处理足迹数据 //处理足迹数据
const foot_print_records = []; const foot_print_records = [];
for (let j in houses) { for (let j in houses) {
if (houses[j].status === 'offline' || Number(houses[j].valid) === 0) { if (houses[j] === null || houses[j].status === 'offline' || Number(houses[j].valid) === 0) {
continue; continue;
} }
const house = houses[j]; const house = houses[j];
const foot_print = foot_prints[j]; const foot_print = foot_prints[j];
const type = foot_print.house_style === 1 ? 'new_house' : 'rental_house'; const type = ConfigType[foot_print.house_style];
const create_time = moment(foot_print.created_at).format('X'); const create_time = moment(foot_print.created_at).format('X');
let time = moment(foot_print.created_at).format('YYYY-MM-DD'); let time = moment(foot_print.created_at).format('YYYY-MM-DD');
const du_time = now_time - create_time; const du_time = now_time - create_time;
...@@ -105,10 +112,11 @@ class FootPrintService extends Service { ...@@ -105,10 +112,11 @@ class FootPrintService extends Service {
name: house.name, name: house.name,
time: time, time: time,
type: type, type: type,
url: type === 'abroad_house' ? house.url : '',
}); });
} }
return { results: foot_print_records, count: foot_prints_rows.count }; return { results: foot_print_records, count: foot_print_records.length };
} }
...@@ -122,7 +130,6 @@ class FootPrintService extends Service { ...@@ -122,7 +130,6 @@ class FootPrintService extends Service {
} }
let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss'); let endDate = moment().subtract(6, 'months').format('YYYY-MM-DD HH:mm:ss');
const filter = { const filter = {
page: 1,
limit: 50, limit: 50,
attributes: ['connect_id', 'house_style'], attributes: ['connect_id', 'house_style'],
where: { where: {
...@@ -135,29 +142,55 @@ class FootPrintService extends Service { ...@@ -135,29 +142,55 @@ class FootPrintService extends Service {
const list = await ctx.realestateModel.FootPrint.findAll(filter); const list = await ctx.realestateModel.FootPrint.findAll(filter);
let count = 0; let count = 0;
if (list.length > 0) { if (list.length > 0) {
let taskList = []; let newIds = [];
let rentalIds = [];
let abroadIds = [];
for (let i in list) { for (let i in list) {
let taskFilter = {
attributes: ['id'],
where: {
status: 'online',
valid: 1,
id: list[i].connect_id
}
}
if (Number(list[i].house_style) === 1) { if (Number(list[i].house_style) === 1) {
taskList[i] = ctx.realestateModel.NewHouse.one(taskFilter); newIds.push(list[i].connect_id);
} }
if (Number(list[i].house_style) === 2) { if (Number(list[i].house_style) === 2) {
taskList[i] = ctx.realestateModel.RentalHouse.one(taskFilter); rentalIds.push(list[i].connect_id);
}
if (Number(list[i].house_style) === 4) {
abroadIds.push(list[i].connect_id);
}
} }
let newTaskFilter = {
attributes: ['id'], where: { status: 'online', valid: 1, id: { $in: newIds } }
} }
let rentalTaskFilter = {
attributes: ['id'], where: { status: 'online', valid: 1, id: { $in: rentalIds } }
}
let abroadTaskFilter = {
attributes: ['id'], where: { status: 'online', valid: 1, id: { $in: abroadIds } }
}
let taskList = [
ctx.realestateModel.NewHouse.findAll(newTaskFilter),
ctx.realestateModel.RentalHouse.findAll(rentalTaskFilter),
ctx.realestateModel.AbroadHouse.findAll(abroadTaskFilter),
];
const retList = await Promise.all(taskList).then(result => { const retList = await Promise.all(taskList).then(result => {
return result; return result;
}).catch(error => { }).catch(error => {
ctx.failed(error); ctx.failed(error);
}); });
count = Number(retList.length);
let validNewIds = _.map(retList[0], 'id');
let validRentalIds = _.map(retList[1], 'id');
let validAbroadIds = _.map(retList[2], 'id');
for (let i in list) {
if (Number(list[i].house_style) === 1 && validNewIds.includes(Number(list[i].connect_id))) {
count++;
}
if (Number(list[i].house_style) === 2 && validRentalIds.includes(Number(list[i].connect_id))) {
count++;
}
if (Number(list[i].house_style) === 4 && validAbroadIds.includes(Number(list[i].connect_id))) {
count++;
}
}
} }
let ret = { let ret = {
count: count count: count
......
...@@ -194,8 +194,8 @@ class NewHouseService extends Service { ...@@ -194,8 +194,8 @@ class NewHouseService extends Service {
description: data.description || '',//描述 description: data.description || '',//描述
tags: data.tags ? eval(data.tags) : [],//项目特色 tags: data.tags ? eval(data.tags) : [],//项目特色
favourable_info: data.favourable_info || '',//优惠 favourable_info: data.favourable_info || '',//优惠
reference_avg_price: data.reference_avg_price === 0 ? '--' : Number(data.reference_avg_price),//均价 reference_avg_price: Number(data.reference_avg_price) === 0 ? '--' : Number(data.reference_avg_price),//均价
reference_total_price: data.reference_total_price === 0 ? '--' : Number(data.reference_total_price),//总价 reference_total_price: Number(data.reference_total_price) === 0 ? '--' : Number(data.reference_total_price),//总价
property_type: data.house_type.split(',').slice(0, 2),//物业类型 property_type: data.house_type.split(',').slice(0, 2),//物业类型
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
'use strict'; 'use strict';
const Service = require('egg').Service; const Service = require('egg').Service;
const _ = require('lodash');
const moment = require('moment'); const moment = require('moment');
class searchHistoryService extends Service { class searchHistoryService extends Service {
...@@ -50,7 +51,9 @@ class searchHistoryService extends Service { ...@@ -50,7 +51,9 @@ class searchHistoryService extends Service {
} }
}; };
//不管有没有登录获取城市相关的热门搜索 //不管有没有登录获取城市相关的热门搜索
if (condition.type && [1, 2].includes(condition.type)) {
ret.hot_search.results = await ctx.service.house.v2.hotSearch.getHotSearch(condition); ret.hot_search.results = await ctx.service.house.v2.hotSearch.getHotSearch(condition);
}
if (!ctx.appUserId || !ctx.userId) { if (!ctx.appUserId || !ctx.userId) {
//如果没有登录就返回 //如果没有登录就返回
...@@ -124,14 +127,7 @@ class searchHistoryService extends Service { ...@@ -124,14 +127,7 @@ class searchHistoryService extends Service {
order: [['created_at', 'desc']], order: [['created_at', 'desc']],
} }
let searchHistoryList = await ctx.realestateModel.SearchHistory.findAll(filter); let searchHistoryList = await ctx.realestateModel.SearchHistory.findAll(filter);
let list = []; let list = _.uniq(_.map(searchHistoryList, 'key_word'));
if (searchHistoryList.length > 0) {
for (let i in searchHistoryList) {
if (list.indexOf(searchHistoryList[i].key_word) === -1) {
list.push(searchHistoryList[i].key_word);
}
}
}
ret = { ret = {
results: list, results: list,
count: list.length count: list.length
......
...@@ -90,7 +90,7 @@ module.exports = appInfo => { ...@@ -90,7 +90,7 @@ module.exports = appInfo => {
// other sequelize configurations // other sequelize configurations
dialect: 'mysql', dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com', host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'prometheus_dev', database: 'prometheus_uat',
username: 'prometheus', username: 'prometheus',
password: 'q9t8Ay4qIUW4sw3s25K28', password: 'q9t8Ay4qIUW4sw3s25K28',
port: 3306, port: 3306,
...@@ -103,7 +103,7 @@ module.exports = appInfo => { ...@@ -103,7 +103,7 @@ module.exports = appInfo => {
// other sequelize configurations // other sequelize configurations
dialect: 'mysql', dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com', host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'class_dev', database: 'class_uat',
username: 'class_testing', username: 'class_testing',
password: 'WV862L32451I6KD58tU9K', password: 'WV862L32451I6KD58tU9K',
port: 3306, port: 3306,
...@@ -139,8 +139,8 @@ module.exports = appInfo => { ...@@ -139,8 +139,8 @@ module.exports = appInfo => {
}; };
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://dev-nginx.jianbing.com/user_api/v1';
config.NODE_BASE_URL = 'https://uat-nginx.jianbing.com'; config.NODE_BASE_URL = 'https://dev-nginx.jianbing.com';
config.HOUSE_SERVICE_API = 'https://uat-nginx.jianbing.com/house-service'; config.HOUSE_SERVICE_API = 'https://uat-nginx.jianbing.com/house-service';
config.CDN_BASE_URL = 'https://r.51gjj.com/image/'; config.CDN_BASE_URL = 'https://r.51gjj.com/image/';
......
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