@@ -0,0 +1,57 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+import logging |
|
4 |
+ |
|
5 |
+from django_six import CompatibilityBaseCommand, close_old_connections |
|
6 |
+ |
|
7 |
+from integral.models import SaleclerkSubmitLogInfo |
|
8 |
+from utils.redis.connect import r |
|
9 |
+from utils.redis.rkeys import QINIU_UPLOAD_LIST |
|
10 |
+from utils.qiniucdn import upload_file_path |
|
11 |
+ |
|
12 |
+ |
|
13 |
+logger = logging.getLogger('console') |
|
14 |
+ |
|
15 |
+ |
|
16 |
+class Command(CompatibilityBaseCommand): |
|
17 |
+ def handle(self, *args, **options): |
|
18 |
+ |
|
19 |
+ logger.info('SubscribeUserInfo is dealing') |
|
20 |
+ |
|
21 |
+ while True: |
|
22 |
+ # r.rpushjson('SUBSCRIBE_USERINFO_LIST', { |
|
23 |
+ # 'model': 'SaleclerkSubmitLogInfo', |
|
24 |
+ # 'pk': 'pk', |
|
25 |
+ # }) |
|
26 |
+ k, v = r.blpopjson(QINIU_UPLOAD_LIST, 60) |
|
27 |
+ if not v: |
|
28 |
+ continue |
|
29 |
+ |
|
30 |
+ logger.info(v) |
|
31 |
+ |
|
32 |
+ model, pk = v.get('model', ''), v.get('pk', '') |
|
33 |
+ |
|
34 |
+ close_old_connections() |
|
35 |
+ |
|
36 |
+ if model == 'SaleclerkSubmitLogInfo': |
|
37 |
+ try: |
|
38 |
+ ssli = SaleclerkSubmitLogInfo.objects.get(pk=pk) |
|
39 |
+ except SaleclerkSubmitLogInfo.DoesNotExist: |
|
40 |
+ continue |
|
41 |
+ |
|
42 |
+ if ssli.image: |
|
43 |
+ try: |
|
44 |
+ upload_file_path(ssli.image.path, key=ssli.image.name, bucket='tamron') |
|
45 |
+ except: |
|
46 |
+ pass |
|
47 |
+ |
|
48 |
+ if ssli.code_image: |
|
49 |
+ try: |
|
50 |
+ upload_file_path(ssli.code_image.path, key=ssli.code_image.name, bucket='tamron') |
|
51 |
+ except: |
|
52 |
+ pass |
|
53 |
+ |
|
54 |
+ ssli.is_upload_qiniu = True |
|
55 |
+ ssli.save() |
|
56 |
+ |
|
57 |
+ close_old_connections() |
@@ -0,0 +1,20 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+# Generated by Django 1.11.29 on 2020-06-08 20:35 |
|
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 |
+ ('integral', '0018_saleclerksubmitloginfo_code_image'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.AddField( |
|
16 |
+ model_name='saleclerksubmitloginfo', |
|
17 |
+ name='is_upload_qiniu', |
|
18 |
+ field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u5df2\u4e0a\u4f20\u4e03\u725b', verbose_name='is_upload_qiniu'), |
|
19 |
+ ), |
|
20 |
+ ] |
@@ -120,6 +120,8 @@ class SaleclerkSubmitLogInfo(BaseModelMixin): |
||
120 | 120 |
is_staff_delete = models.BooleanField(_(u'is_staff_delete'), default=False, help_text=_(u'是否管理员删除'), db_index=True) |
121 | 121 |
code_version = models.IntegerField(_(u'code_version'), default=1, help_text=_(u'统览码版本'), db_index=True) |
122 | 122 |
|
123 |
+ is_upload_qiniu = models.BooleanField(_(u'is_upload_qiniu'), default=False, help_text=_(u'是否已上传七牛'), db_index=True) |
|
124 |
+ |
|
123 | 125 |
class Meta: |
124 | 126 |
verbose_name = _(u'销售员扫码出库记录') |
125 | 127 |
verbose_name_plural = _(u'销售员扫码出库记录') |
@@ -256,6 +256,7 @@ QINIU = { |
||
256 | 256 |
'thumbnail': 'http://thumbnail.img.pai.ai', |
257 | 257 |
'thumbnail2': 'http://thumbnail2.img.pai.ai', |
258 | 258 |
'watermark': 'http://watermark.img.pai.ai', |
259 |
+ 'tamron': 'tamron.s3-cn-south-1.qiniucs.com', |
|
259 | 260 |
} |
260 | 261 |
} |
261 | 262 |
|
@@ -79,3 +79,6 @@ SUBSCRIBE_USERINFO_LIST = 'subscribe:userinfo:%s' |
||
79 | 79 |
MEMBER_SHOT_DATA = 'kodo:member:shot:data' |
80 | 80 |
MEMBER_SEND_COUPON_LIST = 'kodo:member:send:coupon:list' |
81 | 81 |
MEMBER_UPGRADE_INFO = 'kodo:member:upgrade:info:%s:%s' # brand_id, user_id |
82 |
+ |
|
83 |
+# 七牛 |
|
84 |
+QINIU_UPLOAD_LIST = 'kodo:qiniu:upload:list' |