OrderInvoiceReq.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. /*
  3. * Copyright (c) 2008-2016 vip.com, All Rights Reserved.
  4. *
  5. * Powered by com.vip.osp.osp-idlc-2.5.11.
  6. *
  7. */
  8. namespace vipapis\order;
  9. class OrderInvoiceReq {
  10. static $_TSPEC;
  11. public $order_id = null;
  12. public $invoice_type = null;
  13. public $e_invoice = null;
  14. public $paper_invoice = null;
  15. public function __construct($vals=null){
  16. if (!isset(self::$_TSPEC)){
  17. self::$_TSPEC = array(
  18. 1 => array(
  19. 'var' => 'order_id'
  20. ),
  21. 2 => array(
  22. 'var' => 'invoice_type'
  23. ),
  24. 3 => array(
  25. 'var' => 'e_invoice'
  26. ),
  27. 4 => array(
  28. 'var' => 'paper_invoice'
  29. ),
  30. );
  31. }
  32. if (is_array($vals)){
  33. if (isset($vals['order_id'])){
  34. $this->order_id = $vals['order_id'];
  35. }
  36. if (isset($vals['invoice_type'])){
  37. $this->invoice_type = $vals['invoice_type'];
  38. }
  39. if (isset($vals['e_invoice'])){
  40. $this->e_invoice = $vals['e_invoice'];
  41. }
  42. if (isset($vals['paper_invoice'])){
  43. $this->paper_invoice = $vals['paper_invoice'];
  44. }
  45. }
  46. }
  47. public function getName(){
  48. return 'OrderInvoiceReq';
  49. }
  50. public function read($input){
  51. $input->readStructBegin();
  52. while(true){
  53. $schemeField = $input->readFieldBegin();
  54. if ($schemeField == null) break;
  55. $needSkip = true;
  56. if ("order_id" == $schemeField){
  57. $needSkip = false;
  58. $input->readString($this->order_id);
  59. }
  60. if ("invoice_type" == $schemeField){
  61. $needSkip = false;
  62. $input->readI32($this->invoice_type);
  63. }
  64. if ("e_invoice" == $schemeField){
  65. $needSkip = false;
  66. $this->e_invoice = array();
  67. $_size0 = 0;
  68. $input->readListBegin();
  69. while(true){
  70. try{
  71. $elem0 = null;
  72. $elem0 = new \vipapis\order\Einvoice();
  73. $elem0->read($input);
  74. $this->e_invoice[$_size0++] = $elem0;
  75. }
  76. catch(\Exception $e){
  77. break;
  78. }
  79. }
  80. $input->readListEnd();
  81. }
  82. if ("paper_invoice" == $schemeField){
  83. $needSkip = false;
  84. $this->paper_invoice = new \vipapis\order\PaperInvoice();
  85. $this->paper_invoice->read($input);
  86. }
  87. if($needSkip){
  88. \Osp\Protocol\ProtocolUtil::skip($input);
  89. }
  90. $input->readFieldEnd();
  91. }
  92. $input->readStructEnd();
  93. }
  94. public function write($output){
  95. $xfer = 0;
  96. $xfer += $output->writeStructBegin();
  97. $xfer += $output->writeFieldBegin('order_id');
  98. $xfer += $output->writeString($this->order_id);
  99. $xfer += $output->writeFieldEnd();
  100. $xfer += $output->writeFieldBegin('invoice_type');
  101. $xfer += $output->writeI32($this->invoice_type);
  102. $xfer += $output->writeFieldEnd();
  103. if($this->e_invoice !== null) {
  104. $xfer += $output->writeFieldBegin('e_invoice');
  105. if (!is_array($this->e_invoice)){
  106. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  107. }
  108. $output->writeListBegin();
  109. foreach ($this->e_invoice as $iter0){
  110. if (!is_object($iter0)) {
  111. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  112. }
  113. $xfer += $iter0->write($output);
  114. }
  115. $output->writeListEnd();
  116. $xfer += $output->writeFieldEnd();
  117. }
  118. if($this->paper_invoice !== null) {
  119. $xfer += $output->writeFieldBegin('paper_invoice');
  120. if (!is_object($this->paper_invoice)) {
  121. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  122. }
  123. $xfer += $this->paper_invoice->write($output);
  124. $xfer += $output->writeFieldEnd();
  125. }
  126. $xfer += $output->writeFieldStop();
  127. $xfer += $output->writeStructEnd();
  128. return $xfer;
  129. }
  130. }
  131. ?>