|
@@ -1859,23 +1859,12 @@ class InitInfoView(View):
|
|
|
update(**update_dict)
|
|
|
if appBundleId:
|
|
|
user_ex_qs = UserExModel.objects.filter(userID_id=userID)
|
|
|
- # redisObject = RedisObject(db=6)
|
|
|
- # ip = CommonService.get_ip_address(request)
|
|
|
- # key = 'ip_country_{ip}'.format(ip=ip)
|
|
|
- # data = redisObject.get_data(key=key)
|
|
|
- # if data:
|
|
|
- # country = data
|
|
|
- # else:
|
|
|
- # country = CommonService.getAddr(ip)
|
|
|
- # redisObject.set_data(key=key, val=country, expire=3600)
|
|
|
- country = ''
|
|
|
user_ex = None
|
|
|
if user_ex_qs.exists():
|
|
|
update_dict = {
|
|
|
'updTime': now_time,
|
|
|
'appBundleId': appBundleId,
|
|
|
- 'region': lang,
|
|
|
- 'country': country
|
|
|
+ 'region': lang
|
|
|
}
|
|
|
user_ex_qs.update(**update_dict)
|
|
|
user_ex = user_ex_qs[0]
|
|
@@ -1885,8 +1874,7 @@ class InitInfoView(View):
|
|
|
'updTime': now_time,
|
|
|
'appBundleId': appBundleId,
|
|
|
'userID_id': userID,
|
|
|
- 'region': lang,
|
|
|
- 'country': country
|
|
|
+ 'region': lang
|
|
|
}
|
|
|
user_ex = UserExModel.objects.create(**create_dict)
|
|
|
|
|
@@ -1907,15 +1895,6 @@ class InitInfoView(View):
|
|
|
appBundleId = request_dict.get('appBundleId', None)
|
|
|
lang = request_dict.get('lang', '') # 语言区域
|
|
|
if username and appBundleId:
|
|
|
- redisObject = RedisObject(db=6)
|
|
|
- ip = CommonService.get_ip_address(request)
|
|
|
- key = 'ip_country_{ip}'.format(ip=ip)
|
|
|
- data = redisObject.get_data(key=key)
|
|
|
- if data:
|
|
|
- country = data
|
|
|
- else:
|
|
|
- country = CommonService.getAddr(ip)
|
|
|
- redisObject.set_data(key=key, val=country, expire=3600)
|
|
|
user_qs = Device_User.objects.filter(username=username)
|
|
|
if user_qs.exists():
|
|
|
user = user_qs[0]
|
|
@@ -1925,20 +1904,27 @@ class InitInfoView(View):
|
|
|
update_dict = {
|
|
|
'updTime': now_time,
|
|
|
'appBundleId': appBundleId,
|
|
|
- 'region': lang,
|
|
|
- 'country': country
|
|
|
+ 'region': lang
|
|
|
}
|
|
|
user_ex_qs.update(**update_dict)
|
|
|
+ user_ex = user_ex_qs[0]
|
|
|
else:
|
|
|
create_dict = {
|
|
|
'addTime': now_time,
|
|
|
'updTime': now_time,
|
|
|
'appBundleId': appBundleId,
|
|
|
'userID_id': user.userID,
|
|
|
- 'region': lang,
|
|
|
- 'country': country
|
|
|
+ 'region': lang
|
|
|
}
|
|
|
- UserExModel.objects.create(**create_dict)
|
|
|
+ user_ex = UserExModel.objects.create(**create_dict)
|
|
|
+ country_ip_qs = CountryIPModel.objects.filter(user_ex_id=user_ex.id)
|
|
|
+ if not country_ip_qs.exists():
|
|
|
+ countryIp = CountryIPModel(
|
|
|
+ ip=CommonService.get_ip_address(request),
|
|
|
+ add_time=now_time,
|
|
|
+ user_ex_id=user_ex_qs[0].id
|
|
|
+ )
|
|
|
+ countryIp.save()
|
|
|
return response.json(0)
|
|
|
else:
|
|
|
return response.json(104)
|