瀏覽代碼

修改shopify注册添加国家

linhaohong 8 月之前
父節點
當前提交
d5bead75da
共有 1 個文件被更改,包括 17 次插入3 次删除
  1. 17 3
      Controller/ShopifyController.py

+ 17 - 3
Controller/ShopifyController.py

@@ -228,10 +228,11 @@ class ShopifyView(View):
     @staticmethod
     def shopify_register(request_dict, response):
         email = request_dict.get("email", None)
+        country_code = request_dict.get("countryCode", None)
         password = request_dict.get("password", None)
         authcode = request_dict.get("authCode", None)
 
-        if not all([email, password, authcode]):
+        if not all([email, password, authcode, country_code]):
             return response.json(444)
         data_valid = DataValid()
         if data_valid.email_validate(email) is not True:
@@ -263,6 +264,12 @@ class ShopifyView(View):
         # 创建用户
         password = make_password(password)
         new_userID = CommonService.getUserID(μs=False, setOTAID=True)
+        country_code = country_code.upper()
+        countr_qs = CountryModel.objects.filter(country_code=country_code).values("id")
+        if countr_qs.exists():
+            region_country = countr_qs[0]['id']
+        else:
+            return response.json(173)
         user_data = {
             "username": email,
             "NickName": email,
@@ -271,6 +278,8 @@ class ShopifyView(View):
             "userID": new_userID,
             "is_active": True,
             "user_isValid": True,
+            "region_country": region_country,
+            "region_status": 1
         }
         Device_User.objects.create(**user_data)
         reds.del_data(key=email + '_identifyingCode')
@@ -381,8 +390,13 @@ class ShopifyView(View):
 
         user_region_id = user_qs.values_list('region_country', flat=True).first()
         country_code = CountryModel.objects.filter(id=user_region_id).values_list("country_code", flat=True).first()
-
-        return response.json(0, country_code)
+        if country_code:
+            return response.json(0, country_code)
+        elif CONFIG_INFO == CONFIG_EUR:
+            return response.json(0, "uk")
+        elif CONFIG_INFO == CONFIG_US:
+            return response.json(0, "us")
+        return response.json(173)
 
     @staticmethod
     def get_country_domain_list(request_dict, response):