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

loan recommend change abtest

parent 0ccaaa4e
......@@ -157,7 +157,7 @@ class ProductService extends Service {
async getLoanHomeList() {
let ret = await this.getBusinessRecommendList(6, 'home');
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);
}
return ret;
......@@ -213,18 +213,18 @@ class ProductService extends Service {
// 获取推荐列表,按照ABC分组顺序推荐
async getBusinessRecommendList(limit, location = 'list') {
const { ctx } = this;
const { ctx, service } = this;
const userId = ctx.userId;
const R = require('ramda');
const recommendSort = function(a, b) {
return a.recommend_sorter - b.recommend_sorter;
};
let ret = [];
// 如果未登录,则推荐普通贷款
// 如果未登录,则推荐授信贷
if (ctx.isEmpty(userId)) {
const commonLoanList = await this.getCommonBusinessList();
ret = this.formatLoanList(R.take(limit)(R.sort(recommendSort)(commonLoanList)));
console.log('未登录');
// const commonLoanList = await this.getCommonBusinessList();
const loanList = await this.getAllProductsByType(1);
ret = R.take(limit)(R.sort(recommendSort)(loanList));
} else {
// 日志
const log = {
......@@ -251,6 +251,7 @@ class ProductService extends Service {
console.log('rule: ' + String(rule));
// 是否需要计算模型
let isNeedCalc = false;
let userInfo = {};
switch (rule) {
case 1:
isNeedCalc = true;
......@@ -266,8 +267,11 @@ class ProductService extends Service {
})(classList.class_C);
break;
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;
} else {
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