| 
					
				 | 
			
			
				@@ -0,0 +1,70 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# -*- encoding: utf-8 -*- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@File    : WXTechController.py 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Time    : 2023/5/6 16:40 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Author  : stephen 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Email   : zhangdongming@asj6.wecom.work 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Software: PyCharm 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+""" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from django.http import QueryDict 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from django.views import View 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from Ansjer.config import LOGGER 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from Object.ResponseObject import ResponseObject 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from Object.TokenObject import TokenObject 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+from Object.WXTechObject import WXTechObject 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class WXTechController(View): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    class SmartSocketView(View): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        def get(self, request, *args, **kwargs): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            request.encoding = 'utf-8' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operation = kwargs.get('operation') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return self.validation(request.GET, request, operation) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        def post(self, request, *args, **kwargs): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            request.encoding = 'utf-8' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operation = kwargs.get('operation') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return self.validation(request.POST, request, operation) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        def delete(self, request, *args, **kwargs): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            request.encoding = 'utf-8' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operation = kwargs.get('operation') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            delete = QueryDict(request.body) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if not delete: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                delete = request.GET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return self.validation(delete, request, operation) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        def put(self, request, *args, **kwargs): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            request.encoding = 'utf-8' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            operation = kwargs.get('operation') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            put = QueryDict(request.body) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return self.validation(put, request, operation) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        def validation(self, request_dict, request, operation): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            token = TokenObject(request.META.get('HTTP_AUTHORIZATION')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            lang = request_dict.get('lang', token.lang) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response = ResponseObject(lang) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if token.code != 0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return response.json(token.code) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if operation == 'getCardsInfo': 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return self.get_cards_info(request_dict, response) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @classmethod 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        def get_cards_info(cls, request_dict, response): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            五兴单卡获取信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            """ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                iccid = request_dict.get('iccid', None) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                operator = int(request_dict.get('operator', 3)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                LOGGER.info('*****WXTechController.get_cards_info:iccid:{},operator:{}'.format(iccid, operator)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if not iccid: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return response.json(444) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                data = {'iccid': iccid, 'operator': operator} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                wx_tech = WXTechObject() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return response.json(0, wx_tech.get_cards_info(**data)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            except Exception as e: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                LOGGER.info('*****WXTechController.get_cards_info:errLine:{}, errMsg:{}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .format(e.__traceback__.tb_lineno, repr(e))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return response.json(500, repr(e)) 
			 |