Add integral for ModelInfo

Brightcells 7 years ago
parent
commit
71993af1e4
5 changed files with 30 additions and 2 deletions
  1. 1 0
      api/encrypt_views.py
  2. 20 0
      mch/migrations/0010_modelinfo_integral.py
  3. 2 0
      mch/models.py
  4. 6 1
      page/sale_views.py
  5. 1 1
      requirements.txt

+ 1 - 0
api/encrypt_views.py

@@ -84,6 +84,7 @@ def decrypt(request):
84 84
         'model_imgs': model.images if model else [],
85 85
         'goodsInfo': {
86 86
             'Brand': brand.brand_name if brand else '',
87
+            'ModelID': model_pk,
87 88
             'Model': model.model_name if model else '',
88 89
             'SerialNo': sn,
89 90
         }

+ 20 - 0
mch/migrations/0010_modelinfo_integral.py

@@ -0,0 +1,20 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.11 on 2018-03-28 08:51
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
+        ('mch', '0009_auto_20180129_0426'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='modelinfo',
17
+            name='integral',
18
+            field=models.IntegerField(default=100, help_text='\u79ef\u5206', verbose_name='integral'),
19
+        ),
20
+    ]

+ 2 - 0
mch/models.py

@@ -73,6 +73,8 @@ class ModelInfo(BaseModelMixin):
73 73
     model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称')
74 74
     model_descr = models.TextField(_(u'model_descr'), max_length=255, blank=True, null=True, help_text=u'型号描述')
75 75
 
76
+    integral = models.IntegerField(_(u'integral'), default=100, help_text=u'积分')
77
+
76 78
     position = models.IntegerField(_(u'position'), default=1, help_text=u'排序')
77 79
 
78 80
     class Meta:

+ 6 - 1
page/sale_views.py

@@ -10,6 +10,7 @@ from django_response import response
10 10
 
11 11
 from account.models import SaleclerkInfo, UserInfo
12 12
 from integral.models import SaleclerkIntegralIncomeExpensesInfo, SaleclerkSubmitLogInfo
13
+from mch.models import ModelInfo
13 14
 from product.models import ProductCodeSubmitLogInfo, ProductInfo, ProductModelInfo
14 15
 from utils.error.errno_utils import ProductModelStatusCode, ProductStatusCode, SaleclerkStatusCode
15 16
 
@@ -39,6 +40,7 @@ def clerk_sale_submit_api(request):
39 40
     encryptedData = request.POST.get('encryptedData', '')
40 41
     lat = request.POST.get('lat', '')
41 42
     lon = request.POST.get('lon', '')
43
+    ModelID = request.POST.get('ModelID', '')
42 44
     serialNo = request.POST.get('SerialNo', '')
43 45
     verifyResult = request.POST.get('verifyResult', '')
44 46
 
@@ -74,7 +76,10 @@ def clerk_sale_submit_api(request):
74 76
 
75 77
     # 店员积分
76 78
     # TODO: 序列号 vs. 积分
77
-    integral = 100
79
+    try:
80
+        integral = ModelInfo.objects.get(ModelID=ModelID).integral
81
+    except ModelInfo.DoesNotExist:
82
+        return response(ProductModelStatusCode.MODEL_NOT_FOUND)
78 83
 
79 84
     clerk.integral += integral
80 85
     clerk.total_integral += integral

+ 1 - 1
requirements.txt

@@ -9,7 +9,7 @@ django-admin==1.2.0
9 9
 django-curtail-uuid==1.0.4
10 10
 django-detect==1.0.5
11 11
 django-file-md5==1.0.2
12
-django-file-upload==1.0.1
12
+django-file-upload==1.0.2
13 13
 django-ip==1.0.2
14 14
 django-json-render==1.0.0
15 15
 django-json-response==1.1.5