Authored by shuaiguo

Merge branch 'refs/heads/develop'

... ... @@ -14,6 +14,7 @@ const QQStrategy = require('passport-qq').Strategy;
const DoubanStrategy = require('passport-douban').Strategy;
const RenrenStrategy = require('passport-renren').Strategy;
const AlipayStrategy = require('./models/passport-alipay').Strategy;
const request = require('request-promise');
const CaptchaServiceModel = require('./models/captcha-img-service');
... ... @@ -23,6 +24,35 @@ const config = global.yoho.config;
const cookie = global.yoho.cookie;
const logger = global.yoho.logger;
class BaiduSDK {
/*
* @ description: 广告主回传转化数据接口, 上报百度
* @ author: huzhiming
* @ date: 2019-11-19 17:21:29
* @ version: v1.0.0
* 详情见文档:[http://ocpc.baidu.com/developer/d/guide/?iurl=api%2Fapi-doc%2Fapi-interface%2F]
*/
static reportOcpcApi({
token = '7GULUkX90QLZU6cHO9OEqUsRKttGNqpN@O62eFfb91OUVhmkakV1bQHIxF8xURBvP',
conversionTypes = [{ logidUrl: '', newType: null }]
}) {
logger.info('--------------百度ocpc--------------');
request({
method: 'POST',
uri: 'http://ocpc.baidu.com/ocpcapi/api/uploadConvertData',
body: {
token,
conversionTypes
},
json: true
}).then((result) => {
logger.info(`[账号注册成功后上报 百度ocpc返回信息:${JSON.stringify(result)}`);
}).catch((error) => {
logger.info(`[账号注册成功后上报 百度ocpc失败 错误信息:${error}`);
});
}
}
let siteUrl = config.siteUrl.indexOf('//') === 0 ? 'http:' + config.siteUrl : config.siteUrl;
// 本地登录
... ... @@ -48,6 +78,20 @@ passport.use('local', new LocalStrategy({
(async function() {
const result = await req.ctx(LoginApi).signin(type, area, username, password, shoppingKey, close, id, captcha);
if (_.get(result, 'data.nFlag', 'N') === 'Y') {
const logidUrl = req.cookies.bd_vid_path;
logger.info('-------logidUrl---auth-----', `${logidUrl}:${username}`);
if (logidUrl) {
BaiduSDK.reportOcpcApi({
conversionTypes: {
logidUrl,
newType: 3
}
});
}
}
if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) {
return done(null, Object.assign(result.data, {code: result.code}));
}
... ...