Authored by 郭成尧

pay-ctx

@@ -6,479 +6,430 @@ @@ -6,479 +6,430 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -const api = global.yoho.API;  
10 const serviceAPI = global.yoho.ServiceAPI; 9 const serviceAPI = global.yoho.ServiceAPI;
11 const utils = '../../../utils'; 10 const utils = '../../../utils';
12 const productProcess = require(`${utils}/product-process`); 11 const productProcess = require(`${utils}/product-process`);
13 const ApipayConfig = global.yoho.config.alipayConfig; 12 const ApipayConfig = global.yoho.config.alipayConfig;
14 const md5 = require('yoho-md5'); 13 const md5 = require('yoho-md5');
15 -const payApi = require('./pay-api');  
16 -const helpers = global.yoho.helpers; 14 +const payApiModel = require('./pay-api');
17 const _ = require('lodash'); 15 const _ = require('lodash');
18 const co = require('bluebird').coroutine; 16 const co = require('bluebird').coroutine;
19 const logger = global.yoho.logger; 17 const logger = global.yoho.logger;
20 const stringProcess = require(`${global.utils}/string-process`); 18 const stringProcess = require(`${global.utils}/string-process`);
21 19
22 -// 支付方式  
23 -const payments = {  
24 - alipay: 18,  
25 - wechat: 22  
26 -};  
27 -  
28 -// 资源位  
29 -const _getBanner = (param) => {  
30 - return serviceAPI.get('operations/api/v5/resource/get', {  
31 - content_code: param.contentCode,  
32 - platform: 'iphone'  
33 - }, { code: 200 }).then((result) => {  
34 - result = result.data;  
35 -  
36 - return result;  
37 - });  
38 -};  
39 -  
40 -// 购买此商品的用户也购买了  
41 -const _getOthersBuy2 = (param) => {  
42 - return api.get('', {  
43 - method: 'app.recommend.purchased',  
44 - productSkn: param.skn,  
45 - udid: param.uid,  
46 - rec_pos: '100005',  
47 - limit: 2,  
48 - client_id: param.client_id  
49 - }, { code: 200 }).then((result) => {  
50 - if (result && result.data && result.data.product_list) {  
51 - return productProcess.processProductList(result.data.product_list);  
52 - }  
53 -  
54 - });  
55 -};  
56 -  
57 -// 订单信息  
58 -const _getOtherDetail = (param) => {  
59 - if (!param.uid || !param.orderCode || !stringProcess.isNumeric(param.orderCode)) {  
60 - return Promise.resolve({}); 20 +class payModel extends global.yoho.BaseModel {
  21 + constructor(ctx) {
  22 + super(ctx);
  23 + this.ctx = _.get(ctx, 'req.ctx');
61 } 24 }
62 25
63 - return api.get('', {  
64 - method: 'app.SpaceOrders.detail',  
65 - uid: param.uid,  
66 - order_code: param.orderCode,  
67 - session_key: param.sessionKey  
68 - }, { code: 200 }).then(result => {  
69 - return result;  
70 - });  
71 -};  
72 -  
73 -// 购买此商品的用户也购买了,要先从订单详情获取商品skn  
74 -const _getOthersBuy = (param) => {  
75 - return api.all([  
76 - _getOtherDetail(param)  
77 - ]).then((result) => {  
78 -  
79 - let goodSkn = '';  
80 -  
81 - if (result && result[0] && result[0].data && result[0].data.order_goods) {  
82 - goodSkn = result[0].data.order_goods[0].product_skn;  
83 - }  
84 -  
85 - return _getOthersBuy2(Object.assign(param, { skn: goodSkn })); 26 + // 资源位
  27 + _getBanner(param) {
  28 + return this.get({
  29 + api: serviceAPI,
  30 + url: 'operations/api/v5/resource/get',
  31 + data: {
  32 + content_code: param.contentCode,
  33 + platform: 'iphone'
  34 + },
  35 + param: { code: 200 }
  36 + }).then((result) => {
  37 + result = result.data;
86 38
87 - }).then((result) => { 39 + return result;
  40 + });
  41 + }
88 42
89 - return result;  
90 - });  
91 -}; 43 + // 购买此商品的用户也购买了
  44 + _getOthersBuy2(param) {
  45 + return this.get({data: {
  46 + method: 'app.recommend.purchased',
  47 + productSkn: param.skn,
  48 + udid: param.uid,
  49 + rec_pos: '100005',
  50 + limit: 2,
  51 + client_id: param.client_id
  52 + }, param: { code: 200 }}).then((result) => {
  53 + if (result && result.data && result.data.product_list) {
  54 + return productProcess.processProductList(result.data.product_list);
  55 + }
92 56
93 -/**  
94 - * 获取订单支付银行信息  
95 - * @param id  
96 - */  
97 -const getBankByOrder = (id) => {  
98 - return co(function* () {  
99 - let result = yield payApi.getBankByOrder(id); 57 + });
  58 + }
100 59
101 - if (result && result.code === 200 && result.data) {  
102 - return result.data; 60 + // 订单信息
  61 + getOtherDetail(param) {
  62 + if (!param.uid || !param.orderCode || !stringProcess.isNumeric(param.orderCode)) {
  63 + return Promise.resolve({});
103 } 64 }
104 - return {};  
105 - })();  
106 -};  
107 -  
108 -/**  
109 - * 设置订单支付银行  
110 - * @param code  
111 - * @param payment  
112 - * @param bankCode  
113 - */  
114 -const setOrderPayBank = (code, payment, bankCode) => {  
115 - return co(function* () {  
116 - let data = yield payApi.setOrderPayBank(code, payment, bankCode);  
117 -  
118 - return data;  
119 - })();  
120 -};  
121 65
122 -/**  
123 - * 获取支付方式的相关参数, (密钥等信息)  
124 - * @param id  
125 - */  
126 -const getPaymentInfo = (id) => {  
127 - return co(function* () {  
128 - let result = yield payApi.getPaymentInfo(id); 66 + return this.get({data: {
  67 + method: 'app.SpaceOrders.detail',
  68 + uid: param.uid,
  69 + order_code: param.orderCode,
  70 + session_key: param.sessionKey
  71 + }, param: { code: 200 }}).then(result => {
  72 + return result;
  73 + });
  74 + }
129 75
130 - if (result && result.code === 200 && result.data) {  
131 - return result.data;  
132 - }  
133 - return {};  
134 - })();  
135 -}; 76 + // 购买此商品的用户也购买了,要先从订单详情获取商品skn
  77 + _getOthersBuy(param) {
  78 + return Promise.all([
  79 + this.getOtherDetail(param)
  80 + ]).then((result) => {
136 81
137 -/**  
138 - * 支付确认  
139 - * @param code  
140 - * @param payment  
141 - * @param uid  
142 - */  
143 -const sendPayConfirm = (code, payment, uid) => {  
144 - return co(function* () {  
145 - let data = yield payApi.sendPayConfirm(code, payment, uid); 82 + let goodSkn = '';
146 83
147 - return data;  
148 - })();  
149 -}; 84 + if (result && result[0] && result[0].data && result[0].data.order_goods) {
  85 + goodSkn = result[0].data.order_goods[0].product_skn;
  86 + }
150 87
151 -/**  
152 - * 更新订单支付方式  
153 - * @param code  
154 - * @param payment  
155 - * @param uid  
156 - * @returns {*}  
157 - */  
158 -const updateOrderPayment = (code, payment, uid) => {  
159 - return api.get('', {  
160 - method: 'app.SpaceOrders.updateOrdersPaymentByCode',  
161 - order_code: code,  
162 - payment: payment,  
163 - uid: uid  
164 - });  
165 -}; 88 + return this._getOthersBuy2(Object.assign(param, { skn: goodSkn }));
166 89
167 -/**  
168 - * 更新订单支付银行  
169 - * @param code  
170 - * @param payment  
171 - * @param bankCode  
172 - */  
173 -const updateOrderPayBank = (code, payment, bankCode) => {  
174 - return co(function* () {  
175 - let data = yield payApi.updateOrderPayBank(code, payment, bankCode); 90 + }).then((result) => {
176 91
177 - return data;  
178 - })();  
179 -}; 92 + return result;
  93 + });
  94 + }
180 95
181 -/**  
182 - * 支付成功,前端回调时,处理订单信息  
183 - * @param payResult  
184 - * @param uid  
185 - * @param sessionKey  
186 - */  
187 -const procOrderData = (payResult, uid, sessionKey) => {  
188 - return co(function* () {  
189 - let orderCode = payResult.orderCode;  
190 - let result = { code: 400, message: '' }; 96 + /**
  97 + * 获取订单支付银行信息
  98 + * @param id
  99 + */
  100 + getBankByOrder(id) {
  101 + let self = this;
191 102
192 - if (!orderCode) {  
193 - result.message = '未查到订单信息,订单状态更新失败!';  
194 - return result;  
195 - } else {  
196 - let orderInfo = yield _getOtherDetail({  
197 - uid: uid,  
198 - orderCode: orderCode,  
199 - sessionKey: sessionKey  
200 - }); 103 + return co(function* () {
  104 + let result = yield self.ctx(payApiModel).getBankByOrder(id);
201 105
202 - if (orderInfo && orderInfo.data) {  
203 - let order = orderInfo.data;  
204 - let amount = order.payment_amount; 106 + if (result && result.code === 200 && result.data) {
  107 + return result.data;
  108 + }
  109 + return {};
  110 + })();
  111 + }
205 112
206 - if (order.is_cancel === 'Y') {  
207 - logger.warn('front pay success but order is cancel.', { payResult: payResult, order: order }); 113 + /**
  114 + * 设置订单支付银行
  115 + * @param code
  116 + * @param payment
  117 + * @param bankCode
  118 + */
  119 + setOrderPayBank(code, payment, bankCode) {
  120 + let self = this;
208 121
209 - payApi.sendMessage(order.mobile, 'error_sms', '支付成功,但订单已取消,订单号为' + orderCode);  
210 - return { code: 417, message: '支付成功,但订单已取消,需联系客服!' };  
211 - } 122 + return co(function* () {
  123 + let data = yield self.ctx(payApiModel).setOrderPayBank(code, payment, bankCode);
212 124
213 - if (order.payment_status === 'N') {  
214 - logger.warn('front pay success but may be notify fail');  
215 - } 125 + return data;
  126 + })();
  127 + }
216 128
217 - if (_.round(parseFloat(amount), 2) !== _.round(parseFloat(payResult.totalFee), 2)) {  
218 - logger.warn('front pay success but the amount is not same.', {  
219 - payResult: payResult, order: order  
220 - });  
221 - return {  
222 - code: 415,  
223 - message: '支付金额与订单金额不一致,订单状态更新失败!'  
224 - };  
225 - } 129 + /**
  130 + * 获取支付方式的相关参数, (密钥等信息)
  131 + * @param id
  132 + */
  133 + getPaymentInfo(id) {
  134 + let self = this;
226 135
227 - return {  
228 - code: 200,  
229 - message: '支付成功,请等待发货',  
230 - data: {  
231 - order: order  
232 - }  
233 - }; 136 + return co(function* () {
  137 + let result = yield self.ctx(payApiModel).getPaymentInfo(id);
234 138
235 - } else {  
236 - result.message = '未查到订单信息,订单状态更新失败!'; 139 + if (result && result.code === 200 && result.data) {
  140 + return result.data;
237 } 141 }
238 - } 142 + return {};
  143 + })();
  144 + }
239 145
240 - return result;  
241 - })();  
242 -}; 146 + /**
  147 + * 支付确认
  148 + * @param code
  149 + * @param payment
  150 + * @param uid
  151 + */
  152 + sendPayConfirm(code, payment, uid) {
  153 + let self = this;
243 154
244 -/**  
245 - * 支付相关的数据处理函数  
246 - */  
247 -const payTool = { 155 + return co(function* () {
  156 + let data = yield self.ctx(payApiModel).sendPayConfirm(code, payment, uid);
  157 +
  158 + return data;
  159 + })();
  160 + }
248 161
249 /** 162 /**
250 - * 支持的支付方式列表  
251 - * @returns {[*,*]} 163 + * 更新订单支付方式
  164 + * @param code
  165 + * @param payment
  166 + * @param uid
  167 + * @returns {*}
252 */ 168 */
253 - payAppInfo(orderCode) {  
254 - return [{  
255 - appIcon: '',  
256 - payLink: helpers.urlFormat('/cart/index/new/pay', {  
257 - payment: payments.alipay + '_platform',  
258 - order_code: orderCode  
259 - }),  
260 - appId: 'alipay',  
261 - app: '支付宝支付',  
262 - hint: '支付宝钱包支付',  
263 - subHint: '推荐支付宝用户使用'  
264 - }, {  
265 - appIcon: '',  
266 - payLink: '',  
267 - appId: 'weixin',  
268 - app: '微信支付',  
269 - hint: '推荐使用',  
270 - subHint: ''  
271 - }];  
272 - }, 169 + updateOrderPayment(code, payment, uid) {
  170 + return this.get({data: {
  171 + method: 'app.SpaceOrders.updateOrdersPaymentByCode',
  172 + order_code: code,
  173 + payment: payment,
  174 + uid: uid
  175 + }});
  176 + }
273 177
274 /** 178 /**
275 - * 计算购买商品总数量  
276 - * @param goodsArray  
277 - * @returns {number}  
278 - * @private 179 + * 更新订单支付银行
  180 + * @param code
  181 + * @param payment
  182 + * @param bankCode
279 */ 183 */
280 - calBuyNumCount(goodsArray) {  
281 - let buyNumCount = 0; 184 + updateOrderPayBank(code, payment, bankCode) {
  185 + let self = this;
282 186
283 - if (_.isArray(goodsArray)) {  
284 - _.forEach(goodsArray, value => {  
285 - buyNumCount = value.buy_number ? parseInt(value.buy_number, 10) : 0;  
286 - });  
287 - } 187 + return co(function* () {
  188 + let data = yield self.ctx(payApiModel).updateOrderPayBank(code, payment, bankCode);
288 189
289 - return buyNumCount; 190 + return data;
  191 + })();
290 } 192 }
291 -};  
292 193
293 -/**  
294 - * 支付中心  
295 - * @param params  
296 - */  
297 -const payCenter = (params) => {  
298 -  
299 - return _getOtherDetail({  
300 - uid: params.uid,  
301 - orderCode: params.orderCode,  
302 - sessionKey: params.sessionKey  
303 - }).then(result => {  
304 - return _.get(result, 'data', {});  
305 - });  
306 -};  
307 -  
308 -// 货到付款  
309 -const getPayCod = (param) => {  
310 - return api.all([  
311 - _getBanner(param),  
312 - _getOthersBuy(param),  
313 - _getOtherDetail(param)  
314 - ]).then((result) => {  
315 -  
316 - let resu = {  
317 - match: true,  
318 - banner: [],  
319 - othersBuy: []  
320 - };  
321 -  
322 - if (result && result[0]) {  
323 - _.forEach(result[0], function(val) {  
324 - if (val.template_name === 'single_image') {  
325 - resu.banner = val;  
326 - } else if (val.template_name === 'text') {  
327 - resu.prompt = val.data;  
328 - }  
329 - });  
330 - } 194 + /**
  195 + * 支付成功,前端回调时,处理订单信息
  196 + * @param payResult
  197 + * @param uid
  198 + * @param sessionKey
  199 + */
  200 + procOrderData(payResult, uid, sessionKey) {
  201 + let self = this;
331 202
332 - if (result && result[1]) {  
333 - resu.othersBuy = result[1];  
334 - } 203 + return co(function* () {
  204 + let orderCode = payResult.orderCode;
  205 + let result = { code: 400, message: '' };
335 206
336 - if (result && result[2] && result[2].data && result[2].data.payment_amount) {  
337 - resu.payment = result[2].data.payment_amount; 207 + if (!orderCode) {
  208 + result.message = '未查到订单信息,订单状态更新失败!';
  209 + return result;
  210 + } else {
  211 + let orderInfo = yield self._getOtherDetail({
  212 + uid: uid,
  213 + orderCode: orderCode,
  214 + sessionKey: sessionKey
  215 + });
338 216
339 - } else {  
340 - resu.match = false;  
341 - } 217 + if (orderInfo && orderInfo.data) {
  218 + let order = orderInfo.data;
  219 + let amount = order.payment_amount;
342 220
343 - resu.orderCode = param.orderCode; 221 + if (order.is_cancel === 'Y') {
  222 + logger.warn('front pay success but order is cancel.', { payResult: payResult, order: order });
344 223
345 - resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode; 224 + self.ctx(payApiModel).sendMessage(order.mobile, 'error_sms', '支付成功,但订单已取消,订单号为' + orderCode);
  225 + return { code: 417, message: '支付成功,但订单已取消,需联系客服!' };
  226 + }
346 227
347 - return resu;  
348 - });  
349 -}; 228 + if (order.payment_status === 'N') {
  229 + logger.warn('front pay success but may be notify fail');
  230 + }
350 231
351 -const _raw = (args) => {  
352 - let keys = Object.keys(args); 232 + if (_.round(parseFloat(amount), 2) !== _.round(parseFloat(payResult.totalFee), 2)) {
  233 + logger.warn('front pay success but the amount is not same.', {
  234 + payResult: payResult, order: order
  235 + });
  236 + return {
  237 + code: 415,
  238 + message: '支付金额与订单金额不一致,订单状态更新失败!'
  239 + };
  240 + }
353 241
354 - keys = keys.filter(k => {  
355 - let keyValueCheck =  
356 - k === 'sign' ||  
357 - k === 'sign_type' ||  
358 - k === 'code' ||  
359 - args[k] === '' ||  
360 - args[k] === 'undefined'; 242 + return {
  243 + code: 200,
  244 + message: '支付成功,请等待发货',
  245 + data: {
  246 + order: order
  247 + }
  248 + };
361 249
362 - return !keyValueCheck;  
363 - }).sort(); 250 + } else {
  251 + result.message = '未查到订单信息,订单状态更新失败!';
  252 + }
  253 + }
364 254
365 - return keys.map(k => {  
366 - return k + '=' + decodeURI(args[k]);  
367 - }).join('&');  
368 -}; 255 + return result;
  256 + })();
  257 + }
369 258
370 -/**  
371 - * 验证返回结果的正确性  
372 - */  
373 -const _checkResponse = (params) => {  
374 - if (!params.sign) {  
375 - return false; 259 + /**
  260 + * 支付中心
  261 + * @param params
  262 + */
  263 + payCenter(params) {
  264 +
  265 + return this.getOtherDetail({
  266 + uid: params.uid,
  267 + orderCode: params.orderCode,
  268 + sessionKey: params.sessionKey
  269 + }).then(result => {
  270 + return _.get(result, 'data', {});
  271 + });
376 } 272 }
377 - let rawResult = _raw(params);  
378 - let sign = rawResult + ApipayConfig.alipayKey;  
379 - let md5Result = md5(sign);  
380 273
381 - return md5Result === params.sign;  
382 -}; 274 + // 货到付款
  275 + getPayCod(param) {
  276 + return Promise.all([
  277 + this._getBanner(param),
  278 + this._getOthersBuy(param),
  279 + this.getOtherDetail(param)
  280 + ]).then((result) => {
  281 +
  282 + let resu = {
  283 + match: true,
  284 + banner: [],
  285 + othersBuy: []
  286 + };
  287 +
  288 + if (result && result[0]) {
  289 + _.forEach(result[0], function(val) {
  290 + if (val.template_name === 'single_image') {
  291 + resu.banner = val;
  292 + } else if (val.template_name === 'text') {
  293 + resu.prompt = val.data;
  294 + }
  295 + });
  296 + }
383 297
  298 + if (result && result[1]) {
  299 + resu.othersBuy = result[1];
  300 + }
384 301
385 -/**  
386 - * 支付宝支付结果校验  
387 - */  
388 -const alipayResultVerify = (params) => {  
389 - let checkResult = {}; 302 + if (result && result[2] && result[2].data && result[2].data.payment_amount) {
  303 + resu.payment = result[2].data.payment_amount;
390 304
391 - if (params.q) {  
392 - delete params.q;  
393 - } 305 + } else {
  306 + resu.match = false;
  307 + }
  308 +
  309 + resu.orderCode = param.orderCode;
394 310
395 - if (!_checkResponse(params)) {  
396 - checkResult.payResult = false;  
397 - } else {  
398 - _.assign(checkResult, {  
399 - bankName: '',  
400 - orderCode: params.out_trade_no,  
401 - payResult: params.trade_status === 'TRADE_SUCCESS',  
402 - payTime: params.gmt_payment || '',  
403 - totalFee: params.total_fee,  
404 - resultMsg: params.notify_type,  
405 - payOrderCode: params.out_trade_no,  
406 - tradeNo: params.trade_no,  
407 - bankBillNo: '' 311 + resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
  312 +
  313 + return resu;
408 }); 314 });
409 } 315 }
410 316
411 - return checkResult;  
412 -};  
413 -  
414 -// 支付宝支付  
415 -const getPayAli = (param) => {  
416 - return api.all([  
417 - _getBanner(param),  
418 - _getOthersBuy(param),  
419 - _getOtherDetail(param)  
420 - ]).then((result) => {  
421 -  
422 - let resu = {  
423 - match: true,  
424 - banner: [],  
425 - othersBuy: []  
426 - };  
427 -  
428 - if (result && result[0]) {  
429 - _.forEach(result[0], function(val) {  
430 - if (val.template_name === 'single_image') {  
431 - resu.banner = val;  
432 - } else if (val.template_name === 'text') {  
433 - resu.prompt = val.data;  
434 - }  
435 - }); 317 + _raw(args) {
  318 + let keys = Object.keys(args);
  319 +
  320 + keys = keys.filter(k => {
  321 + let keyValueCheck =
  322 + k === 'sign' ||
  323 + k === 'sign_type' ||
  324 + k === 'code' ||
  325 + args[k] === '' ||
  326 + args[k] === 'undefined';
  327 +
  328 + return !keyValueCheck;
  329 + }).sort();
  330 +
  331 + return keys.map(k => {
  332 + return k + '=' + decodeURI(args[k]);
  333 + }).join('&');
  334 + }
  335 +
  336 + /**
  337 + * 验证返回结果的正确性
  338 + */
  339 + _checkResponse(params) {
  340 + if (!params.sign) {
  341 + return false;
  342 + }
  343 + let rawResult = this._raw(params);
  344 + let sign = rawResult + ApipayConfig.alipayKey;
  345 + let md5Result = md5(sign);
  346 +
  347 + return md5Result === params.sign;
  348 + }
  349 +
  350 + /**
  351 + * 支付宝支付结果校验
  352 + */
  353 + alipayResultVerify(params) {
  354 + let checkResult = {};
  355 +
  356 + if (params.q) {
  357 + delete params.q;
436 } 358 }
437 359
438 - if (result && result[1]) {  
439 - resu.othersBuy = result[1]; 360 + if (!this._checkResponse(params)) {
  361 + checkResult.payResult = false;
  362 + } else {
  363 + _.assign(checkResult, {
  364 + bankName: '',
  365 + orderCode: params.out_trade_no,
  366 + payResult: params.trade_status === 'TRADE_SUCCESS',
  367 + payTime: params.gmt_payment || '',
  368 + totalFee: params.total_fee,
  369 + resultMsg: params.notify_type,
  370 + payOrderCode: params.out_trade_no,
  371 + tradeNo: params.trade_no,
  372 + bankBillNo: ''
  373 + });
440 } 374 }
441 375
442 - if (result && result[2] && result[2].data && result[2].data.payment_amount) {  
443 - resu.packageTitle = _.get(result[2], 'data.package_title', ''); 376 + return checkResult;
  377 + }
  378 +
  379 + // 支付宝支付
  380 + getPayAli(param) {
  381 + return Promise.all([
  382 + this._getBanner(param),
  383 + this._getOthersBuy(param),
  384 + this.getOtherDetail(param)
  385 + ]).then((result) => {
  386 +
  387 + let resu = {
  388 + match: true,
  389 + banner: [],
  390 + othersBuy: []
  391 + };
  392 +
  393 + if (result && result[0]) {
  394 + _.forEach(result[0], function(val) {
  395 + if (val.template_name === 'single_image') {
  396 + resu.banner = val;
  397 + } else if (val.template_name === 'text') {
  398 + resu.prompt = val.data;
  399 + }
  400 + });
  401 + }
  402 +
  403 + if (result && result[1]) {
  404 + resu.othersBuy = result[1];
  405 + }
  406 +
  407 + if (result && result[2] && result[2].data && result[2].data.payment_amount) {
  408 + resu.packageTitle = _.get(result[2], 'data.package_title', '');
444 409
445 - resu.payment = result[2].data.payment_amount; 410 + resu.payment = result[2].data.payment_amount;
446 411
447 - if (param.isPay && param.isPay === true) {  
448 - if (result[2].data.payment_status && result[2].data.payment_status === 'Y') {  
449 - resu.payWay = false; 412 + if (param.isPay && param.isPay === true) {
  413 + if (result[2].data.payment_status && result[2].data.payment_status === 'Y') {
  414 + resu.payWay = false;
  415 + } else {
  416 + resu.isCancel = true;
  417 + }
450 } else { 418 } else {
451 - resu.isCancel = true; 419 + resu.payWay = true;
452 } 420 }
  421 +
453 } else { 422 } else {
454 - resu.payWay = true; 423 + resu.match = false;
455 } 424 }
456 425
457 - } else {  
458 - resu.match = false;  
459 - } 426 + resu.orderCode = param.orderCode;
  427 +
  428 + resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
  429 +
  430 + return resu;
  431 + });
  432 + }
  433 +}
460 434
461 - resu.orderCode = param.orderCode;  
462 -  
463 - resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;  
464 -  
465 - return resu;  
466 - });  
467 -};  
468 -  
469 -module.exports = {  
470 - payments,  
471 - getOtherDetail: _getOtherDetail,  
472 - updateOrderPayment,  
473 - updateOrderPayBank,  
474 - getBankByOrder,  
475 - getPaymentInfo,  
476 - setOrderPayBank,  
477 - sendPayConfirm,  
478 - procOrderData,  
479 - payCenter,  
480 - payTool,  
481 - getPayCod,  
482 - getPayAli,  
483 - alipayResultVerify  
484 -}; 435 +module.exports = payModel;