@@ -8,6 +8,7 @@ from logit import logit |
||
| 8 | 8 |
from account.models import TourGuideInfo, UserInfo |
| 9 | 9 |
from utils.error.errno_utils import TourGuideStatusCode |
| 10 | 10 |
from utils.error.response_utils import response |
| 11 |
+from utils.redis.rprofile import set_profile_info |
|
| 11 | 12 |
|
| 12 | 13 |
|
| 13 | 14 |
r = settings.REDIS_CACHE |
@@ -73,4 +74,6 @@ def tourguide_wx_authorize_api(request): |
||
| 73 | 74 |
user.city = city |
| 74 | 75 |
user.save() |
| 75 | 76 |
|
| 77 |
+ set_profile_info(user) |
|
| 78 |
+ |
|
| 76 | 79 |
return response(200, 'Tour Guide Login Success', u'导游登录成功', user.data) |
@@ -15,6 +15,7 @@ from utils.error.errno_utils import LensmanStatusCode, UserStatusCode |
||
| 15 | 15 |
from utils.error.response_utils import response |
| 16 | 16 |
from utils.ip_utils import ip_addr |
| 17 | 17 |
from utils.redis.rguest import get_guest_entrance_control |
| 18 |
+from utils.redis.rprofile import set_profile_info |
|
| 18 | 19 |
from utils.version_utils import is_version_match |
| 19 | 20 |
|
| 20 | 21 |
|
@@ -148,6 +149,8 @@ def user_wx_authorize_api(request): |
||
| 148 | 149 |
user.city = city |
| 149 | 150 |
user.save() |
| 150 | 151 |
|
| 152 |
+ set_profile_info(user) |
|
| 153 |
+ |
|
| 151 | 154 |
return response(200, 'Login Success', u'登录成功', user.data) |
| 152 | 155 |
|
| 153 | 156 |
# unionid 不存在 |
@@ -190,6 +193,8 @@ def user_wx_authorize_api(request): |
||
| 190 | 193 |
signup_at=signup_at, |
| 191 | 194 |
) |
| 192 | 195 |
|
| 196 |
+ set_profile_info(user) |
|
| 197 |
+ |
|
| 193 | 198 |
return response(200, 'Login Success', u'登录成功', user.data) |
| 194 | 199 |
|
| 195 | 200 |
|
@@ -28,6 +28,7 @@ from utils.redis.rgroup import set_group_info |
||
| 28 | 28 |
from utils.redis.rkeys import GROUP_LAST_PHOTO_PK, TODAY_INCOME, TODAY_UPLOAD_PHOTO_AMOUNT, WEEK_INCOME, WEEK_SOLD |
| 29 | 29 |
from utils.redis.rorder import set_lensman_order_record |
| 30 | 30 |
from utils.redis.rprice import get_lensman_price_fixed, set_lensman_price_fixed |
| 31 |
+from utils.redis.rprofile import set_profile_info |
|
| 31 | 32 |
from utils.thumbnail_utils import make_thumbnail |
| 32 | 33 |
from utils.watermark_utils import watermark_wrap |
| 33 | 34 |
|
@@ -116,6 +117,8 @@ def lensman_wx_authorize_api(request): |
||
| 116 | 117 |
user.city = city |
| 117 | 118 |
user.save() |
| 118 | 119 |
|
| 120 |
+ set_profile_info(user) |
|
| 121 |
+ |
|
| 119 | 122 |
return response(200, 'Lensman Login Success', u'摄影师登录成功', user.data) |
| 120 | 123 |
|
| 121 | 124 |
|
@@ -17,6 +17,7 @@ from utils.redis.rgroup import get_group_info, get_group_users_info, set_group_u |
||
| 17 | 17 |
from utils.redis.rkeys import (GROUP_LAST_PHOTO_PK, GROUP_USERS_DELETED_SET, GROUP_USERS_PASSED_SET, |
| 18 | 18 |
GROUP_USERS_QUIT_SET, GROUP_USERS_REFUSED_SET, TOUR_GUIDE_GROUP_CUR_GATHER_INFO, |
| 19 | 19 |
TOUR_GUIDE_GROUP_CUR_SESSION, TOUR_GUIDE_GROUP_GEO_INFO, TOUR_GUIDE_GROUP_USER_GEO_LIST) |
| 20 |
+from utils.redis.rprofile import get_profile_by_id |
|
| 20 | 21 |
from utils.redis.rtourguide import get_tour_guide_own_group |
| 21 | 22 |
|
| 22 | 23 |
|
@@ -176,10 +177,17 @@ def tgu_group_user_locations_api(request): |
||
| 176 | 177 |
# 获取集合经纬度 |
| 177 | 178 |
gather_info = json.loads(r.get(TOUR_GUIDE_GROUP_CUR_GATHER_INFO % group_id) or '{}')
|
| 178 | 179 |
|
| 180 |
+ # [['x', 0.33, (2.68220901489e-06, 1.26736058093e-06)], []] |
|
| 181 |
+ locations = r.georadius(TOUR_GUIDE_GROUP_GEO_INFO % group_id, gather_info.get('gather_lon', 0), gather_info.get('gather_lat', 0), '+inf', unit='m', withdist=True, withcoord=True, sort='ASC')
|
|
| 182 |
+ # [{'location_info': ['x', 0.33, (2.68220901489e-06, 1.26736058093e-06)], 'user_info': {}}, {}]
|
|
| 183 |
+ locations = [{
|
|
| 184 |
+ 'location_info': loc, |
|
| 185 |
+ 'user_info': get_profile_by_id(loc[0]) |
|
| 186 |
+ } for loc in locations] |
|
| 187 |
+ |
|
| 179 | 188 |
return response(200, 'Get Tour Guide Group All User Location Success', u'获取旅行团用户地理位置信息成功', {
|
| 180 | 189 |
'group_id': group_id, |
| 181 |
- 'locations': r.georadius(TOUR_GUIDE_GROUP_GEO_INFO % group_id, gather_info.get('gather_lon', 0), gather_info.get('gather_lat', 0), '+inf', unit='m', withdist=True, withcoord=True, sort='ASC')
|
|
| 182 |
- # 'locations': [['x', 0.33, (2.68220901489e-06, 1.26736058093e-06)]] |
|
| 190 |
+ 'locations': locations, |
|
| 183 | 191 |
}) |
| 184 | 192 |
|
| 185 | 193 |
|
@@ -0,0 +1,34 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+import json |
|
| 4 |
+ |
|
| 5 |
+from django.conf import settings |
|
| 6 |
+ |
|
| 7 |
+from utils.redis.rkeys import PROFILE_INFO |
|
| 8 |
+ |
|
| 9 |
+ |
|
| 10 |
+r = settings.REDIS_CACHE |
|
| 11 |
+ |
|
| 12 |
+ |
|
| 13 |
+# 用户相关 |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+def set_profile_info(user): |
|
| 17 |
+ """ 设置用户信息 """ |
|
| 18 |
+ r.set(PROFILE_INFO % user.user_id, json.dumps(user.data)) |
|
| 19 |
+ return user.data |
|
| 20 |
+ |
|
| 21 |
+ |
|
| 22 |
+def set_profile_by_uid(user_id): |
|
| 23 |
+ """ 获取用户信息 """ |
|
| 24 |
+ from account.models import UserInfo |
|
| 25 |
+ try: |
|
| 26 |
+ user = UserInfo.objects.get(user_id=user_id) |
|
| 27 |
+ except UserInfo.DoesNotExist: |
|
| 28 |
+ return {}
|
|
| 29 |
+ return set_profile_info(user) |
|
| 30 |
+ |
|
| 31 |
+ |
|
| 32 |
+def get_profile_by_id(user_id): |
|
| 33 |
+ """ 获取用户信息 """ |
|
| 34 |
+ return json.loads(r.get(PROFILE_INFO % user_id) or '{}') or set_profile_by_uid(user_id)
|