3334afd0edd7bL327">327 341
         test_user=user.test_user,
328 342
         code_version=code_version,
329 343
         ym=ymd[:6],
@@ -417,12 +431,6 @@ def consumer_info_api(request):
417 431
             'model_id': model.model_id,
418 432
         })
419 433
 
420
-    # 更新销售员提交的表
421
-    logs = SaleclerkSubmitLogInfo.objects.filter(code=serialNo, model_pk=model.pk)
422
-    for log in logs:
423
-        log.has_scan = True
424
-        log.save()
425
-
426 434
     if not dupload:
427 435
         user.shots_num += 1
428 436
         if user.level < UserInfo.MEMBER_BLACK_GOLD:

+ 30 - 0
coupon/migrations/0008_auto_20200411_2143.py

@@ -0,0 +1,30 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2020-04-11 13:43
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
+        ('coupon', '0007_auto_20191230_1605'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='usercouponinfo',
17
+            name='acitvity_id',
18
+            field=models.CharField(blank=True, db_index=True, default=b'MEMBER_BENEFITS', help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='acitvity_id'),
19
+        ),
20
+        migrations.AddField(
21
+            model_name='usercouponinfo',
22
+            name='acitvity_name',
23
+            field=models.CharField(blank=True, db_index=True, default=b'MEMBER_BENEFITS', help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='activity_id'),
24
+        ),
25
+        migrations.AddField(
26
+            model_name='usercouponinfo',
27
+            name='coupon_from',
28
+            field=models.CharField(blank=True, db_index=True, default=b'MEMBER_BENEFITS', help_text='\u52b5\u6765\u6e90', max_length=32, null=True, verbose_name='coupon_from'),
29
+        ),
30
+    ]

+ 25 - 0
coupon/migrations/0009_auto_20200411_2254.py

@@ -0,0 +1,25 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2020-04-11 14:54
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
+        ('coupon', '0008_auto_20200411_2143'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AlterField(
16
+            model_name='usercouponinfo',
17
+            name='acitvity_id',
18
+            field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='acitvity_id'),
19
+        ),
20
+        migrations.AlterField(
21
+            model_name='usercouponinfo',
22
+            name='acitvity_name',
23
+            field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='activity_id'),
24
+        ),
25
+    ]

+ 20 - 0
coupon/migrations/0010_auto_20200411_2254.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2020-04-11 14:54
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
+        ('coupon', '0009_auto_20200411_2254'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AlterField(
16
+            model_name='usercouponinfo',
17
+            name='acitvity_name',
18
+            field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='acitvity_name'),
19
+        ),
20
+    ]

+ 33 - 0
coupon/migrations/0011_auto_20200411_2316.py

@@ -0,0 +1,33 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2020-04-11 15:16
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
+        ('coupon', '0010_auto_20200411_2254'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.RemoveField(
16
+            model_name='usercouponinfo',
17
+            name='acitvity_id',
18
+        ),
19
+        migrations.RemoveField(
20
+            model_name='usercouponinfo',
21
+            name='acitvity_name',
22
+        ),
23
+        migrations.AddField(
24
+            model_name='usercouponinfo',
25
+            name='activity_id',
26
+            field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='activity_id'),
27
+        ),
28
+        migrations.AddField(
29
+            model_name='usercouponinfo',
30
+            name='activity_name',
31
+            field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='activity_name'),
32
+        ),
33
+    ]

+ 19 - 0
coupon/models.py

@@ -42,6 +42,21 @@ class CouponInfo(BaseModelMixin):
42 42
     def __unicode__(self):
43 43
         return unicode(self.pk)
44 44
 
45
+    @property
46
+    def coupon_image_path(self):
47
+        return upload_file_path(self.coupon_image)
48
+
49
+    @property
50
+    def coupon_image_url(self):
51
+        return upload_file_url(self.coupon_image)
52
+
53
+
54
+    @property
55
+    def final_expire_at(self):
56
+        if self.coupon_expire_type == CouponInfo.FIXED_EXPIRED_TIME:
57
+            return self.coupon_expire_at
58
+        return tc.utc_datetime(days=self.coupon_valid_period)
59
+
45 60
 
46 61
 class UserCouponInfo(BaseModelMixin):
47 62
     brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
@@ -66,6 +81,10 @@ class UserCouponInfo(BaseModelMixin):
66 81
     admin_id = models.CharField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'核销员唯一标识', db_index=True)
67 82
     used_at = models.DateTimeField(_(u'used_at'), blank=True, null=True, help_text=u'维修券核销时间')
68 83
 
84
+    coupon_from = models.CharField(_(u'coupon_from'), default='MEMBER_BENEFITS', max_length=32, blank=True, null=True, help_text=u'劵来源', db_index=True)
85
+    activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)
86
+    activity_name = models.CharField(_(u'activity_name'), max_length=32, blank=True, null=True, help_text=u'活动名称', db_index=True)
87
+
69 88
     class Meta:
70 89
         verbose_name = _(u'用户券信息')
71 90
         verbose_name_plural = _(u'用户券信息')

+ 1 - 1
mch/admin.py

@@ -227,7 +227,7 @@ class ConsumeInfoSubmitLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):
227 227
 
228 228
 
229 229
 class ActivityInfoAdmin(admin.ModelAdmin):
