@@ -0,0 +1,25 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.20 on 2019-06-20 09:09 |
|
3 |
+from __future__ import unicode_literals |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('mch', '0033_consumeinfosubmitloginfo_activity_id'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='activityinfo', |
|
17 |
+ name='coupon_expire_type', |
|
18 |
+ field=models.IntegerField(choices=[(0, '\u56fa\u5b9a\u7ed3\u675f\u65f6\u95f4'), (0, '\u53ef\u53d8\u7ed3\u675f\u65f6\u95f4')], default=0, help_text='\u7ef4\u4fee\u5238\u7c7b\u578b', verbose_name='coupon_expire_type'), |
|
19 |
+ ), |
|
20 |
+ migrations.AddField( |
|
21 |
+ model_name='activityinfo', |
|
22 |
+ name='coupon_valid_period', |
|
23 |
+ field=models.IntegerField(default=0, help_text='\u7ef4\u4fee\u5238\u6709\u6548\u65f6\u95f4\uff08\u5355\u4f4d\uff1a\u5929\uff09', verbose_name='coupon_valid_period'), |
|
24 |
+ ), |
|
25 |
+ ] |
@@ -507,15 +507,6 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
507 | 507 |
return unicode(self.pk) |
508 | 508 |
|
509 | 509 |
@property |
510 |
- def final_coupon_expire_at(self): |
|
511 |
- if not self.coupon_expire_at: |
|
512 |
- return '' |
|
513 |
- y = tc.local_string(self.coupon_expire_at, format='%Y') |
|
514 |
- m = tc.local_string(self.coupon_expire_at, format='%m') |
|
515 |
- d = tc.local_string(self.coupon_expire_at, format='%d') |
|
516 |
- return u'{}年{}月{}日'.format(y, m, d) |
|
517 |
- |
|
518 |
- @property |
|
519 | 510 |
def model_info(self): |
520 | 511 |
try: |
521 | 512 |
info = ModelInfo.objects.get(model_id=self.model_id).fulldata |
@@ -524,13 +515,6 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
524 | 515 |
return info |
525 | 516 |
|
526 | 517 |
@property |
527 |
- def coupon_info(self): |
|
528 |
- return { |
|
529 |
- 'coupon_expire_at': self.final_coupon_expire_at, |
|
530 |
- 'coupon_value': self.coupon_value, |
|
531 |
- } |
|
532 |
- |
|
533 |
- @property |
|
534 | 518 |
def data(self): |
535 | 519 |
if self.submit_during_activity: |
536 | 520 |
try: |
@@ -550,11 +534,22 @@ class ConsumeInfoSubmitLogInfo(BaseModelMixin): |
||
550 | 534 |
'serialNo': self.serialNo, |
551 | 535 |
'verifyResult': self.verifyResult, |
552 | 536 |
'submit_during_activity': self.submit_during_activity, |
553 |
- 'coupon_info': act.coupon_info if act else self.coupon_info, |
|
537 |
+ 'coupon_info': act.coupon_info(created_at=self.created_at) if act else { |
|
538 |
+ 'coupon_expire_at': '', |
|
539 |
+ 'coupon_value': 0, |
|
540 |
+ }, |
|
554 | 541 |
} |
555 | 542 |
|
556 | 543 |
|
557 | 544 |
class ActivityInfo(BaseModelMixin): |
545 |
+ FIXED_EXPIRED_TIME = 0 |
|
546 |
+ CHANGED_EXPIRED_TIME = 0 |
|
547 |
+ |
|
548 |
+ COUPON_EXPIRED_TIME_TUPLE = ( |
|
549 |
+ (FIXED_EXPIRED_TIME, u'固定结束时间'), |
|
550 |
+ (CHANGED_EXPIRED_TIME, u'可变结束时间'), |
|
551 |
+ ) |
|
552 |
+ |
|
558 | 553 |
activity_name = models.CharField(_(u'activity_name'), max_length=255, blank=True, null=True, help_text=u'活动名称') |
559 | 554 |
|
560 | 555 |
model_uni_names = JSONField(_(u'model_uni_names'), default=[], blank=True, null=True, help_text=u'型号统一名称列表') |
@@ -562,6 +557,8 @@ class ActivityInfo(BaseModelMixin): |
||
562 | 557 |
start_at = models.DateTimeField(_(u'start_at'), help_text=_(u'start_at')) |
563 | 558 |
end_at = models.DateTimeField(_(u'end_at'), help_text=_(u'end_at')) |
564 | 559 |
|
560 |
+ coupon_expire_type = models.IntegerField(_(u'coupon_expire_type'), choices=COUPON_EXPIRED_TIME_TUPLE, default=FIXED_EXPIRED_TIME, help_text=_(u'维修券类型')) |
|
561 |
+ coupon_valid_period = models.IntegerField(_(u'coupon_valid_period'), default=0, help_text=_(u'维修券有效时间(单位:天)')) |
|
565 | 562 |
coupon_expire_at = models.DateTimeField(_(u'coupon_expire_at'), blank=True, null=True, help_text=_(u'维修券过期时间')) |
566 | 563 |
coupon_value = models.IntegerField(_(u'coupon_value'), default=0, help_text=_(u'维修券金额(单位:分)')) |
567 | 564 |
|
@@ -572,21 +569,25 @@ class ActivityInfo(BaseModelMixin): |
||
572 | 569 |
def __unicode__(self): |
573 | 570 |
return unicode(self.pk) |
574 | 571 |
|
575 |
- @property |
|
576 |
- def final_coupon_expire_at(self): |
|
577 |
- if not self.coupon_expire_at: |
|
572 |
+ def final_expire_at(self, created_at=None): |
|
573 |
+ if self.coupon_expire_type == ActivityInfo.FIXED_EXPIRED_TIME: |
|
574 |
+ return self.coupon_expire_at |
|
575 |
+ return tc.utc_datetime(dt=created_at, days=self.coupon_valid_period) |
|
576 |
+ |
|
577 |
+ def final_coupon_expire_at(self, created_at=None): |
|
578 |
+ final_expire_at = self.final_expire_at(created_at=created_at) |
|
579 |
+ if not final_expire_at: |
|
578 | 580 |
return '' |
579 |
- y = tc.local_string(self.coupon_expire_at, format='%Y') |
|
580 |
- m = tc.local_string(self.coupon_expire_at, format='%m') |
|
581 |
- d = tc.local_string(self.coupon_expire_at, format='%d') |
|
581 |
+ y = tc.local_string(final_expire_at, format='%Y') |
|
582 |
+ m = tc.local_string(final_expire_at, format='%m') |
|
583 |
+ d = tc.local_string(final_expire_at, format='%d') |
|
582 | 584 |
return u'{}年{}月{}日'.format(y, m, d) |
583 | 585 |
|
584 | 586 |
def has_unexpired_activity(self, model_name): |
585 | 587 |
return (self.model_uni_names and model_name in self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at) |
586 | 588 |
|
587 |
- @property |
|
588 |
- def coupon_info(self): |
|
589 |
+ def coupon_info(self, created_at=None): |
|
589 | 590 |
return { |
590 |
- 'coupon_expire_at': self.final_coupon_expire_at, |
|
591 |
+ 'coupon_expire_at': self.final_coupon_expire_at(created_at=created_at), |
|
591 | 592 |
'coupon_value': self.coupon_value, |
592 |
- }, |
|
593 |
+ } |