Browse Source

Merge branch 'dev' into lang

lang 4 years ago
parent
commit
1626d62ccc

+ 4 - 6
Controller/CloudStorage.py

@@ -1523,10 +1523,9 @@ class CloudStorageView(View):
             for oo in oqlist:
                 if ub['id'] == oo['uid_bucket_id']:
                     if ub['bucket__area'] == 'cn':
-                        sys_msg_text = "温馨提示:尊重的客户,您" + ub['uid'] + "设备的云存套餐将在" + time.strftime("%Y-%m-%d",
-                                                                                           ub['endTime']) + "到期"
+                        sys_msg_text = "温馨提示:尊重的客户,您" + ub['uid'] + "设备的云存套餐将在" + time.strftime("%Y-%m-%d", time.localtime(ub['endTime'])) + "到期"
                     else:
-                        sys_msg_text = "Warm tips: Dear customers, the cloud storage package of your " + ub['uid'] + " device will expire at " + time.strftime("%Y-%m-%d",ub['endTime'])
+                        sys_msg_text = "Warm tips: Dear customers, the cloud storage package of your " + ub['uid'] + " device will expire at " + time.strftime("%Y-%m-%d", time.localtime(ub['endTime']))
                     uq_list.append(SysMsgModel(
                         userID_id=oo['userID_id'],
                         addTime=now_time,
@@ -1536,6 +1535,7 @@ class CloudStorageView(View):
                         msg=sys_msg_text,
                         status=0
                     ))
+                    SysMsgModel.objects.bulk_create(uq_list)
                     user_qs = Device_User.objects.filter(userID=oo['userID_id'])
                     if user_qs.exists():
                         user = user_qs[0]
@@ -1546,13 +1546,11 @@ class CloudStorageView(View):
                             S3Email().faEmail(sys_msg_text, username)
                         elif data_valid.mobile_validate(username):
                             params = u'{"devname":"' + ub['uid'] + '","submittime":"' + time.strftime("%Y-%m-%d",
-                                                                                                      ub[
-                                                                                                          'endTime']) + '"}'
+                                                                                                      time.localtime(ub['endTime'])) + '"}'
                             self.sendMessage(username, params, 'SMS_217427260')
 
                         self.pushApp(now_time, ub['uid'], ub['channel'], sys_msg_text)
 
-        SysMsgModel.objects.bulk_create(uq_list)
 
 
     def pushApp(self, nowTime, uid, channel, sys_msg_text):

+ 6 - 4
Controller/DeviceConfirmRegion.py

@@ -78,10 +78,12 @@ class Device_Region(object):
     def get_device_region(self, ip):
 
         ipInfo = CommonService.getIpIpInfo(ip, "CN")
-        if ipInfo['country_code']:
-            device_request_url = CountryModel.objects.filter(country_code=ipInfo['country_code']).values("region__api","region__id")
-            if device_request_url.exists():
-                return device_request_url[0]['region__id']
+
+        #暂时测试国外
+        # if ipInfo['country_code']:
+        #     device_request_url = CountryModel.objects.filter(country_code=ipInfo['country_code']).values("region__api","region__id")
+        #     if device_request_url.exists():
+        #         return device_request_url[0]['region__id']
         # 不存在默认返回美洲地区api
         api = RegionModel.objects.filter(continent_code='NA').values("id")
         return api[0]['id']

+ 4 - 1
Controller/IotCoreController.py

@@ -38,7 +38,8 @@ class IotCoreView(View):
 
     def validate(self, operation, request_dict, request):
         response = ResponseObject()
-
+        lang = request_dict.get('lang', 'en')
+        response.lang = lang
         if operation == 'createKeysAndCertificate':
             return self.create_keys_and_certificate(request_dict, response, request)
         elif operation == 'requestPublishMessage':
@@ -49,6 +50,8 @@ class IotCoreView(View):
             token = TokenObject(request_dict.get('token', None))
             if token.code != 0:
                 return response.json(token.code)
+            response.lang = token.lang
+
             if operation == 'clearIotCerm':
                 return self.clear_Iot_Cerm(request_dict, response)
             else:

+ 11 - 17
Controller/SerialNumberController.py

@@ -188,16 +188,16 @@ class SerialNumberView(View):
 
         if serial_number and len(serial_number) == 9  and company_id:
 
-            token = int(CommonService.decode_data(token))
-            time_stamp = int(time_stamp)
-
-            now_time = int(time.time())
-            distance = now_time - time_stamp
-
-            if token != time_stamp or distance > 60000 or distance < -60000: #为了全球化时间控制在一天内
-                return response.json(404)
-
-            mark = serial_number[6:9]
+            # token = int(CommonService.decode_data(token))
+            # time_stamp = int(time_stamp)
+            #
+            # now_time = int(time.time())
+            # distance = now_time - time_stamp
+            #
+            # if token != time_stamp or distance > 60000 or distance < -60000: #为了全球化时间控制在一天内
+            #     return response.json(404)
+            #
+            # mark = serial_number[6:9]
             serial = serial_number[0:6]
 
             savePoint = transaction.savepoint()
@@ -220,18 +220,12 @@ class SerialNumberView(View):
                         # 该序列号未绑定企业
                         return response.json(173)
                     elif company_serial.status == 1:
-                        # 确定所在区域
-                        country_qs = CountryModel.objects.filter(number=country_id)
-                        if not country_qs.exists():
-                            return response.json(374)
-
-                        region = country_qs.values('region_id')[0]
 
                         count = 0
                         while count < 3:
                             p2p = SerialNumberModel.objects.filter(serial_number=serial).values('p2p')
                             print('此序列号的p2p类型:', p2p[0]['p2p'])
-                            uid_qs = UIDModel.objects.filter(vpg__company_id=company_serial.company.id, vpg__region_id=region['region_id'],
+                            uid_qs = UIDModel.objects.filter(vpg__company_id=company_serial.company.id, vpg__region_id=country_id,
                                                              status=0, p2p_type=p2p[0]['p2p']).order_by('id')[0:10]
                             # uid_qs:未进行绑定的uid列表
                             if uid_qs.exists():

+ 4 - 1
Controller/VPGController.py

@@ -217,6 +217,9 @@ def do_upload_uid(request):
     if (not MAC['is_active']) or (current_mac[-8:] == 'FF.FF.FF'):
         return response.json(175)
 
+    area = 0
+    if vpg_id != 1:
+        area = 1
     # path = '/'.join((BASE_DIR, 'static/uid')).replace('\\', '/') + '/'
     # if not os.path.exists(path):
     #     os.makedirs(path)
@@ -237,7 +240,7 @@ def do_upload_uid(request):
                     status=0,
                     add_time=add_time,
                     update_time=update_time,
-                    area=0,  # 关联vgp表已有区域信息,可以考虑去掉
+                    area=area,  # 关联vgp表已有区域信息,可以考虑去掉
                     vpg_id=vpg_id,
                 )
                 if len(uid) == 14:  # 宸云

+ 2 - 1
Controller/VerifyCodeController.py

@@ -25,7 +25,8 @@ class VerifyCodeView(View):
     def validate(self, request_dict, operation):
 
         response = ResponseObject()
-
+        lang = request_dict.get('lang', 'en')
+        response.lang = lang
         if operation == 'forget':
             return self.verify_forget(request_dict, response)
         elif operation == 'register':