Coupon.py 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class Coupon(object):
  6. def __init__(self):
  7. self._available_amount = None
  8. self._coupon_no = None
  9. self._deduct_amount = None
  10. self._gmt_active = None
  11. self._gmt_create = None
  12. self._gmt_expired = None
  13. self._instructions = None
  14. self._memo = None
  15. self._merchant_uniq_id = None
  16. self._multi_use_flag = None
  17. self._name = None
  18. self._refund_flag = None
  19. self._status = None
  20. self._template_no = None
  21. self._user_id = None
  22. @property
  23. def available_amount(self):
  24. return self._available_amount
  25. @available_amount.setter
  26. def available_amount(self, value):
  27. self._available_amount = value
  28. @property
  29. def coupon_no(self):
  30. return self._coupon_no
  31. @coupon_no.setter
  32. def coupon_no(self, value):
  33. self._coupon_no = value
  34. @property
  35. def deduct_amount(self):
  36. return self._deduct_amount
  37. @deduct_amount.setter
  38. def deduct_amount(self, value):
  39. self._deduct_amount = value
  40. @property
  41. def gmt_active(self):
  42. return self._gmt_active
  43. @gmt_active.setter
  44. def gmt_active(self, value):
  45. self._gmt_active = value
  46. @property
  47. def gmt_create(self):
  48. return self._gmt_create
  49. @gmt_create.setter
  50. def gmt_create(self, value):
  51. self._gmt_create = value
  52. @property
  53. def gmt_expired(self):
  54. return self._gmt_expired
  55. @gmt_expired.setter
  56. def gmt_expired(self, value):
  57. self._gmt_expired = value
  58. @property
  59. def instructions(self):
  60. return self._instructions
  61. @instructions.setter
  62. def instructions(self, value):
  63. self._instructions = value
  64. @property
  65. def memo(self):
  66. return self._memo
  67. @memo.setter
  68. def memo(self, value):
  69. self._memo = value
  70. @property
  71. def merchant_uniq_id(self):
  72. return self._merchant_uniq_id
  73. @merchant_uniq_id.setter
  74. def merchant_uniq_id(self, value):
  75. self._merchant_uniq_id = value
  76. @property
  77. def multi_use_flag(self):
  78. return self._multi_use_flag
  79. @multi_use_flag.setter
  80. def multi_use_flag(self, value):
  81. self._multi_use_flag = value
  82. @property
  83. def name(self):
  84. return self._name
  85. @name.setter
  86. def name(self, value):
  87. self._name = value
  88. @property
  89. def refund_flag(self):
  90. return self._refund_flag
  91. @refund_flag.setter
  92. def refund_flag(self, value):
  93. self._refund_flag = value
  94. @property
  95. def status(self):
  96. return self._status
  97. @status.setter
  98. def status(self, value):
  99. self._status = value
  100. @property
  101. def template_no(self):
  102. return self._template_no
  103. @template_no.setter
  104. def template_no(self, value):
  105. self._template_no = value
  106. @property
  107. def user_id(self):
  108. return self._user_id
  109. @user_id.setter
  110. def user_id(self, value):
  111. self._user_id = value
  112. def to_alipay_dict(self):
  113. params = dict()
  114. if self.available_amount:
  115. if hasattr(self.available_amount, 'to_alipay_dict'):
  116. params['available_amount'] = self.available_amount.to_alipay_dict()
  117. else:
  118. params['available_amount'] = self.available_amount
  119. if self.coupon_no:
  120. if hasattr(self.coupon_no, 'to_alipay_dict'):
  121. params['coupon_no'] = self.coupon_no.to_alipay_dict()
  122. else:
  123. params['coupon_no'] = self.coupon_no
  124. if self.deduct_amount:
  125. if hasattr(self.deduct_amount, 'to_alipay_dict'):
  126. params['deduct_amount'] = self.deduct_amount.to_alipay_dict()
  127. else:
  128. params['deduct_amount'] = self.deduct_amount
  129. if self.gmt_active:
  130. if hasattr(self.gmt_active, 'to_alipay_dict'):
  131. params['gmt_active'] = self.gmt_active.to_alipay_dict()
  132. else:
  133. params['gmt_active'] = self.gmt_active
  134. if self.gmt_create:
  135. if hasattr(self.gmt_create, 'to_alipay_dict'):
  136. params['gmt_create'] = self.gmt_create.to_alipay_dict()
  137. else:
  138. params['gmt_create'] = self.gmt_create
  139. if self.gmt_expired:
  140. if hasattr(self.gmt_expired, 'to_alipay_dict'):
  141. params['gmt_expired'] = self.gmt_expired.to_alipay_dict()
  142. else:
  143. params['gmt_expired'] = self.gmt_expired
  144. if self.instructions:
  145. if hasattr(self.instructions, 'to_alipay_dict'):
  146. params['instructions'] = self.instructions.to_alipay_dict()
  147. else:
  148. params['instructions'] = self.instructions
  149. if self.memo:
  150. if hasattr(self.memo, 'to_alipay_dict'):
  151. params['memo'] = self.memo.to_alipay_dict()
  152. else:
  153. params['memo'] = self.memo
  154. if self.merchant_uniq_id:
  155. if hasattr(self.merchant_uniq_id, 'to_alipay_dict'):
  156. params['merchant_uniq_id'] = self.merchant_uniq_id.to_alipay_dict()
  157. else:
  158. params['merchant_uniq_id'] = self.merchant_uniq_id
  159. if self.multi_use_flag:
  160. if hasattr(self.multi_use_flag, 'to_alipay_dict'):
  161. params['multi_use_flag'] = self.multi_use_flag.to_alipay_dict()
  162. else:
  163. params['multi_use_flag'] = self.multi_use_flag
  164. if self.name:
  165. if hasattr(self.name, 'to_alipay_dict'):
  166. params['name'] = self.name.to_alipay_dict()
  167. else:
  168. params['name'] = self.name
  169. if self.refund_flag:
  170. if hasattr(self.refund_flag, 'to_alipay_dict'):
  171. params['refund_flag'] = self.refund_flag.to_alipay_dict()
  172. else:
  173. params['refund_flag'] = self.refund_flag
  174. if self.status:
  175. if hasattr(self.status, 'to_alipay_dict'):
  176. params['status'] = self.status.to_alipay_dict()
  177. else:
  178. params['status'] = self.status
  179. if self.template_no:
  180. if hasattr(self.template_no, 'to_alipay_dict'):
  181. params['template_no'] = self.template_no.to_alipay_dict()
  182. else:
  183. params['template_no'] = self.template_no
  184. if self.user_id:
  185. if hasattr(self.user_id, 'to_alipay_dict'):
  186. params['user_id'] = self.user_id.to_alipay_dict()
  187. else:
  188. params['user_id'] = self.user_id
  189. return params
  190. @staticmethod
  191. def from_alipay_dict(d):
  192. if not d:
  193. return None
  194. o = Coupon()
  195. if 'available_amount' in d:
  196. o.available_amount = d['available_amount']
  197. if 'coupon_no' in d:
  198. o.coupon_no = d['coupon_no']
  199. if 'deduct_amount' in d:
  200. o.deduct_amount = d['deduct_amount']
  201. if 'gmt_active' in d:
  202. o.gmt_active = d['gmt_active']
  203. if 'gmt_create' in d:
  204. o.gmt_create = d['gmt_create']
  205. if 'gmt_expired' in d:
  206. o.gmt_expired = d['gmt_expired']
  207. if 'instructions' in d:
  208. o.instructions = d['instructions']
  209. if 'memo' in d:
  210. o.memo = d['memo']
  211. if 'merchant_uniq_id' in d:
  212. o.merchant_uniq_id = d['merchant_uniq_id']
  213. if 'multi_use_flag' in d:
  214. o.multi_use_flag = d['multi_use_flag']
  215. if 'name' in d:
  216. o.name = d['name']
  217. if 'refund_flag' in d:
  218. o.refund_flag = d['refund_flag']
  219. if 'status' in d:
  220. o.status = d['status']
  221. if 'template_no' in d:
  222. o.template_no = d['template_no']
  223. if 'user_id' in d:
  224. o.user_id = d['user_id']
  225. return o