VoucherDetail.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. from alipay.aop.api.domain.ContributeDetail import ContributeDetail
  6. class VoucherDetail(object):
  7. def __init__(self):
  8. self._amount = None
  9. self._id = None
  10. self._memo = None
  11. self._merchant_contribute = None
  12. self._name = None
  13. self._other_contribute = None
  14. self._other_contribute_detail = None
  15. self._purchase_ant_contribute = None
  16. self._purchase_buyer_contribute = None
  17. self._purchase_merchant_contribute = None
  18. self._template_id = None
  19. self._type = None
  20. @property
  21. def amount(self):
  22. return self._amount
  23. @amount.setter
  24. def amount(self, value):
  25. self._amount = value
  26. @property
  27. def id(self):
  28. return self._id
  29. @id.setter
  30. def id(self, value):
  31. self._id = value
  32. @property
  33. def memo(self):
  34. return self._memo
  35. @memo.setter
  36. def memo(self, value):
  37. self._memo = value
  38. @property
  39. def merchant_contribute(self):
  40. return self._merchant_contribute
  41. @merchant_contribute.setter
  42. def merchant_contribute(self, value):
  43. self._merchant_contribute = value
  44. @property
  45. def name(self):
  46. return self._name
  47. @name.setter
  48. def name(self, value):
  49. self._name = value
  50. @property
  51. def other_contribute(self):
  52. return self._other_contribute
  53. @other_contribute.setter
  54. def other_contribute(self, value):
  55. self._other_contribute = value
  56. @property
  57. def other_contribute_detail(self):
  58. return self._other_contribute_detail
  59. @other_contribute_detail.setter
  60. def other_contribute_detail(self, value):
  61. if isinstance(value, list):
  62. self._other_contribute_detail = list()
  63. for i in value:
  64. if isinstance(i, ContributeDetail):
  65. self._other_contribute_detail.append(i)
  66. else:
  67. self._other_contribute_detail.append(ContributeDetail.from_alipay_dict(i))
  68. @property
  69. def purchase_ant_contribute(self):
  70. return self._purchase_ant_contribute
  71. @purchase_ant_contribute.setter
  72. def purchase_ant_contribute(self, value):
  73. self._purchase_ant_contribute = value
  74. @property
  75. def purchase_buyer_contribute(self):
  76. return self._purchase_buyer_contribute
  77. @purchase_buyer_contribute.setter
  78. def purchase_buyer_contribute(self, value):
  79. self._purchase_buyer_contribute = value
  80. @property
  81. def purchase_merchant_contribute(self):
  82. return self._purchase_merchant_contribute
  83. @purchase_merchant_contribute.setter
  84. def purchase_merchant_contribute(self, value):
  85. self._purchase_merchant_contribute = value
  86. @property
  87. def template_id(self):
  88. return self._template_id
  89. @template_id.setter
  90. def template_id(self, value):
  91. self._template_id = value
  92. @property
  93. def type(self):
  94. return self._type
  95. @type.setter
  96. def type(self, value):
  97. self._type = value
  98. def to_alipay_dict(self):
  99. params = dict()
  100. if self.amount:
  101. if hasattr(self.amount, 'to_alipay_dict'):
  102. params['amount'] = self.amount.to_alipay_dict()
  103. else:
  104. params['amount'] = self.amount
  105. if self.id:
  106. if hasattr(self.id, 'to_alipay_dict'):
  107. params['id'] = self.id.to_alipay_dict()
  108. else:
  109. params['id'] = self.id
  110. if self.memo:
  111. if hasattr(self.memo, 'to_alipay_dict'):
  112. params['memo'] = self.memo.to_alipay_dict()
  113. else:
  114. params['memo'] = self.memo
  115. if self.merchant_contribute:
  116. if hasattr(self.merchant_contribute, 'to_alipay_dict'):
  117. params['merchant_contribute'] = self.merchant_contribute.to_alipay_dict()
  118. else:
  119. params['merchant_contribute'] = self.merchant_contribute
  120. if self.name:
  121. if hasattr(self.name, 'to_alipay_dict'):
  122. params['name'] = self.name.to_alipay_dict()
  123. else:
  124. params['name'] = self.name
  125. if self.other_contribute:
  126. if hasattr(self.other_contribute, 'to_alipay_dict'):
  127. params['other_contribute'] = self.other_contribute.to_alipay_dict()
  128. else:
  129. params['other_contribute'] = self.other_contribute
  130. if self.other_contribute_detail:
  131. if isinstance(self.other_contribute_detail, list):
  132. for i in range(0, len(self.other_contribute_detail)):
  133. element = self.other_contribute_detail[i]
  134. if hasattr(element, 'to_alipay_dict'):
  135. self.other_contribute_detail[i] = element.to_alipay_dict()
  136. if hasattr(self.other_contribute_detail, 'to_alipay_dict'):
  137. params['other_contribute_detail'] = self.other_contribute_detail.to_alipay_dict()
  138. else:
  139. params['other_contribute_detail'] = self.other_contribute_detail
  140. if self.purchase_ant_contribute:
  141. if hasattr(self.purchase_ant_contribute, 'to_alipay_dict'):
  142. params['purchase_ant_contribute'] = self.purchase_ant_contribute.to_alipay_dict()
  143. else:
  144. params['purchase_ant_contribute'] = self.purchase_ant_contribute
  145. if self.purchase_buyer_contribute:
  146. if hasattr(self.purchase_buyer_contribute, 'to_alipay_dict'):
  147. params['purchase_buyer_contribute'] = self.purchase_buyer_contribute.to_alipay_dict()
  148. else:
  149. params['purchase_buyer_contribute'] = self.purchase_buyer_contribute
  150. if self.purchase_merchant_contribute:
  151. if hasattr(self.purchase_merchant_contribute, 'to_alipay_dict'):
  152. params['purchase_merchant_contribute'] = self.purchase_merchant_contribute.to_alipay_dict()
  153. else:
  154. params['purchase_merchant_contribute'] = self.purchase_merchant_contribute
  155. if self.template_id:
  156. if hasattr(self.template_id, 'to_alipay_dict'):
  157. params['template_id'] = self.template_id.to_alipay_dict()
  158. else:
  159. params['template_id'] = self.template_id
  160. if self.type:
  161. if hasattr(self.type, 'to_alipay_dict'):
  162. params['type'] = self.type.to_alipay_dict()
  163. else:
  164. params['type'] = self.type
  165. return params
  166. @staticmethod
  167. def from_alipay_dict(d):
  168. if not d:
  169. return None
  170. o = VoucherDetail()
  171. if 'amount' in d:
  172. o.amount = d['amount']
  173. if 'id' in d:
  174. o.id = d['id']
  175. if 'memo' in d:
  176. o.memo = d['memo']
  177. if 'merchant_contribute' in d:
  178. o.merchant_contribute = d['merchant_contribute']
  179. if 'name' in d:
  180. o.name = d['name']
  181. if 'other_contribute' in d:
  182. o.other_contribute = d['other_contribute']
  183. if 'other_contribute_detail' in d:
  184. o.other_contribute_detail = d['other_contribute_detail']
  185. if 'purchase_ant_contribute' in d:
  186. o.purchase_ant_contribute = d['purchase_ant_contribute']
  187. if 'purchase_buyer_contribute' in d:
  188. o.purchase_buyer_contribute = d['purchase_buyer_contribute']
  189. if 'purchase_merchant_contribute' in d:
  190. o.purchase_merchant_contribute = d['purchase_merchant_contribute']
  191. if 'template_id' in d:
  192. o.template_id = d['template_id']
  193. if 'type' in d:
  194. o.type = d['type']
  195. return o