ItemUnitInfo.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class ItemUnitInfo(object):
  6. def __init__(self):
  7. self._amount = None
  8. self._price = None
  9. self._spec = None
  10. self._title = None
  11. self._unit = None
  12. @property
  13. def amount(self):
  14. return self._amount
  15. @amount.setter
  16. def amount(self, value):
  17. self._amount = value
  18. @property
  19. def price(self):
  20. return self._price
  21. @price.setter
  22. def price(self, value):
  23. self._price = value
  24. @property
  25. def spec(self):
  26. return self._spec
  27. @spec.setter
  28. def spec(self, value):
  29. self._spec = value
  30. @property
  31. def title(self):
  32. return self._title
  33. @title.setter
  34. def title(self, value):
  35. self._title = value
  36. @property
  37. def unit(self):
  38. return self._unit
  39. @unit.setter
  40. def unit(self, value):
  41. self._unit = value
  42. def to_alipay_dict(self):
  43. params = dict()
  44. if self.amount:
  45. if hasattr(self.amount, 'to_alipay_dict'):
  46. params['amount'] = self.amount.to_alipay_dict()
  47. else:
  48. params['amount'] = self.amount
  49. if self.price:
  50. if hasattr(self.price, 'to_alipay_dict'):
  51. params['price'] = self.price.to_alipay_dict()
  52. else:
  53. params['price'] = self.price
  54. if self.spec:
  55. if hasattr(self.spec, 'to_alipay_dict'):
  56. params['spec'] = self.spec.to_alipay_dict()
  57. else:
  58. params['spec'] = self.spec
  59. if self.title:
  60. if hasattr(self.title, 'to_alipay_dict'):
  61. params['title'] = self.title.to_alipay_dict()
  62. else:
  63. params['title'] = self.title
  64. if self.unit:
  65. if hasattr(self.unit, 'to_alipay_dict'):
  66. params['unit'] = self.unit.to_alipay_dict()
  67. else:
  68. params['unit'] = self.unit
  69. return params
  70. @staticmethod
  71. def from_alipay_dict(d):
  72. if not d:
  73. return None
  74. o = ItemUnitInfo()
  75. if 'amount' in d:
  76. o.amount = d['amount']
  77. if 'price' in d:
  78. o.price = d['price']
  79. if 'spec' in d:
  80. o.spec = d['spec']
  81. if 'title' in d:
  82. o.title = d['title']
  83. if 'unit' in d:
  84. o.unit = d['unit']
  85. return o