ItemBo.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class ItemBo(object):
  6. def __init__(self):
  7. self._attribute = None
  8. self._desc = None
  9. self._logo = None
  10. self._name = None
  11. self._origin_price = None
  12. self._price = None
  13. @property
  14. def attribute(self):
  15. return self._attribute
  16. @attribute.setter
  17. def attribute(self, value):
  18. self._attribute = value
  19. @property
  20. def desc(self):
  21. return self._desc
  22. @desc.setter
  23. def desc(self, value):
  24. self._desc = value
  25. @property
  26. def logo(self):
  27. return self._logo
  28. @logo.setter
  29. def logo(self, value):
  30. self._logo = value
  31. @property
  32. def name(self):
  33. return self._name
  34. @name.setter
  35. def name(self, value):
  36. self._name = value
  37. @property
  38. def origin_price(self):
  39. return self._origin_price
  40. @origin_price.setter
  41. def origin_price(self, value):
  42. self._origin_price = value
  43. @property
  44. def price(self):
  45. return self._price
  46. @price.setter
  47. def price(self, value):
  48. self._price = value
  49. def to_alipay_dict(self):
  50. params = dict()
  51. if self.attribute:
  52. if hasattr(self.attribute, 'to_alipay_dict'):
  53. params['attribute'] = self.attribute.to_alipay_dict()
  54. else:
  55. params['attribute'] = self.attribute
  56. if self.desc:
  57. if hasattr(self.desc, 'to_alipay_dict'):
  58. params['desc'] = self.desc.to_alipay_dict()
  59. else:
  60. params['desc'] = self.desc
  61. if self.logo:
  62. if hasattr(self.logo, 'to_alipay_dict'):
  63. params['logo'] = self.logo.to_alipay_dict()
  64. else:
  65. params['logo'] = self.logo
  66. if self.name:
  67. if hasattr(self.name, 'to_alipay_dict'):
  68. params['name'] = self.name.to_alipay_dict()
  69. else:
  70. params['name'] = self.name
  71. if self.origin_price:
  72. if hasattr(self.origin_price, 'to_alipay_dict'):
  73. params['origin_price'] = self.origin_price.to_alipay_dict()
  74. else:
  75. params['origin_price'] = self.origin_price
  76. if self.price:
  77. if hasattr(self.price, 'to_alipay_dict'):
  78. params['price'] = self.price.to_alipay_dict()
  79. else:
  80. params['price'] = self.price
  81. return params
  82. @staticmethod
  83. def from_alipay_dict(d):
  84. if not d:
  85. return None
  86. o = ItemBo()
  87. if 'attribute' in d:
  88. o.attribute = d['attribute']
  89. if 'desc' in d:
  90. o.desc = d['desc']
  91. if 'logo' in d:
  92. o.logo = d['logo']
  93. if 'name' in d:
  94. o.name = d['name']
  95. if 'origin_price' in d:
  96. o.origin_price = d['origin_price']
  97. if 'price' in d:
  98. o.price = d['price']
  99. return o