>
- ymd=ymd[:6],
|
|
89
|
|
- )
|
|
90
|
|
- if not cpssi.province_name:
|
|
91
|
|
- cpssi.province_name = ProvinceShortModelMixin.PROVINCE_CODE_NAME_DICT.get(province_code)
|
|
92
|
|
- cpssi.users = list(set(cpssi.users + [user_id]))
|
|
93
|
|
- cpssi.num = len(cpssi.users)
|
|
94
|
|
- cpssi.num2 += 1
|
|
95
|
|
- cpssi.save()
|
|
96
|
|
- # 年
|
|
97
|
|
- cpssi, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
|
|
98
|
|
- brand_id=brand_id,
|
|
99
|
|
- province_code=province_code,
|
|
100
|
|
- ymd=ymd[:4],
|
|
101
|
|
- )
|
|
102
|
|
- if not cpssi.province_name:
|
|
103
|
|
- cpssi.province_name = ProvinceShortModelMixin.PROVINCE_CODE_NAME_DICT.get(province_code)
|
|
104
|
|
- cpssi.users = list(set(cpssi.users + [user_id]))
|
|
105
|
|
- cpssi.num = len(cpssi.users)
|
|
106
|
|
- cpssi.num2 += 1
|
|
107
|
|
- cpssi.save()
|
|
108
|
|
-
|
|
109
|
|
- close_old_connections()
|
|
|
58
|
+ try:
|
|
|
59
|
+ province_name = json.loads(phoneinfo.content.split('(')[-1][:-1])['data']['area']
|
|
|
60
|
+ except Exception as e:
|
|
|
61
|
+ logger.info(e.message)
|
|
|
62
|
+ continue
|
|
|
63
|
+ province_code = ProvinceShortModelMixin.PROVINCE_NAME_CODE_DICT.get(province_name)
|
|
|
64
|
+
|
|
|
65
|
+ if not province_code:
|
|
|
66
|
+ continue
|
|
|
67
|
+
|
|
|
68
|
+ brand_id = v.get('brand_id', '')
|
|
|
69
|
+ user_id = v.get('user_id', '')
|
|
|
70
|
+ ymd = v.get('ymd', '')
|
|
|
71
|
+
|
|
|
72
|
+ # [消费者维度]省份销量统计
|
|
|
73
|
+ # 日
|
|
|
74
|
+ cpssi, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
|
|
|
75
|
+ brand_id=brand_id,
|
|
|
76
|
+ province_code=province_code,
|
|
|
77
|
+ ymd=ymd,
|
|
|
78
|
+ )
|
|
|
79
|
+ if not cpssi.province_name:
|
|
|
80
|
+ cpssi.province_name = ProvinceShortModelMixin.PROVINCE_CODE_NAME_DICT.get(province_code)
|
|
|
81
|
+ cpssi.users = list(set(cpssi.users + [user_id]))
|
|
|
82
|
+ cpssi.num = len(cpssi.users)
|
|
|
83
|
+ cpssi.num2 += 1
|
|
|
84
|
+ cpssi.save()
|
|
|
85
|
+ # 月
|
|
|
86
|
+ cpssi, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
|
|
|
87
|
+ brand_id=brand_id,
|
|
|
88
|
+ province_code=province_code,
|
|
|
89
|
+ ymd=ymd[:6],
|
|
|
90
|
+ )
|
|
|
91
|
+ if not cpssi.province_name:
|
|
|
92
|
+ cpssi.province_name = ProvinceShortModelMixin.PROVINCE_CODE_NAME_DICT.get(province_code)
|
|
|
93
|
+ cpssi.users = list(set(cpssi.users + [user_id]))
|
|
|
94
|
+ cpssi.num = len(cpssi.users)
|
|
|
95
|
+ cpssi.num2 += 1
|
|
|
96
|
+ cpssi.save()
|
|
|
97
|
+ # 年
|
|
|
98
|
+ cpssi, _ = ConsumeProvinceSaleStatisticInfo.objects.select_for_update().get_or_create(
|
|
|
99
|
+ brand_id=brand_id,
|
|
|
100
|
+ province_code=province_code,
|
|
|
101
|
+ ymd=ymd[:4],
|
|
|
102
|
+ )
|
|
|
103
|
+ if not cpssi.province_name:
|
|
|
104
|
+ cpssi.province_name = ProvinceShortModelMixin.PROVINCE_CODE_NAME_DICT.get(province_code)
|
|
|
105
|
+ cpssi.users = list(set(cpssi.users + [user_id]))
|
|
|
106
|
+ cpssi.num = len(cpssi.users)
|
|
|
107
|
+ cpssi.num2 += 1
|
|
|
108
|
+ cpssi.save()
|
|
|
109
|
+
|
|
|
110
|
+ close_old_connections()
|
|
|
|
@@ -30,10 +30,10 @@ class Command(CompatibilityBaseCommand):
|
|
30
|
30
|
if not v:
|
|
31
|
31
|
continue
|
|
32
|
32
|
|
|
33
|
|
- close_old_connections()
|
|
34
|
|
-
|
|
35
|
33
|
logger.info(v)
|
|
36
|
34
|
|
|
|
35
|
+ close_old_connections()
|
|
|
36
|
+
|
|
37
|
37
|
with transaction.atomic():
|
|
38
|
38
|
try:
|
|
39
|
39
|
elog = MchInfoEncryptLogInfo.objects.select_for_update().get(sn=v.get('sn', ''))
|
|
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+wxcfg = WECHAT.get('JSAPI', {})
|
|
|
20
|
+
|
|
|
21
|
+appid = wxcfg.get('appID')
|
|
|
22
|
+secret = wxcfg.get('appsecret')
|
|
|
23
|
+
|
|
|
24
|
+
|
|
|
25
|
+logger = logging.getLogger('console')
|
|
|
26
|
+
|
|
|
27
|
+
|
|
|
28
|
+def get_phone(fields):
|
|
|
29
|
+ for field in fields:
|
|
|
30
|
+ name = field.get('name', '')
|
|
|
31
|
+ if name == 'USER_FORM_INFO_FLAG_MOBILE':
|
|
|
32
|
+ return field.get('value', '')
|
|
|
33
|
+ return ''
|
|
|
34
|
+
|
|
|
35
|
+
|
|
|
36
|
+class Command(CompatibilityBaseCommand):
|
|
|
37
|
+ def handle(self, *args, **options):
|
|
|
38
|
+
|
|
|
39
|
+ logger.info('Redpack is dealing')
|
|
|
40
|
+
|
|
|
41
|
+ while True:
|
|
|
42
|
+ # r.rpushjson('MEMBERCARD_USERINFO_LIST', {
|
|
|
43
|
+ # 'card_id': 'card_id',
|
|
|
44
|
+ # 'code': 'code',
|
|
|
45
|
+ # })
|
|
|
46
|
+ k, v = r.blpopjson(MEMBERCARD_USERINFO_LIST, 60)
|
|
|
47
|
+ if not v:
|
|
|
48
|
+ continue
|
|
|
49
|
+
|
|
|
50
|
+ logger.info(v)
|
|
|
51
|
+
|
|
|
52
|
+ card_id, code = v.get('card_id', ''), v.get('code', '')
|
|
|
53
|
+
|
|
|
54
|
+ if not (card_id and code):
|
|
|
55
|
+ continue
|
|
|
56
|
+
|
|
|
57
|
+ userinfo = get_userinfo(card_id, code, appid=appid, secret=secret, storage=RedisStorage(r))
|
|
|
58
|
+
|
|
|
59
|
+ common_field_list = userinfo.get('common_field_list', [])
|
|
|
60
|
+ phone = get_phone(common_field_list)
|
|
|
61
|
+
|
|
|
62
|
+ if not phone:
|
|
|
63
|
+ continue
|
|
|
64
|
+
|
|
|
65
|
+ close_old_connections()
|
|
|
66
|
+
|
|
|
67
|
+ with transaction.atomic():
|
|
|
68
|
+ UserInfo.objects.select_for_update().filter(membercardid=card_id, memberusercardcode=code).update(phone=phone)
|
|
|
69
|
+
|
|
|
70
|
+ close_old_connections()
|
|
|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-Django==1.11.22
|
|
|
1
|
+Django==1.11.23
|
|
2
|
2
|
django-admin==1.3.2
|
|
3
|
3
|
django-cors-headers==3.0.2
|
|
4
|
4
|
django-curtail-uuid==1.0.4
|
|
|
|
@@ -73,3 +73,5 @@ MINI_PROGRAM_GIS_LIST = 'tamron:miniprogram:gis:list'
|
|
73
|
73
|
SCREEN_ADMIN_LOGIN = 'tamron:screen:admin:login:%s:%s' # brand_id, token
|
|
74
|
74
|
|
|
75
|
75
|
REDPACK_WAITING_SEND_LIST = 'tamron:redpack:waiting:send' #
|
|
|
76
|
+
|
|
|
77
|
+MEMBERCARD_USERINFO_LIST = 'tamron:membercard:userinfo' #
|