@@ -8,7 +8,7 @@ from django_six import CompatibilityBaseCommand, close_old_connections |
||
| 8 | 8 |
from TimeConvert import TimeConvert as tc |
| 9 | 9 |
|
| 10 | 10 |
from account.models import UserInfo |
| 11 |
-from coupon.models import UserCouponInfo |
|
| 11 |
+from coupon.models import CouponInfo, UserCouponInfo |
|
| 12 | 12 |
from member.models import RightInfo |
| 13 | 13 |
from utils.redis.connect import r |
| 14 | 14 |
from utils.redis.rkeys import MEMBER_SEND_COUPON_LIST |
@@ -48,8 +48,8 @@ class Command(CompatibilityBaseCommand): |
||
| 48 | 48 |
if coupon_id: |
| 49 | 49 |
# 发放商城兑换券 |
| 50 | 50 |
try: |
| 51 |
- coupon = UserCouponInfo.objects.get(coupon_id=coupon_id) |
|
| 52 |
- except UserCouponInfo.DoesNotExist: |
|
| 51 |
+ coupon = CouponInfo.objects.get(coupon_id=coupon_id) |
|
| 52 |
+ except CouponInfo.DoesNotExist: |
|
| 53 | 53 |
continue |
| 54 | 54 |
|
| 55 | 55 |
UserCouponInfo.objects.create( |
@@ -66,27 +66,33 @@ class Command(CompatibilityBaseCommand): |
||
| 66 | 66 |
coupon_valid_period=coupon.coupon_valid_period, |
| 67 | 67 |
coupon_limit_brand_ids=coupon.coupon_limit_brand_ids, |
| 68 | 68 |
) |
| 69 |
+ |
|
| 69 | 70 |
else: |
| 70 | 71 |
# 发放会员权益 |
| 71 | 72 |
rights = RightInfo.objects.filter(is_send_coupon=True, status=True) |
| 72 | 73 |
for right in rights: |
| 73 | 74 |
if user.level == UserInfo.MEMBER_LRC: |
| 74 | 75 |
coupon_id = right.coupon_level1_id |
| 76 |
+ coupon_num = right.coupon_level1_num |
|
| 75 | 77 |
elif user.level == UserInfo.MEMBER_SILVER: |
| 76 | 78 |
coupon_id = right.coupon_level2_id |
| 79 |
+ coupon_num = right.coupon_level2_num |
|
| 77 | 80 |
elif user.level == UserInfo.MEMBER_SILVER: |
| 78 | 81 |
coupon_id = right.coupon_level3_id |
| 82 |
+ coupon_num = right.coupon_level3_num |
|
| 79 | 83 |
elif user.level == UserInfo.MEMBER_SILVER: |
| 80 | 84 |
coupon_id = right.coupon_level4_id |
| 85 |
+ coupon_num = right.coupon_level4_num |
|
| 81 | 86 |
else: |
| 82 | 87 |
coupon_id = right.coupon_level5_id |
| 88 |
+ coupon_num = right.coupon_level5_num |
|
| 83 | 89 |
|
| 84 | 90 |
try: |
| 85 |
- coupon = UserCouponInfo.objects.get(coupon_id=coupon_id) |
|
| 86 |
- except UserCouponInfo.DoesNotExist: |
|
| 91 |
+ coupon = CouponInfo.objects.get(coupon_id=coupon_id) |
|
| 92 |
+ except CouponInfo.DoesNotExist: |
|
| 87 | 93 |
continue |
| 88 | 94 |
|
| 89 |
- for _ in xrange(right.coupon_num): |
|
| 95 |
+ for _ in xrange(right.coupon_num or coupon_num): |
|
| 90 | 96 |
UserCouponInfo.objects.create( |
| 91 | 97 |
brand_id=coupon.brand_id, |
| 92 | 98 |
brand_name=coupon.brand_name, |
@@ -0,0 +1,21 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2019-12-23 10:30 |
|
| 3 |
+from __future__ import unicode_literals |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations |
|
| 6 |
+import shortuuidfield.fields |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+class Migration(migrations.Migration): |
|
| 10 |
+ |
|
| 11 |
+ dependencies = [ |
|
| 12 |
+ ('coupon', '0004_usercouponinfo_coupon_image'),
|
|
| 13 |
+ ] |
|
| 14 |
+ |
|
| 15 |
+ operations = [ |
|
| 16 |
+ migrations.AlterField( |
|
| 17 |
+ model_name='usercouponinfo', |
|
| 18 |
+ name='coupon_id', |
|
| 19 |
+ field=shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u5238\u552f\u4e00\u6807\u8bc6', max_length=22, null=True), |
|
| 20 |
+ ), |
|
| 21 |
+ ] |
@@ -47,7 +47,7 @@ class UserCouponInfo(BaseModelMixin): |
||
| 47 | 47 |
brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
| 48 | 48 |
brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
| 49 | 49 |
|
| 50 |
- coupon_id = ShortUUIDField(_(u'coupon_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True, unique=True) |
|
| 50 |
+ coupon_id = ShortUUIDField(_(u'coupon_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True) |
|
| 51 | 51 |
user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True) |
| 52 | 52 |
|
| 53 | 53 |
coupon_title = models.CharField(_(u'coupon_title'), max_length=255, blank=True, null=True, help_text=u'券标题') |
@@ -0,0 +1,40 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2019-12-23 10:08 |
|
| 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 |
+ ('member', '0015_auto_20191221_2058'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.AddField( |
|
| 16 |
+ model_name='rightinfo', |
|
| 17 |
+ name='coupon_level1_num', |
|
| 18 |
+ field=models.IntegerField(default=0, help_text='\u5238\u6bcf\u4f1a\u5458\u7ea7\u522b\u53d1\u653e\u5f20\u6570', verbose_name='coupon_level1_num'), |
|
| 19 |
+ ), |
|
| 20 |
+ migrations.AddField( |
|
| 21 |
+ model_name='rightinfo', |
|
| 22 |
+ name='coupon_level2_num', |
|
| 23 |
+ field=models.IntegerField(default=0, help_text='\u5238\u6bcf\u4f1a\u5458\u7ea7\u522b\u53d1\u653e\u5f20\u6570', verbose_name='coupon_level2_num'), |
|
| 24 |
+ ), |
|
| 25 |
+ migrations.AddField( |
|
| 26 |
+ model_name='rightinfo', |
|
| 27 |
+ name='coupon_level3_num', |
|
| 28 |
+ field=models.IntegerField(default=0, help_text='\u5238\u6bcf\u4f1a\u5458\u7ea7\u522b\u53d1\u653e\u5f20\u6570', verbose_name='coupon_level3_num'), |
|
| 29 |
+ ), |
|
| 30 |
+ migrations.AddField( |
|
| 31 |
+ model_name='rightinfo', |
|
| 32 |
+ name='coupon_level4_num', |
|
| 33 |
+ field=models.IntegerField(default=0, help_text='\u5238\u6bcf\u4f1a\u5458\u7ea7\u522b\u53d1\u653e\u5f20\u6570', verbose_name='coupon_level4_num'), |
|
| 34 |
+ ), |
|
| 35 |
+ migrations.AddField( |
|
| 36 |
+ model_name='rightinfo', |
|
| 37 |
+ name='coupon_level5_num', |
|
| 38 |
+ field=models.IntegerField(default=0, help_text='\u5238\u6bcf\u4f1a\u5458\u7ea7\u522b\u53d1\u653e\u5f20\u6570', verbose_name='coupon_level5_num'), |
|
| 39 |
+ ), |
|
| 40 |
+ ] |
@@ -170,6 +170,11 @@ class RightInfo(BaseModelMixin): |
||
| 170 | 170 |
# 券相关 |
| 171 | 171 |
is_send_coupon = models.BooleanField(_(u'is_send_coupon'), default=False, help_text=_(u'是否发券'), db_index=True) |
| 172 | 172 |
coupon_num = models.IntegerField(_(u'coupon_num'), default=0, help_text=_(u'券每会员级别发放张数')) |
| 173 |
+ coupon_level1_num = models.IntegerField(_(u'coupon_level1_num'), default=0, help_text=_(u'券每会员级别发放张数')) |
|
| 174 |
+ coupon_level2_num = models.IntegerField(_(u'coupon_level2_num'), default=0, help_text=_(u'券每会员级别发放张数')) |
|
| 175 |
+ coupon_level3_num = models.IntegerField(_(u'coupon_level3_num'), default=0, help_text=_(u'券每会员级别发放张数')) |
|
| 176 |
+ coupon_level4_num = models.IntegerField(_(u'coupon_level4_num'), default=0, help_text=_(u'券每会员级别发放张数')) |
|
| 177 |
+ coupon_level5_num = models.IntegerField(_(u'coupon_level5_num'), default=0, help_text=_(u'券每会员级别发放张数')) |
|
| 173 | 178 |
coupon_level1_id = models.CharField(_(u'coupon_level1_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True) |
| 174 | 179 |
coupon_level2_id = models.CharField(_(u'coupon_level2_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True) |
| 175 | 180 |
coupon_level3_id = models.CharField(_(u'coupon_level3_id'), max_length=32, blank=True, null=True, help_text=u'券唯一标识', db_index=True) |