MOD:发票信息查询
Showing
2 changed files
with
59 additions
and
0 deletions
| ... | @@ -5,5 +5,6 @@ from . import views | ... | @@ -5,5 +5,6 @@ from . import views |
| 5 | urlpatterns = [ | 5 | urlpatterns = [ |
| 6 | path(r'', views.DocView.as_view()), | 6 | path(r'', views.DocView.as_view()), |
| 7 | path(r'invoice/downloadExcel', views.InvoiceExcelView.as_view()), | 7 | path(r'invoice/downloadExcel', views.InvoiceExcelView.as_view()), |
| 8 | path(r'invoice/queryInfo', views.InvoiceQueryInfoView.as_view()), | ||
| 8 | path(r'contract/v1', views.SEContractView.as_view()), | 9 | path(r'contract/v1', views.SEContractView.as_view()), |
| 9 | ] | 10 | ] | ... | ... |
| ... | @@ -55,6 +55,7 @@ from .models import ( | ... | @@ -55,6 +55,7 @@ from .models import ( |
| 55 | HILCmsStatusInfo, | 55 | HILCmsStatusInfo, |
| 56 | AFCCmsStatusInfo | 56 | AFCCmsStatusInfo |
| 57 | ) | 57 | ) |
| 58 | from common.exceptions import (NoPermissionException) | ||
| 58 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam | 59 | from .named_enum import ErrorType, AutoResult, WholeResult, RPAResult, SystemName, RequestTeam |
| 59 | from .mixins import DocHandler, MPOSHandler, PreSEHandler | 60 | from .mixins import DocHandler, MPOSHandler, PreSEHandler |
| 60 | from . import consts | 61 | from . import consts |
| ... | @@ -1242,6 +1243,14 @@ class CompareResultView(GenericView): | ... | @@ -1242,6 +1243,14 @@ class CompareResultView(GenericView): |
| 1242 | scheme = args.get('scheme') | 1243 | scheme = args.get('scheme') |
| 1243 | case_id = args.get('case_id') | 1244 | case_id = args.get('case_id') |
| 1244 | is_auto = args.get('auto') | 1245 | is_auto = args.get('auto') |
| 1246 | |||
| 1247 | # 角色权限不符,返回异常 | ||
| 1248 | token = request.META.get("HTTP_AUTHORIZATION") | ||
| 1249 | user_role = rh.get_token(token[-11:]) | ||
| 1250 | self.running_log.info('[api doc] [user_role={0}] '.format(user_role)) | ||
| 1251 | if user_role == -1 or (user_role == 1 and entity == 'HIL') or (user_role == 2 and entity == 'AFC'): | ||
| 1252 | raise NoPermissionException('no permission') | ||
| 1253 | |||
| 1245 | if is_auto == 1: | 1254 | if is_auto == 1: |
| 1246 | result_table = HILAutoSettlement if entity == consts.HIL_PREFIX else AFCAutoSettlement | 1255 | result_table = HILAutoSettlement if entity == consts.HIL_PREFIX else AFCAutoSettlement |
| 1247 | 1256 | ||
| ... | @@ -1728,6 +1737,13 @@ class AutoSettlementExcelView(GenericView): | ... | @@ -1728,6 +1737,13 @@ class AutoSettlementExcelView(GenericView): |
| 1728 | 1737 | ||
| 1729 | is_fsm = args.get('is_fsm') | 1738 | is_fsm = args.get('is_fsm') |
| 1730 | 1739 | ||
| 1740 | # 角色权限不符,返回异常 | ||
| 1741 | token = request.META.get("HTTP_AUTHORIZATION") | ||
| 1742 | user_role = rh.get_token(token[-11:]) | ||
| 1743 | self.running_log.info('[api doc] [user_role={0}] '.format(user_role)) | ||
| 1744 | if user_role == -1 or (user_role == 1 and business_type == 'HIL') or (user_role == 2 and business_type == 'AFC'): | ||
| 1745 | raise NoPermissionException('no permission') | ||
| 1746 | |||
| 1731 | if isinstance(auto_result, int): | 1747 | if isinstance(auto_result, int): |
| 1732 | auto_result = consts.RESULT_MAP.get(auto_result) | 1748 | auto_result = consts.RESULT_MAP.get(auto_result) |
| 1733 | if isinstance(whole_result, int): | 1749 | if isinstance(whole_result, int): |
| ... | @@ -1886,6 +1902,13 @@ class InvoiceExcelView(GenericView): | ... | @@ -1886,6 +1902,13 @@ class InvoiceExcelView(GenericView): |
| 1886 | application_ids = args.get('application_ids') | 1902 | application_ids = args.get('application_ids') |
| 1887 | application_entity = args.get('application_entity') | 1903 | application_entity = args.get('application_entity') |
| 1888 | 1904 | ||
| 1905 | # 角色权限不符,返回异常 | ||
| 1906 | token = request.META.get("HTTP_AUTHORIZATION") | ||
| 1907 | user_role = rh.get_token(token[-11:]) | ||
| 1908 | self.running_log.info('[InvoiceExcelView] [user_role={0}] '.format(user_role)) | ||
| 1909 | if user_role == -1 or (user_role == 1 and application_entity == 'HIL') or (user_role == 2 and application_entity == 'AFC'): | ||
| 1910 | raise NoPermissionException('no permission') | ||
| 1911 | |||
| 1889 | url = 'http://127.0.0.1:8088/napi/invoice/downloadExcelOri' | 1912 | url = 'http://127.0.0.1:8088/napi/invoice/downloadExcelOri' |
| 1890 | body = { | 1913 | body = { |
| 1891 | 'applicationIds': application_ids, | 1914 | 'applicationIds': application_ids, |
| ... | @@ -1913,3 +1936,38 @@ class InvoiceExcelView(GenericView): | ... | @@ -1913,3 +1936,38 @@ class InvoiceExcelView(GenericView): |
| 1913 | except Exception as e: | 1936 | except Exception as e: |
| 1914 | self.running_log.error("invoice excel request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | 1937 | self.running_log.error("invoice excel request to java error, url:{0}, param:{1}, errorMsg:{2}".format( |
| 1915 | url, json.dumps(body), traceback.format_exc())) | 1938 | url, json.dumps(body), traceback.format_exc())) |
| 1939 | |||
| 1940 | class InvoiceQueryInfoView(GenericView): | ||
| 1941 | permission_classes = [IsAuthenticated] | ||
| 1942 | authentication_classes = [OAuth2AuthenticationWithUser] | ||
| 1943 | |||
| 1944 | @use_args(invoice_download_args, location='data') | ||
| 1945 | def post(self, request, args): | ||
| 1946 | application_ids = args.get('application_ids') | ||
| 1947 | application_entity = args.get('application_entity') | ||
| 1948 | |||
| 1949 | # 角色权限不符,返回异常 | ||
| 1950 | token = request.META.get("HTTP_AUTHORIZATION") | ||
| 1951 | user_role = rh.get_token(token[-11:]) | ||
| 1952 | self.running_log.info('[InvoiceQueryInfoView] [user_role={0}] '.format(user_role)) | ||
| 1953 | if user_role == -1 or (user_role == 1 and application_entity == 'HIL') or (user_role == 2 and application_entity == 'AFC'): | ||
| 1954 | raise NoPermissionException('no permission') | ||
| 1955 | |||
| 1956 | url = 'http://127.0.0.1:8088/napi/invoice/queryInfoOri' | ||
| 1957 | body = { | ||
| 1958 | 'applicationIds': application_ids, | ||
| 1959 | 'applicationEntity': application_entity | ||
| 1960 | } | ||
| 1961 | try: | ||
| 1962 | self.running_log.info("request java invoice info api, url:{0}, body:{1}".format(url, json.dumps(body))) | ||
| 1963 | headers = { | ||
| 1964 | 'Content-Type': 'application/json' | ||
| 1965 | } | ||
| 1966 | resp = requests.post(url, headers=headers, json=body) | ||
| 1967 | self.running_log.info("java invoice info api finish, applicationIds:{0},{1}".format(application_ids, resp.text)) | ||
| 1968 | res_json = json.loads(resp.text) | ||
| 1969 | java_result = res_json.get('result') | ||
| 1970 | return response.ok(data=java_result) | ||
| 1971 | except Exception as e: | ||
| 1972 | self.running_log.error("invoice info request to java error, url:{0}, param:{1}, errorMsg:{2}".format( | ||
| 1973 | url, json.dumps(body), traceback.format_exc())) | ... | ... |
-
Please register or sign in to post a comment