@@ -13,7 +13,24 @@ from utils.tencentcloud.ess import (create_document, create_flow, create_scheme_ |
||
13 | 13 |
test_upload_document_files, upload_document_files) |
14 | 14 |
|
15 | 15 |
|
16 |
-# @logit(res=True) |
|
16 |
+@logit(res=True) |
|
17 |
+def get_contribtion_contract_status_api(request): |
|
18 |
+ user_id = request.POST.get('user_id', '') |
|
19 |
+ lensman_id = request.POST.get('lensman_id', '') |
|
20 |
+ activity_id = request.POST.get('activity_id', '') |
|
21 |
+ contribtuon_id = request.POST.get('contribtuon_id', '') |
|
22 |
+ |
|
23 |
+ try: |
|
24 |
+ contract = LensmanContributionContractInfo.objects.get(user_id=user_id, activity_id=activity_id, contribtuon_id=contribtuon_id) |
|
25 |
+ except LensmanContributionContractInfo.DoesNotExist: |
|
26 |
+ return response(404, 'Contract Not Found', '合同不存在') |
|
27 |
+ |
|
28 |
+ return response(200, data={ |
|
29 |
+ 'contract_status': contract.contract_status, |
|
30 |
+ }) |
|
31 |
+ |
|
32 |
+ |
|
33 |
+@logit(res=True) |
|
17 | 34 |
def get_contribtion_contract_api(request): |
18 | 35 |
user_id = request.POST.get('user_id', '') |
19 | 36 |
lensman_id = request.POST.get('lensman_id', '') |
@@ -42,7 +59,6 @@ def get_contribtion_contract_api(request): |
||
42 | 59 |
scheme_url = get_contribtion_contract_sign_mppath(lensman, flow_id) |
43 | 60 |
|
44 | 61 |
return response(200, data={ |
45 |
- 'contract': contract.mpdata, |
|
46 | 62 |
'scheme_url': scheme_url |
47 | 63 |
}) |
48 | 64 |
|
@@ -62,9 +78,8 @@ def upload_contribution_images(contribution_id): |
||
62 | 78 |
file_type = 'png' |
63 | 79 |
# upload_files_result = upload_document_files(files, file_type=file_type) |
64 | 80 |
upload_files_result = test_upload_document_files(files, file_type=file_type) |
65 |
- file_ids = upload_files_result.FileIds |
|
66 | 81 |
|
67 |
- return file_ids |
|
82 |
+ return upload_files_result.FileIds |
|
68 | 83 |
|
69 | 84 |
|
70 | 85 |
def create_contribution_contract_flow(lensman): |
@@ -83,9 +98,8 @@ def create_contribution_contract_flow(lensman): |
||
83 | 98 |
"ApproverIdCardNumber": lensman.identity_card_number, |
84 | 99 |
}] |
85 | 100 |
create_flow_result = create_flow(flow_name=FlowName, flow_type=FlowType, approvers=Approvers) |
86 |
- flow_id = create_flow_result.FlowId |
|
87 | 101 |
|
88 |
- return flow_id |
|
102 |
+ return create_flow_result.FlowId |
|
89 | 103 |
|
90 | 104 |
|
91 | 105 |
def create_contribution_contract_document(lensman, contribution_id, file_ids, FlowId): |
@@ -122,18 +136,16 @@ def start_contribution_contract_flow(FlowId): |
||
122 | 136 |
# 发起签署流程 https://qian.tencent.com/developers/companyApis/startFlows/StartFlow |
123 | 137 |
|
124 | 138 |
start_flow_result = start_flow(flow_id=FlowId) |
125 |
- flow_status = start_flow_result.Status |
|
126 | 139 |
|
127 |
- return flow_status |
|
140 |
+ return start_flow_result.Status |
|
128 | 141 |
|
129 | 142 |
|
130 | 143 |
def get_contribtion_contract_sign_mppath(lensman, FlowId): |
131 | 144 |
# 获取签署链接 https://qian.tencent.com/developers/companyApis/startFlows/CreateSchemeUrl |
132 | 145 |
|
133 | 146 |
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) |
134 |
- scheme_url = create_scheme_url_result.SchemeUrl |
|
135 | 147 |
|
136 |
- return scheme_url |
|
148 |
+ return create_scheme_url_result.SchemeUrl |
|
137 | 149 |
|
138 | 150 |
|
139 | 151 |
@logit(res=True) |
@@ -5,6 +5,8 @@ from api.lensman import contract_admin_views, contract_mp_views, activity_admin_ |
||
5 | 5 |
|
6 | 6 |
urlpatterns = [ |
7 | 7 |
url(r'^mp/lensman/contribution/contract/get$', contract_mp_views.get_contribtion_contract_api, name='get_contribtion_contract_api'), |
8 |
+ url(r'^mp/lensman/contribution/contract/status/get$', contract_mp_views.get_contribtion_contract_status_api, name='get_contribtion_contract_status_api'), |
|
9 |
+ |
|
8 | 10 |
url(r'^mp/ess/callback$', contract_mp_views.ess_callback, name='ess_callback'), |
9 | 11 |
] |
10 | 12 |
|
@@ -0,0 +1,43 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+# Generated by Django 3.2.8 on 2024-08-14 10:21 |
|
4 |
+ |
|
5 |
+from django.db import migrations, models |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class Migration(migrations.Migration): |
|
9 |
+ |
|
10 |
+ dependencies = [ |
|
11 |
+ ('contract', '0001_initial'), |
|
12 |
+ ] |
|
13 |
+ |
|
14 |
+ operations = [ |
|
15 |
+ migrations.RemoveField( |
|
16 |
+ model_name='lensmancontributioncontractinfo', |
|
17 |
+ name='approve_status', |
|
18 |
+ ), |
|
19 |
+ migrations.RemoveField( |
|
20 |
+ model_name='lensmancontributioncontractinfo', |
|
21 |
+ name='contract_status', |
|
22 |
+ ), |
|
23 |
+ migrations.AddField( |
|
24 |
+ model_name='lensmancontributioncontractinfo', |
|
25 |
+ name='tencent_approve_status', |
|
26 |
+ field=models.IntegerField(choices=[(2, '待签署'), (7, '待签署'), (3, '已签署'), (4, '拒绝'), (5, '过期没人处理'), (6, '流程已撤回'), (8, '合同待填写'), (9, '流程已终止'), (10, '填写完成'), (15, '解除协议(已解除)'), (15, '已转他人处理')], db_index=True, default=-1, help_text='腾讯电子签签署人签署状态', verbose_name='tencent_approve_status'), |
|
27 |
+ ), |
|
28 |
+ migrations.AddField( |
|
29 |
+ model_name='lensmancontributioncontractinfo', |
|
30 |
+ name='tencent_contract_status', |
|
31 |
+ field=models.IntegerField(choices=[(1, '合同创建'), (2, '合同签署中'), (3, '合同拒签'), (4, '合同签署完成'), (5, '合同流签(合同过期)'), (6, '合同撤回'), (8, '合同待填写'), (21, '解除协议(已解除)'), (16, '合同已失效')], db_index=True, default=-1, help_text='腾讯电子签合同签署状态', verbose_name='tencent_contract_status'), |
|
32 |
+ ), |
|
33 |
+ migrations.AlterField( |
|
34 |
+ model_name='lensmancontributioncontractinfo', |
|
35 |
+ name='document_id', |
|
36 |
+ field=models.CharField(blank=True, help_text='腾讯电子签文档ID', max_length=128, null=True, verbose_name='document_id'), |
|
37 |
+ ), |
|
38 |
+ migrations.AlterField( |
|
39 |
+ model_name='lensmancontributioncontractinfo', |
|
40 |
+ name='flow_id', |
|
41 |
+ field=models.CharField(blank=True, help_text='腾讯电子签流程ID', max_length=128, null=True, verbose_name='flow_id'), |
|
42 |
+ ), |
|
43 |
+ ] |
@@ -52,12 +52,12 @@ class LensmanContributionContractInfo(BaseModelMixin): |
||
52 | 52 |
contract_file = models.FileField(_(u'contract_file'), upload_to=upload_path, blank=True, null=True, help_text=u'图片') |
53 | 53 |
|
54 | 54 |
# 电子签参数 |
55 |
- flow_id = models.CharField(_(u'flow_id'), max_length=128, blank=True, null=True, help_text=u'电子签流程ID') |
|
55 |
+ flow_id = models.CharField(_(u'flow_id'), max_length=128, blank=True, null=True, help_text=u'腾讯电子签流程ID') |
|
56 | 56 |
# 后续需用同样的FlowId再次调用发起签署流程,合同才能进入签署环节 |
57 |
- document_id = models.CharField(_(u'document_id'), max_length=128, blank=True, null=True, help_text=u'电子签文档ID') |
|
57 |
+ document_id = models.CharField(_(u'document_id'), max_length=128, blank=True, null=True, help_text=u'腾讯电子签文档ID') |
|
58 | 58 |
|
59 |
- contract_status = models.IntegerField(_(u'contract_status'), choices=CONTRACT_STATUS_TUPLE, default=1, help_text=u'合同签署状态', db_index=True) |
|
60 |
- approve_status = models.IntegerField(_(u'approve_status'), choices=APPROVE_STATUS_TYPE, default=2, help_text=u'签署人签署状态', db_index=True) |
|
59 |
+ tencent_contract_status = models.IntegerField(_(u'tencent_contract_status'), choices=CONTRACT_STATUS_TUPLE, default=-1, help_text=u'腾讯电子签合同签署状态', db_index=True) |
|
60 |
+ tencent_approve_status = models.IntegerField(_(u'tencent_approve_status'), choices=APPROVE_STATUS_TYPE, default=-1, help_text=u'腾讯电子签签署人签署状态', db_index=True) |
|
61 | 61 |
|
62 | 62 |
class Meta: |
63 | 63 |
verbose_name = _(u'摄影师投稿合同信息') |
@@ -69,7 +69,13 @@ class LensmanContributionContractInfo(BaseModelMixin): |
||
69 | 69 |
@property |
70 | 70 |
def contract_file_url(self): |
71 | 71 |
return qiniu_file_url(self.contract_file.name, bucket='tamron') |
72 |
- |
|
72 |
+ |
|
73 |
+ @property |
|
74 |
+ def contract_status(self): |
|
75 |
+ if(self.tencent_approve_status == 3 and self.tencent_contract_status == 4): |
|
76 |
+ return 1 |
|
77 |
+ else: |
|
78 |
+ return 0 |
|
73 | 79 |
@property |
74 | 80 |
def data(self): |
75 | 81 |
return { |
@@ -79,6 +85,7 @@ class LensmanContributionContractInfo(BaseModelMixin): |
||
79 | 85 |
'contribution_id': self.contribution_id, |
80 | 86 |
'contract_content_fields': json.loads(self.contract_content_fields) if self.contract_content_fields else '', |
81 | 87 |
'contract_file_url': self.contract_file_url, |
88 |
+ 'contract_status': self.contract_status, |
|
82 | 89 |
'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d %H:%M:%S'), |
83 | 90 |
'updated_at': tc.local_string(utc_dt=self.updated_at, format='%Y-%m-%d %H:%M:%S') |
84 | 91 |
} |