230
-    list_display = ('activity_name', 'model_uni_names', 'start_at', 'end_at', 'coupon_expire_type', 'coupon_valid_period', 'coupon_expire_at', 'coupon_value', 'status', 'created_at', 'updated_at')
230
+    list_display = ('activity_id', 'activity_name', 'model_uni_names', 'start_at', 'end_at', 'coupon_expire_type', 'coupon_valid_period', 'coupon_expire_at', 'coupon_value', 'status', 'created_at', 'updated_at')
231 231
     list_filter = ('coupon_expire_type', 'status')
232 232
 
233 233
 

+ 26 - 0
mch/migrations/0054_auto_20200411_2143.py

@@ -0,0 +1,26 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2020-04-11 13:43
3
+from __future__ import unicode_literals
4
+
5
+from django.db import migrations, models
6
+import shortuuidfield.fields
7
+
8
+
9
+class Migration(migrations.Migration):
10
+
11
+    dependencies = [
12
+        ('mch', '0053_auto_20200407_1118'),
13
+    ]
14
+
15
+    operations = [
16
+        migrations.AddField(
17
+            model_name='activityinfo',
18
+            name='activity_id',
19
+            field=shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=22, null=True, unique=True),
20
+        ),
21
+        migrations.AlterField(
22
+            model_name='consumeinfosubmitloginfo',
23
+            name='province',
24
+            field=models.CharField(blank=True, db_index=True, help_text='\u7701\u4efd', max_length=32, null=True, verbose_name='province'),
25
+        ),
26
+    ]

+ 23 - 1
mch/models.py

@@ -9,6 +9,8 @@ from jsonfield import JSONField
9 9
 from shortuuidfield import ShortUUIDField
10 10
 from TimeConvert import TimeConvert as tc
11 11
 
12
+from coupon.models import CouponInfo
13
+
12 14
 
13 15
 class AdministratorInfo(BaseModelMixin):
14 16
     ADMINISTRATOR = 0
@@ -704,6 +706,7 @@ class ActivityInfo(BaseModelMixin):
704 706
         (CHANGED_EXPIRED_TIME, u'可变结束时间'),
705 707
     )
706 708
 
709
+    activity_id = ShortUUIDField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True, unique=True)
707 710
     activity_name = models.CharField(_(u'activity_name'), max_length=255, blank=True, null=True, help_text=u'活动名称')
708 711
 
709 712
     model_uni_names = JSONField(_(u'model_uni_names'), default=[], blank=True, null=True, help_text=u'型号统一名称列表')
@@ -740,7 +743,7 @@ class ActivityInfo(BaseModelMixin):
740 743
         return u'{}年{}月{}日'.format(y, m, d)
741 744
 
742 745
     def has_unexpired_activity(self, model_name):
743
-        return (self.model_uni_names and model_name in self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at)
746
+        return ((self.model_uni_names and model_name in self.model_uni_names) or not self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at)
744 747
 
745 748
     def coupon_info(self, created_at=None):
746 749
         return {
@@ -748,6 +751,25 @@ class ActivityInfo(BaseModelMixin):
748 751
             'coupon_value': self.coupon_value,
749 752
             'coupon_has_expired': tc.utc_datetime() >= self.final_expire_at(created_at=created_at),
750 753
         }
754
+    
751 755
 
752 756
     def coupon_info2(self, created_at=None):
753 757
         return self.coupon_info(created_at=created_at),
758
+
759
+    @property
760
+    def coupon_info3(self):
761
+        try:
762
+            coupon_info = CouponInfo.objects.get(coupon_id=self.coupon_id)
763
+            return {
764
+                'coupon_image': coupon_info.coupon_image_url,
765
+                'coupon_expire_at': coupon_info.coupon_expire_at,
766
+                'coupon_value': coupon_info.coupon_value,
767
+                'coupon_title': coupon_info.coupon_title,
768
+                'coupon_valid_period': coupon_info.coupon_valid_period,
769
+                'coupon_id': coupon_info.coupon_id,
770
+                'activity_id': self.activity_id,
771
+                'activity_name': self.activity_name,
772
+            }
773
+        except:
774
+            return {}
775
+        

kodo - Gogs: Go Git Service

Keine Beschreibung

models.py 1.3KB

    # -*- coding: utf-8 -*- from django.db import models from django.utils.translation import ugettext_lazy as _ from django_models_ext import BaseModelMixin class MarketCodeInfo(BaseModelMixin): isv_application_id = models.CharField(_(u'isv_application_id'), max_length=128, blank=True, null=True, help_text=u'外部单号', db_index=True) application_id = models.IntegerField(_(u'application_id'), default=0, help_text=u'申请单号', db_index=True) lattice = models.CharField(_(u'code'), max_length=361, blank=True, null=True, help_text=u'361 字节的 01 点阵,用于支持生成 19 * 19 的微型码,0 为白,1 为黑') code = models.CharField(_(u'code'), max_length=16, blank=True, null=True, help_text=u'九位的字符串原始码', db_index=True) code_index = models.IntegerField(_(u'code_index'), default=0, help_text=u'该码在批次中的偏移量 ') code_url = models.CharField(_(u'code_url'), max_length=128, blank=True, null=True, help_text=u'28位普通码字符 ', db_index=True) has_used = models.BooleanField(_(u'has_used'), default=False, help_text=_(u'是否已使用')) class Meta: verbose_name = _(u'一物一码信息') verbose_name_plural = _(u'一物一码信息') def __unicode__(self): return '%d' % self.pk