|
@@ -1282,6 +1282,9 @@ class InitInfoView(View):
|
|
|
lang = request_dict.get('lang', '') # 语言区域
|
|
|
# region = request_dict.get('region', '') # 语言区域
|
|
|
nowTime = int(time.time())
|
|
|
+ print(token_val)
|
|
|
+ print(push_type)
|
|
|
+ print(appBundleId)
|
|
|
if all([token_val, push_type, appBundleId]):
|
|
|
push_type = int(push_type)
|
|
|
if push_type == 0:
|
|
@@ -1296,6 +1299,7 @@ class InitInfoView(View):
|
|
|
else:
|
|
|
return response.json(444,'push_type')
|
|
|
uid_list = ModelService.get_uid_list(userID=userID)
|
|
|
+ print('1111111111')
|
|
|
if uid_list:
|
|
|
# 获取设备推送状态
|
|
|
update_dict = {
|
|
@@ -1306,6 +1310,8 @@ class InitInfoView(View):
|
|
|
# 更新当前用户推送设备状态
|
|
|
UidPushModel.objects.filter(userID_id=userID, m_code=m_code,uid_set__detect_status=1).update(**update_dict)
|
|
|
if appBundleId:
|
|
|
+ print('222222222222')
|
|
|
+
|
|
|
user_extend_qs = UserExtendModel.objects.filter(userID_id=userID)
|
|
|
if user_extend_qs.exists():
|
|
|
update_dict = {
|
|
@@ -1314,8 +1320,13 @@ class InitInfoView(View):
|
|
|
'region': lang
|
|
|
# 'is_cn':
|
|
|
}
|
|
|
- user_extend_qs.update(**update_dict)
|
|
|
+ print(update_dict)
|
|
|
+ is_update = user_extend_qs.update(**update_dict)
|
|
|
+ print('isiis')
|
|
|
+ print(is_update)
|
|
|
+
|
|
|
else:
|
|
|
+ print('is_create')
|
|
|
create_dict = {
|
|
|
'addTime': nowTime,
|
|
|
'updTime': nowTime,
|
|
@@ -1324,99 +1335,100 @@ class InitInfoView(View):
|
|
|
'region': lang
|
|
|
}
|
|
|
UserExtendModel.objects.create(**create_dict)
|
|
|
+
|
|
|
res = {
|
|
|
'usmsg': sm_count
|
|
|
}
|
|
|
return response.json(0, res)
|
|
|
|
|
|
# 初始化设备token
|
|
|
- def init_uid22(self, request_dict, userID, response):
|
|
|
- # 未读的系统消息
|
|
|
- sm_count = SysMsgModel.objects.filter(userID_id=userID, status=0).count()
|
|
|
-
|
|
|
- token_val = request_dict.get('token_val', None)
|
|
|
- m_code = request_dict.get('m_code', None)
|
|
|
- push_type = request_dict.get('push_type', None)
|
|
|
- appBundleId = request_dict.get('appBundleId', None)
|
|
|
- tz = request_dict.get('tz', None)
|
|
|
- lang = request_dict.get('lang', '') # 语言区域
|
|
|
- # region = request_dict.get('region', '') # 语言区域
|
|
|
- nowTime = int(time.time())
|
|
|
- if all([token_val, push_type, appBundleId]):
|
|
|
- push_type = int(push_type)
|
|
|
- if push_type == 0:
|
|
|
- # ios
|
|
|
- app_type = 1
|
|
|
- if appBundleId not in APNS_CONFIG.keys():
|
|
|
- return response.json(904)
|
|
|
- elif push_type == 1:
|
|
|
- # android
|
|
|
- app_type = 2
|
|
|
- if appBundleId not in FCM_CONFIG.keys():
|
|
|
- return response.json(904)
|
|
|
- elif push_type == 2:
|
|
|
- # android
|
|
|
- app_type = 2
|
|
|
- if appBundleId not in JPUSH_CONFIG.keys():
|
|
|
- return response.json(904)
|
|
|
- else:
|
|
|
- return response.json(173)
|
|
|
- uid_list = ModelService.get_uid_list(userID=userID)
|
|
|
- if uid_list:
|
|
|
- # 获取设备推送状态
|
|
|
- uid_set_id_list = UidSetModel.objects.filter(uid__in=uid_list, detect_status=1).values_list('id',
|
|
|
- flat=True)
|
|
|
- if uid_set_id_list:
|
|
|
- # 批量绑定推送
|
|
|
- qs_list = []
|
|
|
- for uid_set_id in uid_set_id_list:
|
|
|
- uid_push_create_dict = {
|
|
|
- 'uid_set_id': uid_set_id,
|
|
|
- 'userID_id': userID,
|
|
|
- 'appBundleId': appBundleId,
|
|
|
- 'app_type': app_type,
|
|
|
- 'push_type': push_type,
|
|
|
- 'token_val': token_val,
|
|
|
- 'm_code': m_code,
|
|
|
- 'addTime': nowTime,
|
|
|
- 'updTime': nowTime,
|
|
|
- 'lang': lang,
|
|
|
- 'tz': tz
|
|
|
- }
|
|
|
- qs_list.append(UidPushModel(**uid_push_create_dict))
|
|
|
- UidPushModel.objects.bulk_create(qs_list)
|
|
|
-
|
|
|
- update_dict = {
|
|
|
- 'token_val': token_val,
|
|
|
- 'push_type': push_type,
|
|
|
- 'tz': tz,
|
|
|
- }
|
|
|
- # 更新当前用户推送设备状态
|
|
|
- UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set_id__in=uid_set_id_list). \
|
|
|
- update(**update_dict)
|
|
|
- if appBundleId:
|
|
|
- user_extend_qs = UserExtendModel.objects.filter(userID_id=userID)
|
|
|
- if user_extend_qs.exists():
|
|
|
- update_dict = {
|
|
|
- 'updTime': nowTime,
|
|
|
- 'appBundleId': appBundleId,
|
|
|
- 'region': lang
|
|
|
- # 'is_cn':
|
|
|
- }
|
|
|
- user_extend_qs.update(**update_dict)
|
|
|
- else:
|
|
|
- create_dict = {
|
|
|
- 'addTime': nowTime,
|
|
|
- 'updTime': nowTime,
|
|
|
- 'appBundleId': appBundleId,
|
|
|
- 'userID_id': userID,
|
|
|
- 'region': lang
|
|
|
- }
|
|
|
- UserExtendModel.objects.create(**create_dict)
|
|
|
- res = {
|
|
|
- 'usmsg': sm_count
|
|
|
- }
|
|
|
- return response.json(0, res)
|
|
|
+ # def init_uid22(self, request_dict, userID, response):
|
|
|
+ # # 未读的系统消息
|
|
|
+ # sm_count = SysMsgModel.objects.filter(userID_id=userID, status=0).count()
|
|
|
+ #
|
|
|
+ # token_val = request_dict.get('token_val', None)
|
|
|
+ # m_code = request_dict.get('m_code', None)
|
|
|
+ # push_type = request_dict.get('push_type', None)
|
|
|
+ # appBundleId = request_dict.get('appBundleId', None)
|
|
|
+ # tz = request_dict.get('tz', None)
|
|
|
+ # lang = request_dict.get('lang', '') # 语言区域
|
|
|
+ # # region = request_dict.get('region', '') # 语言区域
|
|
|
+ # nowTime = int(time.time())
|
|
|
+ # if all([token_val, push_type, appBundleId]):
|
|
|
+ # push_type = int(push_type)
|
|
|
+ # if push_type == 0:
|
|
|
+ # # ios
|
|
|
+ # app_type = 1
|
|
|
+ # if appBundleId not in APNS_CONFIG.keys():
|
|
|
+ # return response.json(904)
|
|
|
+ # elif push_type == 1:
|
|
|
+ # # android
|
|
|
+ # app_type = 2
|
|
|
+ # if appBundleId not in FCM_CONFIG.keys():
|
|
|
+ # return response.json(904)
|
|
|
+ # elif push_type == 2:
|
|
|
+ # # android
|
|
|
+ # app_type = 2
|
|
|
+ # if appBundleId not in JPUSH_CONFIG.keys():
|
|
|
+ # return response.json(904)
|
|
|
+ # else:
|
|
|
+ # return response.json(173)
|
|
|
+ # uid_list = ModelService.get_uid_list(userID=userID)
|
|
|
+ # if uid_list:
|
|
|
+ # # 获取设备推送状态
|
|
|
+ # uid_set_id_list = UidSetModel.objects.filter(uid__in=uid_list, detect_status=1).values_list('id',
|
|
|
+ # flat=True)
|
|
|
+ # if uid_set_id_list:
|
|
|
+ # # 批量绑定推送
|
|
|
+ # qs_list = []
|
|
|
+ # for uid_set_id in uid_set_id_list:
|
|
|
+ # uid_push_create_dict = {
|
|
|
+ # 'uid_set_id': uid_set_id,
|
|
|
+ # 'userID_id': userID,
|
|
|
+ # 'appBundleId': appBundleId,
|
|
|
+ # 'app_type': app_type,
|
|
|
+ # 'push_type': push_type,
|
|
|
+ # 'token_val': token_val,
|
|
|
+ # 'm_code': m_code,
|
|
|
+ # 'addTime': nowTime,
|
|
|
+ # 'updTime': nowTime,
|
|
|
+ # 'lang': lang,
|
|
|
+ # 'tz': tz
|
|
|
+ # }
|
|
|
+ # qs_list.append(UidPushModel(**uid_push_create_dict))
|
|
|
+ # UidPushModel.objects.bulk_create(qs_list)
|
|
|
+ #
|
|
|
+ # update_dict = {
|
|
|
+ # 'token_val': token_val,
|
|
|
+ # 'push_type': push_type,
|
|
|
+ # 'tz': tz,
|
|
|
+ # }
|
|
|
+ # # 更新当前用户推送设备状态
|
|
|
+ # UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set_id__in=uid_set_id_list). \
|
|
|
+ # update(**update_dict)
|
|
|
+ # if appBundleId:
|
|
|
+ # user_extend_qs = UserExtendModel.objects.filter(userID_id=userID)
|
|
|
+ # if user_extend_qs.exists():
|
|
|
+ # update_dict = {
|
|
|
+ # 'updTime': nowTime,
|
|
|
+ # 'appBundleId': appBundleId,
|
|
|
+ # 'region': lang
|
|
|
+ # # 'is_cn':
|
|
|
+ # }
|
|
|
+ # user_extend_qs.update(**update_dict)
|
|
|
+ # else:
|
|
|
+ # create_dict = {
|
|
|
+ # 'addTime': nowTime,
|
|
|
+ # 'updTime': nowTime,
|
|
|
+ # 'appBundleId': appBundleId,
|
|
|
+ # 'userID_id': userID,
|
|
|
+ # 'region': lang
|
|
|
+ # }
|
|
|
+ # UserExtendModel.objects.create(**create_dict)
|
|
|
+ # res = {
|
|
|
+ # 'usmsg': sm_count
|
|
|
+ # }
|
|
|
+ # return response.json(0, res)
|
|
|
|
|
|
|
|
|
# 获取验证码
|