|
@@ -421,6 +421,7 @@ class AiServeView(View):
|
|
|
if country_qs.exists():
|
|
|
country = country_qs.first()['country_name']
|
|
|
data_dict['country'] = country
|
|
|
+ data_dict['deviceCountry'] = self.get_device_country(data_dict['ip'])
|
|
|
uid_set_qs = UidSetModel.objects.filter(uid=order['UID']).values('version')
|
|
|
data_dict['version'] = uid_set_qs.first()['version'] if uid_set_qs.exists() else ''
|
|
|
ai_service_qs = AiService.objects.filter(
|
|
@@ -436,6 +437,19 @@ class AiServeView(View):
|
|
|
print(e)
|
|
|
return response.json(500, repr(e))
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def get_device_country(ip):
|
|
|
+ """
|
|
|
+ 根据IP获取国家名称
|
|
|
+ """
|
|
|
+ if not ip:
|
|
|
+ return '未知国家'
|
|
|
+ ipInfo = CommonService.getIpIpInfo(ip, 'EN')
|
|
|
+ country_qs = CountryModel.objects.filter(country_code=ipInfo['country_code']).values('id', 'country_name')
|
|
|
+ if not country_qs.exists():
|
|
|
+ return '未知国家'
|
|
|
+ return country_qs[0]['country_name']
|
|
|
+
|
|
|
def getAiDataList(self, request_dict, response):
|
|
|
year = request_dict.get('year', None)
|
|
|
Jan = int(time.mktime(time.strptime(year + '-1-1 00:00:00', "%Y-%m-%d %H:%M:%S")))
|