|
|
@@ -102,10 +102,16 @@ def tg_group_create_api(request):
|
102
|
102
|
})
|
103
|
103
|
|
104
|
104
|
|
105
|
|
-def set_geo_submit_flag(uinfo, geo_dt):
|
|
105
|
+def set_geo_submit_flag(uinfo, geo_at, gather_at):
|
106
|
106
|
uinfo['geo_submited'] = False
|
107
|
|
- if geo_dt:
|
108
|
|
- pass
|
|
107
|
+ if geo_at and gather_at:
|
|
108
|
+ current_dt = tc.utc_datetime()
|
|
109
|
+ delta_seconds = tc.total_seconds(gather_at - current_dt)
|
|
110
|
+ # 距离集合时间超过30分钟是5分钟,15分钟到30分钟是3分钟,15分钟以内是1分钟
|
|
111
|
+ for delta, gdt in [(1800, 300), (900, 180), (0, 60)]:
|
|
112
|
+ if delta_seconds > delta:
|
|
113
|
+ uinfo['geo_submited'] = tc.total_seconds(current_dt - geo_at) <= gdt
|
|
114
|
+ break
|
109
|
115
|
return uinfo
|
110
|
116
|
|
111
|
117
|
|
|
|
@@ -115,13 +121,21 @@ def tg_group_detail_api(request):
|
115
|
121
|
group_id = request.POST.get('group_id', '')
|
116
|
122
|
user_id = request.POST.get('user_id', '')
|
117
|
123
|
|
|
124
|
+ # GEO last submit datetimes
|
118
|
125
|
geo_dts = r.hgetall(TOUR_GUIDE_GROUP_GEO_SUBMIT_DT % group_id)
|
119
|
126
|
|
|
127
|
+ group_info = get_group_info(group_id)
|
|
128
|
+ # Gather datetime
|
|
129
|
+ gather_at = group_info.get('gather_at', '')
|
|
130
|
+ gather_at = tc.utc_string_to_utc_datetime(gather_at, format='%Y-%m-%dT%H:%M:%SZ') if isinstance(gather_at, basestring) else gather_at
|
|
131
|
+ if gather_at and tc.utc_datetime() > gather_at:
|
|
132
|
+ gather_at = ''
|
|
133
|
+
|
120
|
134
|
group_users_info = get_group_users_info(group_id, user_id)
|
121
|
135
|
# Remove tourguide
|
122
|
136
|
group_passed_users = [uinfo for uinfo in group_users_info['passed'] if not uinfo['subadmin']]
|
123
|
137
|
# GEO Submited Flag
|
124
|
|
- group_passed_users = [set_geo_submit_flag(uinfo, geo_dts.get(uinfo['user_id'], '')) for uinfo in group_passed_users]
|
|
138
|
+ group_passed_users = [set_geo_submit_flag(uinfo, tc.utc_string_to_utc_datetime(geo_dts.get(uinfo['user_id'], '')), gather_at) for uinfo in group_passed_users]
|
125
|
139
|
group_users_info['passed'] = group_passed_users
|
126
|
140
|
# Update passed count
|
127
|
141
|
group_users_info['passed_count'] = len(group_passed_users)
|
|
|
@@ -130,7 +144,7 @@ def tg_group_detail_api(request):
|
130
|
144
|
|
131
|
145
|
return response(200, 'Get Tour Guide Group Detail Info Success', u'获取旅行团详情成功', {
|
132
|
146
|
'group_id': group_id,
|
133
|
|
- 'group': get_group_info(group_id),
|
|
147
|
+ 'group': group_info,
|
134
|
148
|
'users': group_users_info,
|
135
|
149
|
})
|
136
|
150
|
|