fix pay api pay_expire
Showing
3 changed files
with
36 additions
and
9 deletions
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | * @author: weiqingting<qingting.wei@yoho.cn> | 2 | * @author: weiqingting<qingting.wei@yoho.cn> |
3 | */ | 3 | */ |
4 | 'use strict'; | 4 | 'use strict'; |
5 | +const moment = require('moment'); | ||
5 | 6 | ||
6 | module.exports = class extends global.yoho.BaseModel { | 7 | module.exports = class extends global.yoho.BaseModel { |
7 | constructor(ctx) { | 8 | constructor(ctx) { |
@@ -41,7 +42,23 @@ module.exports = class extends global.yoho.BaseModel { | @@ -41,7 +42,23 @@ module.exports = class extends global.yoho.BaseModel { | ||
41 | order_code: orderCode | 42 | order_code: orderCode |
42 | }; | 43 | }; |
43 | 44 | ||
44 | - return this.get({data: options}); | 45 | + return this.get({data: options}).then(result => { |
46 | + if (result.code === 200 && result.data) { | ||
47 | + if (result.data.pay_lefttime) { | ||
48 | + result.data.pay_lefttime = +result.data.pay_lefttime - 3600; | ||
49 | + | ||
50 | + if (result.data.pay_lefttime < 0) { | ||
51 | + result.data.pay_lefttime = 0; | ||
52 | + } | ||
53 | + } | ||
54 | + if (result.data.pay_expire) { | ||
55 | + result.data.pay_expire = moment(result.data.pay_expire) | ||
56 | + .subtract(1, 'hour') | ||
57 | + .format('YYYY-MM-DD HH:mm:ss'); | ||
58 | + } | ||
59 | + } | ||
60 | + return result; | ||
61 | + }); | ||
45 | } | 62 | } |
46 | 63 | ||
47 | /** | 64 | /** |
@@ -39,13 +39,6 @@ const online = (req, res, next) => { | @@ -39,13 +39,6 @@ const online = (req, res, next) => { | ||
39 | return next(); | 39 | return next(); |
40 | } | 40 | } |
41 | 41 | ||
42 | - if (order.pay_lefttime) { | ||
43 | - order.pay_lefttime = +order.pay_lefttime - 3600; | ||
44 | - | ||
45 | - if (order.pay_lefttime < 0) { | ||
46 | - order.pay_lefttime = 0; | ||
47 | - } | ||
48 | - } | ||
49 | 42 | ||
50 | order.payment_type = parseInt(order.payment_type, 10); | 43 | order.payment_type = parseInt(order.payment_type, 10); |
51 | 44 |
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | +const moment = require('moment'); | ||
8 | 9 | ||
9 | module.exports = class extends global.yoho.BaseModel { | 10 | module.exports = class extends global.yoho.BaseModel { |
10 | constructor(ctx) { | 11 | constructor(ctx) { |
@@ -100,7 +101,23 @@ module.exports = class extends global.yoho.BaseModel { | @@ -100,7 +101,23 @@ module.exports = class extends global.yoho.BaseModel { | ||
100 | order_code: orderCode | 101 | order_code: orderCode |
101 | }; | 102 | }; |
102 | 103 | ||
103 | - return this.get({data: options}); | 104 | + return this.get({data: options}).then(result => { |
105 | + if (result.code === 200 && result.data) { | ||
106 | + if (result.data.pay_lefttime) { | ||
107 | + result.data.pay_lefttime = +result.data.pay_lefttime - 3600; | ||
108 | + | ||
109 | + if (result.data.pay_lefttime < 0) { | ||
110 | + result.data.pay_lefttime = 0; | ||
111 | + } | ||
112 | + } | ||
113 | + if (result.data.pay_expire) { | ||
114 | + result.data.pay_expire = moment(result.data.pay_expire) | ||
115 | + .subtract(1, 'hour') | ||
116 | + .format('YYYY-MM-DD HH:mm:ss'); | ||
117 | + } | ||
118 | + } | ||
119 | + return result; | ||
120 | + }); | ||
104 | } | 121 | } |
105 | 122 | ||
106 | /** | 123 | /** |
-
Please register or login to post a comment