...
|
...
|
@@ -14,12 +14,140 @@ const logger = global.yoho.logger; |
|
|
|
|
|
// const camelCase = global.yoho.camelCase;
|
|
|
|
|
|
// 处理还款列表数据
|
|
|
const _processAmtList = (list, queryDays) => {
|
|
|
let overduecount = 0;
|
|
|
let formartData = {
|
|
|
currAmtCount: 0,
|
|
|
currFeeCount: 0
|
|
|
};
|
|
|
|
|
|
list = list || [];
|
|
|
|
|
|
if (list.length > 0) {
|
|
|
_.forEach(list, (data, key) => {
|
|
|
// 第一条选中
|
|
|
if (key === 0) {
|
|
|
data.isChecked = true;
|
|
|
}
|
|
|
|
|
|
// 组装分期的显示格式
|
|
|
if (data.terms === 1) {
|
|
|
data.stage = data.terms;
|
|
|
} else {
|
|
|
data.stage = data.currTerm + '/' + data.terms;
|
|
|
}
|
|
|
|
|
|
// 判断是否逾期
|
|
|
if (data.unExpireDays < 0) {
|
|
|
data.isOverdue = true;
|
|
|
overduecount++;
|
|
|
}
|
|
|
|
|
|
data.day = Math.abs(data.unExpireDays);
|
|
|
});
|
|
|
|
|
|
|
|
|
if (overduecount === 0) {
|
|
|
if (queryDays === 0) { // 待还总金额
|
|
|
list[0].isChecked = true;
|
|
|
formartData.currAmtCount = (+list[0].currAmt);
|
|
|
formartData.currFeeCount = (+list[0].currFee);
|
|
|
|
|
|
if (list.length === 1) {
|
|
|
formartData.isAllChecked = true;
|
|
|
}
|
|
|
} else if (queryDays === 7 || queryDays === 30) { // 近7日待还金额和本月待还金额
|
|
|
_.forEach(list, (data) => {
|
|
|
data.isChecked = true;
|
|
|
formartData.currAmtCount += (+data.currAmt);
|
|
|
formartData.currFeeCount += (+data.currFee);
|
|
|
});
|
|
|
|
|
|
formartData.isAllChecked = true;
|
|
|
}
|
|
|
} else { // 只要有逾期的记录,走这里
|
|
|
_.forEach(list, (data) => {
|
|
|
if (data.unExpireDays < 0) {
|
|
|
data.isChecked = true;
|
|
|
formartData.currAmtCount += (+data.currAmt);
|
|
|
formartData.currFeeCount += (+data.currFee);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (overduecount === list.length) {
|
|
|
formartData.isAllChecked = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 逾期未还款金额
|
|
|
if (queryDays === -1) {
|
|
|
formartData.isAllChecked = true;
|
|
|
}
|
|
|
|
|
|
if (formartData.currFeeCount > 0) {
|
|
|
formartData.isCurrFee = true;
|
|
|
} else {
|
|
|
formartData.isCurrFee = false;
|
|
|
}
|
|
|
|
|
|
return _.assign({
|
|
|
repaymentList: list
|
|
|
}, formartData);
|
|
|
} else {
|
|
|
return {
|
|
|
isNoResult: true
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 处理还款记录数据
|
|
|
const _processRepayList = (list) => {
|
|
|
list = list || [];
|
|
|
|
|
|
if (list.length > 0) {
|
|
|
_.forEach(list, (data) => {
|
|
|
// 组装分期的显示格式
|
|
|
if (data.terms === 1) {
|
|
|
data.stage = data.terms;
|
|
|
} else {
|
|
|
data.stage = data.termNo + '/' + data.terms;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
} else {
|
|
|
return '';
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 银行卡号处理
|
|
|
const _processBankCards = (list) => {
|
|
|
list = list || [];
|
|
|
|
|
|
_.forEach(list, (data) => {
|
|
|
let newCardNo = data.cardNo.split('');
|
|
|
let cardNo = newCardNo.length;
|
|
|
|
|
|
data.cardNo = '';
|
|
|
|
|
|
for (let i = 1; i < cardNo; i++) {
|
|
|
if (i < (cardNo - 4)) {
|
|
|
data.cardNo += '*';
|
|
|
} else {
|
|
|
data.cardNo += newCardNo[i - 1];
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取资源位数据
|
|
|
* @param {[string]} page
|
|
|
* @return {[array]}
|
|
|
*/
|
|
|
const getResources = (page, channel) => {
|
|
|
const getResources = () => {
|
|
|
return serviceAPI.get('operations/api/v5/resource/get', {
|
|
|
content_code: '0876085ff46bed27f1a1eb6ee8b68987'
|
|
|
}, {
|
...
|
...
|
@@ -62,21 +190,21 @@ const getStauts = (uid) => { |
|
|
// 获取用户可用额度信息
|
|
|
const getQueryCreditInfo = (uid) => {
|
|
|
return api.get('', {
|
|
|
method: 'app.order.queryCreditInfo',
|
|
|
method: 'user.instalment.queryCreditLimit',
|
|
|
uid: uid
|
|
|
}).then((result) => {
|
|
|
result = {
|
|
|
alg: 'SALT_MD5',
|
|
|
code: 200,
|
|
|
data: {
|
|
|
initCredit: '8000.00',
|
|
|
currCredit: '5000.00',
|
|
|
status: 2
|
|
|
initCreditLimit: '5000',
|
|
|
currCreditLimit: '2000',
|
|
|
status: '2',
|
|
|
maxOverdueDay: '5'
|
|
|
},
|
|
|
md5: 'c1d725306fb09dcbf504776d276521cb',
|
|
|
message: 'ok'
|
|
|
};
|
|
|
console.log('11');
|
|
|
if (result && result.code === 200) {
|
|
|
return result.data;
|
|
|
} else {
|
...
|
...
|
@@ -92,18 +220,20 @@ const getQueryAmtInfo = (uid) => { |
|
|
method: 'app.order.queryAmtInfo',
|
|
|
uid: uid
|
|
|
}).then((result) => {
|
|
|
result = {
|
|
|
alg: 'SALT_MD5',
|
|
|
code: 200,
|
|
|
data: {
|
|
|
totalAmt: '2000.00',
|
|
|
monthAmt: '800.00',
|
|
|
_7daysAmt: '400.00',
|
|
|
overAmt: '400.00'
|
|
|
},
|
|
|
md5: 'c1d725306fb09dcbf504776d276521cb',
|
|
|
message: 'ok'
|
|
|
};
|
|
|
// result = {
|
|
|
// alg: 'SALT_MD5',
|
|
|
// code: 200,
|
|
|
// data: {
|
|
|
// totalAmt: '2000.00',
|
|
|
// monthAmt: '800.00',
|
|
|
// _7daysAmt: '400.00',
|
|
|
// overAmt: '400.00'
|
|
|
// },
|
|
|
// md5: 'c1d725306fb09dcbf504776d276521cb',
|
|
|
// message: 'ok'
|
|
|
// };
|
|
|
|
|
|
console.log(result);
|
|
|
if (result && result.code === 200) {
|
|
|
result.data.dayAmt = result.data._7daysAmt;
|
|
|
return result.data;
|
...
|
...
|
@@ -114,28 +244,6 @@ const getQueryAmtInfo = (uid) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
// 处理还款列表数据
|
|
|
const _processAmtList = (list) => {
|
|
|
let formatData = [];
|
|
|
|
|
|
list = list || [];
|
|
|
|
|
|
_.forEach(list, (data) => {
|
|
|
if (data.terms === 1) {
|
|
|
data.stage = data.terms;
|
|
|
} else {
|
|
|
data.stage = data.currTerm + '/' + data.terms;
|
|
|
}
|
|
|
|
|
|
if (data.unExpireDays < 0) {
|
|
|
data.isOverdue = true;
|
|
|
}
|
|
|
|
|
|
data.day = data.unExpireDays;
|
|
|
});
|
|
|
|
|
|
return list;
|
|
|
};
|
|
|
|
|
|
// 获取用户待还列表信息 queryDays -1:逾期待还;0:全部待还;7:七日待还;30:本月待还
|
|
|
const getQueryAmtList = (params) => {
|
...
|
...
|
@@ -160,7 +268,7 @@ const getQueryAmtList = (params) => { |
|
|
currNoFeeAmt: '840.00',
|
|
|
currFee: '5.00'
|
|
|
}, {
|
|
|
billNo: 'x00001',
|
|
|
billNo: 'x00002',
|
|
|
terms: 3,
|
|
|
currTerm: 2,
|
|
|
unExpireDays: 10,
|
...
|
...
|
@@ -168,6 +276,15 @@ const getQueryAmtList = (params) => { |
|
|
currAmt: '840.00',
|
|
|
currNoFeeAmt: '840.00',
|
|
|
currFee: '0.00'
|
|
|
}, {
|
|
|
billNo: 'x00003',
|
|
|
terms: 3,
|
|
|
currTerm: 1,
|
|
|
unExpireDays: -3,
|
|
|
billInfo: '三叶草运动休闲鞋',
|
|
|
currAmt: '845.00',
|
|
|
currNoFeeAmt: '840.00',
|
|
|
currFee: '5.00'
|
|
|
}
|
|
|
],
|
|
|
pageNo: 1,
|
...
|
...
|
@@ -178,7 +295,7 @@ const getQueryAmtList = (params) => { |
|
|
message: 'ok'
|
|
|
};
|
|
|
if (result && result.code === 200) {
|
|
|
return _processAmtList(result.data.amtList);
|
|
|
return _processAmtList(result.data.amtList, params.queryDays);
|
|
|
} else {
|
|
|
logger.error('get queryAmtList data return code is not 200');
|
|
|
return '';
|
...
|
...
|
@@ -367,6 +484,95 @@ const getBankInfo = (cardNo) => { |
|
|
}, cardNo);
|
|
|
};
|
|
|
|
|
|
// 还款记录查询
|
|
|
const getQueryRePayList = (params) => {
|
|
|
return api.get('', _.assign({
|
|
|
method: 'app.order.queryRePayList',
|
|
|
pageSize: '10'
|
|
|
}, params), {
|
|
|
cache: true
|
|
|
}).then((result) => {
|
|
|
// result = {
|
|
|
// alg: "SALT_MD5",
|
|
|
// code: 200,
|
|
|
// data: {
|
|
|
// rePayList: [
|
|
|
// {
|
|
|
// billNo: "00001",
|
|
|
// terms: 3,
|
|
|
// termNo: 1,
|
|
|
// time: "2016.06.01",
|
|
|
// status: 1,
|
|
|
// amt: "200.00",
|
|
|
// billInfo: "三叶草运动休闲鞋"
|
|
|
// },
|
|
|
// {
|
|
|
// billNo: "00001",
|
|
|
// terms: 3,
|
|
|
// termNo: 1,
|
|
|
// time: "2016.06.01",
|
|
|
// status: 1,
|
|
|
// amt: "200.00",
|
|
|
// billInfo: "三叶草运动休闲鞋"
|
|
|
// },
|
|
|
// {
|
|
|
// billNo: "00001",
|
|
|
// terms: 3,
|
|
|
// termNo: 1,
|
|
|
// time: "2016.06.01",
|
|
|
// status: 1,
|
|
|
// amt: "200.00",
|
|
|
// billInfo: "三叶草运动休闲鞋"
|
|
|
// },
|
|
|
// ],
|
|
|
// pageNo: 1,
|
|
|
// pageTotal: 1,
|
|
|
// total: 3
|
|
|
// },
|
|
|
// md5: "c1d725306fb09dcbf504776d276521cb",
|
|
|
// message: "ok"
|
|
|
// };
|
|
|
if (result && result.code === 200) {
|
|
|
return _processRepayList(result.data.rePayList);
|
|
|
} else {
|
|
|
logger.error('get queryRePayList data return code is not 200');
|
|
|
return '';
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
// 账号管理
|
|
|
const getBankCards = (uid) => {
|
|
|
return api.get('', {
|
|
|
method: 'user.instalment.getBankCards',
|
|
|
uid: uid
|
|
|
}, {
|
|
|
cache: true
|
|
|
}).then((result) => {
|
|
|
result = {
|
|
|
alg: 'SALT_MD5',
|
|
|
code: 200,
|
|
|
data: [
|
|
|
{
|
|
|
userName: '张三',
|
|
|
cardNo: '25202200000',
|
|
|
bankCode: 'ABC',
|
|
|
bankName: '农业银行',
|
|
|
mobile: '18021200000'
|
|
|
}
|
|
|
],
|
|
|
md5: '6d729d4b35f10fc73531210bd7ecff91',
|
|
|
message: 'success'
|
|
|
};
|
|
|
if (result && result.code === 200) {
|
|
|
return _processBankCards(result.data);
|
|
|
} else {
|
|
|
logger.error('get getBankCards data return code is not 200');
|
|
|
return '';
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getStauts,
|
|
|
getQueryCreditInfo,
|
...
|
...
|
@@ -376,5 +582,7 @@ module.exports = { |
|
|
activateService,
|
|
|
getResources,
|
|
|
getQueryAmtList,
|
|
|
getBankInfo
|
|
|
getBankInfo,
|
|
|
getQueryRePayList,
|
|
|
getBankCards
|
|
|
}; |
...
|
...
|
|