Commit 5e22a2c1 by 马玮

Change webname to website

parent a80e3a24
...@@ -11,7 +11,7 @@ program ...@@ -11,7 +11,7 @@ program
.version('0.1.0') .version('0.1.0')
.option('-t, --task <task name>', 'Task list: addAccount') .option('-t, --task <task name>', 'Task list: addAccount')
.option('-d, --dealerID <thirdparty account ID>', 'Assign dealerID') .option('-d, --dealerID <thirdparty account ID>', 'Assign dealerID')
.option('-w, --webname <thirdparty webname>', 'Webname list: autohome, easypass') .option('-w, --website <thirdparty website>', 'Webname list: autohome, easypass')
.option('-u, --username <thirdparty username>', 'Assign username') .option('-u, --username <thirdparty username>', 'Assign username')
.option('-p, --password <thirdparty password>', 'Assign password') .option('-p, --password <thirdparty password>', 'Assign password')
.parse(process.argv); .parse(process.argv);
...@@ -23,8 +23,8 @@ if (!program.task) { ...@@ -23,8 +23,8 @@ if (!program.task) {
if (!program.dealerID) { if (!program.dealerID) {
commandError.push('缺少dealerID!'); commandError.push('缺少dealerID!');
} }
if (!program.webname) { if (!program.website) {
commandError.push('缺少webname!'); commandError.push('缺少website!');
} }
if (!program.username) { if (!program.username) {
commandError.push('缺少username!'); commandError.push('缺少username!');
...@@ -38,7 +38,7 @@ if (program.task && !validTasks.includes(program.task)) { ...@@ -38,7 +38,7 @@ if (program.task && !validTasks.includes(program.task)) {
} }
const validWebsites = ['autohome', 'easypass']; const validWebsites = ['autohome', 'easypass'];
if (program.webname && !validWebsites.includes(program.webname)) { if (program.website && !validWebsites.includes(program.website)) {
commandError.push('网站类型不合法!'); commandError.push('网站类型不合法!');
} }
......
...@@ -26,7 +26,7 @@ class AutoHome { ...@@ -26,7 +26,7 @@ class AutoHome {
async getCookies() { async getCookies() {
try { try {
const client = await redis.createClient(); const client = await redis.createClient();
const cookies_key = this.params.webname + '_cookies'; const cookies_key = this.params.website + '_cookies';
let cookies = JSON.parse(await client.getAsync(cookies_key)); let cookies = JSON.parse(await client.getAsync(cookies_key));
await cookies.forEach((cookie) => { await cookies.forEach((cookie) => {
cookie.expires = (new Date()).getTime() + (1000 * 60 * 60); cookie.expires = (new Date()).getTime() + (1000 * 60 * 60);
...@@ -137,7 +137,7 @@ class AutoHome { ...@@ -137,7 +137,7 @@ class AutoHome {
// 验证码解码 // 验证码解码
let captchaText; let captchaText;
try { try {
const captchaType = config.get('Dealer')[this.params.webname]['captchaType']; const captchaType = config.get('Dealer')[this.params.website]['captchaType'];
captchaText = await captcha.decode(captchaType, imageFile); captchaText = await captcha.decode(captchaType, imageFile);
console.info('captchaText:', captchaText); console.info('captchaText:', captchaText);
} catch (e) { } catch (e) {
...@@ -167,7 +167,7 @@ class AutoHome { ...@@ -167,7 +167,7 @@ class AutoHome {
const cookies = await horseman .cookies().close(); const cookies = await horseman .cookies().close();
console.log(JSON.stringify(cookies)); console.log(JSON.stringify(cookies));
const cookie_key = this.params.webname + '_cookies'; const cookie_key = this.params.website + '_cookies';
const client = await redis.createClient(); const client = await redis.createClient();
await client.set(cookie_key, JSON.stringify(cookies), redis.print); await client.set(cookie_key, JSON.stringify(cookies), redis.print);
await client.quit(); await client.quit();
......
...@@ -26,7 +26,7 @@ class EasyPass { ...@@ -26,7 +26,7 @@ class EasyPass {
async getCookies() { async getCookies() {
try { try {
const client = await redis.createClient(); const client = await redis.createClient();
const cookies_key = this.params.webname + '_cookies'; const cookies_key = this.params.website + '_cookies';
let cookies = JSON.parse(await client.getAsync(cookies_key)); let cookies = JSON.parse(await client.getAsync(cookies_key));
await cookies.forEach((cookie) => { await cookies.forEach((cookie) => {
cookie.expires = (new Date()).getTime() + (1000 * 60 * 60); cookie.expires = (new Date()).getTime() + (1000 * 60 * 60);
...@@ -134,7 +134,7 @@ class EasyPass { ...@@ -134,7 +134,7 @@ class EasyPass {
// 验证码解码 // 验证码解码
let captchaText; let captchaText;
try { try {
const captchaType = config.get('Dealer')[this.params.webname]['captchaType']; const captchaType = config.get('Dealer')[this.params.website]['captchaType'];
captchaText = await captcha.decode(captchaType, imageFile); captchaText = await captcha.decode(captchaType, imageFile);
console.info('captchaText:', captchaText); console.info('captchaText:', captchaText);
} catch (e) { } catch (e) {
...@@ -165,7 +165,7 @@ class EasyPass { ...@@ -165,7 +165,7 @@ class EasyPass {
const cookies = await horseman .cookies().close(); const cookies = await horseman .cookies().close();
console.log(JSON.stringify(cookies)); console.log(JSON.stringify(cookies));
const cookie_key = this.params.webname + '_cookies'; const cookie_key = this.params.website + '_cookies';
const client = await redis.createClient(); const client = await redis.createClient();
await client.set(cookie_key, JSON.stringify(cookies), redis.print); await client.set(cookie_key, JSON.stringify(cookies), redis.print);
await client.quit(); await client.quit();
......
...@@ -13,7 +13,7 @@ class DealerSpider { ...@@ -13,7 +13,7 @@ class DealerSpider {
getSpider() { getSpider() {
let spider; let spider;
switch (this.params.webname) { switch (this.params.website) {
case 'autoifeng': { case 'autoifeng': {
spider = new AutoIfeng(this.params); spider = new AutoIfeng(this.params);
break; break;
......
...@@ -84,9 +84,9 @@ class DealerHelper { ...@@ -84,9 +84,9 @@ class DealerHelper {
if (params.thirdpartyAccountID) { if (params.thirdpartyAccountID) {
replacements = [params.thirdpartyAccountID]; replacements = [params.thirdpartyAccountID];
whereStr = 'id = ?'; whereStr = 'id = ?';
} else if (params.dealerId && params.webname) { } else if (params.dealerId && params.website) {
replacements = [params.dealerId, params.webname]; replacements = [params.dealerId, params.website];
whereStr = 'dealerID = ? AND webname = ?'; whereStr = 'dealerID = ? AND website = ?';
} }
const connection = await DI.getConnection('MASTER_CRM'); const connection = await DI.getConnection('MASTER_CRM');
...@@ -114,7 +114,7 @@ class DealerHelper { ...@@ -114,7 +114,7 @@ class DealerHelper {
// 线索车系映射 // 线索车系映射
static async mapClues(params) { static async mapClues(params) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const webname = params.webname || ''; const website = params.website || '';
let clues = params.clues || []; let clues = params.clues || [];
const connection = await DI.getConnection('MASTER_CAR'); const connection = await DI.getConnection('MASTER_CAR');
...@@ -124,10 +124,10 @@ class DealerHelper { ...@@ -124,10 +124,10 @@ class DealerHelper {
intentionStrs = Array.from(new Set(intentionStrs)); intentionStrs = Array.from(new Set(intentionStrs));
let sql; let sql;
if (webname === 'autohome') { if (website === 'autohome') {
sql = `SELECT CAR_BRAND_TYPE_ID AS id, CAR_BRAND_TYPE_NAME AS name FROM car_brand_type_info sql = `SELECT CAR_BRAND_TYPE_ID AS id, CAR_BRAND_TYPE_NAME AS name FROM car_brand_type_info
WHERE ${connection.escape(intentionStrs.join())} LIKE CONCAT('%', CAR_BRAND_TYPE_NAME, '%')`; WHERE ${connection.escape(intentionStrs.join())} LIKE CONCAT('%', CAR_BRAND_TYPE_NAME, '%')`;
} else if (webname === 'easypass') { } else if (website === 'easypass') {
sql = `SELECT car_brand_type_id AS id, yc_series_name AS name FROM relation_series_yiche sql = `SELECT car_brand_type_id AS id, yc_series_name AS name FROM relation_series_yiche
WHERE car_brand_type_id > 0 WHERE car_brand_type_id > 0
AND ${connection.escape(intentionStrs.join())} LIKE CONCAT('%', yc_series_name, '%')`; AND ${connection.escape(intentionStrs.join())} LIKE CONCAT('%', yc_series_name, '%')`;
...@@ -161,9 +161,9 @@ class DealerHelper { ...@@ -161,9 +161,9 @@ class DealerHelper {
// 保存线索 // 保存线索
static async saveClues(params) { static async saveClues(params) {
const dealerID = params.dealerID || 0; const dealerID = params.dealerID || 0;
const webname = params.webname || ''; const website = params.website || '';
let clues = params.clues || []; let clues = params.clues || [];
if (!dealerID || !clues.length || !webname) { if (!dealerID || !clues.length || !website) {
throw errors.AppError('Params missing'); throw errors.AppError('Params missing');
} }
...@@ -192,7 +192,7 @@ class DealerHelper { ...@@ -192,7 +192,7 @@ class DealerHelper {
// customer_id, shop_name, salesman_id需要映射 // customer_id, shop_name, salesman_id需要映射
let replacements = [ let replacements = [
0, clue.customerName, clue.customerPhone, clue.intentionDes, clue.intentionID, '', dealerID, clue.salesmanName, 0, 0, clue.customerName, clue.customerPhone, clue.intentionDes, clue.intentionID, '', dealerID, clue.salesmanName, 0,
config.get('CLUE_INPUT_TYPE')[params.webname], 4, clue.createdAt config.get('CLUE_INPUT_TYPE')[params.website], 4, clue.createdAt
]; ];
valueSql = connection.format(valueSql, replacements); valueSql = connection.format(valueSql, replacements);
...@@ -265,10 +265,10 @@ class DealerHelper { ...@@ -265,10 +265,10 @@ class DealerHelper {
try { try {
params.password = new Buffer(params.password).toString('base64'); params.password = new Buffer(params.password).toString('base64');
const sql = `INSERT INTO crm_dealer_thirdparty_account SET const sql = `INSERT INTO crm_dealer_thirdparty_account SET
dealerID = ?, webname = ?, username = ?, password = ?, createdAt = UNIX_TIMESTAMP() dealerID = ?, website = ?, username = ?, password = ?, createdAt = UNIX_TIMESTAMP()
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
username = VALUES(username), password = VALUES(password)`; username = VALUES(username), password = VALUES(password)`;
const replacements = [params.dealerID, params.webname, params.username, params.password]; const replacements = [params.dealerID, params.website, params.username, params.password];
console.log(replacements); console.log(replacements);
const connection = await DI.getConnection('MASTER_CRM'); const connection = await DI.getConnection('MASTER_CRM');
connection.query( connection.query(
......
...@@ -137,7 +137,7 @@ class Autohome { ...@@ -137,7 +137,7 @@ class Autohome {
// 验证码解码 // 验证码解码
let captchaText; let captchaText;
try { try {
const captchaType = config.get(this.params.webname)['captchaType']; const captchaType = config.get(this.params.website)['captchaType'];
captchaText = await captcha.decodeBase64(captchaType, base64Text); captchaText = await captcha.decodeBase64(captchaType, base64Text);
console.info('captchaText:', captchaText); console.info('captchaText:', captchaText);
} catch (e) { } catch (e) {
...@@ -286,7 +286,7 @@ class Autohome { ...@@ -286,7 +286,7 @@ class Autohome {
await DealerHelper.saveClues({ await DealerHelper.saveClues({
clues: clues, clues: clues,
dealerID: this.params.dealerID, dealerID: this.params.dealerID,
webname: this.params.webname website: this.params.website
}); });
} }
......
...@@ -127,7 +127,7 @@ class Easypass { ...@@ -127,7 +127,7 @@ class Easypass {
// 验证码解码 // 验证码解码
let captchaText; let captchaText;
try { try {
const captchaType = config.get(this.params.webname)['captchaType']; const captchaType = config.get(this.params.website)['captchaType'];
captchaText = await captcha.decodeBase64(captchaType, base64Text); captchaText = await captcha.decodeBase64(captchaType, base64Text);
console.info('captchaText:', captchaText); console.info('captchaText:', captchaText);
} catch (e) { } catch (e) {
...@@ -252,7 +252,7 @@ class Easypass { ...@@ -252,7 +252,7 @@ class Easypass {
await DealerHelper.saveClues({ await DealerHelper.saveClues({
clues: clues, clues: clues,
dealerID: this.params.dealerID, dealerID: this.params.dealerID,
webname: this.params.webname website: this.params.website
}); });
} }
......
...@@ -10,7 +10,7 @@ class Spider { ...@@ -10,7 +10,7 @@ class Spider {
getSpider() { getSpider() {
let spider; let spider;
switch (this.params.webname) { switch (this.params.website) {
case 'autoifeng': { case 'autoifeng': {
spider = new dealer.Autoifeng(this.params); spider = new dealer.Autoifeng(this.params);
break; break;
......
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 sign in to comment