GoodInfo.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 GoodInfo(object):
  6. def __init__(self):
  7. self._goods_id = None
  8. self._goods_name = None
  9. self._quantity = None
  10. self._weight = None
  11. @property
  12. def goods_id(self):
  13. return self._goods_id
  14. @goods_id.setter
  15. def goods_id(self, value):
  16. self._goods_id = value
  17. @property
  18. def goods_name(self):
  19. return self._goods_name
  20. @goods_name.setter
  21. def goods_name(self, value):
  22. self._goods_name = 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 weight(self):
  31. return self._weight
  32. @weight.setter
  33. def weight(self, value):
  34. self._weight = value
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.goods_id:
  38. if hasattr(self.goods_id, 'to_alipay_dict'):
  39. params['goods_id'] = self.goods_id.to_alipay_dict()
  40. else:
  41. params['goods_id'] = self.goods_id
  42. if self.goods_name:
  43. if hasattr(self.goods_name, 'to_alipay_dict'):
  44. params['goods_name'] = self.goods_name.to_alipay_dict()
  45. else:
  46. params['goods_name'] = self.goods_name
  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.weight:
  53. if hasattr(self.weight, 'to_alipay_dict'):
  54. params['weight'] = self.weight.to_alipay_dict()
  55. else:
  56. params['weight'] = self.weight
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = GoodInfo()
  63. if 'goods_id' in d:
  64. o.goods_id = d['goods_id']
  65. if 'goods_name' in d:
  66. o.goods_name = d['goods_name']
  67. if 'quantity' in d:
  68. o.quantity = d['quantity']
  69. if 'weight' in d:
  70. o.weight = d['weight']
  71. return o