| @@ -6,6 +6,7 @@ from django_response import response | ||
| 6 | 6 |  | 
| 7 | 7 | from apps.contract.models import LensmanContributionContractInfo | 
| 8 | 8 | from kodo.decorators import check_admin | 
| 9 | +from utils.error.errno_utils import TencentCloudStatusCode | |
| 9 | 10 | from utils.tencentcloud.ess import describe_file_urls | 
| 10 | 11 |  | 
| 11 | 12 |  | 
| @@ -18,6 +19,9 @@ def get_signed_contribtion_contract_file_api(request, administrator): | ||
| 18 | 19 | contract = LensmanContributionContractInfo.objects.filter(contribution_id=contribution_id, user_id=user_id).first() | 
| 19 | 20 |  | 
| 20 | 21 | describe_file_urls_result = describe_file_urls(business_id=contract.flow_id) | 
| 22 | + if not describe_file_urls_result: | |
| 23 | + return response(TencentCloudStatusCode.TENCENT_CLOUD_SDK_EXCEPTION) | |
| 24 | + | |
| 21 | 25 | FileUrls = describe_file_urls_result.FileUrls | 
| 22 | 26 |  | 
| 23 | 27 |      return response(200, data={ | 
| @@ -93,7 +93,6 @@ def upload_contribution_images(contribution_id): | ||
| 93 | 93 |  | 
| 94 | 94 | contribtuon = MemberActivityContributionInfo.objects.get(contribution_id=contribution_id) | 
| 95 | 95 |  | 
| 96 | - # TODO: 从 MemberActivityContributionInfo 生成 files 对象 | |
| 97 | 96 | file_urls = [image['image_url'] for image in contribtuon.images] | 
| 98 | 97 |      file_names = [file_url.split('/')[-1] for file_url in file_urls] | 
| 99 | 98 |      file_type = file_names[0].split('.')[-1] | 
| @@ -110,6 +109,8 @@ def upload_contribution_images(contribution_id): | ||
| 110 | 109 | # file_type = 'png' | 
| 111 | 110 | upload_files_result = upload_document_files(files, file_type=file_type) | 
| 112 | 111 | # upload_files_result = test_upload_document_files(files, file_type=file_type) | 
| 112 | + if not upload_files_result: | |
| 113 | + return [] | |
| 113 | 114 |  | 
| 114 | 115 | return upload_files_result.FileIds | 
| 115 | 116 |  | 
| @@ -130,6 +131,8 @@ def create_contribution_contract_flow(lensman): | ||
| 130 | 131 | "ApproverIdCardNumber": lensman.identity_card_number, | 
| 131 | 132 | }] | 
| 132 | 133 | create_flow_result = create_flow(flow_name=FlowName, flow_type=FlowType, approvers=Approvers) | 
| 134 | + if not create_flow_result: | |
| 135 | + return '' | |
| 133 | 136 |  | 
| 134 | 137 | return create_flow_result.FlowId | 
| 135 | 138 |  | 
| @@ -153,21 +156,24 @@ def create_contribution_contract_document(lensman, contribution_id, file_ids, Fl | ||
| 153 | 156 | "ComponentValue": "零", | 
| 154 | 157 | }] | 
| 155 | 158 |  | 
| 156 | - for i, file_id in enumerate(file_ids): | |
| 159 | + for idx, file_id in enumerate(file_ids): | |
| 157 | 160 |          FormFields.append({ | 
| 158 | - "ComponentId": "ComponentId_" + str(37 + i), | |
| 161 | + "ComponentId": "ComponentId_" + str(37 + idx), | |
| 159 | 162 | "ComponentValue": file_id, | 
| 160 | 163 | }) | 
| 161 | 164 | create_document_result = create_document(flow_id=FlowId, form_fields=FormFields) | 
| 162 | - document_id = create_document_result.DocumentId | |
| 165 | + if not create_document_result: | |
| 166 | + return '', FormFields | |
| 163 | 167 |  | 
| 164 | - return document_id, FormFields | |
| 168 | + return create_document_result.DocumentId, FormFields | |
| 165 | 169 |  | 
| 166 | 170 |  | 
| 167 | 171 | def start_contribution_contract_flow(FlowId): | 
| 168 | 172 | # 发起签署流程 https://qian.tencent.com/developers/companyApis/startFlows/StartFlow | 
| 169 | 173 |  | 
| 170 | 174 | start_flow_result = start_flow(flow_id=FlowId) | 
| 175 | + if not start_flow_result: | |
| 176 | + return '' | |
| 171 | 177 |  | 
| 172 | 178 | return start_flow_result.Status | 
| 173 | 179 |  | 
| @@ -176,6 +182,8 @@ def get_contribtion_contract_sign_mppath(lensman, FlowId): | ||
| 176 | 182 | # 获取签署链接 https://qian.tencent.com/developers/companyApis/startFlows/CreateSchemeUrl | 
| 177 | 183 |  | 
| 178 | 184 | create_scheme_url_result = create_scheme_url(flow_id=FlowId, name=lensman.identity_card_name, mobile=lensman.phone, card_type='ID_CARD', card_number=lensman.identity_card_number) | 
| 185 | + if not create_scheme_url_result: | |
| 186 | + return '' | |
| 179 | 187 |  | 
| 180 | 188 | return create_scheme_url_result.SchemeUrl | 
| 181 | 189 |  | 
| @@ -224,3 +224,8 @@ class TenancyStatusCode(BaseStatusCode): | ||
| 224 | 224 | TENANCY_SHOT_ALREADY_EXIST = StatusCodeField(509002, 'Tenancy Shot Already Exist', description=u'租赁镜头已存在') | 
| 225 | 225 |  | 
| 226 | 226 | TENANCY_SHOT_REQUEST_NOT_FOUND = StatusCodeField(509011, 'Tenancy Shot Request Not Found', description=u'租赁镜头申请不存在') | 
| 227 | + | |
| 228 | + | |
| 229 | +class TencentCloudStatusCode(BaseStatusCode): | |
| 230 | + """ 腾讯云SDK错误码 5099xx """ | |
| 231 | + TENCENT_CLOUD_SDK_EXCEPTION = StatusCodeField(509901, 'Tencent Cloud SDK Exception', description=u'腾讯云SDK报错') |