Commit 4c78d434 authored by 李尚科's avatar 李尚科

gjj product fix

parent a2a0b8c0
Pipeline #8686 passed with stage
in 13 seconds
......@@ -8,12 +8,18 @@ class ProductController extends Controller {
const { ctx } = this;
const type = ctx.params.type || 'credit';
let suit_options;
if(type == 'loan'){
suit_options = await ctx.service.gjj.product.getLoanChannelSuitOptions();
}
const keys = ctx.query.keys ? eval(ctx.query.keys) : [];
const results = await ctx.service.gjj.product.getRecommendOptions(type, keys);
ctx.success({ results });
if(suit_options){
results.unshift(suit_options);
}
const credit_loans = await ctx.service.gjj.product.getAllProductsByType(1);
const common_loans = await ctx.service.gjj.product.getAllProductsByType(4);
ctx.success({ results:results, credit_loans:credit_loans, common_loans: common_loans });
}
}
module.exports = ProductController;
......@@ -71,10 +71,63 @@ class ProductService extends Service {
const { ctx } = this;
const user_id = ctx.userId;
if (user_id) {
const app_user_id = ctx.appUserId;
const credit_loans = await this.getAllProductsByType(1);
const common_loans = 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 = {
id: -1,
key: 'loan_all',
title: '全部',
description: '全部',
_children: [],
}
let children = [{ id: -2, title: '全部', quality: credit_loans_ids, normal: common_loans_ids, }];
if (user_id && app_user_id) {
children.push({
id: -3,
title: '最适合您的',
quality: [7, 8, 29],//TODO
normal: [],
});
} else {
children.push({
id: -4,
title: '51公积金贷',
quality: credit_loans_ids,
normal: [],
});
children.push({
id: -5,
title: '普通贷',
quality: [],
normal: common_loans_ids,
});
}
default_options._children = children;
return default_options;
}
//1 授信贷;2 信用卡;3 普通信用卡;4 普通贷款
async getAllProductsByType(type, elements = []) {
const { ctx } = this;
const url = this.config.NODE_BASE_URL + '/cassandra-server/bu_basic/list?type=' + type;
let products_results = await ctx.helper.send_request(url, {}, { method: 'GET' });
ctx.logger.info(JSON.stringify({ url: url, products_results: products_results }));
let products = [];
if (products_results.status !== 200 || !products_results.data || !products_results.data.ret) {
return products;
}
products = products_results.data.ret;
if (elements && elements.length !== 0) {
products = R.project(elements)(products);
}
return products;
}
}
......
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