暂无描述

models.py 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # -*- coding: utf-8 -*-
  2. from django.db import models
  3. from django.utils.translation import ugettext_lazy as _
  4. from django_models_ext import BaseModelMixin, upload_file_path, upload_path
  5. from jsonfield import JSONField
  6. from shortuuidfield import ShortUUIDField
  7. from TimeConvert import TimeConvert as tc
  8. from utils.qiniucdn import qiniu_file_url
  9. class LensmanContributionContractInfo(BaseModelMixin):
  10. CONTRACT_STATUS_TUPLE = (
  11. (1, u'合同创建'),
  12. (2, u'合同签署中'),
  13. (3, u'合同拒签'),
  14. (4, u'合同签署完成'),
  15. (5, u'合同流签(合同过期)'),
  16. (6, u'合同撤回'),
  17. (8, u'合同待填写'),
  18. (21, u'解除协议(已解除)'),
  19. (16, u'合同已失效'),
  20. )
  21. APPROVE_STATUS_TYPE = (
  22. (2, u'待签署'),
  23. (7, u'待签署'),
  24. (3, u'已签署'),
  25. (4, u'拒绝'),
  26. (5, u'过期没人处理'),
  27. (6, u'流程已撤回'),
  28. (8, u'合同待填写'),
  29. (9, u'流程已终止'),
  30. (10, u'填写完成'),
  31. (15, u'解除协议(已解除)'),
  32. (15, u'已转他人处理'),
  33. )
  34. contract_id = ShortUUIDField(_(u'contract_id'), max_length=32, blank=True, null=True, help_text=u'合同唯一标识', db_index=True, unique=True)
  35. user_id = models.CharField(_(u'user_id'), max_length=32, blank=True, null=True, help_text=u'用户唯一标识', db_index=True)
  36. lensman_id = models.CharField(_(u'lensman_id'), max_length=32, blank=True, null=True, help_text=u'摄影师唯一标识', db_index=True)
  37. activity_id = models.CharField(_(u'activity_id'), max_length=32, blank=True, null=True, help_text=u'活动唯一标识', db_index=True)
  38. contribution_id = models.CharField(_(u'contribution_id'), max_length=32, blank=True, null=True, help_text=u'活动投稿唯一标识', db_index=True)
  39. contract_content_fields = JSONField(_(u'contract_content_fields'), blank=True, null=True, help_text=u'合同内容字段')
  40. contract_file = models.FileField(_(u'contract_file'), upload_to=upload_path, blank=True, null=True, help_text=u'图片')
  41. # 电子签参数
  42. flow_id = models.CharField(_(u'flow_id'), max_length=128, blank=True, null=True, help_text=u'腾讯电子签流程ID')
  43. # 后续需用同样的FlowId再次调用发起签署流程,合同才能进入签署环节
  44. document_id = models.CharField(_(u'document_id'), max_length=128, blank=True, null=True, help_text=u'腾讯电子签文档ID')
  45. tencent_contract_status = models.IntegerField(_(u'tencent_contract_status'), choices=CONTRACT_STATUS_TUPLE, default=-1, help_text=u'腾讯电子签合同签署状态', db_index=True)
  46. tencent_approve_status = models.IntegerField(_(u'tencent_approve_status'), choices=APPROVE_STATUS_TYPE, default=-1, help_text=u'腾讯电子签签署人签署状态', db_index=True)
  47. class Meta:
  48. verbose_name = _(u'摄影师投稿合同信息')
  49. verbose_name_plural = _(u'摄影师投稿合同信息')
  50. def __unicode__(self):
  51. return '%d' % self.pk
  52. @property
  53. def contract_file_url(self):
  54. return qiniu_file_url(self.contract_file.name, bucket='tamron')
  55. @property
  56. def contract_status(self):
  57. if self.tencent_approve_status == 3 and self.tencent_contract_status == 4:
  58. return 1
  59. else:
  60. return 0
  61. @property
  62. def data(self):
  63. return {
  64. 'contract_id': self.contract_id,
  65. 'lensman_id': self.lensman_id,
  66. 'activity_id': self.activity_id,
  67. 'contribution_id': self.contribution_id,
  68. 'contract_content_fields': self.contract_content_fields,
  69. 'contract_file_url': self.contract_file_url,
  70. 'contract_status': self.contract_status,
  71. 'created_at': tc.local_string(utc_dt=self.created_at, format='%Y-%m-%d %H:%M:%S'),
  72. 'updated_at': tc.local_string(utc_dt=self.updated_at, format='%Y-%m-%d %H:%M:%S')
  73. }
  74. @property
  75. def admindata(self):
  76. return self.data
  77. @property
  78. def mpdata(self):
  79. return self.data