AlipayTradeCreateModel.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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.BusinessParams import BusinessParams
  6. from alipay.aop.api.domain.ExtUserInfo import ExtUserInfo
  7. from alipay.aop.api.domain.ExtendParams import ExtendParams
  8. from alipay.aop.api.domain.GoodsDetail import GoodsDetail
  9. from alipay.aop.api.domain.LogisticsDetail import LogisticsDetail
  10. from alipay.aop.api.domain.ReceiverAddressInfo import ReceiverAddressInfo
  11. from alipay.aop.api.domain.RoyaltyInfo import RoyaltyInfo
  12. from alipay.aop.api.domain.SettleInfo import SettleInfo
  13. from alipay.aop.api.domain.SubMerchant import SubMerchant
  14. class AlipayTradeCreateModel(object):
  15. def __init__(self):
  16. self._alipay_store_id = None
  17. self._body = None
  18. self._business_params = None
  19. self._buyer_id = None
  20. self._buyer_logon_id = None
  21. self._disable_pay_channels = None
  22. self._discountable_amount = None
  23. self._enable_pay_channels = None
  24. self._ext_user_info = None
  25. self._extend_params = None
  26. self._goods_detail = None
  27. self._logistics_detail = None
  28. self._merchant_order_no = None
  29. self._operator_id = None
  30. self._out_trade_no = None
  31. self._product_code = None
  32. self._receiver_address_info = None
  33. self._royalty_info = None
  34. self._seller_id = None
  35. self._settle_info = None
  36. self._store_id = None
  37. self._sub_merchant = None
  38. self._subject = None
  39. self._terminal_id = None
  40. self._timeout_express = None
  41. self._total_amount = None
  42. self._undiscountable_amount = None
  43. @property
  44. def alipay_store_id(self):
  45. return self._alipay_store_id
  46. @alipay_store_id.setter
  47. def alipay_store_id(self, value):
  48. self._alipay_store_id = value
  49. @property
  50. def body(self):
  51. return self._body
  52. @body.setter
  53. def body(self, value):
  54. self._body = value
  55. @property
  56. def business_params(self):
  57. return self._business_params
  58. @business_params.setter
  59. def business_params(self, value):
  60. if isinstance(value, BusinessParams):
  61. self._business_params = value
  62. else:
  63. self._business_params = BusinessParams.from_alipay_dict(value)
  64. @property
  65. def buyer_id(self):
  66. return self._buyer_id
  67. @buyer_id.setter
  68. def buyer_id(self, value):
  69. self._buyer_id = value
  70. @property
  71. def buyer_logon_id(self):
  72. return self._buyer_logon_id
  73. @buyer_logon_id.setter
  74. def buyer_logon_id(self, value):
  75. self._buyer_logon_id = value
  76. @property
  77. def disable_pay_channels(self):
  78. return self._disable_pay_channels
  79. @disable_pay_channels.setter
  80. def disable_pay_channels(self, value):
  81. self._disable_pay_channels = value
  82. @property
  83. def discountable_amount(self):
  84. return self._discountable_amount
  85. @discountable_amount.setter
  86. def discountable_amount(self, value):
  87. self._discountable_amount = value
  88. @property
  89. def enable_pay_channels(self):
  90. return self._enable_pay_channels
  91. @enable_pay_channels.setter
  92. def enable_pay_channels(self, value):
  93. self._enable_pay_channels = value
  94. @property
  95. def ext_user_info(self):
  96. return self._ext_user_info
  97. @ext_user_info.setter
  98. def ext_user_info(self, value):
  99. if isinstance(value, ExtUserInfo):
  100. self._ext_user_info = value
  101. else:
  102. self._ext_user_info = ExtUserInfo.from_alipay_dict(value)
  103. @property
  104. def extend_params(self):
  105. return self._extend_params
  106. @extend_params.setter
  107. def extend_params(self, value):
  108. if isinstance(value, ExtendParams):
  109. self._extend_params = value
  110. else:
  111. self._extend_params = ExtendParams.from_alipay_dict(value)
  112. @property
  113. def goods_detail(self):
  114. return self._goods_detail
  115. @goods_detail.setter
  116. def goods_detail(self, value):
  117. if isinstance(value, list):
  118. self._goods_detail = list()
  119. for i in value:
  120. if isinstance(i, GoodsDetail):
  121. self._goods_detail.append(i)
  122. else:
  123. self._goods_detail.append(GoodsDetail.from_alipay_dict(i))
  124. @property
  125. def logistics_detail(self):
  126. return self._logistics_detail
  127. @logistics_detail.setter
  128. def logistics_detail(self, value):
  129. if isinstance(value, LogisticsDetail):
  130. self._logistics_detail = value
  131. else:
  132. self._logistics_detail = LogisticsDetail.from_alipay_dict(value)
  133. @property
  134. def merchant_order_no(self):
  135. return self._merchant_order_no
  136. @merchant_order_no.setter
  137. def merchant_order_no(self, value):
  138. self._merchant_order_no = value
  139. @property
  140. def operator_id(self):
  141. return self._operator_id
  142. @operator_id.setter
  143. def operator_id(self, value):
  144. self._operator_id = value
  145. @property
  146. def out_trade_no(self):
  147. return self._out_trade_no
  148. @out_trade_no.setter
  149. def out_trade_no(self, value):
  150. self._out_trade_no = value
  151. @property
  152. def product_code(self):
  153. return self._product_code
  154. @product_code.setter
  155. def product_code(self, value):
  156. self._product_code = value
  157. @property
  158. def receiver_address_info(self):
  159. return self._receiver_address_info
  160. @receiver_address_info.setter
  161. def receiver_address_info(self, value):
  162. if isinstance(value, ReceiverAddressInfo):
  163. self._receiver_address_info = value
  164. else:
  165. self._receiver_address_info = ReceiverAddressInfo.from_alipay_dict(value)
  166. @property
  167. def royalty_info(self):
  168. return self._royalty_info
  169. @royalty_info.setter
  170. def royalty_info(self, value):
  171. if isinstance(value, RoyaltyInfo):
  172. self._royalty_info = value
  173. else:
  174. self._royalty_info = RoyaltyInfo.from_alipay_dict(value)
  175. @property
  176. def seller_id(self):
  177. return self._seller_id
  178. @seller_id.setter
  179. def seller_id(self, value):
  180. self._seller_id = value
  181. @property
  182. def settle_info(self):
  183. return self._settle_info
  184. @settle_info.setter
  185. def settle_info(self, value):
  186. if isinstance(value, SettleInfo):
  187. self._settle_info = value
  188. else:
  189. self._settle_info = SettleInfo.from_alipay_dict(value)
  190. @property
  191. def store_id(self):
  192. return self._store_id
  193. @store_id.setter
  194. def store_id(self, value):
  195. self._store_id = value
  196. @property
  197. def sub_merchant(self):
  198. return self._sub_merchant
  199. @sub_merchant.setter
  200. def sub_merchant(self, value):
  201. if isinstance(value, SubMerchant):
  202. self._sub_merchant = value
  203. else:
  204. self._sub_merchant = SubMerchant.from_alipay_dict(value)
  205. @property
  206. def subject(self):
  207. return self._subject
  208. @subject.setter
  209. def subject(self, value):
  210. self._subject = value
  211. @property
  212. def terminal_id(self):
  213. return self._terminal_id
  214. @terminal_id.setter
  215. def terminal_id(self, value):
  216. self._terminal_id = value
  217. @property
  218. def timeout_express(self):
  219. return self._timeout_express
  220. @timeout_express.setter
  221. def timeout_express(self, value):
  222. self._timeout_express = value
  223. @property
  224. def total_amount(self):
  225. return self._total_amount
  226. @total_amount.setter
  227. def total_amount(self, value):
  228. self._total_amount = value
  229. @property
  230. def undiscountable_amount(self):
  231. return self._undiscountable_amount
  232. @undiscountable_amount.setter
  233. def undiscountable_amount(self, value):
  234. self._undiscountable_amount = value
  235. def to_alipay_dict(self):
  236. params = dict()
  237. if self.alipay_store_id:
  238. if hasattr(self.alipay_store_id, 'to_alipay_dict'):
  239. params['alipay_store_id'] = self.alipay_store_id.to_alipay_dict()
  240. else:
  241. params['alipay_store_id'] = self.alipay_store_id
  242. if self.body:
  243. if hasattr(self.body, 'to_alipay_dict'):
  244. params['body'] = self.body.to_alipay_dict()
  245. else:
  246. params['body'] = self.body
  247. if self.business_params:
  248. if hasattr(self.business_params, 'to_alipay_dict'):
  249. params['business_params'] = self.business_params.to_alipay_dict()
  250. else:
  251. params['business_params'] = self.business_params
  252. if self.buyer_id:
  253. if hasattr(self.buyer_id, 'to_alipay_dict'):
  254. params['buyer_id'] = self.buyer_id.to_alipay_dict()
  255. else:
  256. params['buyer_id'] = self.buyer_id
  257. if self.buyer_logon_id:
  258. if hasattr(self.buyer_logon_id, 'to_alipay_dict'):
  259. params['buyer_logon_id'] = self.buyer_logon_id.to_alipay_dict()
  260. else:
  261. params['buyer_logon_id'] = self.buyer_logon_id
  262. if self.disable_pay_channels:
  263. if hasattr(self.disable_pay_channels, 'to_alipay_dict'):
  264. params['disable_pay_channels'] = self.disable_pay_channels.to_alipay_dict()
  265. else:
  266. params['disable_pay_channels'] = self.disable_pay_channels
  267. if self.discountable_amount:
  268. if hasattr(self.discountable_amount, 'to_alipay_dict'):
  269. params['discountable_amount'] = self.discountable_amount.to_alipay_dict()
  270. else:
  271. params['discountable_amount'] = self.discountable_amount
  272. if self.enable_pay_channels:
  273. if hasattr(self.enable_pay_channels, 'to_alipay_dict'):
  274. params['enable_pay_channels'] = self.enable_pay_channels.to_alipay_dict()
  275. else:
  276. params['enable_pay_channels'] = self.enable_pay_channels
  277. if self.ext_user_info:
  278. if hasattr(self.ext_user_info, 'to_alipay_dict'):
  279. params['ext_user_info'] = self.ext_user_info.to_alipay_dict()
  280. else:
  281. params['ext_user_info'] = self.ext_user_info
  282. if self.extend_params:
  283. if hasattr(self.extend_params, 'to_alipay_dict'):
  284. params['extend_params'] = self.extend_params.to_alipay_dict()
  285. else:
  286. params['extend_params'] = self.extend_params
  287. if self.goods_detail:
  288. if isinstance(self.goods_detail, list):
  289. for i in range(0, len(self.goods_detail)):
  290. element = self.goods_detail[i]
  291. if hasattr(element, 'to_alipay_dict'):
  292. self.goods_detail[i] = element.to_alipay_dict()
  293. if hasattr(self.goods_detail, 'to_alipay_dict'):
  294. params['goods_detail'] = self.goods_detail.to_alipay_dict()
  295. else:
  296. params['goods_detail'] = self.goods_detail
  297. if self.logistics_detail:
  298. if hasattr(self.logistics_detail, 'to_alipay_dict'):
  299. params['logistics_detail'] = self.logistics_detail.to_alipay_dict()
  300. else:
  301. params['logistics_detail'] = self.logistics_detail
  302. if self.merchant_order_no:
  303. if hasattr(self.merchant_order_no, 'to_alipay_dict'):
  304. params['merchant_order_no'] = self.merchant_order_no.to_alipay_dict()
  305. else:
  306. params['merchant_order_no'] = self.merchant_order_no
  307. if self.operator_id:
  308. if hasattr(self.operator_id, 'to_alipay_dict'):
  309. params['operator_id'] = self.operator_id.to_alipay_dict()
  310. else:
  311. params['operator_id'] = self.operator_id
  312. if self.out_trade_no:
  313. if hasattr(self.out_trade_no, 'to_alipay_dict'):
  314. params['out_trade_no'] = self.out_trade_no.to_alipay_dict()
  315. else:
  316. params['out_trade_no'] = self.out_trade_no
  317. if self.product_code:
  318. if hasattr(self.product_code, 'to_alipay_dict'):
  319. params['product_code'] = self.product_code.to_alipay_dict()
  320. else:
  321. params['product_code'] = self.product_code
  322. if self.receiver_address_info:
  323. if hasattr(self.receiver_address_info, 'to_alipay_dict'):
  324. params['receiver_address_info'] = self.receiver_address_info.to_alipay_dict()
  325. else:
  326. params['receiver_address_info'] = self.receiver_address_info
  327. if self.royalty_info:
  328. if hasattr(self.royalty_info, 'to_alipay_dict'):
  329. params['royalty_info'] = self.royalty_info.to_alipay_dict()
  330. else:
  331. params['royalty_info'] = self.royalty_info
  332. if self.seller_id:
  333. if hasattr(self.seller_id, 'to_alipay_dict'):
  334. params['seller_id'] = self.seller_id.to_alipay_dict()
  335. else:
  336. params['seller_id'] = self.seller_id
  337. if self.settle_info:
  338. if hasattr(self.settle_info, 'to_alipay_dict'):
  339. params['settle_info'] = self.settle_info.to_alipay_dict()
  340. else:
  341. params['settle_info'] = self.settle_info
  342. if self.store_id:
  343. if hasattr(self.store_id, 'to_alipay_dict'):
  344. params['store_id'] = self.store_id.to_alipay_dict()
  345. else:
  346. params['store_id'] = self.store_id
  347. if self.sub_merchant:
  348. if hasattr(self.sub_merchant, 'to_alipay_dict'):
  349. params['sub_merchant'] = self.sub_merchant.to_alipay_dict()
  350. else:
  351. params['sub_merchant'] = self.sub_merchant
  352. if self.subject:
  353. if hasattr(self.subject, 'to_alipay_dict'):
  354. params['subject'] = self.subject.to_alipay_dict()
  355. else:
  356. params['subject'] = self.subject
  357. if self.terminal_id:
  358. if hasattr(self.terminal_id, 'to_alipay_dict'):
  359. params['terminal_id'] = self.terminal_id.to_alipay_dict()
  360. else:
  361. params['terminal_id'] = self.terminal_id
  362. if self.timeout_express:
  363. if hasattr(self.timeout_express, 'to_alipay_dict'):
  364. params['timeout_express'] = self.timeout_express.to_alipay_dict()
  365. else:
  366. params['timeout_express'] = self.timeout_express
  367. if self.total_amount:
  368. if hasattr(self.total_amount, 'to_alipay_dict'):
  369. params['total_amount'] = self.total_amount.to_alipay_dict()
  370. else:
  371. params['total_amount'] = self.total_amount
  372. if self.undiscountable_amount:
  373. if hasattr(self.undiscountable_amount, 'to_alipay_dict'):
  374. params['undiscountable_amount'] = self.undiscountable_amount.to_alipay_dict()
  375. else:
  376. params['undiscountable_amount'] = self.undiscountable_amount
  377. return params
  378. @staticmethod
  379. def from_alipay_dict(d):
  380. if not d:
  381. return None
  382. o = AlipayTradeCreateModel()
  383. if 'alipay_store_id' in d:
  384. o.alipay_store_id = d['alipay_store_id']
  385. if 'body' in d:
  386. o.body = d['body']
  387. if 'business_params' in d:
  388. o.business_params = d['business_params']
  389. if 'buyer_id' in d:
  390. o.buyer_id = d['buyer_id']
  391. if 'buyer_logon_id' in d:
  392. o.buyer_logon_id = d['buyer_logon_id']
  393. if 'disable_pay_channels' in d:
  394. o.disable_pay_channels = d['disable_pay_channels']
  395. if 'discountable_amount' in d:
  396. o.discountable_amount = d['discountable_amount']
  397. if 'enable_pay_channels' in d:
  398. o.enable_pay_channels = d['enable_pay_channels']
  399. if 'ext_user_info' in d:
  400. o.ext_user_info = d['ext_user_info']
  401. if 'extend_params' in d:
  402. o.extend_params = d['extend_params']
  403. if 'goods_detail' in d:
  404. o.goods_detail = d['goods_detail']
  405. if 'logistics_detail' in d:
  406. o.logistics_detail = d['logistics_detail']
  407. if 'merchant_order_no' in d:
  408. o.merchant_order_no = d['merchant_order_no']
  409. if 'operator_id' in d:
  410. o.operator_id = d['operator_id']
  411. if 'out_trade_no' in d:
  412. o.out_trade_no = d['out_trade_no']
  413. if 'product_code' in d:
  414. o.product_code = d['product_code']
  415. if 'receiver_address_info' in d:
  416. o.receiver_address_info = d['receiver_address_info']
  417. if 'royalty_info' in d:
  418. o.royalty_info = d['royalty_info']
  419. if 'seller_id' in d:
  420. o.seller_id = d['seller_id']
  421. if 'settle_info' in d:
  422. o.settle_info = d['settle_info']
  423. if 'store_id' in d:
  424. o.store_id = d['store_id']
  425. if 'sub_merchant' in d:
  426. o.sub_merchant = d['sub_merchant']
  427. if 'subject' in d:
  428. o.subject = d['subject']
  429. if 'terminal_id' in d:
  430. o.terminal_id = d['terminal_id']
  431. if 'timeout_express' in d:
  432. o.timeout_express = d['timeout_express']
  433. if 'total_amount' in d:
  434. o.total_amount = d['total_amount']
  435. if 'undiscountable_amount' in d:
  436. o.undiscountable_amount = d['undiscountable_amount']
  437. return o