ItemOrderDetail.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import json
  4. from alipay.aop.api.constant.ParamConstants import *
  5. class ItemOrderDetail(object):
  6. def __init__(self):
  7. self._original_price = None
  8. self._price = None
  9. self._quantity = None
  10. self._sku_id = None
  11. @property
  12. def original_price(self):
  13. return self._original_price
  14. @original_price.setter
  15. def original_price(self, value):
  16. self._original_price = value
  17. @property
  18. def price(self):
  19. return self._price
  20. @price.setter
  21. def price(self, value):
  22. self._price = value
  23. @property
  24. def quantity(self):
  25. return self._quantity
  26. @quantity.setter
  27. def quantity(self, value):
  28. self._quantity = value
  29. @property
  30. def sku_id(self):
  31. return self._sku_id
  32. @sku_id.setter
  33. def sku_id(self, value):
  34. self._sku_id = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.original_price:
  38. if hasattr(self.original_price, 'to_alipay_dict'):
  39. params['original_price'] = self.original_price.to_alipay_dict()
  40. else:
  41. params['original_price'] = self.original_price
  42. if self.price:
  43. if hasattr(self.price, 'to_alipay_dict'):
  44. params['price'] = self.price.to_alipay_dict()
  45. else:
  46. params['price'] = self.price
  47. if self.quantity:
  48. if hasattr(self.quantity, 'to_alipay_dict'):
  49. params['quantity'] = self.quantity.to_alipay_dict()
  50. else:
  51. params['quantity'] = self.quantity
  52. if self.sku_id:
  53. if hasattr(self.sku_id, 'to_alipay_dict'):
  54. params['sku_id'] = self.sku_id.to_alipay_dict()
  55. else:
  56. params['sku_id'] = self.sku_id
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = ItemOrderDetail()
  63. if 'original_price' in d:
  64. o.original_price = d['original_price']
  65. if 'price' in d:
  66. o.price = d['price']
  67. if 'quantity' in d:
  68. o.quantity = d['quantity']
  69. if 'sku_id' in d:
  70. o.sku_id = d['sku_id']
  71. return o