:art: Add MemberActivityContributionWelfareUnlockingInfo

huangqimin001 2 年之前
父节点
当前提交
2986e79e27

+ 8 - 0
kodo/basemodels.py

@@ -95,3 +95,11 @@ class LensmanTypeBoolMixin(LensmanTypeChoicesMixin):
95 95
 
96 96
     class Meta:
97 97
         abstract = True
98
+
99
+
100
+class BrandInfoMixin(models.Model):
101
+    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
102
+    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
103
+
104
+    class Meta:
105
+        abstract = True

+ 10 - 3
member/admin.py

@@ -6,8 +6,9 @@ from django_admin import DeleteModelAdmin
6 6
 
7 7
 from account.models import UserInfo
8 8
 from member.models import (GoodsInfo, GoodsOrderInfo, MemberActivityContributionInfo,
9
-                           MemberActivityContributionWelfareInfo, MemberActivityGroupShareInfo, MemberActivityInfo,
10
-                           MemberActivitySigninInfo, MemberActivitySignupInfo, RightInfo, ShotTypeInfo)
9
+                           MemberActivityContributionWelfareInfo, MemberActivityContributionWelfareUnlockingInfo,
10
+                           MemberActivityGroupShareInfo, MemberActivityInfo, MemberActivitySigninInfo,
11
+                           MemberActivitySignupInfo, RightInfo, ShotTypeInfo)
11 12
 from pre.custom_message import sendwxasubscribemessage
12 13
 from utils.redis.rshot import update_member_shot_data
13 14
 
@@ -104,10 +105,15 @@ class MemberActivityContributionInfoAdmin(admin.ModelAdmin):
104 105
 
105 106
 
106 107
 class MemberActivityContributionWelfareInfoAdmin(admin.ModelAdmin):
107
-    list_display = ('activity_id', 'welfare_id', 'welfare_type', 'welfare_title', 'welfare_detail', 'welfare_value', 'welfare_image', 'status', 'created_at', 'updated_at')
108
+    list_display = ('welfare_id', 'activity_id', 'welfare_type', 'welfare_title', 'welfare_detail', 'welfare_value', 'welfare_image', 'status', 'created_at', 'updated_at')
108 109
     list_filter = ('activity_id', 'welfare_type', 'status')
109 110
 
110 111
 
112
+class MemberActivityContributionWelfareUnlockingInfoAdmin(admin.ModelAdmin):
113
+    list_display = ('unlocking_id', 'admin_id', 'user_id', 'activity_id', 'contribution_id', 'welfare_id', 'name', 'phone', 'address', 'tracking_number', 'is_handled', 'status', 'created_at', 'updated_at')
114
+    list_filter = ('admin_id', 'activity_id', 'welfare_id', 'is_handled', 'status')
115
+
116
+
111 117
 admin.site.register(GoodsInfo, GoodsInfoAdmin)
112 118
 admin.site.register(GoodsOrderInfo, GoodsOrderInfoAdmin)
113 119
 admin.site.register(RightInfo, RightInfoAdmin)
@@ -118,3 +124,4 @@ admin.site.register(MemberActivitySigninInfo, MemberActivitySigninInfoAdmin)
118 124
 admin.site.register(MemberActivityGroupShareInfo, MemberActivityGroupShareInfoAdmin)
119 125
 admin.site.register(MemberActivityContributionInfo, MemberActivityContributionInfoAdmin)
120 126
 admin.site.register(MemberActivityContributionWelfareInfo, MemberActivityContributionWelfareInfoAdmin)
127
+admin.site.register(MemberActivityContributionWelfareUnlockingInfo, MemberActivityContributionWelfareUnlockingInfoAdmin)

+ 41 - 0
member/migrations/0042_memberactivitycontributionwelfareunlockinginfo.py

