Commit 5e22a2c1 by 马玮

Change webname to website

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