AlipayItemVoucherTemplete.py 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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.AlipayItemDescription import AlipayItemDescription
  6. from alipay.aop.api.domain.AlipayItemGoodsList import AlipayItemGoodsList
  7. from alipay.aop.api.domain.AlipayItemLimitPeriodInfo import AlipayItemLimitPeriodInfo
  8. class AlipayItemVoucherTemplete(object):
  9. def __init__(self):
  10. self._delay_minute = None
  11. self._desc_details = None
  12. self._discount_rate = None
  13. self._external_goods_list = None
  14. self._limit_period_info_list = None
  15. self._original_amount = None
  16. self._original_rate = None
  17. self._reduce_to_amount = None
  18. self._rounding_rule = None
  19. self._threshold_amount = None
  20. self._threshold_quantity = None
  21. self._valid_period = None
  22. self._value_amount = None
  23. self._voucher_desc = None
  24. self._voucher_type = None
  25. @property
  26. def delay_minute(self):
  27. return self._delay_minute
  28. @delay_minute.setter
  29. def delay_minute(self, value):
  30. self._delay_minute = value
  31. @property
  32. def desc_details(self):
  33. return self._desc_details
  34. @desc_details.setter
  35. def desc_details(self, value):
  36. if isinstance(value, list):
  37. self._desc_details = list()
  38. for i in value:
  39. if isinstance(i, AlipayItemDescription):
  40. self._desc_details.append(i)
  41. else:
  42. self._desc_details.append(AlipayItemDescription.from_alipay_dict(i))
  43. @property
  44. def discount_rate(self):
  45. return self._discount_rate
  46. @discount_rate.setter
  47. def discount_rate(self, value):
  48. self._discount_rate = value
  49. @property
  50. def external_goods_list(self):
  51. return self._external_goods_list
  52. @external_goods_list.setter
  53. def external_goods_list(self, value):
  54. if isinstance(value, AlipayItemGoodsList):
  55. self._external_goods_list = value
  56. else:
  57. self._external_goods_list = AlipayItemGoodsList.from_alipay_dict(value)
  58. @property
  59. def limit_period_info_list(self):
  60. return self._limit_period_info_list
  61. @limit_period_info_list.setter
  62. def limit_period_info_list(self, value):
  63. if isinstance(value, list):
  64. self._limit_period_info_list = list()
  65. for i in value:
  66. if isinstance(i, AlipayItemLimitPeriodInfo):
  67. self._limit_period_info_list.append(i)
  68. else:
  69. self._limit_period_info_list.append(AlipayItemLimitPeriodInfo.from_alipay_dict(i))
  70. @property
  71. def original_amount(self):
  72. return self._original_amount
  73. @original_amount.setter
  74. def original_amount(self, value):
  75. self._original_amount = value
  76. @property
  77. def original_rate(self):
  78. return self._original_rate
  79. @original_rate.setter
  80. def original_rate(self, value):
  81. self._original_rate = value
  82. @property
  83. def reduce_to_amount(self):
  84. return self._reduce_to_amount
  85. @reduce_to_amount.setter
  86. def reduce_to_amount(self, value):
  87. self._reduce_to_amount = value
  88. @property
  89. def rounding_rule(self):
  90. return self._rounding_rule
  91. @rounding_rule.setter
  92. def rounding_rule(self, value):
  93. self._rounding_rule = value
  94. @property
  95. def threshold_amount(self):
  96. return self._threshold_amount
  97. @threshold_amount.setter
  98. def threshold_amount(self, value):
  99. self._threshold_amount = value
  100. @property
  101. def threshold_quantity(self):
  102. return self._threshold_quantity
  103. @threshold_quantity.setter
  104. def threshold_quantity(self, value):
  105. self._threshold_quantity = value
  106. @property
  107. def valid_period(self):
  108. return self._valid_period
  109. @valid_period.setter
  110. def valid_period(self, value):
  111. self._valid_period = value
  112. @property
  113. def value_amount(self):
  114. return self._value_amount
  115. @value_amount.setter
  116. def value_amount(self, value):
  117. self._value_amount = value
  118. @property
  119. def voucher_desc(self):
  120. return self._voucher_desc
  121. @voucher_desc.setter
  122. def voucher_desc(self, value):
  123. self._voucher_desc = value
  124. @property
  125. def voucher_type(self):
  126. return self._voucher_type
  127. @voucher_type.setter
  128. def voucher_type(self, value):
  129. self._voucher_type = value
  130. def to_alipay_dict(self):
  131. params = dict()
  132. if self.delay_minute:
  133. if hasattr(self.delay_minute, 'to_alipay_dict'):
  134. params['delay_minute'] = self.delay_minute.to_alipay_dict()
  135. else:
  136. params['delay_minute'] = self.delay_minute
  137. if self.desc_details:
  138. if isinstance(self.desc_details, list):
  139. for i in range(0, len(self.desc_details)):
  140. element = self.desc_details[i]
  141. if hasattr(element, 'to_alipay_dict'):
  142. self.desc_details[i] = element.to_alipay_dict()
  143. if hasattr(self.desc_details, 'to_alipay_dict'):
  144. params['desc_details'] = self.desc_details.to_alipay_dict()
  145. else:
  146. params['desc_details'] = self.desc_details
  147. if self.discount_rate:
  148. if hasattr(self.discount_rate, 'to_alipay_dict'):
  149. params['discount_rate'] = self.discount_rate.to_alipay_dict()
  150. else:
  151. params['discount_rate'] = self.discount_rate
  152. if self.external_goods_list:
  153. if hasattr(self.external_goods_list, 'to_alipay_dict'):
  154. params['external_goods_list'] = self.external_goods_list.to_alipay_dict()
  155. else:
  156. params['external_goods_list'] = self.external_goods_list
  157. if self.limit_period_info_list:
  158. if isinstance(self.limit_period_info_list, list):
  159. for i in range(0, len(self.limit_period_info_list)):
  160. element = self.limit_period_info_list[i]
  161. if hasattr(element, 'to_alipay_dict'):
  162. self.limit_period_info_list[i] = element.to_alipay_dict()
  163. if hasattr(self.limit_period_info_list, 'to_alipay_dict'):
  164. params['limit_period_info_list'] = self.limit_period_info_list.to_alipay_dict()
  165. else:
  166. params['limit_period_info_list'] = self.limit_period_info_list
  167. if self.original_amount:
  168. if hasattr(self.original_amount, 'to_alipay_dict'):
  169. params['original_amount'] = self.original_amount.to_alipay_dict()
  170. else:
  171. params['original_amount'] = self.original_amount
  172. if self.original_rate:
  173. if hasattr(self.original_rate, 'to_alipay_dict'):
  174. params['original_rate'] = self.original_rate.to_alipay_dict()
  175. else:
  176. params['original_rate'] = self.original_rate
  177. if self.reduce_to_amount:
  178. if hasattr(self.reduce_to_amount, 'to_alipay_dict'):
  179. params['reduce_to_amount'] = self.reduce_to_amount.to_alipay_dict()
  180. else:
  181. params['reduce_to_amount'] = self.reduce_to_amount
  182. if self.rounding_rule:
  183. if hasattr(self.rounding_rule, 'to_alipay_dict'):
  184. params['rounding_rule'] = self.rounding_rule.to_alipay_dict()
  185. else:
  186. params['rounding_rule'] = self.rounding_rule
  187. if self.threshold_amount:
  188. if hasattr(self.threshold_amount, 'to_alipay_dict'):
  189. params['threshold_amount'] = self.threshold_amount.to_alipay_dict()
  190. else:
  191. params['threshold_amount'] = self.threshold_amount
  192. if self.threshold_quantity:
  193. if hasattr(self.threshold_quantity, 'to_alipay_dict'):
  194. params['threshold_quantity'] = self.threshold_quantity.to_alipay_dict()
  195. else:
  196. params['threshold_quantity'] = self.threshold_quantity
  197. if self.valid_period:
  198. if hasattr(self.valid_period, 'to_alipay_dict'):
  199. params['valid_period'] = self.valid_period.to_alipay_dict()
  200. else:
  201. params['valid_period'] = self.valid_period
  202. if self.value_amount:
  203. if hasattr(self.value_amount, 'to_alipay_dict'):
  204. params['value_amount'] = self.value_amount.to_alipay_dict()
  205. else:
  206. params['value_amount'] = self.value_amount
  207. if self.voucher_desc:
  208. if hasattr(self.voucher_desc, 'to_alipay_dict'):
  209. params['voucher_desc'] = self.voucher_desc.to_alipay_dict()
  210. else:
  211. params['voucher_desc'] = self.voucher_desc
  212. if self.voucher_type:
  213. if hasattr(self.voucher_type, 'to_alipay_dict'):
  214. params['voucher_type'] = self.voucher_type.to_alipay_dict()
  215. else:
  216. params['voucher_type'] = self.voucher_type
  217. return params
  218. @staticmethod
  219. def from_alipay_dict(d):
  220. if not d:
  221. return None
  222. o = AlipayItemVoucherTemplete()
  223. if 'delay_minute' in d:
  224. o.delay_minute = d['delay_minute']
  225. if 'desc_details' in d:
  226. o.desc_details = d['desc_details']
  227. if 'discount_rate' in d:
  228. o.discount_rate = d['discount_rate']
  229. if 'external_goods_list' in d:
  230. o.external_goods_list = d['external_goods_list']
  231. if 'limit_period_info_list' in d:
  232. o.limit_period_info_list = d['limit_period_info_list']
  233. if 'original_amount' in d:
  234. o.original_amount = d['original_amount']
  235. if 'original_rate' in d:
  236. o.original_rate = d['original_rate']
  237. if 'reduce_to_amount' in d:
  238. o.reduce_to_amount = d['reduce_to_amount']
  239. if 'rounding_rule' in d:
  240. o.rounding_rule = d['rounding_rule']
  241. if 'threshold_amount' in d:
  242. o.threshold_amount = d['threshold_amount']
  243. if 'threshold_quantity' in d:
  244. o.threshold_quantity = d['threshold_quantity']
  245. if 'valid_period' in d:
  246. o.valid_period = d['valid_period']
  247. if 'value_amount' in d:
  248. o.value_amount = d['value_amount']
  249. if 'voucher_desc' in d:
  250. o.voucher_desc = d['voucher_desc']
  251. if 'voucher_type' in d:
  252. o.voucher_type = d['voucher_type']
  253. return o