final_coupon_expire_at

Kimi.Huang vor 6 Jahren
Ursprung
Commit
b8ba7d7473
2 geänderte Dateien mit 21 neuen Zeilen und 3 gelöschten Zeilen
  1. 2 2
      api/encrypt_views.py
  2. 19 1
      mch/models.py

+ 2 - 2
api/encrypt_views.py

@@ -112,7 +112,7 @@ def decrypt(request):
112 112
     has_unexpired_activity = True if act and act.has_unexpired_activity(model.model_uni_name) else False
113 113
 
114 114
     coupon_info = {
115
-        'coupon_expire_at': act.coupon_expire_at,
115
+        'coupon_expire_at': act.final_coupon_expire_at,
116 116
         'coupon_value': act.coupon_value,
117 117
     } if has_unexpired_activity else {
118 118
         'coupon_expire_at': '',
@@ -132,5 +132,5 @@ def decrypt(request):
132 132
             'SerialNo': sn,
133 133
         },
134 134
         'has_unexpired_activity': has_unexpired_activity,
135
-        'coupon_info': coupon_info
135
+        'coupon_info': coupon_info,
136 136
     })

+ 19 - 1
mch/models.py

@@ -506,6 +506,15 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin):
506 506
         return unicode(self.pk)
507 507
 
508 508
     @property
509
+    def final_coupon_expire_at(self):
510
+        if not self.coupon_expire_at:
511
+            return ''
512
+        y = tc.local_string(self.coupon_expire_at, format='%Y')
513
+        m = tc.local_string(self.coupon_expire_at, format='%m')
514
+        d = tc.local_string(self.coupon_expire_at, format='%d')
515
+        return u'{}年{}月{}日'.format(y, m, d)
516
+
517
+    @property
509 518
     def model_info(self):
510 519
         try:
511 520
             info = ModelInfo.objects.get(model_id=self.model_id).fulldata
@@ -527,7 +536,7 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin):
527 536
             'verifyResult': self.verifyResult,
528 537
             'submit_during_activity': self.submit_during_activity,
529 538
             'coupon_info': {
530
-                'coupon_expire_at': self.coupon_expire_at,
539
+                'coupon_expire_at': self.final_coupon_expire_at,
531 540
                 'coupon_value': self.coupon_value,
532 541
             },
533 542
         }
@@ -551,5 +560,14 @@ class ActivityInfo(BaseModelMixin):
551 560
     def __unicode__(self):
552 561
         return unicode(self.pk)
553 562
 
563
+    @property
564
+    def final_coupon_expire_at(self):
565
+        if not self.coupon_expire_at:
566
+            return ''
567
+        y = tc.local_string(self.coupon_expire_at, format='%Y')
568
+        m = tc.local_string(self.coupon_expire_at, format='%m')
569
+        d = tc.local_string(self.coupon_expire_at, format='%d')
570
+        return u'{}年{}月{}日'.format(y, m, d)
571
+
554 572
     def has_unexpired_activity(self, model_name):
555 573
         return (self.model_uni_names and model_name in self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at)