@@ -385,12 +385,14 @@ def consumer_info_api(request): |
||
385 | 385 |
amount = 100 |
386 | 386 |
if user.openid: |
387 | 387 |
send_jsapi_hb(user.openid, amount, transfer=False) |
388 |
+ |
|
388 | 389 |
elog.has_send_redpack = True |
389 | 390 |
elog.user_id = user.user_id |
390 | 391 |
elog.nickname = user.nickname |
391 | 392 |
elog.save() |
392 | 393 |
else: |
393 | 394 |
r.rpushjson(REDPACK_WAITING_SEND_LIST, { |
395 |
+ 'sn': serialNo, |
|
394 | 396 |
'user_id': user.user_id, |
395 | 397 |
'amount': amount, |
396 | 398 |
}) |
@@ -23,7 +23,7 @@ class Command(CompatibilityBaseCommand): |
||
23 | 23 |
logger.info('Gis is dealing') |
24 | 24 |
|
25 | 25 |
while True: |
26 |
- # r.rpushjson('TEMPLET_CMD_KEY', { |
|
26 |
+ # r.rpushjson('MINI_PROGRAM_GIS_LIST', { |
|
27 | 27 |
# 'brand_id': 'brand_id', |
28 | 28 |
# 'lat': .0, |
29 | 29 |
# 'lon': .0, |
@@ -0,0 +1,57 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+import logging |
|
4 |
+ |
|
5 |
+from django.db import transaction |
|
6 |
+from django_six import CompatibilityBaseCommand, close_old_connections |
|
7 |
+ |
|
8 |
+from account.models import UserInfo |
|
9 |
+from logs.models import MchInfoEncryptLogInfo |
|
10 |
+from miniapp.redpack_views import send_jsapi_hb |
|
11 |
+from utils.redis.connect import r |
|
12 |
+from utils.redis.rkeys import REDPACK_WAITING_SEND_LIST |
|
13 |
+ |
|
14 |
+ |
|
15 |
+logger = logging.getLogger('console') |
|
16 |
+ |
|
17 |
+ |
|
18 |
+class Command(CompatibilityBaseCommand): |
|
19 |
+ def handle(self, *args, **options): |
|
20 |
+ |
|
21 |
+ logger.info('Gis is dealing') |
|
22 |
+ |
|
23 |
+ while True: |
|
24 |
+ # r.rpushjson('REDPACK_WAITING_SEND_LIST', { |
|
25 |
+ # 'sn': 'sn', |
|
26 |
+ # 'user_id': 'user_id', |
|
27 |
+ # 'amount': amount, |
|
28 |
+ # }) |
|
29 |
+ k, v = r.blpopjson(REDPACK_WAITING_SEND_LIST, 60) |
|
30 |
+ if v: |
|
31 |
+ |
|
32 |
+ close_old_connections() |
|
33 |
+ |
|
34 |
+ logger.info(v) |
|
35 |
+ |
|
36 |
+ with transaction.atomic(): |
|
37 |
+ try: |
|
38 |
+ elog = MchInfoEncryptLogInfo.objects.select_for_update().get(sn=v.get('sn', '')) |
|
39 |
+ except MchInfoEncryptLogInfo.DoesNotExist: |
|
40 |
+ continue |
|
41 |
+ |
|
42 |
+ try: |
|
43 |
+ user = UserInfo.objects.get(user_id=v.get('user_id', '')) |
|
44 |
+ except UserInfo.DoesNotExist: |
|
45 |
+ continue |
|
46 |
+ |
|
47 |
+ if not user.openid: |
|
48 |
+ continue |
|
49 |
+ |
|
50 |
+ send_jsapi_hb(user.openid, v.get('amount', 100), transfer=False) |
|
51 |
+ |
|
52 |
+ elog.has_send_redpack = True |
|
53 |
+ elog.user_id = user.user_id |
|
54 |
+ elog.nickname = user.nickname |
|
55 |
+ elog.save() |
|
56 |
+ |
|
57 |
+ close_old_connections() |