3334afd0edd7bL327">327
test_user=user.test_user,
code_version=code_version,
ym=ymd[:6],
@@ -417,12 +431,6 @@ def consumer_info_api(request):
'model_id': model.model_id,
})
- # 更新销售员提交的表
- logs = SaleclerkSubmitLogInfo.objects.filter(code=serialNo, model_pk=model.pk)
- for log in logs:
- log.has_scan = True
- log.save()
-
if not dupload:
user.shots_num += 1
if user.level < UserInfo.MEMBER_BLACK_GOLD:
@@ -0,0 +1,30 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2020-04-11 13:43 |
|
| 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 |
+ ('coupon', '0007_auto_20191230_1605'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.AddField( |
|
| 16 |
+ model_name='usercouponinfo', |
|
| 17 |
+ name='acitvity_id', |
|
| 18 |
+ field=models.CharField(blank=True, db_index=True, default=b'MEMBER_BENEFITS', help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='acitvity_id'), |
|
| 19 |
+ ), |
|
| 20 |
+ migrations.AddField( |
|
| 21 |
+ model_name='usercouponinfo', |
|
| 22 |
+ name='acitvity_name', |
|
| 23 |
+ field=models.CharField(blank=True, db_index=True, default=b'MEMBER_BENEFITS', help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='activity_id'), |
|
| 24 |
+ ), |
|
| 25 |
+ migrations.AddField( |
|
| 26 |
+ model_name='usercouponinfo', |
|
| 27 |
+ name='coupon_from', |
|
| 28 |
+ field=models.CharField(blank=True, db_index=True, default=b'MEMBER_BENEFITS', help_text='\u52b5\u6765\u6e90', max_length=32, null=True, verbose_name='coupon_from'), |
|
| 29 |
+ ), |
|
| 30 |
+ ] |
@@ -0,0 +1,25 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2020-04-11 14:54 |
|
| 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 |
+ ('coupon', '0008_auto_20200411_2143'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.AlterField( |
|
| 16 |
+ model_name='usercouponinfo', |
|
| 17 |
+ name='acitvity_id', |
|
| 18 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='acitvity_id'), |
|
| 19 |
+ ), |
|
| 20 |
+ migrations.AlterField( |
|
| 21 |
+ model_name='usercouponinfo', |
|
| 22 |
+ name='acitvity_name', |
|
| 23 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='activity_id'), |
|
| 24 |
+ ), |
|
| 25 |
+ ] |
@@ -0,0 +1,20 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2020-04-11 14:54 |
|
| 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 |
+ ('coupon', '0009_auto_20200411_2254'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.AlterField( |
|
| 16 |
+ model_name='usercouponinfo', |
|
| 17 |
+ name='acitvity_name', |
|
| 18 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='acitvity_name'), |
|
| 19 |
+ ), |
|
| 20 |
+ ] |
@@ -0,0 +1,33 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2020-04-11 15:16 |
|
| 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 |
+ ('coupon', '0010_auto_20200411_2254'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.RemoveField( |
|
| 16 |
+ model_name='usercouponinfo', |
|
| 17 |
+ name='acitvity_id', |
|
| 18 |
+ ), |
|
| 19 |
+ migrations.RemoveField( |
|
| 20 |
+ model_name='usercouponinfo', |
|
| 21 |
+ name='acitvity_name', |
|
| 22 |
+ ), |
|
| 23 |
+ migrations.AddField( |
|
| 24 |
+ model_name='usercouponinfo', |
|
| 25 |
+ name='activity_id', |
|
| 26 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='activity_id'), |
|
| 27 |
+ ), |
|
| 28 |
+ migrations.AddField( |
|
| 29 |
+ model_name='usercouponinfo', |
|
| 30 |
+ name='activity_name', |
|
| 31 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u6d3b\u52a8\u540d\u79f0', max_length=32, null=True, verbose_name='activity_name'), |
|
| 32 |
+ ), |
|
| 33 |
+ ] |
@@ -42,6 +42,21 @@ class CouponInfo(BaseModelMixin): |
||
| 42 | 42 |
def __unicode__(self): |
| 43 | 43 |
return unicode(self.pk) |
| 44 | 44 |
|
| 45 |
+ @property |
|
| 46 |
+ def coupon_image_path(self): |
|
| 47 |
+ return upload_file_path(self.coupon_image) |
|
| 48 |
+ |
|
| 49 |
+ @property |
|
| 50 |
+ def coupon_image_url(self): |
|
| 51 |
+ return upload_file_url(self.coupon_image) |
|
| 52 |
+ |
|
| 53 |
+ |
|
| 54 |
+ @property |
|
| 55 |
+ def final_expire_at(self): |
|
| 56 |
+ if self.coupon_expire_type == CouponInfo.FIXED_EXPIRED_TIME: |
|
| 57 |
+ return self.coupon_expire_at |
|
| 58 |
+ return tc.utc_datetime(days=self.coupon_valid_period) |
|
| 59 |
+ |
|
| 45 | 60 |
|
| 46 | 61 |
class UserCouponInfo(BaseModelMixin): |
| 47 | 62 |
brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
@@ -66,6 +81,10 @@ class UserCouponInfo(BaseModelMixin): |
||
| 66 | 81 |
admin_id = models.CharField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'核销员唯一标识', db_index=True) |
| 67 | 82 |
used_at = models.DateTimeField(_(u'used_at'), blank=True, null=True, help_text=u'维修券核销时间') |
| 68 | 83 |
|
| 84 |
+ coupon_from = models.CharField(_(u'coupon_from'), default='MEMBER_BENEFITS', max_length=32, blank=True, null=True, help_text=u'劵来源', db_index=True) |
|
| 85 |
+ activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True) |
|
| 86 |
+ activity_name = models.CharField(_(u'activity_name'), max_length=32, blank=True, null=True, help_text=u'活动名称', db_index=True) |
|
| 87 |
+ |
|
| 69 | 88 |
class Meta: |
| 70 | 89 |
verbose_name = _(u'用户券信息') |
| 71 | 90 |
verbose_name_plural = _(u'用户券信息') |
@@ -227,7 +227,7 @@ class ConsumeInfoSubmitLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): |
||
| 227 | 227 |
|
| 228 | 228 |
|
| 229 | 229 |
class ActivityInfoAdmin(admin.ModelAdmin): |
| 230 |
- list_display = ('activity_name', 'model_uni_names', 'start_at', 'end_at', 'coupon_expire_type', 'coupon_valid_period', 'coupon_expire_at', 'coupon_value', 'status', 'created_at', 'updated_at')
|
|
| 230 |
+ list_display = ('activity_id', 'activity_name', 'model_uni_names', 'start_at', 'end_at', 'coupon_expire_type', 'coupon_valid_period', 'coupon_expire_at', 'coupon_value', 'status', 'created_at', 'updated_at')
|
|
| 231 | 231 |
list_filter = ('coupon_expire_type', 'status')
|
| 232 | 232 |
|
| 233 | 233 |
|
@@ -0,0 +1,26 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.26 on 2020-04-11 13:43 |
|
| 3 |
+from __future__ import unicode_literals |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations, models |
|
| 6 |
+import shortuuidfield.fields |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+class Migration(migrations.Migration): |
|
| 10 |
+ |
|
| 11 |
+ dependencies = [ |
|
| 12 |
+ ('mch', '0053_auto_20200407_1118'),
|
|
| 13 |
+ ] |
|
| 14 |
+ |
|
| 15 |
+ operations = [ |
|
| 16 |
+ migrations.AddField( |
|
| 17 |
+ model_name='activityinfo', |
|
| 18 |
+ name='activity_id', |
|
| 19 |
+ field=shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u6d3b\u52a8\u552f\u4e00\u6807\u8bc6', max_length=22, null=True, unique=True), |
|
| 20 |
+ ), |
|
| 21 |
+ migrations.AlterField( |
|
| 22 |
+ model_name='consumeinfosubmitloginfo', |
|
| 23 |
+ name='province', |
|
| 24 |
+ field=models.CharField(blank=True, db_index=True, help_text='\u7701\u4efd', max_length=32, null=True, verbose_name='province'), |
|
| 25 |
+ ), |
|
| 26 |
+ ] |
@@ -9,6 +9,8 @@ from jsonfield import JSONField |
||
| 9 | 9 |
from shortuuidfield import ShortUUIDField |
| 10 | 10 |
from TimeConvert import TimeConvert as tc |
| 11 | 11 |
|
| 12 |
+from coupon.models import CouponInfo |
|
| 13 |
+ |
|
| 12 | 14 |
|
| 13 | 15 |
class AdministratorInfo(BaseModelMixin): |
| 14 | 16 |
ADMINISTRATOR = 0 |
@@ -704,6 +706,7 @@ class ActivityInfo(BaseModelMixin): |
||
| 704 | 706 |
(CHANGED_EXPIRED_TIME, u'可变结束时间'), |
| 705 | 707 |
) |
| 706 | 708 |
|
| 709 |
+ activity_id = ShortUUIDField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True, unique=True) |
|
| 707 | 710 |
activity_name = models.CharField(_(u'activity_name'), max_length=255, blank=True, null=True, help_text=u'活动名称') |
| 708 | 711 |
|
| 709 | 712 |
model_uni_names = JSONField(_(u'model_uni_names'), default=[], blank=True, null=True, help_text=u'型号统一名称列表') |
@@ -740,7 +743,7 @@ class ActivityInfo(BaseModelMixin): |
||
| 740 | 743 |
return u'{}年{}月{}日'.format(y, m, d)
|
| 741 | 744 |
|
| 742 | 745 |
def has_unexpired_activity(self, model_name): |
| 743 |
- return (self.model_uni_names and model_name in self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at) |
|
| 746 |
+ return ((self.model_uni_names and model_name in self.model_uni_names) or not self.model_uni_names) and (self.start_at <= tc.utc_datetime() < self.end_at) |
|
| 744 | 747 |
|
| 745 | 748 |
def coupon_info(self, created_at=None): |
| 746 | 749 |
return {
|
@@ -748,6 +751,25 @@ class ActivityInfo(BaseModelMixin): |
||
| 748 | 751 |
'coupon_value': self.coupon_value, |
| 749 | 752 |
'coupon_has_expired': tc.utc_datetime() >= self.final_expire_at(created_at=created_at), |
| 750 | 753 |
} |
| 754 |
+ |
|
| 751 | 755 |
|
| 752 | 756 |
def coupon_info2(self, created_at=None): |
| 753 | 757 |
return self.coupon_info(created_at=created_at), |
| 758 |
+ |
|
| 759 |
+ @property |
|
| 760 |
+ def coupon_info3(self): |
|
| 761 |
+ try: |
|
| 762 |
+ coupon_info = CouponInfo.objects.get(coupon_id=self.coupon_id) |
|
| 763 |
+ return {
|
|
| 764 |
+ 'coupon_image': coupon_info.coupon_image_url, |
|
| 765 |
+ 'coupon_expire_at': coupon_info.coupon_expire_at, |
|
| 766 |
+ 'coupon_value': coupon_info.coupon_value, |
|
| 767 |
+ 'coupon_title': coupon_info.coupon_title, |
|
| 768 |
+ 'coupon_valid_period': coupon_info.coupon_valid_period, |
|
| 769 |
+ 'coupon_id': coupon_info.coupon_id, |
|
| 770 |
+ 'activity_id': self.activity_id, |
|
| 771 |
+ 'activity_name': self.activity_name, |
|
| 772 |
+ } |
|
| 773 |
+ except: |
|
| 774 |
+ return {}
|
|
| 775 |
+ |