|
@@ -1,5 +1,8 @@
|
|
|
+import time
|
|
|
+
|
|
|
+import requests
|
|
|
from django.views import View
|
|
|
-from Model.models import Device_User, Order_Model, CountryModel
|
|
|
+from Model.models import Device_User, Order_Model, CountryModel, SysMsgModel
|
|
|
from Object.AWS.S3Email import S3Email
|
|
|
from Ansjer.config import CONFIG_INFO, CONFIG_US
|
|
|
from Object.ResponseObject import ResponseObject
|
|
@@ -22,9 +25,11 @@ class RegionCountryView(View):
|
|
|
|
|
|
def validate(self, request_dict, operation):
|
|
|
response = ResponseObject()
|
|
|
+ if operation == 'sendSysMsg':
|
|
|
+ return self.send_sys_msg(request_dict, response)
|
|
|
token = TokenObject(request_dict.get('token', None))
|
|
|
- if token.code != 0:
|
|
|
- return response.json(token.code)
|
|
|
+ # if token.code != 0:
|
|
|
+ # return response.json(token.code)
|
|
|
|
|
|
if operation == 'initUserRegion':
|
|
|
return self.init_user_region(token.userID, request_dict, response)
|
|
@@ -50,7 +55,7 @@ class RegionCountryView(View):
|
|
|
return response.json(104)
|
|
|
|
|
|
region_country = int(region_country)
|
|
|
- # 云存用户切换为欧洲地区,发邮件提醒
|
|
|
+ # 云存用户切换为欧洲地区,发邮件提醒和系统消息
|
|
|
if CONFIG_INFO == CONFIG_US:
|
|
|
country_qs = CountryModel.objects.filter(id=region_country).values('region_id')
|
|
|
if country_qs.exists():
|
|
@@ -60,5 +65,22 @@ class RegionCountryView(View):
|
|
|
email_content = '云存用户切换为欧洲地区,请处理云存数据,user_id:{}'.format(user_id)
|
|
|
S3Email().faEmail(email_content, '1073329609@qq.com')
|
|
|
|
|
|
+ # 请求欧洲服发送系统消息
|
|
|
+ url = 'https://api.zositeche.com/regionCountry/sendSysMsg'
|
|
|
+ data = {'user_id': user_id}
|
|
|
+ requests.post(url=url, data=data, timeout=5)
|
|
|
+
|
|
|
device_user_qs.update(region_country=region_country, region_status=True)
|
|
|
return response.json(0)
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def send_sys_msg(request_dict, response):
|
|
|
+ user_id = request_dict.get('user_id', None)
|
|
|
+ if not user_id:
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ now_time = int(time.time())
|
|
|
+ msg = 'System upgrading. It may have influence on the cloud storage usage.' \
|
|
|
+ 'Please feel free to contact Zosi customer service if you have any questions anytime.'
|
|
|
+ SysMsgModel.objects.create(userID_id=user_id, msg=msg, addTime=now_time, updTime=now_time)
|
|
|
+ return response.json(0)
|