ItemSkuInfo.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.ItemExtInfo import ItemExtInfo
  6. class ItemSkuInfo(object):
  7. def __init__(self):
  8. self._cost_price = None
  9. self._ext_info = None
  10. self._gmt_create = None
  11. self._gmt_modified = None
  12. self._item_id = None
  13. self._original_price = None
  14. self._price = None
  15. self._sku_id = None
  16. self._status = None
  17. @property
  18. def cost_price(self):
  19. return self._cost_price
  20. @cost_price.setter
  21. def cost_price(self, value):
  22. self._cost_price = value
  23. @property
  24. def ext_info(self):
  25. return self._ext_info
  26. @ext_info.setter
  27. def ext_info(self, value):
  28. if isinstance(value, list):
  29. self._ext_info = list()
  30. for i in value:
  31. if isinstance(i, ItemExtInfo):
  32. self._ext_info.append(i)
  33. else:
  34. self._ext_info.append(ItemExtInfo.from_alipay_dict(i))
  35. @property
  36. def gmt_create(self):
  37. return self._gmt_create
  38. @gmt_create.setter
  39. def gmt_create(self, value):
  40. self._gmt_create = value
  41. @property
  42. def gmt_modified(self):
  43. return self._gmt_modified
  44. @gmt_modified.setter
  45. def gmt_modified(self, value):
  46. self._gmt_modified = value
  47. @property
  48. def item_id(self):
  49. return self._item_id
  50. @item_id.setter
  51. def item_id(self, value):
  52. self._item_id = value
  53. @property
  54. def original_price(self):
  55. return self._original_price
  56. @original_price.setter
  57. def original_price(self, value):
  58. self._original_price = value
  59. @property
  60. def price(self):
  61. return self._price
  62. @price.setter
  63. def price(self, value):
  64. self._price = value
  65. @property
  66. def sku_id(self):
  67. return self._sku_id
  68. @sku_id.setter
  69. def sku_id(self, value):
  70. self._sku_id = value
  71. @property
  72. def status(self):
  73. return self._status
  74. @status.setter
  75. def status(self, value):
  76. self._status = value
  77. def to_alipay_dict(self):
  78. params = dict()
  79. if self.cost_price:
  80. if hasattr(self.cost_price, 'to_alipay_dict'):
  81. params['cost_price'] = self.cost_price.to_alipay_dict()
  82. else:
  83. params['cost_price'] = self.cost_price
  84. if self.ext_info:
  85. if isinstance(self.ext_info, list):
  86. for i in range(0, len(self.ext_info)):
  87. element = self.ext_info[i]
  88. if hasattr(element, 'to_alipay_dict'):
  89. self.ext_info[i] = element.to_alipay_dict()
  90. if hasattr(self.ext_info, 'to_alipay_dict'):
  91. params['ext_info'] = self.ext_info.to_alipay_dict()
  92. else:
  93. params['ext_info'] = self.ext_info
  94. if self.gmt_create:
  95. if hasattr(self.gmt_create, 'to_alipay_dict'):
  96. params['gmt_create'] = self.gmt_create.to_alipay_dict()
  97. else:
  98. params['gmt_create'] = self.gmt_create
  99. if self.gmt_modified:
  100. if hasattr(self.gmt_modified, 'to_alipay_dict'):
  101. params['gmt_modified'] = self.gmt_modified.to_alipay_dict()
  102. else:
  103. params['gmt_modified'] = self.gmt_modified
  104. if self.item_id:
  105. if hasattr(self.item_id, 'to_alipay_dict'):
  106. params['item_id'] = self.item_id.to_alipay_dict()
  107. else:
  108. params['item_id'] = self.item_id
  109. if self.original_price:
  110. if hasattr(self.original_price, 'to_alipay_dict'):
  111. params['original_price'] = self.original_price.to_alipay_dict()
  112. else:
  113. params['original_price'] = self.original_price
  114. if self.price:
  115. if hasattr(self.price, 'to_alipay_dict'):
  116. params['price'] = self.price.to_alipay_dict()
  117. else:
  118. params['price'] = self.price
  119. if self.sku_id:
  120. if hasattr(self.sku_id, 'to_alipay_dict'):
  121. params['sku_id'] = self.sku_id.to_alipay_dict()
  122. else:
  123. params['sku_id'] = self.sku_id
  124. if self.status:
  125. if hasattr(self.status, 'to_alipay_dict'):
  126. params['status'] = self.status.to_alipay_dict()
  127. else:
  128. params['status'] = self.status
  129. return params
  130. @staticmethod
  131. def from_alipay_dict(d):
  132. if not d:
  133. return None
  134. o = ItemSkuInfo()
  135. if 'cost_price' in d:
  136. o.cost_price = d['cost_price']
  137. if 'ext_info' in d:
  138. o.ext_info = d['ext_info']
  139. if 'gmt_create' in d:
  140. o.gmt_create = d['gmt_create']
  141. if 'gmt_modified' in d:
  142. o.gmt_modified = d['gmt_modified']
  143. if 'item_id' in d:
  144. o.item_id = d['item_id']
  145. if 'original_price' in d:
  146. o.original_price = d['original_price']
  147. if 'price' in d:
  148. o.price = d['price']
  149. if 'sku_id' in d:
  150. o.sku_id = d['sku_id']
  151. if 'status' in d:
  152. o.status = d['status']
  153. return o