| @@ -8,8 +8,8 @@ from mch.models import ConsumeInfoSubmitLogInfo | ||
| 8 | 8 |  | 
| 9 | 9 |  | 
| 10 | 10 | class UserInfoAdmin(ChangeOnlyModelAdmin, admin.ModelAdmin): | 
| 11 | -    list_display = ('user_id', 'nickname', 'phone', 'appid', 'unionid', 'openid', 'openid_miniapp', 'location', 'balance', 'integral', 'freeze_integral', 'user_status', 'test_user', 'status', 'created_at', 'updated_at') | |
| 12 | -    list_filter = ('user_from', 'appid', 'subscribe', 'has_membercard', 'test_user', 'sex', 'user_status', 'status', 'code_version', 'new_subscribe', 'created_at', 'integral') | |
| 11 | +    list_display = ('user_id', 'nickname', 'phone', 'appid', 'unionid', 'openid', 'openid_miniapp', 'location', 'balance', 'integral', 'freeze_integral', 'user_status', 'test_user', 'integral', 'freeze_integral', 'shots_num', 'level', 'coupon_expire_at', 'is_maintenance', 'status', 'created_at', 'updated_at') | |
| 12 | +    list_filter = ('user_from', 'appid', 'subscribe', 'has_membercard', 'test_user', 'is_maintenance', 'sex', 'user_status', 'status', 'code_version', 'new_subscribe', 'created_at', 'integral') | |
| 13 | 13 |      readonly_fields = ('user_id', ) | 
| 14 | 14 |      search_fields = ('user_id', 'username', 'unionid', 'openid', 'openid_miniapp', 'name', 'phone', 'location', 'memberusercardcode') | 
| 15 | 15 |  | 
| @@ -0,0 +1,20 @@ | ||
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | +# Generated by Django 1.11.29 on 2021-09-05 17:09 | |
| 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 | +        ('account', '0053_userinfo_resgister_at'), | |
| 12 | + ] | |
| 13 | + | |
| 14 | + operations = [ | |
| 15 | + migrations.AddField( | |
| 16 | + model_name='userinfo', | |
| 17 | + name='coupon_expire_at', | |
| 18 | + field=models.DateTimeField(blank=True, help_text='\u4f18\u60e0\u5238\u8fc7\u671f\u65f6\u95f4', null=True, verbose_name='coupon_expire_at'), | |
| 19 | + ), | |
| 20 | + ] | 
| @@ -139,6 +139,9 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin): | ||
| 139 | 139 | shots_num = models.IntegerField(_(u'shots_num'), default=0, help_text=u'主持镜头数') | 
| 140 | 140 | level = models.IntegerField(_(u'level'), choices=LEVEL_TUPLE, default=MEMBER_NO, help_text=u'会员等级') | 
| 141 | 141 |  | 
| 142 | + # 优惠券信息 | |
| 143 | + coupon_expire_at = models.DateTimeField(_(u'coupon_expire_at'), blank=True, null=True, help_text=_(u'优惠券过期时间')) | |
| 144 | + | |
| 142 | 145 | # 维修员信息 | 
| 143 | 146 | is_maintenance = models.BooleanField(_(u'is_maintenance'), default=False, help_text=_(u'是否维修员')) | 
| 144 | 147 |  | 
| @@ -0,0 +1,43 @@ | ||
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | + | |
| 3 | +import logging | |
| 4 | +import time | |
| 5 | + | |
| 6 | +from django_six import CompatibilityBaseCommand, close_old_connections | |
| 7 | +from TimeConvert import TimeConvert as tc | |
| 8 | + | |
| 9 | +from account.models import UserInfo | |
| 10 | +from coupon.models import CouponInfo, UserCouponInfo | |
| 11 | +from member.models import RightInfo | |
| 12 | +from utils.redis.connect import r | |
| 13 | +from utils.redis.rkeys import MEMBER_SEND_COUPON_LIST | |
| 14 | + | |
| 15 | + | |
| 16 | +logger = logging.getLogger('console') | |
| 17 | + | |
| 18 | + | |
| 19 | +class Command(CompatibilityBaseCommand): | |
| 20 | + def handle(self, *args, **options): | |
| 21 | + coupon_ids = [] | |
| 22 | + | |
| 23 | + rights = RightInfo.objects.filter(is_send_coupon=True, status=True) | |
| 24 | + for right in rights: | |
| 25 | + for coupon_id in [right.coupon_level1_id, right.coupon_level2_id, right.coupon_level3_id, right.coupon_level4_id, right.coupon_level5_id]: | |
| 26 | + if not coupon_id: | |
| 27 | + continue | |
| 28 | + | |
| 29 | + try: | |
| 30 | + coupon = CouponInfo.objects.get(coupon_id=coupon_id) | |
| 31 | + except CouponInfo.DoesNotExist: | |
| 32 | + continue | |
| 33 | + | |
| 34 | + coupon_ids.append(coupon_id) | |
| 35 | + | |
| 36 | + users = UserInfo.objects.all() | |
| 37 | + for user in users: | |
| 38 | +            coupons = UserCouponInfo.objects.filter(coupon_id__in=coupon_ids, status=True).order_by('-expire_at') | |
| 39 | + if not coupons: | |
| 40 | + continue | |
| 41 | + | |
| 42 | + user.coupon_expire_at = coupons[0].expire_at | |
| 43 | + user.save() | 
| @@ -87,7 +87,7 @@ class SaleclerkSubmitLogInfo(BaseModelMixin): | ||
| 87 | 87 | model_uni_name = models.CharField(_(u'model_uni_name'), max_length=255, blank=True, null=True, help_text=u'型号统称') | 
| 88 | 88 |  | 
| 89 | 89 | distributor_pk = models.IntegerField(_(u'distributor_pk'), default=0, help_text=u'经销商PK', db_index=True) | 
| 90 | - distributor_id = models.CharField(_(u'distributor_id'), max_length=32, blank=True, null=True, help_text=u'经销商唯一标识', db_index=True) | |
| 90 | + distributor_id = models.CharField(_(u'distributor_id'), max_length=32, blank=True, null=True, help_text=u'经销商唯一标识', db_index=True) | |
| 91 | 91 | distributor_name = models.CharField(_(u'distributor_name'), max_length=32, blank=True, null=True, help_text=u'经销商名称') | 
| 92 | 92 |  | 
| 93 | 93 | clerk_id = models.CharField(_(u'clerk_id'), max_length=32, blank=True, null=True, help_text=u'店员唯一标识', db_index=True) | 
| @@ -152,11 +152,19 @@ class SaleclerkSubmitLogInfo(BaseModelMixin): | ||
| 152 | 152 | def admindata(self): | 
| 153 | 153 | try: | 
| 154 | 154 | distributor = DistributorInfo.objects.get(distributor_id=self.distributor_id) | 
| 155 | - sr = SalesResponsibilityInfo.objects.get(sr_id=distributor.sr_id) | |
| 156 | - | |
| 155 | + except DistributorInfo.DoesNotExist: | |
| 156 | + distributor = None | |
| 157 | + if distributor: | |
| 158 | + try: | |
| 159 | + sr = SalesResponsibilityInfo.objects.get(sr_id=distributor.sr_id) | |
| 160 | + except SalesResponsibilityInfo.DoesNotExist: | |
| 161 | + sr = None | |
| 162 | + else: | |
| 163 | + sr = None | |
| 164 | + if sr: | |
| 157 | 165 | office = distributor.office | 
| 158 | 166 | sr_name = sr.name | 
| 159 | - except: | |
| 167 | + else: | |
| 160 | 168 | office = '' | 
| 161 | 169 | sr_name = '' | 
| 162 | 170 |  | 
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | CodeConvert==3.0.2 | 
| 2 | 2 | Pillow==8.3.1 | 
| 3 | 3 | StatusCode==1.0.0 | 
| 4 | -TimeConvert==1.5.4 | |
| 4 | +TimeConvert==1.6.0 | |
| 5 | 5 | furl==2.1.2 | 
| 6 | 6 | isoweek==1.3.3 | 
| 7 | 7 | jsonfield==3.1.0 |