|
@@ -35,6 +35,7 @@ from django.http import JsonResponse, HttpResponseRedirect, HttpResponse
|
|
|
from django.db import transaction
|
|
|
from django.views.generic.base import View
|
|
|
import jwt
|
|
|
+from Object.ETkObject import ETkObject
|
|
|
from pyfcm import FCMNotification
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_ARN, SERVER_DOMAIN, PAYPAL_CRD, \
|
|
|
SERVER_DOMAIN_SSL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ARN, APNS_MODE, APNS_CONFIG, BASE_DIR, \
|
|
@@ -42,7 +43,8 @@ from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_AR
|
|
|
from Controller.CheckUserData import DataValid
|
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, VodHlsModel, OssCrdModel, UID_Bucket, StsCrdModel, \
|
|
|
ExperienceContextModel, Pay_Type, CDKcontextModel, Device_User, SysMassModel, SysMsgModel, UidPushModel, \
|
|
|
- Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel, VideoPlaybackTimeModel, CloudLogModel, CouponModel, AiStoreMeal, AiService
|
|
|
+ Unused_Uid_Meal, UIDMainUser, UserModel, PromotionRuleModel, VideoPlaybackTimeModel, CloudLogModel, CouponModel, \
|
|
|
+ AiStoreMeal, AiService, UidSetModel
|
|
|
from Object.AWS.S3Email import S3Email
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
@@ -135,37 +137,33 @@ class AiView(View):
|
|
|
return response.json(904)
|
|
|
else:
|
|
|
return response.json(173)
|
|
|
+ hasAiService = AiService.objects.filter(uid=uid,use_status=1)
|
|
|
+ if not hasAiService.exists():
|
|
|
+ return response.json(10053)
|
|
|
+ nowTime = int(time.time())
|
|
|
+ endTime = hasAiService.values('endTime')[0]['endTime']
|
|
|
+ if nowTime >endTime:
|
|
|
+ return response.json(10054)
|
|
|
dvqs = Device_Info.objects.filter(userID_id=userID, UID=uid)
|
|
|
status = int(status)
|
|
|
- # 获取用户区域
|
|
|
- # ip = self.ip
|
|
|
- # ipInfo = CommonService.getIpIpInfo(ip=ip, lang='EN')
|
|
|
- # area = ipInfo['country_name']
|
|
|
- # if area == 'China':
|
|
|
- # DETECT_PUSH_DOMAIN = 'cn.push.dvema.com'
|
|
|
- # else:
|
|
|
- # DETECT_PUSH_DOMAIN = 'en.push.dvema.com'
|
|
|
-
|
|
|
nowTime = int(time.time())
|
|
|
if dvqs.exists():
|
|
|
# 修改状态
|
|
|
- dvqs.update(NotificationMode=status)
|
|
|
+ # dvqs.update(NotificationMode=status)
|
|
|
uid_set_qs = UidSetModel.objects.filter(uid=uid)
|
|
|
# uid配置信息是否存在
|
|
|
|
|
|
if uid_set_qs.exists():
|
|
|
uid_set_id = uid_set_qs[0].id
|
|
|
qs_data = {
|
|
|
- 'detect_status': status,
|
|
|
- 'updTime': nowTime,
|
|
|
+ 'status': status,
|
|
|
+
|
|
|
}
|
|
|
if interval:
|
|
|
qs_data['detect_interval'] = int(interval)
|
|
|
if detect_group:
|
|
|
qs_data['detect_group'] = detect_group
|
|
|
- print(qs_data)
|
|
|
uid_set_qs.update(**qs_data)
|
|
|
-
|
|
|
else:
|
|
|
qs_data = {
|
|
|
'uid': uid,
|
|
@@ -179,15 +177,17 @@ class AiView(View):
|
|
|
qs_data['detect_group'] = detect_group
|
|
|
# 添加设备配置
|
|
|
uid_set_qs = UidSetModel.objects.create(**qs_data)
|
|
|
-
|
|
|
uid_set_id = uid_set_qs.id
|
|
|
|
|
|
+
|
|
|
if status == 0:
|
|
|
- UidPushModel.objects.filter(uid_set__uid=uid).delete()
|
|
|
+ hasAiService.update(**qs_data)
|
|
|
+ # UidPushModel.objects.filter(uid_set__uid=uid).delete()
|
|
|
# 状态为0的时候删除redis缓存数据
|
|
|
- self.do_delete_redis(uid)
|
|
|
+ # self.do_delete_redis(uid)
|
|
|
return response.json(0)
|
|
|
elif status == 1:
|
|
|
+ hasAiService.update(status=1)
|
|
|
uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
|
|
|
|
|
|
if uid_push_qs.exists():
|
|
@@ -219,18 +219,20 @@ class AiView(View):
|
|
|
# 绑定设备推送
|
|
|
UidPushModel.objects.create(**uid_push_create_dict)
|
|
|
|
|
|
- if interval:
|
|
|
- self.do_delete_redis(uid, int(interval))
|
|
|
- else:
|
|
|
- self.do_delete_redis(uid)
|
|
|
+ # if interval:
|
|
|
+ # self.do_delete_redis(uid, int(interval))
|
|
|
+ # else:
|
|
|
+ # self.do_delete_redis(uid)
|
|
|
# utko = UidTokenObject()
|
|
|
# # right
|
|
|
# utko.generate(data={'uid': uid})
|
|
|
etkObj = ETkObject(etk='')
|
|
|
etk = etkObj.encrypt(uid)
|
|
|
- detectUrl = "{DETECT_PUSH_DOMAIN}notify/push?etk={etk}". \
|
|
|
- format(etk=etk, DETECT_PUSH_DOMAIN=DETECT_PUSH_DOMAIN)
|
|
|
- return response.json(0, {'detectUrl': detectUrl})
|
|
|
+ detectUrl = "{DETECT_PUSH_DOMAIN}AiService/push?etk={etk}&endTime={endTime}". \
|
|
|
+ format(etk=etk, DETECT_PUSH_DOMAIN=SERVER_DOMAIN_SSL, endTime=endTime)
|
|
|
+ aiIdentificationUrl = "{DETECT_PUSH_DOMAIN}AiService/identification?etk={etk}&endTime={endTime}". \
|
|
|
+ format(etk=etk, DETECT_PUSH_DOMAIN=SERVER_DOMAIN_SSL, endTime=endTime)
|
|
|
+ return response.json(0, {'detectUrl': detectUrl,'aiIdentificationUrl':aiIdentificationUrl})
|
|
|
else:
|
|
|
return response.json(14)
|
|
|
|
|
@@ -317,8 +319,8 @@ class AiView(View):
|
|
|
else:
|
|
|
use_status = 1
|
|
|
# return response.json(0)
|
|
|
- AiService.objects.create(orders_id=orderID, uid=uid, channel=channel, status=0,
|
|
|
- endTime=nowTime+(day*86400), addTime=nowTime, updateTime=nowTime,
|
|
|
- use_status=use_status, detect_type='1')
|
|
|
+ AiService.objects.create(orders_id=orderID, uid=uid, channel=channel, detect_status=0,
|
|
|
+ endTime=nowTime+(day*86400), addTime=nowTime, updTime=nowTime,
|
|
|
+ use_status=use_status, detect_group='1')
|
|
|
return response.json(0, {"orderID": orderID})
|
|
|
return response.json(10, 'generate_order_false')
|