Commit b2e90804 authored by 谢永靖's avatar 谢永靖

#18188 子任务 后台 运营管理/频道管理/贷款列表配置

parent 6e28c3ad
Pipeline #38663 passed with stage
in 9 seconds
......@@ -34,10 +34,43 @@ class ProductController extends Controller {
ctx.success({ results, credit_loans, common_loans, common_credits, credit_cards });
}
async getOptionProductsNew() {
const { ctx } = this;
const type = ctx.params.type || 'credit';
const keys = ctx.query.keys ? ctx.query.keys.split(',') : [];
const results = await ctx.service.gjj.product.getRecommendOptions(type, keys);
let suit_options;
let credit_loans = [];
let common_loans = [];
let common_credits = [];
let credit_cards = [];
let result_loans = [];
if (type === 'loan') {
suit_options = await ctx.service.gjj.productNew.getLoanChannelSuitOptions();
if (suit_options) {
results.unshift(suit_options);
}
credit_loans = await ctx.service.gjj.product.getAllProductsByType(1);
credit_loans = ctx.service.gjj.product.getLoanList(credit_loans);
common_loans = await ctx.service.gjj.product.getAllProductsByType(4);
common_loans = ctx.service.gjj.product.getLoanList(common_loans);
result_loans = credit_loans.concat(credit_loans, common_loans);
} else {
credit_cards = await ctx.service.gjj.product.getAllProductsByType(2);
common_credits = await ctx.service.gjj.product.getAllProductsByType(3);
result_loans = credit_loans.concat(credit_cards, common_credits);
}
ctx.success({ results, result_loans });
}
// 贷款频道首页热门推荐
async getLoanHomeRecommendList() {
const { ctx } = this;
const ret = await ctx.service.gjj.product.getLoanHomeList();
const ret = await ctx.service.gjj.productNew.getLoanHomeList();
ctx.success({ results: ret, count: ret.length });
}
......
......@@ -6,5 +6,7 @@ module.exports = app => {
router.get('/recommend/channel/options/:type', 'gjj.product.getOptionProducts');// 筛选项
router.get('/recommend/channel/home', 'gjj.product.getLoanHomeRecommendList'); // 贷款频道首页
// #18188 新版贷款列表 按配置排序
router.get('/recommend_new/channel/options/:type', 'gjj.product.getOptionProductsNew');
};
'use strict';
const Service = require('egg').Service;
const R = require('ramda');
class ProductNewService extends Service {
//
async getLoanChannelSuitOptions() {
const { ctx } = this;
const user_id = ctx.userId;
const app_user_id = ctx.appUserId;
const recommendSort = function(a, b) {
if (a.recommend_sorter === b.recommend_sorter) {
return b.business_id - a.business_id;
}
return a.recommend_sorter - b.recommend_sorter;
};
const credit_loans = await ctx.service.gjj.product.getAllProductsByType(1);
const common_loans = await ctx.service.gjj.product.getAllProductsByType(4);
const result_loans = R.sort(recommendSort)(credit_loans.concat(common_loans));
const credit_loans_ids = R.pluck('business_id', credit_loans);
const common_loans_ids = R.pluck('business_id', common_loans);
const result_loans_ids = R.pluck('business_id', result_loans);
const default_options = {
id: -1,
key: 'loan_all',
title: '全部',
description: '全部',
_children: [],
};
const children = [
{
id: -2,
title: '全部',
quality: result_loans_ids,
},
];
if (app_user_id) {
const userGjj = await ctx.helper.send_request(
this.config.NODE_BASE_URL + '/cassandra-server/gjj/list/' + user_id,
{},
{ method: 'GET' }
);
if (userGjj.status === 200 && !ctx.isEmpty(userGjj.data.ret)) {
children.push({
id: -3,
title: '最适合您的',
quality: await ctx.service.gjj.product.getSuitLoans(),
});
} else {
children.push({
id: -4,
title: '51公积金贷',
quality: credit_loans_ids.concat(common_loans_ids),
});
children.push({
id: -5,
title: '普通贷',
quality: common_loans_ids,
});
}
} else {
children.push({
id: -4,
title: '51公积金贷',
quality: credit_loans_ids.concat(common_loans_ids),
});
children.push({
id: -5,
title: '普通贷',
quality: common_loans_ids,
});
}
default_options._children = children;
return default_options;
}
// 贷款频道首页热门推荐
async getLoanHomeList() {
const { ctx } = this;
const recommendSort = function(a, b) {
if (a.recommend_sorter === b.recommend_sorter) {
return b.business_id - a.business_id;
}
return a.recommend_sorter - b.recommend_sorter;
};
const credit_loans = await ctx.service.gjj.product.getAllProductsByType(1);
const common_loans = await ctx.service.gjj.product.getAllProductsByType(4);
const ret = R.take(6)(R.sort(recommendSort)(credit_loans.concat(common_loans)));
return ret;
}
}
module.exports = ProductNewService;
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