@@ -6,17 +6,19 @@ from django_response import response |
||
6 | 6 |
|
7 | 7 |
from kodo.decorators import check_admin |
8 | 8 |
from apps.lensman.activity.models import LensmanContributionActivityIncomeExpensesInfo |
9 |
+from account.models import LensmanInfo |
|
9 | 10 |
|
10 | 11 |
@logit(res=True) |
11 | 12 |
@check_admin |
12 | 13 |
def add_lensman_contribution_income_api(request, administrator): |
13 |
- contrbution_id = request.POST.get('contribution_id', '') |
|
14 |
- lensman_id = request.POST.get('lensman_id', '') |
|
14 |
+ contribution_id = request.POST.get('contribution_id', '') |
|
15 | 15 |
activity_id = request.POST.get('activity_id', '') |
16 | 16 |
user_id = request.POST.get('user_id', '') |
17 | 17 |
|
18 | 18 |
amount = int(request.POST.get('amount', '0')) |
19 | 19 |
|
20 |
- LensmanContributionActivityIncomeExpensesInfo.objects.update_or_create(contrbution_id=contrbution_id, lensman_id=lensman_id, activity_id=activity_id, user_id=user_id, defaults={'amount': amount}) |
|
20 |
+ lensman = LensmanInfo.objects.get(user_id=user_id) |
|
21 |
+ |
|
22 |
+ LensmanContributionActivityIncomeExpensesInfo.objects.update_or_create(contribution_id=contribution_id, lensman_id=lensman.lensman_id, activity_id=activity_id, user_id=user_id, defaults={'amount': amount}) |
|
21 | 23 |
|
22 | 24 |
return response(200, '增加摄影师投稿收入成功') |
@@ -27,23 +27,19 @@ def get_contribtion_contract_api(request): |
||
27 | 27 |
|
28 | 28 |
file_ids = upload_contribution_images(contribution_id) |
29 | 29 |
|
30 |
- operator = { |
|
31 |
- # "UserId": settings.CONTRACT_LENSMAN_CONTRIBUTION_OPERATOR_ID |
|
32 |
- } |
|
33 |
- |
|
34 |
- flow_id = create_contribution_contract_flow(lensman, operator) |
|
30 |
+ flow_id = create_contribution_contract_flow(lensman) |
|
35 | 31 |
contract.flow_id = flow_id |
36 | 32 |
contract.save() |
37 | 33 |
|
38 |
- document_id, fields = create_contribution_contract_document(lensman, file_ids, flow_id, operator) |
|
34 |
+ document_id, fields = create_contribution_contract_document(lensman, contribution_id, file_ids, flow_id) |
|
39 | 35 |
contract.contract_content_fields = fields |
40 | 36 |
contract.document_id = document_id |
41 | 37 |
contract.save() |
42 | 38 |
|
43 | 39 |
# 发起签署流程 |
44 |
- flow_status = start_contribution_contract_flow(flow_id, operator) |
|
40 |
+ flow_status = start_contribution_contract_flow(flow_id) |
|
45 | 41 |
|
46 |
- scheme_url = get_contribtion_contract_sign_mppath(operator, lensman, flow_id) |
|
42 |
+ scheme_url = get_contribtion_contract_sign_mppath(lensman, flow_id) |
|
47 | 43 |
|
48 | 44 |
return response(200, data={ |
49 | 45 |
'contract': contract.mpdata, |
@@ -66,17 +62,17 @@ def upload_contribution_images(contribution_id): |
||
66 | 62 |
file_type = 'png' |
67 | 63 |
# upload_files_result = upload_document_files(files, file_type=file_type) |
68 | 64 |
upload_files_result = test_upload_document_files(files, file_type=file_type) |
69 |
- file_ids = upload_files_result.get('FileIds', []) |
|
65 |
+ file_ids = upload_files_result.FileIds |
|
70 | 66 |
|
71 | 67 |
return file_ids |
72 | 68 |
|
73 | 69 |
|
74 |
-def create_contribution_contract_flow(lensman, Operator): |
|
70 |
+def create_contribution_contract_flow(lensman): |
|
75 | 71 |
# 创建签署流程 https://qian.tencent.com/developers/companyApis/startFlows/CreateFlow |
76 | 72 |
|
77 | 73 |
# 创建签署流程参数 Operator |
78 |
- FlowName = lensman.identity_card_name + "的投稿合同" + tc.local_string(format='%Y%m%d') |
|
79 |
- FlowType = '活动投稿授权书' |
|
74 |
+ FlowName = lensman.identity_card_name + u"的投稿合同" + tc.local_string(format='%Y%m%d') |
|
75 |
+ FlowType = u"活动投稿授权书" |
|
80 | 76 |
Approvers = [{ |
81 | 77 |
"ApproverType": 1, |
82 | 78 |
"Required": True, |
@@ -87,12 +83,12 @@ def create_contribution_contract_flow(lensman, Operator): |
||
87 | 83 |
"ApproverIdCardNumber": lensman.identity_card_number, |
88 | 84 |
}] |
89 | 85 |
create_flow_result = create_flow(flow_name=FlowName, flow_type=FlowType, approvers=Approvers) |
90 |
- flow_id = create_flow_result.get('FlowId') |
|
86 |
+ flow_id = create_flow_result.FlowId |
|
91 | 87 |
|
92 | 88 |
return flow_id |
93 | 89 |
|
94 | 90 |
|
95 |
-def create_contribution_contract_document(lensman, contribution_id, file_ids, FlowId, Operator): |
|
91 |
+def create_contribution_contract_document(lensman, contribution_id, file_ids, FlowId): |
|
96 | 92 |
# 创建电子签文档 https://qian.tencent.com/developers/companyApis/startFlows/CreateDocument |
97 | 93 |
|
98 | 94 |
income = LensmanContributionActivityIncomeExpensesInfo.objects.get(contribution_id=contribution_id, lensman_id=lensman.lensman_id) |
@@ -117,25 +113,25 @@ def create_contribution_contract_document(lensman, contribution_id, file_ids, Fl |
||
117 | 113 |
"ComponentValue": file_id, |
118 | 114 |
}) |
119 | 115 |
create_document_result = create_document(flow_id=FlowId, form_fields=FormFields) |
120 |
- document_id = create_document_result.get('DocumentId') |
|
116 |
+ document_id = create_document_result.DocumentId |
|
121 | 117 |
|
122 | 118 |
return document_id, FormFields |
123 | 119 |
|
124 | 120 |
|
125 |
-def start_contribution_contract_flow(FlowId, Operator): |
|
121 |
+def start_contribution_contract_flow(FlowId): |
|
126 | 122 |
# 发起签署流程 https://qian.tencent.com/developers/companyApis/startFlows/StartFlow |
127 | 123 |
|
128 | 124 |
start_flow_result = start_flow(flow_id=FlowId) |
129 |
- flow_status = start_flow_result.get('Status') |
|
125 |
+ flow_status = start_flow_result.Status |
|
130 | 126 |
|
131 | 127 |
return flow_status |
132 | 128 |
|
133 | 129 |
|
134 |
-def get_contribtion_contract_sign_mppath(Operator, lensman, FlowId): |
|
130 |
+def get_contribtion_contract_sign_mppath(lensman, FlowId): |
|
135 | 131 |
# 获取签署链接 https://qian.tencent.com/developers/companyApis/startFlows/CreateSchemeUrl |
136 | 132 |
|
137 | 133 |
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) |
138 |
- scheme_url = create_scheme_url_result.get('SchemeUrl') |
|
134 |
+ scheme_url = create_scheme_url_result.SchemeUrl |
|
139 | 135 |
|
140 | 136 |
return scheme_url |
141 | 137 |
|