IntelligentGuideTradeInfo.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.IntelligentGuideTradeDetail import IntelligentGuideTradeDetail
  6. class IntelligentGuideTradeInfo(object):
  7. def __init__(self):
  8. self._shop_id = None
  9. self._shop_name = None
  10. self._trade_details = None
  11. @property
  12. def shop_id(self):
  13. return self._shop_id
  14. @shop_id.setter
  15. def shop_id(self, value):
  16. self._shop_id = value
  17. @property
  18. def shop_name(self):
  19. return self._shop_name
  20. @shop_name.setter
  21. def shop_name(self, value):
  22. self._shop_name = value
  23. @property
  24. def trade_details(self):
  25. return self._trade_details
  26. @trade_details.setter
  27. def trade_details(self, value):
  28. if isinstance(value, list):
  29. self._trade_details = list()
  30. for i in value:
  31. if isinstance(i, IntelligentGuideTradeDetail):
  32. self._trade_details.append(i)
  33. else:
  34. self._trade_details.append(IntelligentGuideTradeDetail.from_alipay_dict(i))
  35. def to_alipay_dict(self):
  36. params = dict()
  37. if self.shop_id:
  38. if hasattr(self.shop_id, 'to_alipay_dict'):
  39. params['shop_id'] = self.shop_id.to_alipay_dict()
  40. else:
  41. params['shop_id'] = self.shop_id
  42. if self.shop_name:
  43. if hasattr(self.shop_name, 'to_alipay_dict'):
  44. params['shop_name'] = self.shop_name.to_alipay_dict()
  45. else:
  46. params['shop_name'] = self.shop_name
  47. if self.trade_details:
  48. if isinstance(self.trade_details, list):
  49. for i in range(0, len(self.trade_details)):
  50. element = self.trade_details[i]
  51. if hasattr(element, 'to_alipay_dict'):
  52. self.trade_details[i] = element.to_alipay_dict()
  53. if hasattr(self.trade_details, 'to_alipay_dict'):
  54. params['trade_details'] = self.trade_details.to_alipay_dict()
  55. else:
  56. params['trade_details'] = self.trade_details
  57. return params
  58. @staticmethod
  59. def from_alipay_dict(d):
  60. if not d:
  61. return None
  62. o = IntelligentGuideTradeInfo()
  63. if 'shop_id' in d:
  64. o.shop_id = d['shop_id']
  65. if 'shop_name' in d:
  66. o.shop_name = d['shop_name']
  67. if 'trade_details' in d:
  68. o.trade_details = d['trade_details']
  69. return o