@@ -0,0 +1,41 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 3.2.16 on 2022-10-25 18:16
3
+
4
+from django.db import migrations, models
5
+import shortuuidfield.fields
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+        ('member', '0041_auto_20221025_1236'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.CreateModel(
16
+            name='MemberActivityContributionWelfareUnlockingInfo',
17
+            fields=[
18
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19
+                ('status', models.BooleanField(default=True, help_text='Status', verbose_name='status')),
20
+                ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
21
+                ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
22
+                ('unlocking_id', shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='福利解锁唯一标识', max_length=22, null=True, unique=True)),
23
+                ('brand_id', models.CharField(blank=True, db_index=True, help_text='品牌唯一标识', max_length=32, null=True, verbose_name='brand_id')),
24
+                ('brand_name', models.CharField(blank=True, help_text='品牌名称', max_length=255, null=True, verbose_name='brand_name')),
25
+                ('admin_id', models.CharField(blank=True, db_index=True, help_text='管理员唯一标识', max_length=32, null=True, verbose_name='admin_id')),
26
+                ('user_id', models.CharField(blank=True, db_index=True, help_text='用户唯一标识', max_length=32, null=True, verbose_name='user_id')),
27
+                ('activity_id', models.CharField(blank=True, db_index=True, help_text='活动唯一标识', max_length=32, null=True, verbose_name='activity_id')),
28
+                ('contribution_id', models.CharField(blank=True, db_index=True, help_text='投稿唯一标识', max_length=32, null=True, verbose_name='contribution_id')),
29
+                ('welfare_id', models.CharField(blank=True, db_index=True, help_text='福利唯一标识', max_length=32, null=True, verbose_name='welfare_id')),
30
+                ('name', models.CharField(blank=True, help_text='姓名', max_length=255, null=True, verbose_name='name')),
31
+                ('phone', models.CharField(blank=True, help_text='电话', max_length=255, null=True, verbose_name='phone')),
32
+                ('address', models.CharField(blank=True, help_text='地址', max_length=255, null=True, verbose_name='address')),
33
+                ('tracking_number', models.CharField(blank=True, help_text='快递单号', max_length=255, null=True, verbose_name='tracking_number')),
34
+                ('is_handled', models.BooleanField(default=False, help_text='是否已处理', verbose_name='is_handled')),
35
+            ],
36
+            options={
37
+                'verbose_name': '会员活动投稿福利解锁信息',
38
+                'verbose_name_plural': '会员活动投稿福利解锁信息',
39
+            },
40
+        ),
41
+    ]

+ 24 - 0
member/migrations/0043_auto_20221026_0221.py

@@ -0,0 +1,24 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 3.2.16 on 2022-10-25 18:21
3
+
4
+from django.db import migrations, models
5
+
6
+
7
+class Migration(migrations.Migration):
8
+
9
+    dependencies = [
10
+        ('member', '0042_memberactivitycontributionwelfareunlockinginfo'),
11
+    ]
12
+
13
+    operations = [
14
+        migrations.AlterField(
15
+            model_name='memberactivityinfo',
16
+            name='brand_id',
17
+            field=models.CharField(blank=True, db_index=True, help_text='品牌唯一标识', max_length=32, null=True, verbose_name='brand_id'),
18
+        ),
19
+        migrations.AlterField(
20
+            model_name='memberactivityinfo',
21
+            name='brand_name',
22
+            field=models.CharField(blank=True, help_text='品牌名称', max_length=255, null=True, verbose_name='brand_name'),
23
+        ),
24
+    ]

+ 69 - 43
member/models.py

@@ -10,12 +10,13 @@ from shortuuidfield import ShortUUIDField
10 10
 from TimeConvert import TimeConvert as tc
11 11
 
12 12
 from coupon.models import CouponInfo
13
+from kodo.basemodels import BrandInfoMixin
13 14
 from mch.models import ModelInfo
14 15
 from simditor.fields import RichTextField
15 16
 from utils.qiniucdn import qiniu_file_url
16 17
 
17 18
 
18
-class GoodsInfo(BaseModelMixin):
19
+class GoodsInfo(BaseModelMixin, BrandInfoMixin):
19 20
     PHYSICAL = 0
