Authored by 王水玲

Merge branch 'release/2.0' of git.yoho.cn:fe/yoho-blk into release/2.0

... ... @@ -20,6 +20,10 @@ const Alibank = {
pay(user, order, param, protocol) {
let payParams = JSON.parse(param.payParams);
let extraParam = JSON.stringify({
sign_id_ext: user.uid,
defaultbank: param.bankCode || ''
});
let params = {
service: 'create_direct_pay_by_user',
... ... @@ -34,8 +38,7 @@ const Alibank = {
payment_type: '1',
defaultbank: param.bankCode,
seller_email: payParams.merchant_other_code,
sign_id_ext: user.uid,
sign_name_ext: user.username
extra_common_param: extraParam
};
// TODO 防钓鱼配置,参考php
... ... @@ -52,9 +55,10 @@ const Alibank = {
},
notify(data, param) {
let payParams = JSON.parse(param.payParams);
let outTradeNos = data.out_trade_no && data.out_trade_no.split('_');
let orderCode = parseInt(outTradeNos[0], 10);
let bankName = outTradeNos[1] && payHelpersBank.getList()[outTradeNos[1]].name || '';
let orderCode = parseInt(data.out_trade_no, 10);
let extraParam = data.extra_common_param && JSON.parse(data.extra_common_param) || {};
let bankName = payHelpersBank.getList()[extraParam.defaultbank] &&
payHelpersBank.getList()[extraParam.defaultbank].name || '';
logger.info(`Alibank notify, params = ${JSON.stringify(data)}`);
... ... @@ -70,7 +74,7 @@ const Alibank = {
resultMsg: data.notify_type,
payOrderCode: orderCode,
tradeNo: data.trade_no,
bankBillNo: ''
bankBillNo: data.bank_seq_no || ''
};
}
},
... ...
... ... @@ -19,7 +19,10 @@ const Alipay = {
pay(user, order, param, protocol) {
let payParams = JSON.parse(param.payParams);
let extraParam = JSON.stringify({
sign_id_ext: user.uid,
defaultbank: param.bankCode || ''
});
let params = {
service: 'create_direct_pay_by_user',
partner: payParams.merchant_id,
... ... @@ -32,8 +35,7 @@ const Alipay = {
total_fee: order.payment_amount,
payment_type: '1',
seller_email: payParams.merchant_other_code,
sign_id_ext: user.uid,
sign_name_ext: user.username
extra_common_param: extraParam
};
// TODO 防钓鱼配置,参考php
... ...
... ... @@ -14,7 +14,7 @@ const Sign = {
}).sort();
return keys.map(k => {
return k + '=' + args[k];
return k + '=' + decodeURI(args[k]);
}).join('&');
},
... ... @@ -26,7 +26,7 @@ const Sign = {
}).sort();
return keys.map(k => {
return k.toLowerCase() + '=' + encodeURIComponent(args[k]);
return k.toLowerCase() + '=' + encodeURI(args[k]);
}).join('&');
}
};
... ...
... ... @@ -90,14 +90,12 @@ const Payment = {
beforePay(user, order, method, bankCode) {
return Promise.all([
OrderData.updateOrderPayment(order.order_code, method, user.uid),
PayData.savePrePayInfo(order.order_code, method, user.uid),
PayData.getBankByOrder(order.order_code)
]).then(result => {
let paymentRecord = result[0];
let prePayResult = result[1];
let bankRecord = result[2];
let bankRecord = result[1];
if (!paymentRecord || paymentRecord.code !== 200 || !prePayResult || prePayResult.code !== 200) {
if (!paymentRecord || paymentRecord.code !== 200) {
let message = paymentRecord && paymentRecord.message ? paymentRecord.message : '系统繁忙,请稍后再试';
return {code: 400, message: message};
... ...
... ... @@ -61,16 +61,6 @@ const sendPayConfirm = (code, payment, uid) => {
});
};
/* 选择支付,校验时间间隔,插入数据,为用户取消订单做准备<用户支付取消订单,10分钟间隔>。*/
const savePrePayInfo = (code, payment, uid) => {
return api.get('', {
method: 'app.order.savePrePayInfo',
orderCode: code,
payment: payment,
uid: uid
});
};
const sendMessage = (mobile, template, codes) => {
return api.get('', {
method: 'app.message.sendMsg',
... ... @@ -87,6 +77,5 @@ module.exports = {
setOrderPayBank,
updateOrderPayBank,
sendPayConfirm,
savePrePayInfo,
sendMessage
};
... ...
... ... @@ -7,7 +7,7 @@
'use strict';
const api = require('./pay-api');
const payApi = require('./pay-api');
const Promise = require('bluebird');
const co = Promise.coroutine;
const camelCase = global.yoho.camelCase;
... ... @@ -29,7 +29,7 @@ const payments = {
* @returns {*|Promise.<TResult>}
*/
const getOnlinePayProvider = () => {
return api.getPayProvider().then(result => {
return payApi.getPayProvider().then(result => {
let payPattern = [], nav = [];
if (!(result.code && result.code === 200)) {
... ... @@ -95,7 +95,7 @@ const getOrderInfo = (uid, code) => {
*/
const getBankByOrder = (id) => {
return co(function *() {
let data = yield api.getBankByOrder(id);
let data = yield payApi.getBankByOrder(id);
if (data && data.code === 200 && data.data) {
return camelCase(data.data);
... ... @@ -141,7 +141,7 @@ const getPayInfo = (uid, code) => {
*/
const getPaymentInfo = (id) => {
return co(function *() {
let data = yield api.getPaymentInfo(id);
let data = yield payApi.getPaymentInfo(id);
if (data && data.code === 200 && data.data) {
return camelCase(data.data);
... ... @@ -158,7 +158,7 @@ const getPaymentInfo = (id) => {
*/
const setOrderPayBank = (code, payment, bankCode) => {
return co(function *() {
let data = yield api.setOrderPayBank(code, payment, bankCode);
let data = yield payApi.setOrderPayBank(code, payment, bankCode);
return data;
})();
... ... @@ -172,28 +172,13 @@ const setOrderPayBank = (code, payment, bankCode) => {
*/
const updateOrderPayBank = (code, payment, bankCode) => {
return co(function *() {
let data = yield api.updateOrderPayBank(code, payment, bankCode);
let data = yield payApi.updateOrderPayBank(code, payment, bankCode);
return data;
})();
};
/**
* 选择支付,校验时间间隔,插入数据
* @param code
* @param payment
* @param uid
*/
const savePrePayInfo = (code, payment, uid) => {
return co(function *() {
let data = yield api.savePrePayInfo(code, payment, uid);
return data;
})();
};
/**
* 支付确认
* @param code
* @param payment
... ... @@ -201,7 +186,7 @@ const savePrePayInfo = (code, payment, uid) => {
*/
const sendPayConfirm = (code, payment, uid) => {
return co(function *() {
let data = yield api.sendPayConfirm(code, payment, uid);
let data = yield payApi.sendPayConfirm(code, payment, uid);
return data;
})();
... ... @@ -230,7 +215,7 @@ const procOrderData = (payResult, uid) => {
if (order.is_cancel === 'Y') {
logger.warn('front pay success but order is cancel.', {payResult: payResult, order: order});
api.sendMessage(order.mobile, 'error_sms', '支付成功,但订单已取消,订单号为' + orderCode);
payApi.sendMessage(order.mobile, 'error_sms', '支付成功,但订单已取消,订单号为' + orderCode);
return {code: 417, message: '支付成功,但订单已取消,需联系客服!'};
}
... ... @@ -271,7 +256,6 @@ module.exports = {
updateOrderPayBank,
sendPayConfirm,
procOrderData,
savePrePayInfo,
payments
};
... ...
... ... @@ -22,23 +22,17 @@ module.exports = {
},
cookieDomain: 'yohoblk.com',
domains: {
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.yohoops.org/',
// service: 'http://service.yoho.yohoops.org/',
// search: 'http://search.yohoops.org/yohosearch/'
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// search: 'http://search.yohoops.org/yohosearch/'
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://192.168.102.205:8080/gateway/',
service: 'http://192.168.102.205:8080/gateway/',
search: 'http://192.168.102.216:8080/yohosearch/'
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api.yoho.yohoops.org/',
// service: 'http://service.yoho.yohoops.org/',
// search: 'http://search.yohoops.org/yohosearch/'
// singleApi: 'http://single.yoho.cn/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// search: 'http://search.yohoops.org/yohosearch/'
... ...