Authored by 郝肖肖

添加银行支付方式

... ... @@ -26,7 +26,7 @@ const online = (req, res, next) => {
let uid = req.user.uid;
if (!integerTest.test(orderCode)) {
//不合法订单号
// 不合法订单号
return next();
}
... ... @@ -37,7 +37,7 @@ const online = (req, res, next) => {
let amount = _.toNumber(order.paymentAmount);
if (!order.orderCode) {
//不合法订单号
// 不合法订单号
return next();
}
... ... @@ -91,7 +91,7 @@ const toPay = (req, res, next) => {
let user = req.user;
if (!integerTest.test(orderCode)) {
//不合法订单号
// 不合法订单号
return next();
}
... ... @@ -125,7 +125,7 @@ const weixinQr = (req, res, next) => {
let uid = req.user.uid;
if (!integerTest.test(code)) {
//不合法订单号
// 不合法订单号
return next();
}
... ...
... ... @@ -4,7 +4,7 @@
'use strict';
const Bank = {
getList: () => {
getList() {
return {
BOCB2C: {
name: '中国银行',
... ...
/**
* Created by TaoHuang on 2016/7/18.
*/
'use strict';
const Bank = {
getList: () => {
return {
{
id: 12,
name: '中国银行',
value: 'BOCB2C',
ico: '//static.yohobuy.com/images/pay/icon/zhongguo.png'
},
{
id: 12,
name: '中国农业银行',
value: 'ABC',
ico: '//static.yohobuy.com/images/pay/icon/nongye.png'
},
{
id: 12,
name: '平安银行',
value: 'SPABANK',
ico: '//static.yohobuy.com/images/pay/icon/pingan.png'
},
{
id: 12,
name: '中国民生银行',
value: 'CMBC',
ico: '//static.yohobuy.com/images/pay/icon/minsheng.png'
},
{
id: 12,
name: '中国工商银行',
value: 'ICBCB2C',
ico: '//static.yohobuy.com/images/pay/icon/gongshang.png'
},
{
id: 12,
name: '浦发银行',
value: 'SPDB',
ico: '//static.yohobuy.com/images/pay/icon/pufa.png'
},
{
id: 12,
name: '北京农商银行',
value: 'BJRCB',
ico: '//static.yohobuy.com/images/pay/icon/beijingnongshang.png'
},
{
id: 12,
name: '杭州银行',
value: 'HZCBB2C',
ico: '//static.yohobuy.com/images/pay/icon/hangzhou.png'
},
{
id: 12,
name: '招商银行',
value: 'CMB',
ico: '//static.yohobuy.com/images/pay/icon/zhaoshang.png'
},
{
id: 12,
name: '兴业银行',
value: 'CIB',
ico: '//static.yohobuy.com/images/pay/icon/xingye.png'
},
{
id: 12,
name: '富滇银行',
value: 'FDB',
ico: '//static.yohobuy.com/images/pay/icon/fudian.png'
},
{
id: 12,
name: '中国光大银行',
value: 'CEBDEBIT',
ico: '//static.yohobuy.com/images/pay/icon/guangda.png'
},
{
id: 12,
name: '中国建设银行',
value: 'CCB',
ico: '//static.yohobuy.com/images/pay/icon/zhongguojianshe.png'
},
{
id: 12,
name: '广发银行',
value: 'GDB',
ico: '//static.yohobuy.com/images/pay/icon/guangfa.png'
},
{
id: 12,
name: '中国邮政储蓄',
value: 'POSTGC',
ico: '//static.yohobuy.com/images/pay/icon/zhongguoyouzhengchuxu.png'
},
{
id: 12,
name: '上海银行',
value: 'SHBANK',
ico: '//static.yohobuy.com/images/pay/icon/shanghai.png'
},
{
id: 12,
name: '宁波银行',
value: 'NBBANK',
ico: '//static.yohobuy.com/images/pay/icon/ningbo.png'
}
};
}
};
module.exports = Bank;
... ...
... ... @@ -8,14 +8,14 @@
const api = global.yoho.API;
//获取支付宝等平台支付方式列表
// 获取支付宝等平台支付方式列表
const getPayProvider = () => {
return api.get('', {
method: 'web.SpaceOrders.getPaymentList'
});
};
//获取单个支付方式相关详细信息
// 获取单个支付方式相关详细信息
const getPaymentInfo = (id) => {
return api.get('', {
method: 'web.SpaceOrders.getPaymentById',
... ... @@ -23,7 +23,7 @@ const getPaymentInfo = (id) => {
});
};
/*获取上次使用的支付方式*/
/* 获取上次使用的支付方式*/
const getBankByOrder = (code) => {
return api.get('', {
method: 'web.SpaceOrders.getOrderPayBank',
... ... @@ -31,7 +31,7 @@ const getBankByOrder = (code) => {
});
};
/*记录支付方式*/
/* 记录支付方式*/
const setOrderPayBank = (code, payment, bankCode) => {
return api.get('', {
method: 'web.SpaceOrders.addOrderPayBank',
... ... @@ -41,7 +41,7 @@ const setOrderPayBank = (code, payment, bankCode) => {
});
};
/*更改支付方式*/
/* 更改支付方式*/
const updateOrderPayBank = (code, payment, bankCode) => {
return api.get('', {
method: 'web.SpaceOrders.modifyOrderPayBank',
... ... @@ -51,7 +51,7 @@ const updateOrderPayBank = (code, payment, bankCode) => {
});
};
/*发送支付确认*/
/* 发送支付确认*/
const sendPayConfirm = (code, payment, uid) => {
return api.get('', {
method: 'app.SpaceOrders.payConfirm',
... ... @@ -61,7 +61,7 @@ const sendPayConfirm = (code, payment, uid) => {
});
};
/*选择支付,校验时间间隔,插入数据,为用户取消订单做准备<用户支付取消订单,10分钟间隔>。*/
/* 选择支付,校验时间间隔,插入数据,为用户取消订单做准备<用户支付取消订单,10分钟间隔>。*/
const savePrePayInfo = (code, payment, uid) => {
return api.get('', {
method: 'app.order.savePrePayInfo',
... ...
... ... @@ -12,6 +12,7 @@ const Promise = require('bluebird');
const co = Promise.coroutine;
const camelCase = global.yoho.camelCase;
const OrderData = require('./order');
const payHelpersBank = require('./../helpers/bank');
const logger = global.yoho.logger;
... ... @@ -28,34 +29,48 @@ const payments = {
*/
const getOnlinePayProvider = () => {
return api.getPayProvider().then(result => {
let payPattern = [], nav = [];
if (!(result.code && result.code === 200)) {
return [];
return payPattern;
}
let online = _(result.data)
.filter(i => _.includes(_.values(payments), i.id))
.map(i => {
return {
id: i.id,
name: i.payName,
img: i.payIcon,
selected: i.id === payments.alipay
};
})
.value();
let nav = [
{
id: 'onlinePay',
name: '支付宝等平台',
selected: true
// 处理支付宝等平台数据
_.each(result.data, val => {
// 去除icon为空的
if (_.isEmpty(val.payIcon)) {
return true;
}
];
return {
type: nav,
onlinePay: online
};
nav.push({
id: val.id,
name: val.payName,
value: val.id + '_platform',
img: val.payIcon
});
});
payPattern.push({
name: '支付宝等平台',
children: nav
});
// 处理使用银行卡数据
nav = [];
_.each(payHelpersBank.getList(), (val, key) => {
nav.push({
id: 12,
name: val.name,
value: '12_' + key,
img: val.ico
});
});
payPattern.push({
name: '使用银行卡',
selected: true,
children: nav
});
return payPattern;
});
};
... ...
... ... @@ -44,26 +44,27 @@
</div>
{{/order}}
{{# pay}}
{{#if pay}}
<div class="pay-type">
<div class="pay-nav">
<ul class="tabs clearfix">
{{#each type}}
<li{{#if selected}} class="active"{{/if}} data-type="{{id}}">{{name}}</li>
{{/each}}
{{# pay}}
<li{{#if selected}} class="active"{{/if}}>{{name}}</li>
{{/pay}}
</ul>
</div>
<div id="online">
{{# onlinePay}}
<div class="pay-type-icon online-pay{{#if selected}} active{{/if}}" data-name="{{name}}" data-id="{{id}}">
<img src="{{img}}">
<span class="choose-tag iconfont">&#xe63b;</span>
</div>
{{/ onlinePay}}
</div>
{{# pay}}
<div class="pay-icon {{#unless selected}} hide{{/unless}}">
{{# children}}
<div class="pay-type-icon online-pay{{#if selected}} active{{/if}}" data-name="{{name}}" data-id="{{id}}" data-value="{{value}}">
<img src="{{img}}">
<span class="choose-tag iconfont">&#xe63b;</span>
</div>
{{/children}}
</div>
{{/pay}}
</div>
{{/ pay}}
{{/if}}
<div class="pay-ctrl">
<span id="go-pay-btn" class="btn btn-shape right" data-order="{{order.orderCode}}"><em id="pay-type-name">支付宝</em>支付</span>
... ...
... ... @@ -9,6 +9,9 @@ var $orderDetail = $('.order-detail'),
var Dialog = require('../plugins/dialog');
var $payTypeIcon = $('.pay-type-icon'),
$payIcon = $('.pay-icon');
var tpl = '<div class="pay-page-tips">' +
'<h3>请您在新打开的页面完成付款</h3>' +
'<p>付款完成前请不要关闭此窗口</p>' +
... ... @@ -40,7 +43,7 @@ $orderDetailCtrl.click(function() {
$orderDetail.slideToggle('slow');
});
$('.pay-type-icon').click(function() {
$payTypeIcon.click(function() {
var $this = $(this);
if ($this.hasClass('active')) {
... ... @@ -48,12 +51,24 @@ $('.pay-type-icon').click(function() {
}
// 切换选中状态
$this.siblings('.active').removeClass('active');
$payTypeIcon.removeClass('active');
$this.addClass('active');
$('#pay-type-name').text($this.data('name'));
});
// 切换支付方式tabs 委托事件
$('.pay-nav .tabs').click(function(event) {
var $li = $(event.target).closest('li');
if ($li.length <= 0) {
return true;
}
$li.addClass('active').siblings('li').removeClass('active');
$payIcon.eq($li.index()).removeClass('hide').siblings('.pay-icon').addClass('hide');
});
function showDialog() {
infoDaialog.show();
... ...