AlipayTradePrecreateModel.py 16 KB

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