pay-process.js
1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
// 支付方式
const PAYMENTS = {
ALIPAY: 18,
WECHAT: 22
};
/**
* 支付相关的数据处理函数
*/
const payTool = {
/**
* 支持的支付方式列表
* @returns {[*,*]}
*/
payAppInfo(orderCode) {
return [{
appIcon: '',
payLink: helpers.urlFormat('/cart/index/new/pay', {
payment: PAYMENTS.ALIPAY + '_platform',
order_code: orderCode
}),
appId: 'alipay',
app: '支付宝支付',
hint: '支付宝钱包支付',
subHint: '推荐支付宝用户使用'
}, {
appIcon: '',
payLink: '',
appId: 'weixin',
app: '微信支付',
hint: '推荐使用',
subHint: ''
}];
},
/**
* 计算购买商品总数量
* @param goodsArray
* @returns {number}
* @private
*/
calBuyNumCount(goodsArray) {
let buyNumCount = 0;
if (_.isArray(goodsArray)) {
_.forEach(goodsArray, value => {
buyNumCount = value.buy_number ? parseInt(value.buy_number, 10) : 0;
});
}
return buyNumCount;
}
};
module.exports = {
PAYMENTS,
payTool
};