MallDiscountDetail.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class MallDiscountDetail(object):
  6. def __init__(self):
  7. self._discount_amount = None
  8. self._discount_desc = None
  9. self._discount_type = None
  10. self._id = None
  11. self._name = None
  12. self._purchased = None
  13. @property
  14. def discount_amount(self):
  15. return self._discount_amount
  16. @discount_amount.setter
  17. def discount_amount(self, value):
  18. self._discount_amount = value
  19. @property
  20. def discount_desc(self):
  21. return self._discount_desc
  22. @discount_desc.setter
  23. def discount_desc(self, value):
  24. if isinstance(value, list):
  25. self._discount_desc = list()
  26. for i in value:
  27. self._discount_desc.append(i)
  28. @property
  29. def discount_type(self):
  30. return self._discount_type
  31. @discount_type.setter
  32. def discount_type(self, value):
  33. self._discount_type = value
  34. @property
  35. def id(self):
  36. return self._id
  37. @id.setter
  38. def id(self, value):
  39. self._id = value
  40. @property
  41. def name(self):
  42. return self._name
  43. @name.setter
  44. def name(self, value):
  45. self._name = value
  46. @property
  47. def purchased(self):
  48. return self._purchased
  49. @purchased.setter
  50. def purchased(self, value):
  51. self._purchased = value
  52. def to_alipay_dict(self):
  53. params = dict()
  54. if self.discount_amount:
  55. if hasattr(self.discount_amount, 'to_alipay_dict'):
  56. params['discount_amount'] = self.discount_amount.to_alipay_dict()
  57. else:
  58. params['discount_amount'] = self.discount_amount
  59. if self.discount_desc:
  60. if isinstance(self.discount_desc, list):
  61. for i in range(0, len(self.discount_desc)):
  62. element = self.discount_desc[i]
  63. if hasattr(element, 'to_alipay_dict'):
  64. self.discount_desc[i] = element.to_alipay_dict()
  65. if hasattr(self.discount_desc, 'to_alipay_dict'):
  66. params['discount_desc'] = self.discount_desc.to_alipay_dict()
  67. else:
  68. params['discount_desc'] = self.discount_desc
  69. if self.discount_type:
  70. if hasattr(self.discount_type, 'to_alipay_dict'):
  71. params['discount_type'] = self.discount_type.to_alipay_dict()
  72. else:
  73. params['discount_type'] = self.discount_type
  74. if self.id:
  75. if hasattr(self.id, 'to_alipay_dict'):
  76. params['id'] = self.id.to_alipay_dict()
  77. else:
  78. params['id'] = self.id
  79. if self.name:
  80. if hasattr(self.name, 'to_alipay_dict'):
  81. params['name'] = self.name.to_alipay_dict()
  82. else:
  83. params['name'] = self.name
  84. if self.purchased:
  85. if hasattr(self.purchased, 'to_alipay_dict'):
  86. params['purchased'] = self.purchased.to_alipay_dict()
  87. else:
  88. params['purchased'] = self.purchased
  89. return params
  90. @staticmethod
  91. def from_alipay_dict(d):
  92. if not d:
  93. return None
  94. o = MallDiscountDetail()
  95. if 'discount_amount' in d:
  96. o.discount_amount = d['discount_amount']
  97. if 'discount_desc' in d:
  98. o.discount_desc = d['discount_desc']
  99. if 'discount_type' in d:
  100. o.discount_type = d['discount_type']
  101. if 'id' in d:
  102. o.id = d['id']
  103. if 'name' in d:
  104. o.name = d['name']
  105. if 'purchased' in d:
  106. o.purchased = d['purchased']
  107. return o