@@ -6,6 +6,7 @@ import os |
||
| 6 | 6 |
from django_six import CompatibilityBaseCommand, close_old_connections |
| 7 | 7 |
|
| 8 | 8 |
from integral.models import SaleclerkSubmitLogInfo |
| 9 |
+from logs.models import ComplementCodeLogInfo |
|
| 9 | 10 |
from utils.qiniucdn import upload_file_path |
| 10 | 11 |
from utils.redis.connect import r |
| 11 | 12 |
from utils.redis.rkeys import QINIU_UPLOAD_LIST |
@@ -62,4 +63,31 @@ class Command(CompatibilityBaseCommand): |
||
| 62 | 63 |
ssli.is_upload_qiniu = is_upload_qiniu |
| 63 | 64 |
ssli.save() |
| 64 | 65 |
|
| 66 |
+ elif model == 'ComplementCodeLogInfo': |
|
| 67 |
+ try: |
|
| 68 |
+ ccli = ComplementCodeLogInfo.objects.get(pk=pk) |
|
| 69 |
+ except ComplementCodeLogInfo.DoesNotExist: |
|
| 70 |
+ continue |
|
| 71 |
+ |
|
| 72 |
+ is_upload_qiniu = True |
|
| 73 |
+ |
|
| 74 |
+ if ccli.shot_image: |
|
| 75 |
+ try: |
|
| 76 |
+ if os.path.exists(ccli.shot_image.path): |
|
| 77 |
+ upload_file_path(ccli.shot_image.path, key=ccli.shot_image.name, bucket='tamron') |
|
| 78 |
+ os.remove(ccli.shot_image.path) |
|
| 79 |
+ except Exception: |
|
| 80 |
+ is_upload_qiniu = False |
|
| 81 |
+ |
|
| 82 |
+ if ccli.invoice_image: |
|
| 83 |
+ try: |
|
| 84 |
+ if os.path.exists(ccli.invoice_image.path): |
|
| 85 |
+ upload_file_path(ccli.invoice_image.path, key=ccli.invoice_image.name, bucket='tamron') |
|
| 86 |
+ os.remove(ccli.invoice_image.path) |
|
| 87 |
+ except Exception: |
|
| 88 |
+ is_upload_qiniu = False |
|
| 89 |
+ |
|
| 90 |
+ ccli.is_upload_qiniu = is_upload_qiniu |
|
| 91 |
+ ccli.save() |
|
| 92 |
+ |
|
| 65 | 93 |
close_old_connections() |
@@ -5,6 +5,7 @@ import logging |
||
| 5 | 5 |
from django_six import CompatibilityBaseCommand |
| 6 | 6 |
|
| 7 | 7 |
from integral.models import SaleclerkSubmitLogInfo |
| 8 |
+from logs.models import ComplementCodeLogInfo |
|
| 8 | 9 |
from utils.redis.connect import r |
| 9 | 10 |
from utils.redis.rkeys import QINIU_UPLOAD_LIST |
| 10 | 11 |
|
@@ -18,9 +19,15 @@ class Command(CompatibilityBaseCommand): |
||
| 18 | 19 |
logger.info('Upload image qiniu producer is dealing')
|
| 19 | 20 |
|
| 20 | 21 |
sslis = SaleclerkSubmitLogInfo.objects.filter(is_upload_qiniu=False) |
| 21 |
- |
|
| 22 | 22 |
for ssli in sslis: |
| 23 | 23 |
r.rpushjson(QINIU_UPLOAD_LIST, {
|
| 24 | 24 |
'model': 'SaleclerkSubmitLogInfo', |
| 25 | 25 |
'pk': ssli.pk, |
| 26 | 26 |
}) |
| 27 |
+ |
|
| 28 |
+ cclis = ComplementCodeLogInfo.objects.filter(is_upload_qiniu=False) |
|
| 29 |
+ for ccli in cclis: |
|
| 30 |
+ r.rpushjson(QINIU_UPLOAD_LIST, {
|
|
| 31 |
+ 'model': 'ComplementCodeLogInfo', |
|
| 32 |
+ 'pk': ccli.pk, |
|
| 33 |
+ }) |
@@ -29,8 +29,8 @@ class MchSearchModelAndCameraLogInfoAdmin(admin.ModelAdmin): |
||
| 29 | 29 |
|
| 30 | 30 |
|
| 31 | 31 |
class ComplementCodeLogInfoAdmin(admin.ModelAdmin): |
| 32 |
- list_display = ('user_id', 'log_id', 'name', 'phone', 'model_id', 'model_name', 'sn', 'shot_image', 'invoice_image', 'audit_status', 'ciphertext', 'is_contacted', 'status', 'created_at', 'updated_at')
|
|
| 33 |
- list_filter = ('model_id', 'audit_status', 'is_contacted', 'status')
|
|
| 32 |
+ list_display = ('user_id', 'log_id', 'name', 'phone', 'model_id', 'model_name', 'sn', 'shot_image', 'invoice_image', 'audit_status', 'ciphertext', 'is_contacted', 'is_upload_qiniu', 'status', 'created_at', 'updated_at')
|
|
| 33 |
+ list_filter = ('model_id', 'audit_status', 'is_contacted', 'is_upload_qiniu', 'status')
|
|
| 34 | 34 |
|
| 35 | 35 |
|
| 36 | 36 |
admin.site.register(MchInfoDecryptLogInfo, MchInfoDecryptLogInfoAdmin) |
@@ -0,0 +1,20 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.29 on 2021-11-01 07: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 |
+ ('logs', '0016_auto_20210107_1438'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.AddField( |
|
| 16 |
+ model_name='complementcodeloginfo', |
|
| 17 |
+ name='is_upload_qiniu', |
|
| 18 |
+ field=models.BooleanField(default=False, help_text='\u662f\u5426\u5df2\u4e0a\u4f20\u4e03\u725b', verbose_name='is_upload_qiniu'), |
|
| 19 |
+ ), |
|
| 20 |
+ ] |
@@ -7,6 +7,7 @@ from shortuuidfield import ShortUUIDField |
||
| 7 | 7 |
from TimeConvert import TimeConvert as tc |
| 8 | 8 |
|
| 9 | 9 |
from mch.models import ModelInfo, OperatorInfo |
| 10 |
+from utils.qiniucdn import qiniu_file_url |
|
| 10 | 11 |
|
| 11 | 12 |
|
| 12 | 13 |
class MchInfoEncryptLogInfo(BaseModelMixin): |
@@ -147,6 +148,8 @@ class ComplementCodeLogInfo(BaseModelMixin): |
||
| 147 | 148 |
|
| 148 | 149 |
is_contacted = models.BooleanField(_(u'is_contacted'), default=False, help_text=u'是否已联系用户') |
| 149 | 150 |
|
| 151 |
+ is_upload_qiniu = models.BooleanField(_(u'is_upload_qiniu'), default=False, help_text=_(u'是否已上传七牛')) |
|
| 152 |
+ |
|
| 150 | 153 |
class Meta: |
| 151 | 154 |
verbose_name = _(u'补码记录') |
| 152 | 155 |
verbose_name_plural = _(u'补码记录') |
@@ -156,7 +159,7 @@ class ComplementCodeLogInfo(BaseModelMixin): |
||
| 156 | 159 |
|
| 157 | 160 |
@property |
| 158 | 161 |
def shot_image_url(self): |
| 159 |
- return upload_file_url(self.shot_image) |
|
| 162 |
+ return qiniu_file_url(self.shot_image.name, bucket='tamron') if self.is_upload_qiniu else upload_file_url(self.shot_image) |
|
| 160 | 163 |
|
| 161 | 164 |
@property |
| 162 | 165 |
def shot_image_path(self): |
@@ -164,7 +167,7 @@ class ComplementCodeLogInfo(BaseModelMixin): |
||
| 164 | 167 |
|
| 165 | 168 |
@property |
| 166 | 169 |
def invoice_image_url(self): |
| 167 |
- return upload_file_url(self.invoice_image) |
|
| 170 |
+ return qiniu_file_url(self.invoice_image.name, bucket='tamron') if self.is_upload_qiniu else upload_file_url(self.invoice_image) |
|
| 168 | 171 |
|
| 169 | 172 |
@property |
| 170 | 173 |
def invoice_image_path(self): |