20 21
     VIRTUAL = 1
21 22
 
@@ -24,9 +25,6 @@ class GoodsInfo(BaseModelMixin):
24 25
         (VIRTUAL, u'虚拟'),
25 26
     )
26 27
 
27
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
28
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
29
-
30 28
     good_id = ShortUUIDField(_(u'good_id'), max_length=32, blank=True, null=True, help_text=u'商品唯一标识', db_index=True, unique=True)
31 29
     good_type = models.IntegerField(_(u'good_type'), choices=GOOD_TYPE_TUPLE, default=VIRTUAL, help_text=u'商品类型', db_index=True)
32 30
 
@@ -151,7 +149,7 @@ class GoodsInfo(BaseModelMixin):
151 149
         }
152 150
 
153 151
 
154
-class GoodsOrderInfo(BaseModelMixin):
152
+class GoodsOrderInfo(BaseModelMixin, BrandInfoMixin):
155 153
     PHYSICAL = 0
156 154
     VIRTUAL = 1
157 155
 
@@ -160,9 +158,6 @@ class GoodsOrderInfo(BaseModelMixin):
160 158
         (VIRTUAL, u'虚拟'),
161 159
     )
162 160
 
163
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
164
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
165
-
166 161
     order_id = ShortUUIDField(_(u'order_id'), max_length=32, blank=True, null=True, help_text=u'订单唯一标识', db_index=True, unique=True)
167 162
 
168 163
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
@@ -213,7 +208,7 @@ class GoodsOrderInfo(BaseModelMixin):
213 208
         }
214 209
 
215 210
 
216
-class RightInfo(BaseModelMixin):
211
+class RightInfo(BaseModelMixin, BrandInfoMixin):
217 212
     PHYSICAL = 0
218 213
     VIRTUAL = 1
219 214
     COUPON = 2
@@ -224,9 +219,6 @@ class RightInfo(BaseModelMixin):
224 219
         (COUPON, u'优惠券'),
225 220
     )
226 221
 
227
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
228
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
229
-
230 222
     right_id = ShortUUIDField(_(u'right_id'), max_length=32, blank=True, null=True, help_text=u'权益唯一标识', db_index=True, unique=True)
231 223
     right_type = models.IntegerField(_(u'right_type'), choices=RIGHT_TYPE_TUPLE, default=VIRTUAL, help_text=u'权益类型', db_index=True)
232 224
 
@@ -311,10 +303,7 @@ class RightInfo(BaseModelMixin):
311 303
         return right_detail
312 304
 
313 305
 
314
-class ShotTypeInfo(BaseModelMixin):
315
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
316
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
317
-
306
+class ShotTypeInfo(BaseModelMixin, BrandInfoMixin):
318 307
     shot_type_id = ShortUUIDField(_(u'shot_type_id'), max_length=32, blank=True, null=True, help_text=u'镜头类型唯一标识', db_index=True, unique=True)
319 308
     shot_type_name = models.CharField(_(u'shot_type_name'), max_length=255, blank=True, null=True, help_text=u'镜头类型名称')
320 309
 
@@ -341,7 +330,7 @@ class ShotTypeInfo(BaseModelMixin):
341 330
         }
342 331
 
343 332
 
344
-class MemberActivityInfo(BaseModelMixin):
333
+class MemberActivityInfo(BaseModelMixin, BrandInfoMixin):
345 334
     ACTIVITY_TYPE = (
346 335
         (0, u'线下活动'),
347 336
         (1, u'公众号文章'),
@@ -355,9 +344,6 @@ class MemberActivityInfo(BaseModelMixin):
355 344
         (2, u'下线'),
356 345
     )
357 346
 
358
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, default='', help_text=u'品牌唯一标识', db_index=True)
359
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, default='', help_text=u'品牌名称')
360
-
361 347
     activity_id = ShortUUIDField(_(u'activity_id'), max_length=32, blank=True, help_text=u'活动唯一标识', db_index=True, unique=True)
362 348
 
363 349
     activity_type = models.IntegerField(_(u'activity_type'), choices=ACTIVITY_TYPE, default=0, help_text=u'活动类型', db_index=True)
@@ -572,10 +558,7 @@ class MemberActivityInfo(BaseModelMixin):
572 558
         }
573 559
 
574 560
 
575
-class MemberActivitySignupInfo(BaseModelMixin):
576
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
577
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
578
-
561
+class MemberActivitySignupInfo(BaseModelMixin, BrandInfoMixin):
579 562
     signup_id = ShortUUIDField(_(u'signup_id'), max_length=32, blank=True, null=True, help_text=u'活动报名唯一标识', db_index=True, unique=True)
580 563
 
581 564
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
@@ -610,10 +593,7 @@ class MemberActivitySignupInfo(BaseModelMixin):
610 593
         }
611 594
 
612 595
 
613
-class MemberActivitySigninInfo(BaseModelMixin):
614
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
615
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
616
-
596
+class MemberActivitySigninInfo(BaseModelMixin, BrandInfoMixin):
617 597
     signin_id = ShortUUIDField(_(u'signin_id'), max_length=32, blank=True, null=True, help_text=u'活动签到唯一标识', db_index=True, unique=True)
618 598
 
619 599
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
@@ -634,10 +614,7 @@ class MemberActivitySigninInfo(BaseModelMixin):
634 614
         return '%d' % self.pk
635 615
 
636 616
 
637
-class MemberActivityGroupShareInfo(BaseModelMixin):
638
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
639
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
640
-
617
+class MemberActivityGroupShareInfo(BaseModelMixin, BrandInfoMixin):
641 618
     group_share_id = ShortUUIDField(_(u'group_share_id'), max_length=32, blank=True, null=True, help_text=u'活动群组分享唯一标识', db_index=True)
642 619
 
643 620
     activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)
@@ -664,7 +641,7 @@ class MemberActivityGroupShareInfo(BaseModelMixin):
664 641
         return '%d' % self.pk
665 642
 
666 643
 
667
-class MemberActivityContributionInfo(BaseModelMixin):
644
+class MemberActivityContributionInfo(BaseModelMixin, BrandInfoMixin):
668 645
     CONTENT_TYPE = (
669 646
         (0, u'投稿'),
670 647
         (1, u'创作日记'),
@@ -678,9 +655,6 @@ class MemberActivityContributionInfo(BaseModelMixin):
678 655
         (2, u'未通过'),
679 656
     )
680 657
 
681
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
682
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
683
-
684 658
     contribution_id = ShortUUIDField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'投稿唯一标识', db_index=True, unique=True)
685 659
 
686 660
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
@@ -715,6 +689,8 @@ class MemberActivityContributionInfo(BaseModelMixin):
715 689
     def data(self):
716 690
         return {
717 691
             'contribution_id': self.contribution_id,
692
+            'brand_id': self.brand_id,
693
+            'brand_name': self.brand_name,
718 694
             'user_id': self.user_id,
719 695
             'activity_id': self.activity_id,
720 696
             'content_type': self.content_type,
@@ -730,22 +706,18 @@ class MemberActivityContributionInfo(BaseModelMixin):
730 706
         }
731 707
 
732 708
 
733
-class MemberActivityContributionWelfareInfo(BaseModelMixin):
709
+class MemberActivityContributionWelfareInfo(BaseModelMixin, BrandInfoMixin):
734 710
     WELFARE_TYPE = (
735 711
         (0, u'实物'),
736 712
         (1, u'积分'),
737 713
         (2, u'虚拟'),
738 714
     )
739 715
 
740
-    brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True)
741
-    brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称')
716
+    welfare_id = ShortUUIDField(_(u'welfare_id'), max_length=32, blank=True, null=True, help_text=u'福利唯一标识', db_index=True, unique=True)
742 717
 
743 718
     activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)
744 719
 
