Commit 68e33aa7 authored by 任国军's avatar 任国军

add loan sort

parent 7cd7f1b4
Pipeline #11634 passed with stage
in 20 seconds
......@@ -69,12 +69,14 @@ class ProductService extends Service {
//
async getLoanChannelSuitOptions() {
const { ctx } = this;
const user_id = ctx.userId;
const app_user_id = ctx.appUserId;
const credit_loans = await this.getAllProductsByType(1);
const common_loans = await this.getAllProductsByType(4);
const recommendSort = function(a, b) {
return a.recommend_sorter - b.recommend_sorter;
};
const credit_loans = R.sort(recommendSort)(await this.getAllProductsByType(1));
const common_loans = R.sort(recommendSort)(await this.getAllProductsByType(4));
const credit_loans_ids = R.pluck('business_id', credit_loans);
const common_loans_ids = R.pluck('business_id', common_loans);
const default_options = {
......@@ -213,7 +215,7 @@ class ProductService extends Service {
// 获取推荐列表,按照ABC分组顺序推荐
async getBusinessRecommendList(limit, location = 'list') {
const { ctx, service } = this;
const { ctx } = this;
const userId = ctx.userId;
const R = require('ramda');
const recommendSort = function(a, b) {
......@@ -247,11 +249,13 @@ class ProductService extends Service {
// 获取开关状态,判断是自动推荐or手动推荐orABTest
const keyword = location === 'list' ? 'config_list_smart_recommend' : 'config_loan_smart_recommend';
const ruleSetting = await this.app.huodongModel.Setting.findOne({ where: { keyword } });
const rule = Number(ruleSetting.value);
let rule = Number(ruleSetting.value);
console.log('rule: ' + String(rule));
rule = 3;
// 是否需要计算模型
let isNeedCalc = false;
let userInfo = {};
let userResult = {};
switch (rule) {
case 1:
isNeedCalc = true;
......@@ -270,7 +274,10 @@ class ProductService extends Service {
// 获取不到手机号则默认使用手动推荐
isNeedCalc = false;
// 获取用户手机号,根据手机号末尾判断是否自动推荐
userInfo = await service.user.get_user(ctx.appUserId);
userResult = await ctx.helper.send_request(this.config.USER_CENTER_API_URI + '/v1/appusers/' + ctx.appUserId, {}, {
method: 'GET',
});
userInfo = userResult.status === 200 ? userResult.data : {};
if (!ctx.isEmpty(userInfo) && !ctx.isEmpty(userInfo.user) && !ctx.isEmpty(userInfo.user.phone) && (Number(userInfo.user.phone) % 2 === 0)) {
isNeedCalc = true;
} else {
......
......@@ -50,7 +50,7 @@ module.exports = appInfo => {
// other sequelize configurations
dialect: 'mysql',
host: 'rm-bp1mnwmta5778y0d3jo.mysql.rds.aliyuncs.com',
database: 'poseidon_dev',
database: 'poseidon_uat',
username: 'kf_liuhaihua',
password: '24u1GaFh96khR31T7zs2y',
port: 3306,
......
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