PromoItemInfo.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.ConstraintInfo import ConstraintInfo
  6. from alipay.aop.api.domain.Voucher import Voucher
  7. class PromoItemInfo(object):
  8. def __init__(self):
  9. self._constraint_info = None
  10. self._id = None
  11. self._sale_end_time = None
  12. self._sale_start_time = None
  13. self._total_inventory = None
  14. self._voucher = None
  15. @property
  16. def constraint_info(self):
  17. return self._constraint_info
  18. @constraint_info.setter
  19. def constraint_info(self, value):
  20. if isinstance(value, ConstraintInfo):
  21. self._constraint_info = value
  22. else:
  23. self._constraint_info = ConstraintInfo.from_alipay_dict(value)
  24. @property
  25. def id(self):
  26. return self._id
  27. @id.setter
  28. def id(self, value):
  29. self._id = value
  30. @property
  31. def sale_end_time(self):
  32. return self._sale_end_time
  33. @sale_end_time.setter
  34. def sale_end_time(self, value):
  35. self._sale_end_time = value
  36. @property
  37. def sale_start_time(self):
  38. return self._sale_start_time
  39. @sale_start_time.setter
  40. def sale_start_time(self, value):
  41. self._sale_start_time = value
  42. @property
  43. def total_inventory(self):
  44. return self._total_inventory
  45. @total_inventory.setter
  46. def total_inventory(self, value):
  47. self._total_inventory = value
  48. @property
  49. def voucher(self):
  50. return self._voucher
  51. @voucher.setter
  52. def voucher(self, value):
  53. if isinstance(value, Voucher):
  54. self._voucher = value
  55. else:
  56. self._voucher = Voucher.from_alipay_dict(value)
  57. def to_alipay_dict(self):
  58. params = dict()
  59. if self.constraint_info:
  60. if hasattr(self.constraint_info, 'to_alipay_dict'):
  61. params['constraint_info'] = self.constraint_info.to_alipay_dict()
  62. else:
  63. params['constraint_info'] = self.constraint_info
  64. if self.id:
  65. if hasattr(self.id, 'to_alipay_dict'):
  66. params['id'] = self.id.to_alipay_dict()
  67. else:
  68. params['id'] = self.id
  69. if self.sale_end_time:
  70. if hasattr(self.sale_end_time, 'to_alipay_dict'):
  71. params['sale_end_time'] = self.sale_end_time.to_alipay_dict()
  72. else:
  73. params['sale_end_time'] = self.sale_end_time
  74. if self.sale_start_time:
  75. if hasattr(self.sale_start_time, 'to_alipay_dict'):
  76. params['sale_start_time'] = self.sale_start_time.to_alipay_dict()
  77. else:
  78. params['sale_start_time'] = self.sale_start_time
  79. if self.total_inventory:
  80. if hasattr(self.total_inventory, 'to_alipay_dict'):
  81. params['total_inventory'] = self.total_inventory.to_alipay_dict()
  82. else:
  83. params['total_inventory'] = self.total_inventory
  84. if self.voucher:
  85. if hasattr(self.voucher, 'to_alipay_dict'):
  86. params['voucher'] = self.voucher.to_alipay_dict()
  87. else:
  88. params['voucher'] = self.voucher
  89. return params
  90. @staticmethod
  91. def from_alipay_dict(d):
  92. if not d:
  93. return None
  94. o = PromoItemInfo()
  95. if 'constraint_info' in d:
  96. o.constraint_info = d['constraint_info']
  97. if 'id' in d:
  98. o.id = d['id']
  99. if 'sale_end_time' in d:
  100. o.sale_end_time = d['sale_end_time']
  101. if 'sale_start_time' in d:
  102. o.sale_start_time = d['sale_start_time']
  103. if 'total_inventory' in d:
  104. o.total_inventory = d['total_inventory']
  105. if 'voucher' in d:
  106. o.voucher = d['voucher']
  107. return o