decrypt2

huangqimin 5 年 前
コミット
f17ee852fd
共有3 個のファイルを変更した56 個の追加9 個の削除を含む
  1. 15 9
      api/encrypt_views.py
  2. 35 0
      logs/migrations/0007_auto_20200114_1229.py
  3. 6 0
      logs/models.py

+ 15 - 9
api/encrypt_views.py

@@ -57,6 +57,7 @@ def encrypt(request):
57 57
                 marketcode.has_used = True
58 58
                 marketcode.save()
59 59
 
60
+                mieli.application_id = marketcode.application_id
60 61
                 mieli.code = marketcode.code
61 62
                 mieli.code_url = marketcode.code_url
62 63
                 mieli.brand_pk = brand_pk
@@ -191,11 +192,11 @@ def decrypt2(request):
191 192
     code = code_info.get('code', '')
192 193
 
193 194
     try:
194
-        miel = MchInfoEncryptLogInfo.objects.get(code=code)
195
+        mieli = MchInfoEncryptLogInfo.objects.get(code=code)
195 196
     except MchInfoEncryptLogInfo.DoesNotExist:
196 197
         return response()
197 198
 
198
-    plaintext = miel.plaintext
199
+    plaintext = mieli.plaintext
199 200
 
200 201
     # brand_id#model_id#distributor_id#sn#time
201 202
     # AAAA#AAAAAA#AAAAA#AAAAAAAAAAAAAA#180224
@@ -211,13 +212,18 @@ def decrypt2(request):
211 212
     except ModelInfo.DoesNotExist:
212 213
         model = None
213 214
 
214
-    mdli, created_at = MchInfoDecryptLogInfo.objects.get_or_create(ciphertext=ciphertext, defaults={
215
-        'brand_pk': brand_pk,
216
-        'model_pk': model_pk,
217
-        'distributor_pk': distributor_pk,
218
-        'sn': sn,
219
-        'decrypt_count': 1,
220
-    })
215
+    mdli, created_at = MchInfoDecryptLogInfo.objects.get_or_create(
216
+        application_id=mieli.application_id,
217
+        code=mieli.code,
218
+        code_url=mieli.code_url,
219
+        defaults={
220
+            'brand_pk': brand_pk,
221
+            'model_pk': model_pk,
222
+            'distributor_pk': distributor_pk,
223
+            'sn': sn,
224
+            'decrypt_count': 1,
225
+        }
226
+    )
221 227
 
222 228
     if not created_at:
223 229
         mdli.decrypt_count += 1

+ 35 - 0
logs/migrations/0007_auto_20200114_1229.py

@@ -0,0 +1,35 @@
1
+# -*- coding: utf-8 -*-
2
+# Generated by Django 1.11.26 on 2020-01-14 04:29
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', '0006_auto_20200113_1832'),
12
+    ]
13
+
14
+    operations = [
15
+        migrations.AddField(
16
+            model_name='mchinfodecryptloginfo',
17
+            name='application_id',
18
+            field=models.IntegerField(db_index=True, default=0, help_text='\u7533\u8bf7\u5355\u53f7', verbose_name='application_id'),
19
+        ),
20
+        migrations.AddField(
21
+            model_name='mchinfodecryptloginfo',
22
+            name='code',
23
+            field=models.CharField(blank=True, db_index=True, help_text='\u4e5d\u4f4d\u7684\u5b57\u7b26\u4e32\u539f\u59cb\u7801', max_length=16, null=True, verbose_name='code'),
24
+        ),
25
+        migrations.AddField(
26
+            model_name='mchinfodecryptloginfo',
27
+            name='code_url',
28
+            field=models.CharField(blank=True, db_index=True, help_text='28\u4f4d\u666e\u901a\u7801\u5b57\u7b26\t', max_length=128, null=True, verbose_name='code_url'),
29
+        ),
30
+        migrations.AddField(
31
+            model_name='mchinfoencryptloginfo',
32
+            name='application_id',
33
+            field=models.IntegerField(db_index=True, default=0, help_text='\u7533\u8bf7\u5355\u53f7', verbose_name='application_id'),
34
+        ),
35
+    ]

+ 6 - 0
logs/models.py

@@ -19,6 +19,7 @@ class MchInfoEncryptLogInfo(BaseModelMixin):
19 19
     sn = models.CharField(_(u'sn'), max_length=32, blank=True, null=True, help_text=u'序列号', db_index=True)
20 20
 
21 21
     # 一物一码
22
+    application_id = models.IntegerField(_(u'application_id'), default=0, help_text=u'申请单号', db_index=True)
22 23
     code = models.CharField(_(u'code'), max_length=16, blank=True, null=True, help_text=u'九位的字符串原始码', db_index=True)
23 24
     code_url = models.CharField(_(u'code_url'), max_length=128, blank=True, null=True, help_text=u'28位普通码字符	', db_index=True)
24 25
 
@@ -41,6 +42,11 @@ class MchInfoDecryptLogInfo(BaseModelMixin):
41 42
 
42 43
     sn = models.CharField(_(u'sn'), max_length=32, blank=True, null=True, help_text=u'序列号', db_index=True)
43 44
 
45
+    # 一物一码
46
+    application_id = models.IntegerField(_(u'application_id'), default=0, help_text=u'申请单号', db_index=True)
47
+    code = models.CharField(_(u'code'), max_length=16, blank=True, null=True, help_text=u'九位的字符串原始码', db_index=True)
48
+    code_url = models.CharField(_(u'code_url'), max_length=128, blank=True, null=True, help_text=u'28位普通码字符	', db_index=True)
49
+
44 50
     decrypt_count = models.IntegerField(_(u'decrypt_count'), default=1, help_text=u'解密次数')
45 51
 
46 52
     class Meta: