="add-code nl-19 ol-19">
+ gather_lat = models.FloatField(_(u'gather_lat'), blank=True, null=True, help_text=_(u'旅游团集合纬度'))
class Meta:
verbose_name = _(u'groupinfo')
@@ -66,12 +69,14 @@ class GroupInfo(CreateUpdateMixin):
'group_from': self.group_from,
'group_lock': self.group_lock,
'group_initio': self.group_initio,
- 'started_at': self.started_at.replace(microsecond=0),
- 'ended_at': self.ended_at.replace(microsecond=0),
- 'gather_at': self.gather_at.replace(microsecond=0),
+ 'name': self.name,
+ 'phone': self.phone,
+ 'started_at': tc.remove_microsecond(self.started_at),
+ 'ended_at': tc.remove_microsecond(self.ended_at),
+ 'gather_at': tc.remove_microsecond(self.gather_at),
'gather_lon': self.gather_lon,
'gather_lat': self.gather_lat,
- 'created_at': self.created_at.replace(microsecond=0),
+ 'created_at': tc.remove_microsecond(self.created_at),
}
def users(self, admin=True, user_id=None):
@@ -125,7 +130,7 @@ class GroupUserInfo(CreateUpdateMixin):
refused_at = models.DateTimeField(_(u'refused_at'), blank=True, null=True, help_text=_(u'拒绝时间'))
deleted_at = models.DateTimeField(_(u'deleted_at'), blank=True, null=True, help_text=_(u'删除时间'))
quit_at = models.DateTimeField(_(u'quit_at'), blank=True, null=True, help_text=_(u'退出时间'))
- # 导游团相关
+ # 旅行团相关
subadmin = models.BooleanField(_(u'subadmin'), default=False, help_text=u'副群组管理员')
name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'用户姓名')
phone = models.CharField(_(u'phone'), max_length=255, blank=True, null=True, help_text=u'用户电话')
@@ -321,7 +326,7 @@ class PhotoCommentInfo(CreateUpdateMixin):
'avatar': self.avatar,
'to_uid': self.to_uid,
'comment': self.comment,
- 'created_at': self.created_at.replace(microsecond=0),
+ 'created_at': tc.remove_microsecond(self.created_at),
}
@@ -26,7 +26,7 @@ r = settings.REDIS_CACHE |
||
| 26 | 26 |
@logit |
| 27 | 27 |
def tg_group_create_api(request): |
| 28 | 28 |
""" |
| 29 |
- 导游团创建 |
|
| 29 |
+ 旅行团创建 |
|
| 30 | 30 |
:param request: |
| 31 | 31 |
:return: |
| 32 | 32 |
""" |
@@ -46,7 +46,7 @@ def tg_group_create_api(request): |
||
| 46 | 46 |
if not user.istourguide: |
| 47 | 47 |
return response(GroupStatusCode.NOT_GROUP_ADMIN) |
| 48 | 48 |
|
| 49 |
- # 导游团校验 |
|
| 49 |
+ # 旅行团校验 |
|
| 50 | 50 |
if GroupInfo.objects.filter( |
| 51 | 51 |
admin_id=user_id, |
| 52 | 52 |
group_closed=False, |
@@ -65,6 +65,8 @@ def tg_group_create_api(request): |
||
| 65 | 65 |
group_name=group_name, |
| 66 | 66 |
group_default_avatar=group_default_avatar, |
| 67 | 67 |
group_from=GroupInfo.TOURGUIDE_GROUP, |
| 68 |
+ name=user.name, |
|
| 69 |
+ phone=user.phone, |
|
| 68 | 70 |
started_at=started_at, |
| 69 | 71 |
ended_at=ended_at, |
| 70 | 72 |
) |
@@ -87,10 +89,10 @@ def tg_group_create_api(request): |
||
| 87 | 89 |
# Redis 群组用户数据缓存 |
| 88 | 90 |
group_users = set_group_users_info(group) |
| 89 | 91 |
|
| 90 |
- # Redis 设置导游拥有的导游团 |
|
| 92 |
+ # Redis 设置导游拥有的旅行团 |
|
| 91 | 93 |
set_tour_guide_own_group(user_id, group_id) |
| 92 | 94 |
|
| 93 |
- return response(200, 'Create Tour Guide Group Success', u'导游团创建成功', {
|
|
| 95 |
+ return response(200, 'Create Tour Guide Group Success', u'旅行团创建成功', {
|
|
| 94 | 96 |
'group_id': group_id, |
| 95 | 97 |
'group': group_info, |
| 96 | 98 |
'users': group_users, |
@@ -100,14 +102,14 @@ def tg_group_create_api(request): |
||
| 100 | 102 |
@logit |
| 101 | 103 |
def tg_group_detail_api(request): |
| 102 | 104 |
""" |
| 103 |
- 导游团详情 |
|
| 105 |
+ 旅行团详情 |
|
| 104 | 106 |
:param request: |
| 105 | 107 |
:return: |
| 106 | 108 |
""" |
| 107 | 109 |
group_id = request.POST.get('group_id', '')
|
| 108 | 110 |
user_id = request.POST.get('user_id', '')
|
| 109 | 111 |
|
| 110 |
- return response(200, 'Get Tour Guide Group Detail Info Success', u'获取导游团详情成功', {
|
|
| 112 |
+ return response(200, 'Get Tour Guide Group Detail Info Success', u'获取旅行团详情成功', {
|
|
| 111 | 113 |
'group_id': group_id, |
| 112 | 114 |
'group': get_group_info(group_id), |
| 113 | 115 |
'users': get_group_users_info(group_id, user_id), |
@@ -117,7 +119,7 @@ def tg_group_detail_api(request): |
||
| 117 | 119 |
@logit |
| 118 | 120 |
def tg_group_update_api(request): |
| 119 | 121 |
""" |
| 120 |
- 导游团更新 |
|
| 122 |
+ 旅行团更新 |
|
| 121 | 123 |
:param request: |
| 122 | 124 |
:return: |
| 123 | 125 |
""" |
@@ -128,8 +130,8 @@ def tg_group_update_api(request): |
||
| 128 | 130 |
|
| 129 | 131 |
group_avatar = request.FILES.get('group_avatar', '')
|
| 130 | 132 |
|
| 131 |
- started_at = request.POST.get('started_at', '')
|
|
| 132 |
- ended_at = request.POST.get('ended_at', '')
|
|
| 133 |
+ started_at = request.POST.get('started_at', '') # UTC, %Y-%m-%dT%H:%M:%SZ
|
|
| 134 |
+ ended_at = request.POST.get('ended_at', '') # UTC, %Y-%m-%dT%H:%M:%SZ
|
|
| 133 | 135 |
|
| 134 | 136 |
# 群组校验 |
| 135 | 137 |
try: |
@@ -173,7 +175,7 @@ def tg_group_update_api(request): |
||
| 173 | 175 |
@logit |
| 174 | 176 |
def tg_group_close_api(request): |
| 175 | 177 |
""" |
| 176 |
- 导游团关闭 |
|
| 178 |
+ 旅行团关闭 |
|
| 177 | 179 |
:param request: |
| 178 | 180 |
:return: |
| 179 | 181 |
""" |
@@ -198,19 +200,19 @@ def tg_group_close_api(request): |
||
| 198 | 200 |
# Redis 群组数据缓存更新 |
| 199 | 201 |
set_group_info(group) |
| 200 | 202 |
|
| 201 |
- return response(200, u'Close Tour Guide Group Success', u'导游团关闭成功') |
|
| 203 |
+ return response(200, u'Close Tour Guide Group Success', u'旅行团关闭成功') |
|
| 202 | 204 |
|
| 203 | 205 |
|
| 204 | 206 |
@logit |
| 205 | 207 |
def tg_group_gather_start_api(request): |
| 206 | 208 |
""" |
| 207 |
- 导游团设置集合时间和地点 |
|
| 209 |
+ 旅行团设置集合时间和地点 |
|
| 208 | 210 |
:param request: |
| 209 | 211 |
:return: |
| 210 | 212 |
""" |
| 211 | 213 |
group_id = request.POST.get('group_id', '')
|
| 212 | 214 |
admin_id = request.POST.get('admin_id', '') or request.POST.get('user_id', '')
|
| 213 |
- gather_at = request.POST.get('gather_at', '')
|
|
| 215 |
+ gather_at = request.POST.get('gather_at', '') # UTC, %Y-%m-%dT%H:%M:%SZ
|
|
| 214 | 216 |
gather_lon = request.POST.get('lon', '') # 经度
|
| 215 | 217 |
gather_lat = request.POST.get('lat', '') # 纬度
|
| 216 | 218 |
|
@@ -236,4 +238,4 @@ def tg_group_gather_start_api(request): |
||
| 236 | 238 |
# 更新Session |
| 237 | 239 |
r.set(TOUR_GUIDE_GROUP_CUR_SESSION, shortuuid.uuid()) |
| 238 | 240 |
|
| 239 |
- return response(200, u'Set Tour Guide Group Gather Info Success', u'设置导游团集合信息成功') |
|
| 241 |
+ return response(200, u'Set Tour Guide Group Gather Info Success', u'设置旅行团集合信息成功') |
@@ -26,7 +26,7 @@ r = settings.REDIS_CACHE |
||
| 26 | 26 |
@logit |
| 27 | 27 |
def tgu_group_user_join_api(request): |
| 28 | 28 |
""" |
| 29 |
- 导游团用户加群 |
|
| 29 |
+ 旅行团用户加群 |
|
| 30 | 30 |
:param request: |
| 31 | 31 |
:return: |
| 32 | 32 |
""" |
@@ -34,7 +34,7 @@ def tgu_group_user_join_api(request): |
||
| 34 | 34 |
user_id = request.POST.get('user_id', '')
|
| 35 | 35 |
nickname = request.POST.get('nickname', '')
|
| 36 | 36 |
|
| 37 |
- # 获取导游团唯一标识 |
|
| 37 |
+ # 获取旅行团唯一标识 |
|
| 38 | 38 |
group_id = get_tour_guide_own_group(admin_id) |
| 39 | 39 |
|
| 40 | 40 |
# 用户校验 |
@@ -92,7 +92,7 @@ def tgu_group_user_join_api(request): |
||
| 92 | 92 |
@logit |
| 93 | 93 |
def tgu_group_user_update_api(request): |
| 94 | 94 |
""" |
| 95 |
- 导游团用户更新 |
|
| 95 |
+ 旅行团用户更新 |
|
| 96 | 96 |
:param request: |
| 97 | 97 |
:return: |
| 98 | 98 |
""" |
@@ -141,7 +141,7 @@ def tgu_group_user_update_api(request): |
||
| 141 | 141 |
@logit |
| 142 | 142 |
def tgu_group_user_locations_api(request): |
| 143 | 143 |
""" |
| 144 |
- 导游团所有用户位置信息 |
|
| 144 |
+ 旅行团所有用户位置信息 |
|
| 145 | 145 |
:param request: |
| 146 | 146 |
:return: |
| 147 | 147 |
""" |
@@ -152,7 +152,7 @@ def tgu_group_user_locations_api(request): |
||
| 152 | 152 |
if not GroupUserInfo.objects.filter(group_id=group_id, user_id=admin_id, subadmin=True, status=True).exists(): |
| 153 | 153 |
return response(GroupStatusCode.NO_LOCATION_PERMISSION) |
| 154 | 154 |
|
| 155 |
- return response(200, 'Get Tour Guide Group All User Location Success', u'获取导游团用户地理位置信息成功', {
|
|
| 155 |
+ return response(200, 'Get Tour Guide Group All User Location Success', u'获取旅行团用户地理位置信息成功', {
|
|
| 156 | 156 |
'group_id': group_id, |
| 157 | 157 |
'locations': r.georadius(TOUR_GUIDE_GROUP_GEO_INFO % group_id, 0, 0, '+inf', unit='m', withdist=True, withcoord=True, sort='ASC') |
| 158 | 158 |
# 'locations': [['x', 0.33, (2.68220901489e-06, 1.26736058093e-06)]] |
@@ -162,7 +162,7 @@ def tgu_group_user_locations_api(request): |
||
| 162 | 162 |
@logit |
| 163 | 163 |
def tgu_group_user_location_api(request): |
| 164 | 164 |
""" |
| 165 |
- 导游团单个用户位置信息 |
|
| 165 |
+ 旅行团单个用户位置信息 |
|
| 166 | 166 |
:param request: |
| 167 | 167 |
:return: |
| 168 | 168 |
""" |
@@ -177,7 +177,7 @@ def tgu_group_user_location_api(request): |
||
| 177 | 177 |
session_id = r.get(TOUR_GUIDE_GROUP_CUR_SESSION % group_id) |
| 178 | 178 |
locations = r.lrange(TOUR_GUIDE_GROUP_USER_GEO_LIST % (group_id, session_id, user_id), 0, -1) |
| 179 | 179 |
|
| 180 |
- return response(200, 'Get Tour Guide Group User Location Success', u'获取导游团用户地理位置信息成功', {
|
|
| 180 |
+ return response(200, 'Get Tour Guide Group User Location Success', u'获取旅行团用户地理位置信息成功', {
|
|
| 181 | 181 |
'group_id': group_id, |
| 182 | 182 |
'user_id': user_id, |
| 183 | 183 |
'locations': [json.loads(loc) for loc in locations] |
@@ -3,6 +3,7 @@ |
||
| 3 | 3 |
from django.conf import settings |
| 4 | 4 |
from django.db import models |
| 5 | 5 |
from django.utils.translation import ugettext_lazy as _ |
| 6 |
+from TimeConvert import TimeConvert as tc |
|
| 6 | 7 |
|
| 7 | 8 |
from group.models import GroupPhotoInfo |
| 8 | 9 |
from pai2.basemodels import CreateUpdateMixin |
@@ -72,7 +73,7 @@ class UserMessageInfo(CreateUpdateMixin): |
||
| 72 | 73 |
'msg_title': self.msg_title, |
| 73 | 74 |
'msg_content': self.msg_content, |
| 74 | 75 |
'read': self.read, |
| 75 |
- 'created_at': self.created_at.replace(microsecond=0), |
|
| 76 |
+ 'created_at': tc.remove_microsecond(self.created_at), |
|
| 76 | 77 |
} |
| 77 | 78 |
|
| 78 | 79 |
|
@@ -3,6 +3,7 @@ |
||
| 3 | 3 |
from django.db import models |
| 4 | 4 |
from django.utils.translation import ugettext_lazy as _ |
| 5 | 5 |
from shortuuidfield import ShortUUIDField |
| 6 |
+from TimeConvert import TimeConvert as tc |
|
| 6 | 7 |
|
| 7 | 8 |
from group.models import GroupPhotoInfo |
| 8 | 9 |
from pai2.basemodels import CreateUpdateMixin |
@@ -96,8 +97,8 @@ class OrderInfo(CreateUpdateMixin): |
||
| 96 | 97 |
'body': self.body, |
| 97 | 98 |
'total_fee': self.total_fee, |
| 98 | 99 |
'pay_status': self.pay_status, |
| 99 |
- 'paid_at': self.paid_at and self.paid_at.replace(microsecond=0), |
|
| 100 |
- 'created_at': self.created_at.replace(microsecond=0), |
|
| 100 |
+ 'paid_at': tc.remove_microsecond(self.paid_at), |
|
| 101 |
+ 'created_at': tc.remove_microsecond(self.created_at), |
|
| 101 | 102 |
} |
| 102 | 103 |
|
| 103 | 104 |
@property |
@@ -80,7 +80,7 @@ class GroupUserStatusCode(BaseStatusCode): |
||
| 80 | 80 |
GROUP_USER_NOT_FOUND = StatusCodeField(402101, u'Group User Not Found', description=u'群组用户不存在') |
| 81 | 81 |
GROUP_USER_HAS_DELETED = StatusCodeField(402102, u'Group User Has Deleted', description=u'群组用户被移除') |
| 82 | 82 |
|
| 83 |
- USER_HAS_NOT_JOIN_GROUP = StatusCodeField(402131, u'User Has Not Join Group', description=u'用户未加入导游团') |
|
| 83 |
+ USER_HAS_NOT_JOIN_GROUP = StatusCodeField(402131, u'User Has Not Join Group', description=u'用户未加入旅行团') |
|
| 84 | 84 |
|
| 85 | 85 |
|
| 86 | 86 |
class GroupPhotoStatusCode(BaseStatusCode): |
@@ -11,8 +11,8 @@ TOUR_GUIDE_GROUP_GEO_INFO = 'tour:guide:group:geo:info:%s' # ZSET,旅游团 |
||
| 11 | 11 |
TOUR_GUIDE_GROUP_CUR_SESSION = 'tour:guide:group:cur:session:%s' # STRING,旅游团当前Session,group_id,导游设置集合时间的时候更新 |
| 12 | 12 |
TOUR_GUIDE_GROUP_USER_GEO_LIST = 'tour:guide:group:user:geo:list:%s:%s:%s' # LIST,旅游团当前用户地理位置列表,group_id、session_id、user_id |
| 13 | 13 |
|
| 14 |
-TOUR_GUIDE_GROUP_USER_OWN = 'tour:guide:group:user:own:%s' # STRING,导游当前拥有的导游团,user_id,导游创建导游团的时候更新 |
|
| 15 |
-TOUR_GUIDE_GROUP_USER_BELONG = 'tour:guide:group:user:belong:%s' # STRING,用户当前所属导游团,user_id,用户加入导游团的时候更新 |
|
| 14 |
+TOUR_GUIDE_GROUP_USER_OWN = 'tour:guide:group:user:own:%s' # STRING,导游当前拥有的旅行团,user_id,导游创建旅行团的时候更新 |
|
| 15 |
+TOUR_GUIDE_GROUP_USER_BELONG = 'tour:guide:group:user:belong:%s' # STRING,用户当前所属旅行团,user_id,用户加入旅行团的时候更新 |
|
| 16 | 16 |
|
| 17 | 17 |
# 群组相关 |
| 18 | 18 |
GROUP_INFO = 'group:info:%s' # STRING,群组信息,group_id |
@@ -12,10 +12,10 @@ r = settings.REDIS_CACHE |
||
| 12 | 12 |
|
| 13 | 13 |
|
| 14 | 14 |
def set_tour_guide_own_group(user_id, group_id): |
| 15 |
- """ 设置导游拥有的导游团 """ |
|
| 15 |
+ """ 设置导游拥有的旅行团 """ |
|
| 16 | 16 |
r.set(TOUR_GUIDE_GROUP_USER_OWN % user_id, group_id) |
| 17 | 17 |
|
| 18 | 18 |
|
| 19 | 19 |
def get_tour_guide_own_group(user_id): |
| 20 |
- """ 获取导游拥有的导游团 """ |
|
| 20 |
+ """ 获取导游拥有的旅行团 """ |
|
| 21 | 21 |
return r.get(TOUR_GUIDE_GROUP_USER_OWN % user_id) |