|
@@ -31,14 +31,14 @@ class cloudTestView(View):
|
|
return self.validation(request.POST, request, operation)
|
|
return self.validation(request.POST, request, operation)
|
|
|
|
|
|
def validation(self, request_dict, request, operation):
|
|
def validation(self, request_dict, request, operation):
|
|
- response = ResponseObject()
|
|
|
|
|
|
+ lang = request_dict.get('lang', None)
|
|
|
|
+ response = ResponseObject(lang) if lang else ResponseObject()
|
|
if operation is None:
|
|
if operation is None:
|
|
return response.json(444, 'error path')
|
|
return response.json(444, 'error path')
|
|
else:
|
|
else:
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
# 设备主键uid
|
|
# 设备主键uid
|
|
tko = TokenObject(token)
|
|
tko = TokenObject(token)
|
|
- response.lang = tko.lang
|
|
|
|
if tko.code != 0:
|
|
if tko.code != 0:
|
|
return response.json(tko.code)
|
|
return response.json(tko.code)
|
|
userID = tko.userID
|
|
userID = tko.userID
|
|
@@ -59,12 +59,13 @@ class cloudTestView(View):
|
|
|
|
|
|
try:
|
|
try:
|
|
# 查询该userID下是否存在此设备
|
|
# 查询该userID下是否存在此设备
|
|
- old_deviceInfo_qs = Device_Info.objects.filter(userID_id=oldUserID, UID=uid, isExist=1).values('isShare','vodPrimaryUserID')
|
|
|
|
|
|
+ old_deviceInfo_qs = Device_Info.objects.filter(userID_id=oldUserID, UID=uid, isExist=1).values('isShare',
|
|
|
|
+ 'vodPrimaryUserID')
|
|
if not old_deviceInfo_qs.exists():
|
|
if not old_deviceInfo_qs.exists():
|
|
return response.json(10008)
|
|
return response.json(10008)
|
|
|
|
|
|
- newUserID = ModelService.get_userID_byname(username) # 根据username获取userID
|
|
|
|
- if newUserID is None: # 没有此用户
|
|
|
|
|
|
+ newUserID = ModelService.get_userID_byname(username) # 根据username获取userID
|
|
|
|
+ if newUserID is None: # 没有此用户
|
|
return response.json(104)
|
|
return response.json(104)
|
|
if newUserID == oldUserID: # 新用户的userID跟旧用户的一样
|
|
if newUserID == oldUserID: # 新用户的userID跟旧用户的一样
|
|
return response.json(10009)
|
|
return response.json(10009)
|
|
@@ -89,12 +90,11 @@ class cloudTestView(View):
|
|
return response.json(10009)
|
|
return response.json(10009)
|
|
|
|
|
|
# 旧用户如果开启云存自动续费,不可转移
|
|
# 旧用户如果开启云存自动续费,不可转移
|
|
- hasCycle = Order_Model.objects.filter(userID=oldUserID,UID=uid)
|
|
|
|
|
|
+ hasCycle = Order_Model.objects.filter(userID=oldUserID, UID=uid)
|
|
hasCycle = hasCycle.filter(~Q(agreement_id=''))
|
|
hasCycle = hasCycle.filter(~Q(agreement_id=''))
|
|
if hasCycle.exists():
|
|
if hasCycle.exists():
|
|
return response.json(10056)
|
|
return response.json(10056)
|
|
|
|
|
|
-
|
|
|
|
# 获取新设备的username
|
|
# 获取新设备的username
|
|
newUserName = Device_User.objects.get(userID=newUserID).username
|
|
newUserName = Device_User.objects.get(userID=newUserID).username
|
|
vodPrimaryUserID = newUserID
|
|
vodPrimaryUserID = newUserID
|
|
@@ -104,7 +104,8 @@ class cloudTestView(View):
|
|
# 更新旧设备的userID,设备添加时间,关闭推送消息提醒
|
|
# 更新旧设备的userID,设备添加时间,关闭推送消息提醒
|
|
old_deviceInfo_qs.update(userID=newUserID, data_joined=now_time, NotificationMode=0)
|
|
old_deviceInfo_qs.update(userID=newUserID, data_joined=now_time, NotificationMode=0)
|
|
# 更新设备的主用户信息
|
|
# 更新设备的主用户信息
|
|
- Device_Info.objects.filter(UID=uid).update(vodPrimaryUserID=vodPrimaryUserID, vodPrimaryMaster=vodPrimaryMaster)
|
|
|
|
|
|
+ Device_Info.objects.filter(UID=uid).update(vodPrimaryUserID=vodPrimaryUserID,
|
|
|
|
+ vodPrimaryMaster=vodPrimaryMaster)
|
|
VodHlsModel.objects.filter(uid=uid).delete()
|
|
VodHlsModel.objects.filter(uid=uid).delete()
|
|
|
|
|
|
# UIDMainUser.objects.filter(UID=uid).delete()
|
|
# UIDMainUser.objects.filter(UID=uid).delete()
|
|
@@ -128,7 +129,8 @@ class cloudTestView(View):
|
|
|
|
|
|
try:
|
|
try:
|
|
# 查询两个UID是否在同一账号下
|
|
# 查询两个UID是否在同一账号下
|
|
- old_deviceInfo_qs = Device_Info.objects.filter(userID_id=userID, UID=old_uid).values('isExist','vodPrimaryUserID')
|
|
|
|
|
|
+ old_deviceInfo_qs = Device_Info.objects.filter(userID_id=userID, UID=old_uid).values('isExist',
|
|
|
|
+ 'vodPrimaryUserID')
|
|
new_deviceInfo_qs = Device_Info.objects.filter(userID_id=userID, UID=new_uid).values('isExist')
|
|
new_deviceInfo_qs = Device_Info.objects.filter(userID_id=userID, UID=new_uid).values('isExist')
|
|
if not (old_deviceInfo_qs.exists() and new_deviceInfo_qs.exists()):
|
|
if not (old_deviceInfo_qs.exists() and new_deviceInfo_qs.exists()):
|
|
return response.json(10010)
|
|
return response.json(10010)
|
|
@@ -145,7 +147,10 @@ class cloudTestView(View):
|
|
return response.json(10011)
|
|
return response.json(10011)
|
|
|
|
|
|
# 查询转出设备正在使用的套餐
|
|
# 查询转出设备正在使用的套餐
|
|
- old_using_uid_bucket = UID_Bucket.objects.filter(uid=old_uid, endTime__gte=nowTime).values('id', 'bucket_id', 'has_unused').order_by('addTime')
|
|
|
|
|
|
+ old_using_uid_bucket = UID_Bucket.objects.filter(uid=old_uid, endTime__gte=nowTime).values('id',
|
|
|
|
+ 'bucket_id',
|
|
|
|
+ 'has_unused').order_by(
|
|
|
|
+ 'addTime')
|
|
if not old_using_uid_bucket.exists():
|
|
if not old_using_uid_bucket.exists():
|
|
return response.json(10013)
|
|
return response.json(10013)
|
|
|
|
|
|
@@ -163,10 +168,11 @@ class cloudTestView(View):
|
|
|
|
|
|
# 如果转出设备有未使用套餐,更改第一个未使用套餐为正在使用
|
|
# 如果转出设备有未使用套餐,更改第一个未使用套餐为正在使用
|
|
if old_using_uid_bucket[0]['has_unused'] == 1:
|
|
if old_using_uid_bucket[0]['has_unused'] == 1:
|
|
- old_unused_uid_bucket = Unused_Uid_Meal.objects.filter(uid=old_uid).values('id', 'channel', 'bucket_id', 'addTime', 'expire', 'num')
|
|
|
|
|
|
+ old_unused_uid_bucket = Unused_Uid_Meal.objects.filter(uid=old_uid).values('id', 'channel', 'bucket_id',
|
|
|
|
+ 'addTime', 'expire', 'num')
|
|
count = old_unused_uid_bucket.count()
|
|
count = old_unused_uid_bucket.count()
|
|
unused = old_unused_uid_bucket[0]
|
|
unused = old_unused_uid_bucket[0]
|
|
- has_unused = 1 if count>1 else 0 # 如果存在不止一个未使用套餐,has_unused=1
|
|
|
|
|
|
+ has_unused = 1 if count > 1 else 0 # 如果存在不止一个未使用套餐,has_unused=1
|
|
endTime = CommonService.calcMonthLater(unused['expire'] * unused['num'])
|
|
endTime = CommonService.calcMonthLater(unused['expire'] * unused['num'])
|
|
data_dict = {
|
|
data_dict = {
|
|
'uid': old_uid,
|
|
'uid': old_uid,
|
|
@@ -180,15 +186,16 @@ class cloudTestView(View):
|
|
'has_unused': has_unused
|
|
'has_unused': has_unused
|
|
}
|
|
}
|
|
UID_Bucket.objects.create(**data_dict) # 正在使用套餐表添加数据
|
|
UID_Bucket.objects.create(**data_dict) # 正在使用套餐表添加数据
|
|
- Unused_Uid_Meal.objects.filter(uid=old_uid).first().delete() # 删除未使用套餐表中的数据
|
|
|
|
|
|
+ Unused_Uid_Meal.objects.filter(uid=old_uid).first().delete() # 删除未使用套餐表中的数据
|
|
|
|
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
# 更新转入设备的主用户信息
|
|
# 更新转入设备的主用户信息
|
|
- Device_Info.objects.filter(UID=new_uid).update(vodPrimaryUserID=vodPrimaryUserID, vodPrimaryMaster=vodPrimaryMaster)
|
|
|
|
|
|
+ Device_Info.objects.filter(UID=new_uid).update(vodPrimaryUserID=vodPrimaryUserID,
|
|
|
|
+ vodPrimaryMaster=vodPrimaryMaster)
|
|
# 更新正在使用套餐的uid,重置拥有未使用套餐
|
|
# 更新正在使用套餐的uid,重置拥有未使用套餐
|
|
old_using_uid_bucket_id = old_using_uid_bucket[0]['id']
|
|
old_using_uid_bucket_id = old_using_uid_bucket[0]['id']
|
|
- UID_Bucket.objects.filter(id=old_using_uid_bucket_id).update(uid=new_uid,has_unused=0)
|
|
|
|
- StsCrdModel.objects.filter(uid=old_uid).delete() # 删除转出设备stscrd表关联数据
|
|
|
|
|
|
+ UID_Bucket.objects.filter(id=old_using_uid_bucket_id).update(uid=new_uid, has_unused=0)
|
|
|
|
+ StsCrdModel.objects.filter(uid=old_uid).delete() # 删除转出设备stscrd表关联数据
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
# print(e)
|
|
# print(e)
|