745
-    welfare_id = ShortUUIDField(_(u'welfare_id'), max_length=32, blank=True, null=True, help_text=u'福利唯一标识', db_index=True, unique=True)
746
-
747 720
     welfare_type = models.IntegerField(_(u'welfare_type'), choices=WELFARE_TYPE, default=0, help_text=u'福利类型', db_index=True)
748
-
749 721
     welfare_title = models.CharField(_(u'welfare_title'), max_length=255, blank=True, null=True, help_text=u'福利标题')
750 722
     welfare_detail = RichTextField(_(u'welfare_detail'), blank=True, null=True, help_text=u'福利详情')
751 723
     welfare_value = models.IntegerField(_(u'welfare_value'), default=0, help_text=_(u'福利数量'))
@@ -771,8 +743,10 @@ class MemberActivityContributionWelfareInfo(BaseModelMixin):
771 743
     @property
772 744
     def data(self):
773 745
         return {
774
-            'activity_id': self.activity_id,
775 746
             'welfare_id': self.welfare_id,
747
+            'brand_id': self.brand_id,
748
+            'brand_name': self.brand_name,
749
+            'activity_id': self.activity_id,
776 750
             'welfare_type': self.welfare_type,
777 751
             'welfare_type_str': dict(MemberActivityContributionWelfareInfo.WELFARE_TYPE).get(self.welfare_type),
778 752
             'welfare_title': self.welfare_title,
@@ -781,3 +755,55 @@ class MemberActivityContributionWelfareInfo(BaseModelMixin):
781 755
             'welfare_image_url': self.welfare_image_url,
782 756
             'welfare_image_path': self.welfare_image_path,
783 757
         }
758
+
759
+
760
+class MemberActivityContributionWelfareUnlockingInfo(BaseModelMixin, BrandInfoMixin):
761
+    WELFARE_TYPE = (
762
+        (0, u'实物'),
763
+        (1, u'积分'),
764
+        (2, u'虚拟'),
765
+    )
766
+
767
+    unlocking_id = ShortUUIDField(_(u'unlocking_id'), max_length=32, blank=True, null=True, help_text=u'福利解锁唯一标识', db_index=True, unique=True)
768
+
769
+    admin_id = models.CharField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'管理员唯一标识', db_index=True)
770
+    user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
771
+
772
+    activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)
773
+
774
+    contribution_id = models.CharField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'投稿唯一标识', db_index=True)
775
+
776
+    welfare_id = models.CharField(_(u'welfare_id'), max_length=32, blank=True, null=True, help_text=u'福利唯一标识', db_index=True)
777
+
778
+    name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'姓名')
779
+    phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'电话')
780
+    address = models.CharField(_(u'address'), max_length=255, blank=True, null=True, help_text=u'地址')
781
+
782
+    tracking_number = models.CharField(_(u'tracking_number'), max_length=255, blank=True, null=True, help_text=u'快递单号')
783
+
784
+    is_handled = models.BooleanField(_(u'is_handled'), default=False, help_text=_(u'是否已处理'))
785
+
786
+    class Meta:
787
+        verbose_name = _(u'会员活动投稿福利解锁信息')
788
+        verbose_name_plural = _(u'会员活动投稿福利解锁信息')
789
+
790
+    def __unicode__(self):
791
+        return '%d' % self.pk
792
+
793
+    @property
794
+    def data(self):
795
+        return {
796
+            'unlocking_id': self.unlocking_id,
797
+            'brand_id': self.brand_id,
798
+            'brand_name': self.brand_name,
799
+            'admin_id': self.admin_id,
800
+            'user_id': self.user_id,
801
+            'activity_id': self.activity_id,
802
+            'contribution_id': self.contribution_id,
803
+            'welfare_id': self.welfare_id,
804
+            'name': self.name,
805
+            'phone': self.phone,
806
+            'address': self.address,
807
+            'tracking_number': self.tracking_number,
808
+            'is_handled': self.is_handled,
809
+        }