:art: UserIds

huangqimin преди 6 години
родител
ревизия
3caa1c3bd8
променени са 3 файла, в които са добавени 27 реда и са изтрити 1 реда
  1. 3 1
      api/mch_views.py
  2. 21 0
      logs/migrations/0013_mchinfoencryptloginfo_user_ids.py
  3. 3 0
      logs/models.py

+ 3 - 1
api/mch_views.py

@@ -394,7 +394,9 @@ def consumer_info_api(request):
394 394
         elog = None
395 395
 
396 396
     # if elog and (not dupload) and elog.is_send_redpack and (not elog.has_send_redpack) and (elog.redpack_amount or elog.redpack_max_amount):
397
-    if elog and elog.is_send_redpack and (not elog.has_send_redpack) and (elog.redpack_amount or elog.redpack_max_amount):
397
+    if elog and (user.user_id not in elog.user_ids) and elog.is_send_redpack and (not elog.has_send_redpack) and (elog.redpack_amount or elog.redpack_max_amount):
398
+        elog.user_ids = list(set(elog.user_ids + [user.user_id]))
399
+        elog.save()
398 400
         amount = elog.redpack_amount
399 401
         if elog.redpack_max_amount:
400 402
             amount = random.randint(100, elog.redpack_max_amount)

+ 21 - 0
logs/migrations/0013_mchinfoencryptloginfo_user_ids.py

@@ -0,0 +1,21 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.28 on 2020-03-16 10:09
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
+        ('logs', '0012_mchinfoencryptloginfo_pre_redpack_send_amount'),
13
+    ]
14
+
15
+    operations = [
16
+        migrations.AddField(
17
+            model_name='mchinfoencryptloginfo',
18
+            name='user_ids',
19
+            field=jsonfield.fields.JSONField(default=[], help_text='USER_IDS', verbose_name='user_ids'),
20
+        ),
21
+    ]

+ 3 - 0
logs/models.py

@@ -3,6 +3,7 @@
3 3
 from django.db import models
4 4
 from django.utils.translation import ugettext_lazy as _
5 5
 from django_models_ext import BaseModelMixin, upload_path
6
+from jsonfield import JSONField
6 7
 from shortuuidfield import ShortUUIDField
7 8
 
8 9
 
@@ -32,6 +33,8 @@ class MchInfoEncryptLogInfo(BaseModelMixin):
32 33
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识(红包)', db_index=True)
33 34
     nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称')
34 35
 
36
+    user_ids = JSONField(_(u'user_ids'), default=[], help_text=u'USER_IDS')
37
+
35 38
     is_clerk_send_redpack = models.BooleanField(_(u'is_clerk_send_redpack'), default=False, help_text=u'销售员是否发放红包', db_index=True)
36 39
     clerk_redpack_amount = models.IntegerField(_(u'clerk_redpack_amount'), default=0, help_text=u'销售员红包固定金额,单位:分')
37 40
     clerk_redpack_max_amount = models.IntegerField(_(u'clerk_redpack_max_amount'), default=0, help_text=u'销售员红包金额范围,单位:分)')