import views as geo_views 12 12
 from group import (groupuser_views, lensman_views, tourguidegroup_views, tourguidegroupadmin_views,
@@ -304,7 +304,10 @@ urlpatterns += [
304 304
     url(r'^admin/statistic/distributor$', admin_views.statistic_distributor, name='statistic_distributor'),
305 305
 
306 306
     url(r'^admin/statistic/deep/analyze$', admin_views.statistic_deep_analyze, name='statistic_deep_analyze'),
307
+]
307 308
 
309
+urlpatterns += [
310
+    url(r'^refresh/phone$', refresh_views.phone, name='phone'),
308 311
 ]
309 312
 
310 313
 urlpatterns += [

+ 77 - 0
commands/management/commands/membercard.py

@@ -0,0 +1,77 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+import logging
4
+
5
+from django.conf import settings
6
+from django.db import transaction
7
+from django_six import CompatibilityBaseCommand, close_old_connections
8
+from pywe_membercard import get_userinfo
9
+from pywe_storage import RedisStorage
10
+
11
+from account.models import UserInfo
12
+from utils.redis.connect import r
13
+from utils.redis.rkeys import MEMBERCARD_USERINFO_LIST
14
+
15
+
16
+WECHAT = settings.WECHAT
17
+
18
+
19
+logger = logging.getLogger('console')
20
+
21
+
22
+def get_phone(fields):
23
+    for field in fields:
24
+        name = field.get('name', '')
25
+        if name == 'USER_FORM_INFO_FLAG_MOBILE':
26
+            return field.get('value', '')
27
+    return ''
28
+
29
+
30
+class Command(CompatibilityBaseCommand):
31
+    def handle(self, *args, **options):
32
+
33
+        logger.info('MemberCard userinfo is dealing')
34
+
35
+        while True:
36
+            # r.rpushjson('MEMBERCARD_USERINFO_LIST', {
37
+            #    'brand_id': 'brand_id',
38
+            #    'card_id': 'card_id',
39
+            #    'code': 'code',
40
+            # })
41
+            k, v = r.blpopjson(MEMBERCARD_USERINFO_LIST, 60)
42
+            if not v:
43
+                continue
44
+
45
+            logger.info(v)
46
+
47
+            brand_id, card_id, code = v.get('brand_id', ''), v.get('card_id', ''), v.get('code', '')
48
+
49
+            if not (card_id and code):
50
+                continue
51
+
52
+            # wxcfg = WECHAT.get('{}:JSAPI'.format(brand_id), {})
53
+            wxcfg = WECHAT.get('JSAPI', {})
54
+
55
+            appid = wxcfg.get('appID')
56
+            secret = wxcfg.get('appsecret')
57
+
58
+            userinfo = get_userinfo(card_id, code, appid=appid, secret=secret, storage=RedisStorage(r))
59
+
60
+            logger.info(userinfo)
61
+
62
+            userinfo = userinfo.get('user_info', {})
63
+            if not userinfo:
64
+                continue
65
+
66
+            common_field_list = userinfo.get('common_field_list', [])
67
+            phone = get_phone(common_field_list)
68
+
69
+            if not phone:
70
+                continue
71
+
72
+            close_old_connections()
73
+
74
+            with transaction.atomic():
75
+                UserInfo.objects.select_for_update().filter(membercardid=card_id, memberusercardcode=code).update(phone=phone)
76
+
77
+            close_old_connections()

+ 2 - 0
utils/redis/rkeys.py

@@ -72,6 +72,8 @@ MINI_PROGRAM_GIS_LIST = 'tamron:miniprogram:gis:list'
72 72
 
73 73
 SCREEN_ADMIN_LOGIN = 'tamron:screen:admin:login:%s:%s'  # brand_id, token
74 74
 
75
+MEMBERCARD_USERINFO_LIST = 'tamron:membercard:userinfo'  #
76
+
75 77
 SUBSCRIBE_USERINFO_LIST = 'subscribe:userinfo:%s'
76 78
 
77 79
 MEMBER_SHOT_DATA = 'kodo:member:shot:data'

kodo - Gogs: Go Git Service

暂无描述

Brightcells: a7cbbf15a7 Update max_length for CharField 8 年之前
..
0001_initial.py e184e7dd5b add api group_create/group_join 11 年之前
0002_groupinfo_session_id.py e184e7dd5b add api group_create/group_join 11 年之前
0003_groupinfo_admin_id.py 7e305483ab add api group_detail/group_lock/group_pass/group_refuse 11 年之前
0004_auto_20151216_2337.py 7467a3e68a add api group_update/group_remove 11 年之前
0005_groupuserinfo_current_id.py f587f0a48f user can just see photo after he joined the group & zh_Hans replace zh_CN in settings.py 11 年之前
0006_groupuserinfo_avatar.py 4afdb94e20 add avatar for GroupUserInfo 11 年之前
0007_auto_20160112_2040.py df1df69fe3 add api upgrade/splash 10 年之前
0008_photocommentinfo.py c72d89f6e5 add api comment_submit_api/comment_list_api/thumbup_submit_api/thumbup_list_api/thumbup_cancel_api 10 年之前
0009_photothumbupinfo.py c72d89f6e5 add api comment_submit_api/comment_list_api/thumbup_submit_api/thumbup_list_api/thumbup_cancel_api 10 年之前
0010_auto_20160120_1830.py a121b75ff2 add db_index=True for status field 10 年之前
0011_auto_20160302_2048.py da2a81fff1 add api pai2_home 10 年之前
0012_groupinfo_group_avatar.py da2a81fff1 add api pai2_home 10 年之前
0013_groupinfo_group_default_avatar.py f6a88c632b add group_default_avatar field for GroupInfo 10 年之前
0014_auto_20160308_2347.py ca727b0362 store/return w/h for photo 10 年之前
0015_groupphotoinfo_avatar.py 88049b12db store/return more field for photo 10 年之前
0016_auto_20160321_1535.py 537bd9bd41 add api group_quit_api 10 年之前
0017_groupphotoinfo_photo_from.py dbea356558 add photo_from field for GroupPhotoInfo and return photo_from for some api 10 年之前
0018_auto_20160417_2246.py d64b3c216b add and return photo_thumbnail2 relative 10 年之前
0019_auto_20160422_1322.py 102152ca4a add api lensman_photo_bought & modify api wx_order_create_api and adjust return field 10 年之前
0020_groupphotoinfo_session_id.py 102152ca4a add api lensman_photo_bought & modify api wx_order_create_api and adjust return field 10 年之前
0021_photocommentinfo_to_uid.py fa36c26ce4 extend param to_uid for comment_submit_api 10 年之前
0022_auto_20160901_1439.py 6199c8f7ad add api lensman_origin_wanted_api/lensman_origin_photo_upload_api 10 年之前
0023_groupinfo_group_initio.py e06dc10006 Make join session group by scan group qrcode fetch group photos initio 10 年之前
0024_auto_20161214_1329.py f724e0f9c0 Add tour guide apis 10 年之前
0025_auto_20161214_1659.py ad69866b26 Add tour guide's name and phone in GroupInfo 10 年之前
0026_auto_20161216_1301.py 034acddb68 Add total_persons for GroupInfo 10 年之前
0027_groupuserinfo_authority.py 88f0697a89 Add authority field for GroupUserInfo 10 年之前
0028_auto_20161220_1815.py 272f181c50 Makemigrations 9 年之前
0029_auto_20161224_1616.py 564ff620d7 Add unique_together = (('group_id', 'user_id'),) for GroupUserInfo 9 年之前
0030_groupinfo_gather_location.py 90d377ee6e Add gather location 9 年之前
0031_groupphotoinfo_photo_md5.py d824fbd441 Add photo_md5 for GroupPhotoInfo 9 年之前
0032_groupinfo_gather_screenshot.py e8cd9652b7 Add gather_screenshot for api tg_group_gather_start_api 9 年之前
0033_groupphotoinfo_photo_id.py 3c6e34823b Add photo_id for GroupPhotoInfo replaced pk 9 年之前
0034_auto_20170411_1156.py 14d5d63e3b Add nomark/origin price for GroupPhotoInfo 9 年之前
0035_groupuserinfo_admin_status.py 9e4ac4fd3b Add admin_status for GroupUserInfo 9 年之前
0036_groupphotoinfo_has_watermark.py 3b92e37156 Add field has_watermark for GroupPhotoInfo 9 年之前
0037_auto_20170821_1600.py bf678fc740 Add unique_together = (('session_id', 'group_from'),) 9 年之前
0038_auto_20170821_1608.py 7060597dd6 Add unique_together = (('group_id', 'user_id', 'photo_md5'),) for GroupPhotoInfo 9 年之前
0039_auto_20170821_1613.py 9f4c919c29 Add unique_together = (('photo_id', 'user_id'),) for PhotoThumbUpInfo 9 年之前
0040_auto_20170825_1342.py e5ad69259f Add unique_together = (('group_id', 'session_id', 'user_id', 'photo_id', 'lensman_photo_id'),) for GroupPhotoOrderInfo 9 年之前
0041_auto_20170825_1342.py e5ad69259f Add unique_together = (('group_id', 'session_id', 'user_id', 'photo_id', 'lensman_photo_id'),) for GroupPhotoOrderInfo 9 年之前
0042_groupphotoinfo_lensman_type.py a6195fa70d Add outtake lensman 9 年之前
0043_auto_20180101_2220.py 9bb56c50cc Makemigrations 8 年之前
0044_auto_20180103_0446.py a7cbbf15a7 Update max_length for CharField 8 年之前
__init__.py e184e7dd5b add api group_create/group_join 11 年之前