OrderDetail.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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\delivery;
  9. class OrderDetail {
  10. static $_TSPEC;
  11. public $order_id = null;
  12. public $barcode = null;
  13. public $amount = null;
  14. public $price = null;
  15. public $brand_id = null;
  16. public $promotions = null;
  17. public $failed_promotions = null;
  18. public $date = null;
  19. public $actual_market_price = null;
  20. public function __construct($vals=null){
  21. if (!isset(self::$_TSPEC)){
  22. self::$_TSPEC = array(
  23. 1 => array(
  24. 'var' => 'order_id'
  25. ),
  26. 2 => array(
  27. 'var' => 'barcode'
  28. ),
  29. 3 => array(
  30. 'var' => 'amount'
  31. ),
  32. 4 => array(
  33. 'var' => 'price'
  34. ),
  35. 5 => array(
  36. 'var' => 'brand_id'
  37. ),
  38. 6 => array(
  39. 'var' => 'promotions'
  40. ),
  41. 8 => array(
  42. 'var' => 'failed_promotions'
  43. ),
  44. 9 => array(
  45. 'var' => 'date'
  46. ),
  47. 10 => array(
  48. 'var' => 'actual_market_price'
  49. ),
  50. );
  51. }
  52. if (is_array($vals)){
  53. if (isset($vals['order_id'])){
  54. $this->order_id = $vals['order_id'];
  55. }
  56. if (isset($vals['barcode'])){
  57. $this->barcode = $vals['barcode'];
  58. }
  59. if (isset($vals['amount'])){
  60. $this->amount = $vals['amount'];
  61. }
  62. if (isset($vals['price'])){
  63. $this->price = $vals['price'];
  64. }
  65. if (isset($vals['brand_id'])){
  66. $this->brand_id = $vals['brand_id'];
  67. }
  68. if (isset($vals['promotions'])){
  69. $this->promotions = $vals['promotions'];
  70. }
  71. if (isset($vals['failed_promotions'])){
  72. $this->failed_promotions = $vals['failed_promotions'];
  73. }
  74. if (isset($vals['date'])){
  75. $this->date = $vals['date'];
  76. }
  77. if (isset($vals['actual_market_price'])){
  78. $this->actual_market_price = $vals['actual_market_price'];
  79. }
  80. }
  81. }
  82. public function getName(){
  83. return 'OrderDetail';
  84. }
  85. public function read($input){
  86. $input->readStructBegin();
  87. while(true){
  88. $schemeField = $input->readFieldBegin();
  89. if ($schemeField == null) break;
  90. $needSkip = true;
  91. if ("order_id" == $schemeField){
  92. $needSkip = false;
  93. $input->readString($this->order_id);
  94. }
  95. if ("barcode" == $schemeField){
  96. $needSkip = false;
  97. $input->readString($this->barcode);
  98. }
  99. if ("amount" == $schemeField){
  100. $needSkip = false;
  101. $input->readI32($this->amount);
  102. }
  103. if ("price" == $schemeField){
  104. $needSkip = false;
  105. $input->readDouble($this->price);
  106. }
  107. if ("brand_id" == $schemeField){
  108. $needSkip = false;
  109. $input->readString($this->brand_id);
  110. }
  111. if ("promotions" == $schemeField){
  112. $needSkip = false;
  113. $this->promotions = array();
  114. $_size0 = 0;
  115. $input->readListBegin();
  116. while(true){
  117. try{
  118. $elem0 = null;
  119. $elem0 = new \vipapis\delivery\PromotionInfo();
  120. $elem0->read($input);
  121. $this->promotions[$_size0++] = $elem0;
  122. }
  123. catch(\Exception $e){
  124. break;
  125. }
  126. }
  127. $input->readListEnd();
  128. }
  129. if ("failed_promotions" == $schemeField){
  130. $needSkip = false;
  131. $this->failed_promotions = array();
  132. $_size1 = 0;
  133. $input->readListBegin();
  134. while(true){
  135. try{
  136. $elem1 = null;
  137. $elem1 = new \vipapis\delivery\FailedPromotionInfo();
  138. $elem1->read($input);
  139. $this->failed_promotions[$_size1++] = $elem1;
  140. }
  141. catch(\Exception $e){
  142. break;
  143. }
  144. }
  145. $input->readListEnd();
  146. }
  147. if ("date" == $schemeField){
  148. $needSkip = false;
  149. $input->readString($this->date);
  150. }
  151. if ("actual_market_price" == $schemeField){
  152. $needSkip = false;
  153. $input->readDouble($this->actual_market_price);
  154. }
  155. if($needSkip){
  156. \Osp\Protocol\ProtocolUtil::skip($input);
  157. }
  158. $input->readFieldEnd();
  159. }
  160. $input->readStructEnd();
  161. }
  162. public function write($output){
  163. $xfer = 0;
  164. $xfer += $output->writeStructBegin();
  165. if($this->order_id !== null) {
  166. $xfer += $output->writeFieldBegin('order_id');
  167. $xfer += $output->writeString($this->order_id);
  168. $xfer += $output->writeFieldEnd();
  169. }
  170. if($this->barcode !== null) {
  171. $xfer += $output->writeFieldBegin('barcode');
  172. $xfer += $output->writeString($this->barcode);
  173. $xfer += $output->writeFieldEnd();
  174. }
  175. if($this->amount !== null) {
  176. $xfer += $output->writeFieldBegin('amount');
  177. $xfer += $output->writeI32($this->amount);
  178. $xfer += $output->writeFieldEnd();
  179. }
  180. if($this->price !== null) {
  181. $xfer += $output->writeFieldBegin('price');
  182. $xfer += $output->writeDouble($this->price);
  183. $xfer += $output->writeFieldEnd();
  184. }
  185. if($this->brand_id !== null) {
  186. $xfer += $output->writeFieldBegin('brand_id');
  187. $xfer += $output->writeString($this->brand_id);
  188. $xfer += $output->writeFieldEnd();
  189. }
  190. if($this->promotions !== null) {
  191. $xfer += $output->writeFieldBegin('promotions');
  192. if (!is_array($this->promotions)){
  193. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  194. }
  195. $output->writeListBegin();
  196. foreach ($this->promotions as $iter0){
  197. if (!is_object($iter0)) {
  198. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  199. }
  200. $xfer += $iter0->write($output);
  201. }
  202. $output->writeListEnd();
  203. $xfer += $output->writeFieldEnd();
  204. }
  205. if($this->failed_promotions !== null) {
  206. $xfer += $output->writeFieldBegin('failed_promotions');
  207. if (!is_array($this->failed_promotions)){
  208. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  209. }
  210. $output->writeListBegin();
  211. foreach ($this->failed_promotions as $iter0){
  212. if (!is_object($iter0)) {
  213. throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
  214. }
  215. $xfer += $iter0->write($output);
  216. }
  217. $output->writeListEnd();
  218. $xfer += $output->writeFieldEnd();
  219. }
  220. if($this->date !== null) {
  221. $xfer += $output->writeFieldBegin('date');
  222. $xfer += $output->writeString($this->date);
  223. $xfer += $output->writeFieldEnd();
  224. }
  225. if($this->actual_market_price !== null) {
  226. $xfer += $output->writeFieldBegin('actual_market_price');
  227. $xfer += $output->writeDouble($this->actual_market_price);
  228. $xfer += $output->writeFieldEnd();
  229. }
  230. $xfer += $output->writeFieldStop();
  231. $xfer += $output->writeStructEnd();
  232. return $xfer;
  233. }
  234. }
  235. ?>