Pārlūkot izejas kodu

注册新增 - 定制化推送订阅

linhaohong 1 gadu atpakaļ
vecāks
revīzija
e4e571d3e4
1 mainītis faili ar 17 papildinājumiem un 7 dzēšanām
  1. 17 7
      Controller/UserController.py

+ 17 - 7
Controller/UserController.py

@@ -32,7 +32,8 @@ from Controller.CheckUserData import DataValid, date_handler, RandomStr
 from Controller.UserDevice.UserSubscriptionController import UserSubscriptionControllerView
 from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
     UserAppFrequencyModel, CountryIPModel, CountryModel, UidChannelSetModel, Order_Model, UID_Bucket, Unused_Uid_Meal, \
-    GatewayPush, CountryLanguageModel, LanguageModel, IcloudUseDetails, IcloudStorageRecord, VodBucketModel, LogModel
+    GatewayPush, CountryLanguageModel, LanguageModel, IcloudUseDetails, IcloudStorageRecord, VodBucketModel, LogModel, \
+    UserEmailSubscriptions
 from Object.AWS.AmazonS3Util import AmazonS3Util
 from Object.AWS.SesClassObject import SesClassObject
 from Object.AliSmsObject import AliSmsObject
@@ -1281,6 +1282,7 @@ class v3registerView(TemplateView):
         salt = request_dict.get('salt', None)
         region_status = request_dict.get('region_status', None)
         email_scription = request_dict.get('email_scription', None)
+        push_scription = request_dict.get('push_scription', None)
 
         if unique:
             delete_local_account(unique)
@@ -1331,14 +1333,15 @@ class v3registerView(TemplateView):
 
             if phone is not None:
                 return self.do_phone_register(phone, password, authcode, number, region_status, response,
-                                              password_version, salt)
+                                              password_version, salt, push_scription)
             elif email is not None:
                 return self.do_email_register(email, password, authcode, number, region_status, response,
-                                              password_version, salt, email_scription)
+                                              password_version, salt, email_scription, push_scription)
             else:
                 return response.json(444, 'phone or email')
 
-    def do_phone_register(self, phone, password, authcode, number, region_status, response, password_version, salt):
+    def do_phone_register(self, phone, password, authcode, number, region_status, response, password_version, salt,
+                          push_scription):
         data_valid = DataValid()
         if data_valid.mobile_validate(phone) is not True:
             return response.json(100)
@@ -1365,12 +1368,13 @@ class v3registerView(TemplateView):
         if phone_qs.exists():
             return response.json(101)
         try:
+            userID = CommonService.getUserID(μs=False, setOTAID=True)
             create_data = {
                 "username": phone,
                 "NickName": phone,
                 "phone": phone,
                 "password": password,
-                "userID": CommonService.getUserID(μs=False, setOTAID=True),
+                "userID": userID,
                 "is_active": True,
                 "user_isValid": True,
                 "region_status": region_status
@@ -1378,6 +1382,8 @@ class v3registerView(TemplateView):
             if number:
                 create_data["region_country"] = number
             Device_User.objects.create(**create_data)
+            if push_scription:
+                UserEmailSubscriptions.objects.create(phone=phone, user_id=userID, push_sub_status=1)
 
         except Exception as e:
             errorInfo = traceback.format_exc()
@@ -1416,7 +1422,8 @@ class v3registerView(TemplateView):
         res['phone'] = user_list[0]["phone"] if user_list[0]["phone"] is not None else ''
         return response.json(0, res)
 
-    def do_email_register(self, email, password, authcode, number, region_status, response, password_version, salt, email_scription):
+    def do_email_register(self, email, password, authcode, number, region_status, response, password_version, salt,
+                          email_scription, push_scription):
         data_valid = DataValid()
         if data_valid.email_validate(email) is not True:
             return response.json(105)
@@ -1444,12 +1451,13 @@ class v3registerView(TemplateView):
         if email_qs.exists():
             return response.json(103)
         try:
+            userID = CommonService.getUserID(μs=False, setOTAID=True)
             create_data = {
                 "username": email,
                 "NickName": email,
                 "userEmail": email,
                 "password": password,
-                "userID": CommonService.getUserID(μs=False, setOTAID=True),
+                "userID": userID,
                 "is_active": True,
                 "user_isValid": True,
                 "region_status": region_status
@@ -1457,6 +1465,8 @@ class v3registerView(TemplateView):
             if number:
                 create_data["region_country"] = number
             Device_User.objects.create(**create_data)
+            if push_scription:
+                UserEmailSubscriptions.objects.create(user_id=userID, email=email, push_sub_status=1)
             if email_scription:
                 subscribers = {
                     "userEmail": email,