@@ -109,6 +109,7 @@ def decrypt(request): |
||
| 109 | 109 |
mdli.save() |
| 110 | 110 |
|
| 111 | 111 |
act = ActivityInfo.objects.filter(brand_id=brand.brand_id, status=True).order_by('-pk').first()
|
| 112 |
+ has_unexpired_activity = True if act and act.has_unexpired_activity(model.model_uni_name) else False |
|
| 112 | 113 |
|
| 113 | 114 |
# 红包 |
| 114 | 115 |
try: |
@@ -128,6 +129,6 @@ def decrypt(request): |
||
| 128 | 129 |
'DistributorID': distributor_pk, |
| 129 | 130 |
'SerialNo': sn, |
| 130 | 131 |
}, |
| 131 |
- 'has_unexpired_activity': True if act and act.has_unexpired_activity else False, |
|
| 132 |
+ 'has_unexpired_activity': has_unexpired_activity, |
|
| 132 | 133 |
'redpack_info': elog.redpack_info if elog else {},
|
| 133 | 134 |
}) |
@@ -269,7 +269,7 @@ def consumer_info_api(request): |
||
| 269 | 269 |
).exists() |
| 270 | 270 |
|
| 271 | 271 |
act = ActivityInfo.objects.filter(status=True).order_by('-pk').first()
|
| 272 |
- during_activity = True if act and act.has_unexpired_activity else False |
|
| 272 |
+ during_activity = True if act and act.has_unexpired_activity(model.model_uni_name) else False |
|
| 273 | 273 |
|
| 274 | 274 |
# 记录用户信息提交记录 |
| 275 | 275 |
log = ConsumeInfoSubmitLogInfo.objects.create( |
@@ -0,0 +1,21 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.20 on 2019-05-21 06:34 |
|
| 3 |
+from __future__ import unicode_literals |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations |
|
| 6 |
+import jsonfield.fields |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+class Migration(migrations.Migration): |
|
| 10 |
+ |
|
| 11 |
+ dependencies = [ |
|
| 12 |
+ ('mch', '0033_brandinfo_tousername'),
|
|
| 13 |
+ ] |
|
| 14 |
+ |
|
| 15 |
+ operations = [ |
|
| 16 |
+ migrations.AddField( |
|
| 17 |
+ model_name='activityinfo', |
|
| 18 |
+ name='model_uni_names', |
|
| 19 |
+ field=jsonfield.fields.JSONField(blank=True, default=[], help_text='\u578b\u53f7\u7edf\u4e00\u540d\u79f0\u5217\u8868', null=True, verbose_name='model_uni_names'), |
|
| 20 |
+ ), |
|
| 21 |
+ ] |
@@ -5,6 +5,7 @@ from django.db import models |
||
| 5 | 5 |
from django.utils.translation import ugettext_lazy as _ |
| 6 | 6 |
from django_models_ext import (BaseModelMixin, ProvinceShortModelMixin, SexModelMixin, upload_file_path, |
| 7 | 7 |
upload_file_url, upload_path) |
| 8 |
+from jsonfield import JSONField |
|
| 8 | 9 |
from shortuuidfield import ShortUUIDField |
| 9 | 10 |
from TimeConvert import TimeConvert as tc |
| 10 | 11 |
|
@@ -537,6 +538,8 @@ class ActivityInfo(BaseModelMixin): |
||
| 537 | 538 |
|
| 538 | 539 |
activity_name = models.CharField(_(u'activity_name'), max_length=255, blank=True, null=True, help_text=u'活动名称') |
| 539 | 540 |
|
| 541 |
+ model_uni_names = JSONField(_(u'model_uni_names'), default=[], blank=True, null=True, help_text=u'型号统一名称列表') |
|
| 542 |
+ |
|
| 540 | 543 |
start_at = models.DateTimeField(_(u'start_at'), help_text=_(u'start_at')) |
| 541 | 544 |
end_at = models.DateTimeField(_(u'end_at'), help_text=_(u'end_at')) |
| 542 | 545 |
|
@@ -547,6 +550,5 @@ class ActivityInfo(BaseModelMixin): |
||
| 547 | 550 |
def __unicode__(self): |
| 548 | 551 |
return unicode(self.pk) |
| 549 | 552 |
|
| 550 |
- @property |
|
| 551 |
- def has_unexpired_activity(self): |
|
| 552 |
- return self.start_at <= tc.utc_datetime() < self.end_at |
|
| 553 |
+ def has_unexpired_activity(self, model_name): |
|
| 554 |
+ return model_name in self.model_uni_names and self.start_at <= tc.utc_datetime() < self.end_at |