redpack_send_num

Brightcells 7 anos atrás
pai
commit
8b5e39b6aa

+ 4 - 0
api/hb_views.py

@@ -7,12 +7,16 @@ from miniapp.redpack_views import send_jsapi_hb
7 7
 
8 8
 
9 9
 def exec_send_jsapi_hb(user, elog, amount):
10
+    if elog.redpack_send_num >= 3:
11
+        return
12
+
10 13
     send_jsapi_hb(user.brand_id, user.openid, amount, transfer=False)
11 14
 
12 15
     elog.has_send_redpack = True
13 16
     elog.redpack_send_amount = amount
14 17
     elog.user_id = user.user_id
15 18
     elog.nickname = user.nickname
19
+    elog.redpack_send_num += 1
16 20
     elog.save()
17 21
 
18 22
     RedpackSendLogInfo.objects.create(

+ 2 - 1
api/mch_views.py

@@ -393,7 +393,8 @@ def consumer_info_api(request):
393 393
     except MchInfoEncryptLogInfo.MultipleObjectsReturned:
394 394
         elog = None
395 395
 
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):
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 398
         amount = elog.redpack_amount
398 399
         if elog.redpack_max_amount:
399 400
             amount = random.randint(100, elog.redpack_max_amount)

+ 20 - 0
logs/migrations/0011_mchinfoencryptloginfo_redpack_send_num.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.22 on 2019-09-18 08:27
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
+        ('logs', '0010_auto_20190816_1827'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='mchinfoencryptloginfo',
17
+            name='redpack_send_num',
18
+            field=models.IntegerField(default=0, help_text='\u7ea2\u5305\u53d1\u653e\u4e2a\u6570', verbose_name='redpack_send_num'),
19
+        ),
20
+    ]

+ 2 - 0
logs/models.py

@@ -26,6 +26,8 @@ class MchInfoEncryptLogInfo(BaseModelMixin):
26 26
     has_send_redpack = models.BooleanField(_(u'has_send_redpack'), default=False, help_text=u'是否已发放红包', db_index=True)
27 27
     redpack_send_amount = models.IntegerField(_(u'redpack_send_amount'), default=0, help_text=u'红包发放金额,单位:分)')
28 28
 
29
+    redpack_send_num = models.IntegerField(_(u'redpack_send_num'), default=0, help_text=u'红包发放个数')
30
+
29 31
     user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识(红包)', db_index=True)
30 32
     nickname = models.CharField(_(u'nickname'), max_length=255, blank=True, null=True, help_text=u'用户昵称')
31 33