Commit 4e4c6a2f authored by 任国军's avatar 任国军

loan recommend change abtest

parent 0ccaaa4e
...@@ -157,7 +157,7 @@ class ProductService extends Service { ...@@ -157,7 +157,7 @@ class ProductService extends Service {
async getLoanHomeList() { async getLoanHomeList() {
let ret = await this.getBusinessRecommendList(6, 'home'); let ret = await this.getBusinessRecommendList(6, 'home');
if (ret.length < 6) { if (ret.length < 6) {
const creditLoan = R.take(6 - ret.length)(await this.getAllProductsByType(1)); const creditLoan = R.take(6 - ret.length)(await this.getAllProductsByType(4));
ret = R.insertAll(ret.length, creditLoan)(ret); ret = R.insertAll(ret.length, creditLoan)(ret);
} }
return ret; return ret;
...@@ -213,18 +213,18 @@ class ProductService extends Service { ...@@ -213,18 +213,18 @@ class ProductService extends Service {
// 获取推荐列表,按照ABC分组顺序推荐 // 获取推荐列表,按照ABC分组顺序推荐
async getBusinessRecommendList(limit, location = 'list') { async getBusinessRecommendList(limit, location = 'list') {
const { ctx } = this; const { ctx, service } = this;
const userId = ctx.userId; const userId = ctx.userId;
const R = require('ramda'); const R = require('ramda');
const recommendSort = function(a, b) { const recommendSort = function(a, b) {
return a.recommend_sorter - b.recommend_sorter; return a.recommend_sorter - b.recommend_sorter;
}; };
let ret = []; let ret = [];
// 如果未登录,则推荐普通贷款 // 如果未登录,则推荐授信贷
if (ctx.isEmpty(userId)) { if (ctx.isEmpty(userId)) {
const commonLoanList = await this.getCommonBusinessList(); // const commonLoanList = await this.getCommonBusinessList();
ret = this.formatLoanList(R.take(limit)(R.sort(recommendSort)(commonLoanList))); const loanList = await this.getAllProductsByType(1);
console.log('未登录'); ret = R.take(limit)(R.sort(recommendSort)(loanList));
} else { } else {
// 日志 // 日志
const log = { const log = {
...@@ -251,6 +251,7 @@ class ProductService extends Service { ...@@ -251,6 +251,7 @@ class ProductService extends Service {
console.log('rule: ' + String(rule)); console.log('rule: ' + String(rule));
// 是否需要计算模型 // 是否需要计算模型
let isNeedCalc = false; let isNeedCalc = false;
let userInfo = {};
switch (rule) { switch (rule) {
case 1: case 1:
isNeedCalc = true; isNeedCalc = true;
...@@ -266,8 +267,11 @@ class ProductService extends Service { ...@@ -266,8 +267,11 @@ class ProductService extends Service {
})(classList.class_C); })(classList.class_C);
break; break;
case 3: case 3:
// 根据时间戳毫秒来判断,偶数为A,奇数为B // 获取不到手机号则默认使用手动推荐
if (Number(moment().milliseconds()) % 2 === 0) { isNeedCalc = false;
// 获取用户手机号,根据手机号末尾判断是否自动推荐
userInfo = await service.user.get_user(ctx.appUserId);
if (!ctx.isEmpty(userInfo) && !ctx.isEmpty(userInfo.user) && !ctx.isEmpty(userInfo.user.phone) && (Number(userInfo.user.phone) % 2 === 0)) {
isNeedCalc = true; isNeedCalc = true;
} else { } else {
classList.class_C = R.map(function(e) { classList.class_C = R.map(function(e) {
......
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