Authored by 王水玲

有货分期

... ... @@ -40,8 +40,7 @@ const _reviewStatus = (status) => {
}
};
const index = (req, res) => {
let query = req.query.query || '';
const index = (req, res, next) => {
let uid = req.user.uid || 3236556;
Promise.all([installmentModel.getStauts(uid), installmentModel.getSearchIntallment()]).then((result) => {
... ... @@ -50,14 +49,13 @@ const index = (req, res) => {
let openStatus = result[0];
if (openStatus === 0) {
return installmentModel.getResources().then(data => {
return {
bannerTop: {
data: [
{
url: '',
src: '//img11.static.yhbimg.com/yhb-img01/2016/07/29/11/0112d076e4fa0c53635ed93b118ee3f74e.jpg?imageView2/2/w/640/h/240/q/70' // eslint-disable-line
}
]
data: [{
src: '//img10.static.yhbimg.com/yhb-img01/2016/08/03/11/0131193afdd030b09af40b93eeb1c33ae5.jpg?imageView2/2/w/640/h/240/q/70',
url: ''
}]
},
notOpen: true,
installmentOnly: {
... ... @@ -65,30 +63,27 @@ const index = (req, res) => {
goods: result[1]
}
};
});
} else if (openStatus === 2) {
if (query === 'usable') {
return installmentModel.getQueryCreditInfo(uid).then((data) => {
if (data.status === 2) {
data.replayStatus = '逾期';
} else if (data.status === 3) {
data.replayStatus = '不可用';
}
return _.assign({
isUnable: true,
return Promise.all([installmentModel.getQueryCreditInfo(uid), installmentModel.getQueryAmtInfo(uid)]).then((data) => {
let params = _.assign({
isOverdue: false,
installmentOnly: {
title: '分期专享',
goods: result[1]
}
}, data);
});
} else {
return installmentModel.getQueryAmtInfo(uid).then((data) => {
return _.assign({
isRepay: true
}, data);
});
}, data[0], data[1]);
// status: 1 正常 2 逾期 3 不可用 4 未开通
if (data[0].status === 2) {
params.replayStatus = '逾期';
params.isOverdue = true;
} else if (data[0].status === 3) {
params.replayStatus = '不可用';
}
return params;
});
} else if (openStatus === 1) {
res.redirect('/home/installment/review?status=' + openStatus);
} else {
... ... @@ -107,10 +102,10 @@ const index = (req, res) => {
page: 'installment',
title: '有货分期'
}, result));
});
}).catch(next);
};
const review = (req, res) => {
const review = (req, res, next) => {
let openStatus = req.query.status || false;
let uid = req.user.uid || 20000032;
let data = {
... ... @@ -130,7 +125,7 @@ const review = (req, res) => {
return _reviewStatus(status);
}).then((params) => {
res.render('installment/open-result', _.assign(data, params));
});
}).catch(next);
}
};
... ... @@ -150,9 +145,30 @@ const verifyCode = (req, res, next) => {
}).catch(next);
};
// 逾期未还款列表
const overdueList = (req, res, next) => {
let params = {
uid: req.user.uid || 0,
queryDays: -1,
pageNo: '1'
};
installmentModel.getQueryAmtList(params).then((result) => {
res.render('installment/repayment-list', {
repaymentList: result
});
});
};
// // 7日待还款列表
const sevenDayList = (req, res, next) => {
res.send('1');
};
module.exports = {
index,
review,
startingService,
verifyCode
verifyCode,
overdueList,
sevenDayList
};
... ...
... ... @@ -6,11 +6,34 @@
'use strict';
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const resourcesProcess = require(`${utils}/resources-process`);
const _ = require('lodash');
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const logger = global.yoho.logger;
// const camelCase = global.yoho.camelCase;
/**
* 获取资源位数据
* @param {[string]} page
* @return {[array]}
*/
const getResources = (page, channel) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: '0876085ff46bed27f1a1eb6ee8b68987'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
logger.error('get resources data return code is not 200');
return [];
}
});
};
// 获取分期开通状态
const getStauts = (uid) => {
... ... @@ -22,7 +45,7 @@ const getStauts = (uid) => {
alg: 'SALT_MD5',
code: 200,
data: {
status: 0
status: 2
},
md5: '6d729d4b35f10fc73531210bd7ecff91',
message: 'success'
... ... @@ -30,7 +53,7 @@ const getStauts = (uid) => {
if (result && result.code === 200) {
return result.data.status;
} else {
logger.error('get installment open status return is not 200');
logger.error('get installment open status return code is not 200');
return '';
}
});
... ... @@ -39,7 +62,7 @@ const getStauts = (uid) => {
// 获取用户可用额度信息
const getQueryCreditInfo = (uid) => {
return api.get('', {
method: 'order.queryCreditInfo',
method: 'app.order.queryCreditInfo',
uid: uid
}).then((result) => {
result = {
... ... @@ -53,10 +76,11 @@ const getQueryCreditInfo = (uid) => {
md5: 'c1d725306fb09dcbf504776d276521cb',
message: 'ok'
};
console.log('11');
if (result && result.code === 200) {
return result.data;
} else {
logger.error('get user installment usable price info return is not 200');
logger.error('get user installment usable price info return code is not 200');
return '';
}
});
... ... @@ -65,7 +89,7 @@ const getQueryCreditInfo = (uid) => {
// 获取用户待还款金额
const getQueryAmtInfo = (uid) => {
return api.get('', {
method: 'order.queryAmtInfo',
method: 'app.order.queryAmtInfo',
uid: uid
}).then((result) => {
result = {
... ... @@ -84,143 +108,216 @@ const getQueryAmtInfo = (uid) => {
result.data.dayAmt = result.data._7daysAmt;
return result.data;
} else {
logger.error('get user installment repay info return is not 200');
logger.error('get user installment repay info return code is not 200');
return '';
}
});
};
// 分期专享推荐商品
const getSearchIntallment = () => {
return api.post('', {
method: 'app.search.instalment',
limit: '50',
order: 's_t_desc'
}, {
// 处理还款列表数据
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) => {
return api.get('', _.assign({
method: 'app.order.queryAmtList',
pageSize: '20'
}, params), {
cache: true
}).then((result) => {
result = {
alg: 'SALT_MD5',
code: 200,
data: {
product_list: [
amtList: [
{
brand_domain: '5cm',
brand_id: 4,
brand_name: '5CM',
cn_alphabet: '5CMPeiShi5CXTIT0600S66',
default_images: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
edit_time: 1456119592,
gender: '1',
goods_list: [
{
color_code: '333333',
color_id: '2',
color_name: '黑色',
color_value: '',
cover_1: '',
cover_2: '',
goods_id: '476147',
images_url: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
is_default: 'N',
product_skc: '346699',
status: '1'
}
],
is_advance: 'N',
is_discount: 'N',
is_limited: 'N',
is_new: 'Y',
is_outlets: 2,
is_promotion: 104,
is_soon_sold_out: 'N',
is_special: 'N',
market_price: 359,
max_sort_id: 8,
middle_sort_id: 66,
product_id: 373507,
product_name: '5CM 字母印花领带',
product_skn: 51206745,
sales_num: 0,
sales_phrase: '春潮新势力',
sales_price: 359,
shelve_time: 1457140500,
small_sort_id: 77,
status: 1,
stock_number: 25,
storage_num: 25,
tags: [
'is_new'
],
vip1_price: 341.05,
vip2_price: 323.1,
vip3_price: 315.92,
vip_discount_type: 1,
vip_price: 0
billNo: 'x00001',
terms: 3,
currTerm: 1,
unExpireDays: -3,
billInfo: '三叶草运动休闲鞋',
currAmt: '845.00',
currNoFeeAmt: '840.00',
currFee: '5.00'
}, {
brand_domain: '5cm',
brand_id: 4,
brand_name: '5CM',
cn_alphabet: '5CMPeiShi5CXTIT0603S66',
default_images: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
edit_time: 1456119581,
gender: '1',
goods_list: [
{
color_code: '333333',
color_id: '2',
color_name: '黑色',
color_value: '',
cover_1: '',
cover_2: '',
goods_id: '476153',
images_url: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
is_default: 'N',
product_skc: '346702',
status: '1'
billNo: 'x00001',
terms: 3,
currTerm: 2,
unExpireDays: 10,
billInfo: '三叶草运动休闲鞋',
currAmt: '840.00',
currNoFeeAmt: '840.00',
currFee: '0.00'
}
],
is_advance: 'N',
is_discount: 'N',
is_limited: 'N',
is_new: 'Y',
is_outlets: 2,
is_promotion: 104,
is_soon_sold_out: 'N',
is_special: 'N',
market_price: 359,
max_sort_id: 8,
middle_sort_id: 66,
product_id: 373513,
product_name: '5CM 字母印花领结',
product_skn: 51206748,
sales_num: 0,
sales_phrase: '春潮新势力',
sales_price: 359,
shelve_time: 1457140500,
small_sort_id: 77,
status: 1,
stock_number: 19,
storage_num: 19,
tags: [
'is_new'
],
vip1_price: 341.05,
vip2_price: 323.1,
vip3_price: 315.92,
vip_discount_type: 1,
vip_price: 0
}
],
rec_id: '00f185af-936a-4053-97f8-1c802cb91e8b'
pageNo: 1,
pageTotal: 1,
total: 2
},
md5: 'ace93d0f598db0bebec30234381c0cbf',
message: 'Product List.'
md5: 'c1d725306fb09dcbf504776d276521cb',
message: 'ok'
};
if (result && result.code === 200) {
return _processAmtList(result.data.amtList);
} else {
logger.error('get queryAmtList data return code is not 200');
return '';
}
});
};
// 分期专享推荐商品
const getSearchIntallment = () => {
return api.post('', {
// method: 'app.search.instalment',
method: 'app.search.newProduct',
limit: '50',
order: 's_t_desc'
}, {
cache: true
}).then((result) => {
// result = {
// alg: 'SALT_MD5',
// code: 200,
// data: {
// product_list: [
// {
// brand_domain: '5cm',
// brand_id: 4,
// brand_name: '5CM',
// cn_alphabet: '5CMPeiShi5CXTIT0600S66',
// default_images: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// edit_time: 1456119592,
// gender: '1',
// goods_list: [
// {
// color_code: '333333',
// color_id: '2',
// color_name: '黑色',
// color_value: '',
// cover_1: '',
// cover_2: '',
// goods_id: '476147',
// images_url: 'http://img13.static.yhbimg.com/goodsimg/2016/02/21/07/026d569b2db7d9ce9339a79bcb3fe420f8.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// is_default: 'N',
// product_skc: '346699',
// status: '1'
// }
// ],
// is_advance: 'N',
// is_discount: 'N',
// is_limited: 'N',
// is_new: 'Y',
// is_outlets: 2,
// is_promotion: 104,
// is_soon_sold_out: 'N',
// is_special: 'N',
// market_price: 359,
// max_sort_id: 8,
// middle_sort_id: 66,
// product_id: 373507,
// product_name: '5CM 字母印花领带',
// product_skn: 51206745,
// sales_num: 0,
// sales_phrase: '春潮新势力',
// sales_price: 359,
// shelve_time: 1457140500,
// small_sort_id: 77,
// status: 1,
// stock_number: 25,
// storage_num: 25,
// tags: [
// 'is_new'
// ],
// vip1_price: 341.05,
// vip2_price: 323.1,
// vip3_price: 315.92,
// vip_discount_type: 1,
// vip_price: 0
// }, {
// brand_domain: '5cm',
// brand_id: 4,
// brand_name: '5CM',
// cn_alphabet: '5CMPeiShi5CXTIT0603S66',
// default_images: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// edit_time: 1456119581,
// gender: '1',
// goods_list: [
// {
// color_code: '333333',
// color_id: '2',
// color_name: '黑色',
// color_value: '',
// cover_1: '',
// cover_2: '',
// goods_id: '476153',
// images_url: 'http://img12.static.yhbimg.com/goodsimg/2016/02/21/07/02d463c9f8945ad14f824e8ba35efb9555.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// is_default: 'N',
// product_skc: '346702',
// status: '1'
// }
// ],
// is_advance: 'N',
// is_discount: 'N',
// is_limited: 'N',
// is_new: 'Y',
// is_outlets: 2,
// is_promotion: 104,
// is_soon_sold_out: 'N',
// is_special: 'N',
// market_price: 359,
// max_sort_id: 8,
// middle_sort_id: 66,
// product_id: 373513,
// product_name: '5CM 字母印花领结',
// product_skn: 51206748,
// sales_num: 0,
// sales_phrase: '春潮新势力',
// sales_price: 359,
// shelve_time: 1457140500,
// small_sort_id: 77,
// status: 1,
// stock_number: 19,
// storage_num: 19,
// tags: [
// 'is_new'
// ],
// vip1_price: 341.05,
// vip2_price: 323.1,
// vip3_price: 315.92,
// vip_discount_type: 1,
// vip_price: 0
// }
// ],
// rec_id: '00f185af-936a-4053-97f8-1c802cb91e8b'
// },
// md5: 'ace93d0f598db0bebec30234381c0cbf',
// message: 'Product List.'
// };
if (result && result.code === 200) {
return productProcess.processProductList(result.data.product_list);
} else {
logger.error('get instalment promote goods return is not 200');
logger.error('get instalment promote goods return code is not 200');
return '';
}
});
... ... @@ -264,5 +361,7 @@ module.exports = {
getQueryAmtInfo,
getSearchIntallment,
sendVerifyCode,
activateService
activateService,
getResources,
getQueryAmtList
};
... ...
... ... @@ -17,4 +17,6 @@ router.get('/installment/index', installment.index);// 开通分期首页
router.get('/installment/review', installment.review); // 开通分期首页
router.get('/installment/starting-service', installment.startingService); // 分期付款开通
router.get('/installment/starting-service/verify-code', installment.verifyCode);
router.get('/installment/overdue', installment.overdueList); // 逾期未还款列表
router.get('/installment/7daylist', installment.sevenDayList); // 7日待还款列表
module.exports = router;
... ...
... ... @@ -19,7 +19,7 @@
</li>
</ul>
<div class="open-btn">立即开通</div>
<a href="/home/installment/starting-service" class="open-btn">立即开通</a>
</div>
{{# installmentOnly}}
... ... @@ -27,15 +27,17 @@
{{/ installmentOnly}}
{{else}}
<div class="detail-tab">
<a href="/home/installment/index?query=repay"><span class="{{#if isRepay}}on{{/if}}">待还款金额</span></a>
<a href="/home/installment/index?query=usable"><span class="{{#if isUnable}}on{{/if}}">可用额度</span></a>
<span class="on is-repay">待还款金额</span>
<span class="is-usable">可用额度</span>
</div>
{{#if isRepay}}
<div class="repay installment-cont">
<div class="repay-area detail-bg">
<p class="detail-txt1">近7日代还款</p>
<p class="detail-txt1">¥<span class="detail-txt2">{{round dayAmt}}</span></p>
<p class="detail-txt3">您有¥{{round dayAmt}}已逾期3天,点击<a href="">查看详情</a></p>
<a href="" class="see-btn">明细</a>
{{#if isOverdue}}
<p class="detail-txt3">您有¥{{round dayAmt}}已逾期,点击<a href="/home/installment/overdue">查看详情</a></p>
{{/if}}
<a href="/home/installment/7daylist" class="see-btn">明细</a>
</div>
<ul class="group-list">
<li><a href="">本月待还金额:<div class="iconfont"><span class="list-r-txt">¥{{monthAmt}}</span> &#xe604;</div></a></li>
... ... @@ -47,19 +49,18 @@
<ul class="group-list">
<li><a href="">账户管理:<span class="iconfont">&#xe604;</span></a></li>
</ul>
{{/if}}
{{#if isUnable}}
</div>
<div class="usable installment-cont">
<div class="usable-area detail-bg">
{{#replayStatus}}<div class="replay-status">{{.}}</div>{{/replayStatus}}
<p class="detail-txt1">可用额度</p>
<p class="detail-txt1">¥<span class="detail-txt2">{{round currCredit}}</span></p>
<p class="detail-txt1">总额度:¥{{round initCredit}}</p>
<p class="detail-txt1">¥<span class="detail-txt2">{{round currCreditLimit}}</span></p>
<p class="detail-txt1">总额度:¥{{round initCreditLimit}}</p>
<a href="" class="terms">服务条款</a>
</div>
{{# installmentOnly}}
{{> installment/installment-only}}
{{/ installmentOnly}}
{{/if}}
</div>
{{/if}}
</div>
... ...
<div class="repayment-list-page">
<ul class="repay-list">
{{#each repaymentList}}
<li>
<span></span>
<div class="cont">
<p>¥{{round currNoFeeAmt}}</p>
<p>【全{{stage}}期】{{billInfo}}</p>
</div>
<div class="list-right">
{{#if isOverdue}}
<div class="color-r">逾期{{day}}<span class="iconfont">&#xe639;</span></div>
{{else}}
剩余{{day}}
{{/if}}
<span class="iconfont">&#xe604;</span>
</div>
</li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -15,8 +15,12 @@ module.exports = {
port: 6001,
siteUrl: '//m.yohobuy.com',
domains: {
api: 'http://devapi.yoho.cn:58078/',
service: 'http://devservice.yoho.cn:58077/'
// api: 'http://devapi.yoho.cn:58078/',
// service: 'http://devservice.yoho.cn:58077/'
api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/'
service: 'http://testservice.yoho.cn:28077'
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -27,3 +27,8 @@ if ($('.installment-bg').length > 0) {
background: '#efefef'
});
}
$('.detail-tab span').on('click', function() {
$(this).addClass('on').siblings().removeClass('on');
$('.installment-cont').hide().eq($(this).index()).show();
});
... ...
@import "installment";
@import "starting-service";
@import "repayment-list"
... ...
... ... @@ -159,7 +159,7 @@
color: #fff;
}
a:first-child span {
span:first-child {
border-right: 1px solid #fff;
}
}
... ... @@ -182,7 +182,7 @@
.detail-txt3 {
color: #ce051d;
font-size: 14px;
font-size: 22px;
a {
color: #ce051d;
... ... @@ -236,6 +236,10 @@
height: 345px;
}
.usable {
display: none;
}
.usable-area {
position: relative;
height: 510px;
... ...
.repayment-list-page {
.repay-list li {
height: 120px;
background: #fff;
.cont {
width: 370px;
overflow: hidden;
height: 120px;
float: left;
}
.list-right {
float: right;
color: #b0b0b0;
}
.color-r {
color: #d0021b;
}
}
}
\ No newline at end of file
... ...