Commit 1cdd9ed3 authored by Hsinli's avatar Hsinli

add home api

parent 705802bc
Pipeline #13605 passed with stage
in 24 seconds
......@@ -11,6 +11,10 @@ module.exports = app => {
router.post('/order/pay_notice', 'credit.order.payNotice');
router.get('/order/check_pay/:order_id', 'credit.order.checkPay');
router.get('/blacklist/home', 'credit.home.home');//首页
//我的信用-黑名单报告
router.get('/blacklist/report/:report_id', loginAuth, 'credit.blacklist.getBlacklistReport');//获取报告信息
router.post('/blacklist/report', loginAuth, 'credit.blacklist.applyBlacklistReport');//查询个人黑名单报告
......
......@@ -6,7 +6,71 @@ const Service = require('egg').Service;
class HomeService extends Service {
/**
* 我的信用首页
*/
async home() {
const { ctx } = this;
let ret = {
have_history: false,
have_be_pay: false,
be_pay: {
send: 'tab',
order_id: null
}
}
if (!ctx.userId) {
return ret;
}
let taskList = [
ctx.service.credit.order.getHistoryOrders('blacklist'),
ctx.service.credit.order.getHistoryOrders('callrisk')
];
let retList = await Promise.all(taskList).then(result => {
return result;
}).catch(error => {
ctx.failed(error);
});
let historyAmount = 0;
for (let i in retList) {
if (retList[i] === null) {
continue;
}
historyAmount += retList[i].worth_h + retList[i].worth_l;
}
ret.have_history = historyAmount > 0 ? true : false;
let bePayOrder = [];
if (historyAmount > 0) {
let blacklist = retList[0].worth_h;
let callrisk = retList[1].worth_h;
for (let i in blacklist) {
if (blacklist[i].state === '待支付') {
bePayOrder.push(blacklist[i]);
}
}
for (let i in callrisk) {
if (callrisk[i].state === '待支付') {
bePayOrder.push(callrisk[i]);
}
}
}
if (bePayOrder.length > 0) {
ret.have_be_pay = true;
if (bePayOrder.length === 1) {
ret.be_pay.send = bePayOrder[0].type;
ret.be_pay.order_id = bePayOrder[0].order_id;
} else {
ret.be_pay.send = 'tab';
}
}
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