Commit 3cf615f3 authored by 李尚科's avatar 李尚科

add loan channel

parent 9b27f67c
Pipeline #7776 passed with stage
in 4 seconds
'use strict';
const Controller = require('egg').Controller;
class ProductController extends Controller {
// 筛选项列表
async getOptionProducts() {
const { ctx } = this;
const type = ctx.params.type || 'credit';
if(type == 'loan'){
}
const keys = ctx.query.keys ? eval(ctx.query.keys) : [];
const results = await ctx.service.gjj.product.getRecommendOptions(type, keys);
ctx.success({ results });
}
}
module.exports = ProductController;
...@@ -11,7 +11,7 @@ module.exports = app => { ...@@ -11,7 +11,7 @@ module.exports = app => {
identifier: STRING, identifier: STRING,
type: ENUM('normal', 'quality'), type: ENUM('normal', 'quality'),
order: INTEGER, order: INTEGER,
status: ENUM('offline', 'online'), // status: ENUM('offline', 'online'),
valid: INTEGER, valid: INTEGER,
// 注意,需要转成string // 注意,需要转成string
created_at: { created_at: {
......
'use strict';
module.exports = app => {
const router = app.router.namespace(app.config.projectRootPath + '/product');
router.get('/recommend/channel/options/:type', 'gjj.product.getOptionProducts');//
};
'use strict'; 'use strict';
const Service = require('egg').Service; const Service = require('egg').Service;
const R = require('ramda') const R = require('ramda')
class LoanService extends Service { class ProductService extends Service {
//通过 type=loan/credit 频道 option_ids 筛选项数组 all_product_ids //通过 type=loan/credit 频道 option_ids 筛选项数组 all_product_ids
...@@ -27,12 +27,14 @@ class LoanService extends Service { ...@@ -27,12 +27,14 @@ class LoanService extends Service {
//获取筛选项列表 带 product_id //获取筛选项列表 带 product_id
//return : [{"id":3,"title":"银行分类","description":"信用卡银行分类","_children":[{"id":12,"title":"招商银行","quality":["1"],"normal":["1"]},{"id":16,"title":"广发银行","quality":[],"normal":[]}]},{"id":4,"title":"主题分类","description":"信用卡主题分类","_children":[]},{"id":5,"title":"信用卡筛选项","description":"信用卡筛选项","_children":[]}] //return : [{"id":3,"title":"银行分类","description":"信用卡银行分类","_children":[{"id":12,"title":"招商银行","quality":["1"],"normal":["1"]},{"id":16,"title":"广发银行","quality":[],"normal":[]}]},{"id":4,"title":"主题分类","description":"信用卡主题分类","_children":[]},{"id":5,"title":"信用卡筛选项","description":"信用卡筛选项","_children":[]}]
async getRecommendOptions(type = 'credit', keys = ['loan_organization', 'loan_filter', 'credit_bank', 'credit_theme', 'credit_filter']) { async getRecommendOptions(type = 'credit', keys = []) {
const { ctx } = this; const { ctx } = this;
// const type = 'credit'; // const type = 'credit';
// const keys = ['loan_organization', 'loan_filter', 'credit_bank', 'credit_theme', 'credit_filter']; // keys = ['loan_organization', 'loan_filter', 'credit_bank', 'credit_theme', 'credit_filter'];
// console.info(keys);
let classifies = await ctx.blockModel.RecommendChannelClassify.all({ where: { type: type, valid: 1, key: { $in: keys } } }); let classifies = await ctx.blockModel.RecommendChannelClassify.all({ where: { type: type, valid: 1, key: { $in: keys } } });
// return classifies;
classifies = R.project(['id', 'title', 'description'])(classifies); classifies = R.project(['id', 'title', 'description'])(classifies);
const classify_ids = R.pluck('id', classifies); const classify_ids = R.pluck('id', classifies);
let options = await ctx.blockModel.RecommendChannelOption.all({ where: { classify_id: { $in: classify_ids }, status: 'online', valid: 1 }, order: [['order', 'asc']] }); let options = await ctx.blockModel.RecommendChannelOption.all({ where: { classify_id: { $in: classify_ids }, status: 'online', valid: 1 }, order: [['order', 'asc']] });
...@@ -64,6 +66,17 @@ class LoanService extends Service { ...@@ -64,6 +66,17 @@ class LoanService extends Service {
return ret; return ret;
} }
//
async getLoanChannelSuitOptions() {
const { ctx } = this;
const user_id = ctx.userId;
if (user_id) {
}
}
} }
module.exports = LoanService; module.exports = ProductService;
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