GoodsDetail.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class GoodsDetail(object):
  6. def __init__(self):
  7. self._alipay_goods_id = None
  8. self._body = None
  9. self._categories_tree = None
  10. self._goods_category = None
  11. self._goods_id = None
  12. self._goods_name = None
  13. self._price = None
  14. self._quantity = None
  15. self._show_url = None
  16. @property
  17. def alipay_goods_id(self):
  18. return self._alipay_goods_id
  19. @alipay_goods_id.setter
  20. def alipay_goods_id(self, value):
  21. self._alipay_goods_id = value
  22. @property
  23. def body(self):
  24. return self._body
  25. @body.setter
  26. def body(self, value):
  27. self._body = value
  28. @property
  29. def categories_tree(self):
  30. return self._categories_tree
  31. @categories_tree.setter
  32. def categories_tree(self, value):
  33. self._categories_tree = value
  34. @property
  35. def goods_category(self):
  36. return self._goods_category
  37. @goods_category.setter
  38. def goods_category(self, value):
  39. self._goods_category = value
  40. @property
  41. def goods_id(self):
  42. return self._goods_id
  43. @goods_id.setter
  44. def goods_id(self, value):
  45. self._goods_id = value
  46. @property
  47. def goods_name(self):
  48. return self._goods_name
  49. @goods_name.setter
  50. def goods_name(self, value):
  51. self._goods_name = value
  52. @property
  53. def price(self):
  54. return self._price
  55. @price.setter
  56. def price(self, value):
  57. self._price = value
  58. @property
  59. def quantity(self):
  60. return self._quantity
  61. @quantity.setter
  62. def quantity(self, value):
  63. self._quantity = value
  64. @property
  65. def show_url(self):
  66. return self._show_url
  67. @show_url.setter
  68. def show_url(self, value):
  69. self._show_url = value
  70. def to_alipay_dict(self):
  71. params = dict()
  72. if self.alipay_goods_id:
  73. if hasattr(self.alipay_goods_id, 'to_alipay_dict'):
  74. params['alipay_goods_id'] = self.alipay_goods_id.to_alipay_dict()
  75. else:
  76. params['alipay_goods_id'] = self.alipay_goods_id
  77. if self.body:
  78. if hasattr(self.body, 'to_alipay_dict'):
  79. params['body'] = self.body.to_alipay_dict()
  80. else:
  81. params['body'] = self.body
  82. if self.categories_tree:
  83. if hasattr(self.categories_tree, 'to_alipay_dict'):
  84. params['categories_tree'] = self.categories_tree.to_alipay_dict()
  85. else:
  86. params['categories_tree'] = self.categories_tree
  87. if self.goods_category:
  88. if hasattr(self.goods_category, 'to_alipay_dict'):
  89. params['goods_category'] = self.goods_category.to_alipay_dict()
  90. else:
  91. params['goods_category'] = self.goods_category
  92. if self.goods_id:
  93. if hasattr(self.goods_id, 'to_alipay_dict'):
  94. params['goods_id'] = self.goods_id.to_alipay_dict()
  95. else:
  96. params['goods_id'] = self.goods_id
  97. if self.goods_name:
  98. if hasattr(self.goods_name, 'to_alipay_dict'):
  99. params['goods_name'] = self.goods_name.to_alipay_dict()
  100. else:
  101. params['goods_name'] = self.goods_name
  102. if self.price:
  103. if hasattr(self.price, 'to_alipay_dict'):
  104. params['price'] = self.price.to_alipay_dict()
  105. else:
  106. params['price'] = self.price
  107. if self.quantity:
  108. if hasattr(self.quantity, 'to_alipay_dict'):
  109. params['quantity'] = self.quantity.to_alipay_dict()
  110. else:
  111. params['quantity'] = self.quantity
  112. if self.show_url:
  113. if hasattr(self.show_url, 'to_alipay_dict'):
  114. params['show_url'] = self.show_url.to_alipay_dict()
  115. else:
  116. params['show_url'] = self.show_url
  117. return params
  118. @staticmethod
  119. def from_alipay_dict(d):
  120. if not d:
  121. return None
  122. o = GoodsDetail()
  123. if 'alipay_goods_id' in d:
  124. o.alipay_goods_id = d['alipay_goods_id']
  125. if 'body' in d:
  126. o.body = d['body']
  127. if 'categories_tree' in d:
  128. o.categories_tree = d['categories_tree']
  129. if 'goods_category' in d:
  130. o.goods_category = d['goods_category']
  131. if 'goods_id' in d:
  132. o.goods_id = d['goods_id']
  133. if 'goods_name' in d:
  134. o.goods_name = d['goods_name']
  135. if 'price' in d:
  136. o.price = d['price']
  137. if 'quantity' in d:
  138. o.quantity = d['quantity']
  139. if 'show_url' in d:
  140. o.show_url = d['show_url']
  141. return o