|
@@ -11,15 +11,15 @@ const serviceAPI = global.yoho.ServiceAPI; |
|
@@ -11,15 +11,15 @@ const serviceAPI = global.yoho.ServiceAPI; |
11
|
const utils = '../../../utils';
|
11
|
const utils = '../../../utils';
|
12
|
const productProcess = require(`${utils}/product-process`);
|
12
|
const productProcess = require(`${utils}/product-process`);
|
13
|
const _ = require('lodash');
|
13
|
const _ = require('lodash');
|
|
|
14
|
+const ApipayConfig = global.yoho.config.alipayConfig;
|
|
|
15
|
+const md5 = require('md5');
|
14
|
|
16
|
|
15
|
// 资源位
|
17
|
// 资源位
|
16
|
const _getBanner = (param) => {
|
18
|
const _getBanner = (param) => {
|
17
|
return serviceAPI.get('operations/api/v5/resource/get', {
|
19
|
return serviceAPI.get('operations/api/v5/resource/get', {
|
18
|
content_code: param.contentCode,
|
20
|
content_code: param.contentCode,
|
19
|
platform: 'iphone'
|
21
|
platform: 'iphone'
|
20
|
- }, {
|
|
|
21
|
- code: 200
|
|
|
22
|
- }).then((result) => {
|
22
|
+ }, { code: 200 }).then((result) => {
|
23
|
|
23
|
|
24
|
result = result.data;
|
24
|
result = result.data;
|
25
|
|
25
|
|
|
@@ -36,9 +36,7 @@ const _getOthersBuy2 = (param) => { |
|
@@ -36,9 +36,7 @@ const _getOthersBuy2 = (param) => { |
36
|
rec_pos: '100005',
|
36
|
rec_pos: '100005',
|
37
|
limit: 2,
|
37
|
limit: 2,
|
38
|
client_id: param.client_id
|
38
|
client_id: param.client_id
|
39
|
- }, {
|
|
|
40
|
- code: 200
|
|
|
41
|
- }).then((result) => {
|
39
|
+ }, { code: 200 }).then((result) => {
|
42
|
|
40
|
|
43
|
if (result && result.data && result.data.product_list) {
|
41
|
if (result && result.data && result.data.product_list) {
|
44
|
return productProcess.processProductList(result.data.product_list);
|
42
|
return productProcess.processProductList(result.data.product_list);
|
|
@@ -53,9 +51,7 @@ const _getOtherDetail = (param) => { |
|
@@ -53,9 +51,7 @@ const _getOtherDetail = (param) => { |
53
|
method: 'app.SpaceOrders.detail',
|
51
|
method: 'app.SpaceOrders.detail',
|
54
|
uid: param.uid,
|
52
|
uid: param.uid,
|
55
|
order_code: param.orderCode
|
53
|
order_code: param.orderCode
|
56
|
- }, {
|
|
|
57
|
- code: 200
|
|
|
58
|
- }).then((result) => {
|
54
|
+ }, { code: 20 }).then((result) => {
|
59
|
|
55
|
|
60
|
return result;
|
56
|
return result;
|
61
|
|
57
|
|
|
@@ -74,7 +70,7 @@ const _getOthersBuy = (param) => { |
|
@@ -74,7 +70,7 @@ const _getOthersBuy = (param) => { |
74
|
goodSkn = result[0].data.order_goods[0].product_skn;
|
70
|
goodSkn = result[0].data.order_goods[0].product_skn;
|
75
|
}
|
71
|
}
|
76
|
|
72
|
|
77
|
- return _getOthersBuy2(Object.assign(param, {skn: goodSkn}));
|
73
|
+ return _getOthersBuy2(Object.assign(param, { skn: goodSkn }));
|
78
|
|
74
|
|
79
|
}).then((result) => {
|
75
|
}).then((result) => {
|
80
|
|
76
|
|
|
@@ -125,6 +121,69 @@ const getPayCod = (param) => { |
|
@@ -125,6 +121,69 @@ const getPayCod = (param) => { |
125
|
});
|
121
|
});
|
126
|
};
|
122
|
};
|
127
|
|
123
|
|
|
|
124
|
+const _raw = (args) => {
|
|
|
125
|
+ let keys = Object.keys(args);
|
|
|
126
|
+
|
|
|
127
|
+ keys = keys.filter(k => {
|
|
|
128
|
+ let keyValueCheck =
|
|
|
129
|
+ k === 'sign' ||
|
|
|
130
|
+ k === 'sign_type' ||
|
|
|
131
|
+ k === 'code' ||
|
|
|
132
|
+ args[k] === '' ||
|
|
|
133
|
+ args[k] === 'undefined';
|
|
|
134
|
+
|
|
|
135
|
+ return !keyValueCheck;
|
|
|
136
|
+ }).sort();
|
|
|
137
|
+
|
|
|
138
|
+ return keys.map(k => {
|
|
|
139
|
+ return k + '=' + decodeURI(args[k]);
|
|
|
140
|
+ }).join('&');
|
|
|
141
|
+};
|
|
|
142
|
+
|
|
|
143
|
+/**
|
|
|
144
|
+ * 验证返回结果的正确性
|
|
|
145
|
+ */
|
|
|
146
|
+const _checkResponse = (params) => {
|
|
|
147
|
+ if (!params.sign) {
|
|
|
148
|
+ return false;
|
|
|
149
|
+ }
|
|
|
150
|
+ let rawResult = _raw(params);
|
|
|
151
|
+ let sign = rawResult + ApipayConfig.alipayKey;
|
|
|
152
|
+ let md5Result = md5(sign);
|
|
|
153
|
+
|
|
|
154
|
+ return md5Result === params.sign;
|
|
|
155
|
+};
|
|
|
156
|
+
|
|
|
157
|
+
|
|
|
158
|
+/**
|
|
|
159
|
+ * 支付宝支付结果校验
|
|
|
160
|
+ */
|
|
|
161
|
+const alipayResultVerify = (params) => {
|
|
|
162
|
+ let checkResult = {};
|
|
|
163
|
+
|
|
|
164
|
+ if (params.q) {
|
|
|
165
|
+ delete params.q;
|
|
|
166
|
+ }
|
|
|
167
|
+
|
|
|
168
|
+ if (!_checkResponse(params)) {
|
|
|
169
|
+ checkResult.payResult = false;
|
|
|
170
|
+ } else {
|
|
|
171
|
+ _.assign(checkResult, {
|
|
|
172
|
+ bankName: '',
|
|
|
173
|
+ orderCode: params.out_trade_no,
|
|
|
174
|
+ payResult: params.trade_status === 'TRADE_SUCCESS',
|
|
|
175
|
+ payTime: params.gmt_payment || '',
|
|
|
176
|
+ totalFee: params.total_fee,
|
|
|
177
|
+ resultMsg: params.notify_type,
|
|
|
178
|
+ payOrderCode: params.out_trade_no,
|
|
|
179
|
+ tradeNo: params.trade_no,
|
|
|
180
|
+ bankBillNo: ''
|
|
|
181
|
+ });
|
|
|
182
|
+ }
|
|
|
183
|
+
|
|
|
184
|
+ return checkResult;
|
|
|
185
|
+};
|
|
|
186
|
+
|
128
|
// 支付宝支付
|
187
|
// 支付宝支付
|
129
|
const getPayAli = (param) => {
|
188
|
const getPayAli = (param) => {
|
130
|
return api.all([
|
189
|
return api.all([
|
|
@@ -171,5 +230,6 @@ const getPayAli = (param) => { |
|
@@ -171,5 +230,6 @@ const getPayAli = (param) => { |
171
|
|
230
|
|
172
|
module.exports = {
|
231
|
module.exports = {
|
173
|
getPayCod,
|
232
|
getPayCod,
|
174
|
- getPayAli
|
233
|
+ getPayAli,
|
|
|
234
|
+ alipayResultVerify
|
175
|
}; |
235
|
}; |