Commit 7d34f5e9 authored by 任国军's avatar 任国军

fix sort

parent 1f46d615
Pipeline #13004 passed with stage
in 5 seconds
......@@ -72,11 +72,8 @@ class ProductService extends Service {
const { ctx } = this;
const user_id = ctx.userId;
const app_user_id = ctx.appUserId;
const recommendSort = function(a, b) {
return Number(a.recommend_sorter) - Number(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 = 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 = {
......@@ -101,7 +98,7 @@ class ProductService extends Service {
id: -4,
title: '51公积金贷',
quality: credit_loans_ids,
normal: [],
normal: common_loans_ids,
});
children.push({
id: -5,
......@@ -115,7 +112,7 @@ class ProductService extends Service {
id: -4,
title: '51公积金贷',
quality: credit_loans_ids,
normal: [],
normal: common_loans_ids,
});
children.push({
id: -5,
......@@ -141,7 +138,13 @@ class ProductService extends Service {
return products;
}
products = products_results.data.ret;
products.sort(function(x, y) { return x.recommend_sorter - y.recommend_sorter; });
const sort = function(a, b) {
if (a.recommend_sorter === b.recommend_sorter) {
return b.business_id - a.business_id;
}
return a.recommend_sorter - b.recommend_sorter;
};
products = R.sort(sort)(products);
products = await this.formatProducts(products);
return products;
......@@ -172,8 +175,6 @@ class ProductService extends Service {
const url = ctx.app.config.NODE_BASE_URL + '/cassandra-server/loan_list/bu_class/list';
const param = { uid: userId, app_uid: appUserId, app_id: ctx.appId };
const resp = await ctx.helper.send_request(url, param, { method: 'GET' });
console.log(param);
console.log(resp);
if (resp.status !== 200) {
ctx.failed('[bu_class]内部接口错误');
}
......@@ -220,19 +221,22 @@ class ProductService extends Service {
const userId = ctx.userId;
const R = require('ramda');
const recommendSort = function(a, b) {
return Number(a.recommend_sorter) - Number(b.recommend_sorter);
if (a.recommend_sorter === b.recommend_sorter) {
return b.business_id - a.business_id;
}
return a.recommend_sorter - b.recommend_sorter;
};
let ret = [];
// 如果未登录或者没有导入公积金,则推荐授信贷
if (ctx.isEmpty(userId)) {
// const commonLoanList = await this.getCommonBusinessList();
const loanList = await this.getAllProductsByType(1);
ret = R.take(limit)(R.sort(recommendSort)(loanList));
ret = R.take(limit)(loanList);
} else {
const userGjj = await ctx.helper.send_request(this.config.NODE_BASE_URL + '/cassandra-server/gjj/list/' + userId, {}, { method: 'GET' });
if (userGjj.status !== 200 || ctx.isEmpty(userGjj.data.ret)) {
const loanList = await this.getAllProductsByType(1);
ret = R.take(limit)(R.sort(recommendSort)(loanList));
ret = R.take(limit)(loanList);
return ret;
}
......
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