|
@@ -7,7 +7,8 @@ from django.views.generic.base import View
|
|
|
|
|
|
from Ansjer.config import SERVER_TYPE
|
|
|
from Model.models import AppSetModel, PromotionRuleModel, PopupsConfig, RedDotsConfig, Device_Info, UidSetModel, \
|
|
|
- UserOperationLog, Order_Model
|
|
|
+ UserOperationLog, Order_Model, IPAddr
|
|
|
+from Object.IPWeatherObject import IPQuery
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -277,18 +278,37 @@ class AppSetView(View):
|
|
|
return response.json(500)
|
|
|
return response.json(0)
|
|
|
|
|
|
- @staticmethod
|
|
|
- def status_by_ip(request, response):
|
|
|
+
|
|
|
+ def status_by_ip(self, request, response):
|
|
|
"""
|
|
|
根据ip 解析地址返回状态
|
|
|
"""
|
|
|
try:
|
|
|
# 这里加sdStatus过滤条件条件
|
|
|
ip = CommonService.get_ip_address(request)
|
|
|
- LOGGER.info(f"请求ip地址为 {ip}")
|
|
|
- splashAdStatus = 1
|
|
|
+ splashAdStatus = 0
|
|
|
+ ip_addr_qs = IPAddr.objects.filter(ip=ip, is_geoip2=False).values('district', 'city')
|
|
|
+ if ip_addr_qs.exists():
|
|
|
+ ip_country_code = ip_addr_qs[0]['country_code']
|
|
|
+ ip_region = ip_addr_qs[0]['region']
|
|
|
+ ip_city = ip_addr_qs[0]['city']
|
|
|
+ ip_district = ip_addr_qs[0]['district']
|
|
|
+ if ip_country_code == 'CN' and ip_region == '广东' and ip_city == '中山市':
|
|
|
+ splashAdStatus = 1
|
|
|
+ else:
|
|
|
+ ip_qs = IPQuery(ip)
|
|
|
+ ip_country_code = ip_addr_qs.country_id
|
|
|
+ ip_region = ip_qs.region
|
|
|
+ ip_city = ip_addr_qs.city
|
|
|
+ ip_district = ip_addr_qs.district
|
|
|
+ if ip_country_code == 'CN' and ip_region == '广东' and ip_city == '中山市':
|
|
|
+ splashAdStatus = 1
|
|
|
+ IPAddr.objects.create(ip=ip, country_code=ip_country_code, region=ip_region, city=ip_city,
|
|
|
+ district=ip_district)
|
|
|
+ LOGGER.info(f"请求ip地址为 {ip}, 解析为{ip_country_code},{ip_region},{ip_city},{ip_district}")
|
|
|
response_data = {"splashAdStatus": splashAdStatus}
|
|
|
return response.json(0, response_data)
|
|
|
except Exception as e:
|
|
|
LOGGER.info('根据ip解析地址返回状态异常,errLine:{}, errMsg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
return response.json(500)
|
|
|
+
|