@@ -43,12 +43,14 @@ class OrderInfo(BaseModelMixin): |
||
43 | 43 |
PAID = 1 |
44 | 44 |
FAIL = 2 |
45 | 45 |
# DELETED = 9 |
46 |
+ CANCELED = 10 |
|
46 | 47 |
|
47 | 48 |
PAY_STATUS = ( |
48 | 49 |
(WAITING_PAY, u'待支付'), |
49 | 50 |
(PAID, u'已支付'), |
50 | 51 |
(FAIL, u'已失败'), |
51 | 52 |
# (DELETED, u'已删除'), |
53 |
+ (CANCELED, u'已取消'), |
|
52 | 54 |
) |
53 | 55 |
|
54 | 56 |
order_id = ShortUUIDField(_(u'order_id'), max_length=32, help_text=u'订单唯一标识', db_index=True) |
@@ -90,6 +92,12 @@ class OrderInfo(BaseModelMixin): |
||
90 | 92 |
def __unicode__(self): |
91 | 93 |
return u'{0.pk}'.format(self) |
92 | 94 |
|
95 |
+ @property |
|
96 |
+ def final_pay_status(self): |
|
97 |
+ if self.pay_status == OrderInfo.CANCELED: |
|
98 |
+ return OrderInfo.FAIL |
|
99 |
+ return self.pay_status |
|
100 |
+ |
|
93 | 101 |
def data(self, user_id=None): |
94 | 102 |
try: |
95 | 103 |
group_photo = GroupPhotoInfo.objects.get(photo_id=self.photo_id) |
@@ -104,7 +112,7 @@ class OrderInfo(BaseModelMixin): |
||
104 | 112 |
'to_uid': self.to_uid, |
105 | 113 |
'body': self.body, |
106 | 114 |
'total_fee': self.total_fee, |
107 |
- 'pay_status': self.pay_status, |
|
115 |
+ 'pay_status': self.final_pay_status, |
|
108 | 116 |
'paid_at': tc.remove_microsecond(self.paid_at), |
109 | 117 |
'created_at': tc.remove_microsecond(self.created_at), |
110 | 118 |
} |
@@ -248,6 +248,9 @@ def wx_order_cancel_api(request): |
||
248 | 248 |
if user_id not in [order.from_uid]: |
249 | 249 |
return response(OrderStatusCode.NO_CANCEL_PERMISSION) |
250 | 250 |
|
251 |
+ order.pay_status = OrderInfo.CANCELED |
|
252 |
+ order.save() |
|
253 |
+ |
|
251 | 254 |
return response(200, 'Order Cancel Success', u'订单取消成功') |
252 | 255 |
|
253 | 256 |
|