Promotion.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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\finance;
  9. class Promotion {
  10. static $_TSPEC;
  11. public $promotion_type = null;
  12. public $promotion_name = null;
  13. public $promotion_description = null;
  14. public $vendor_ratio = null;
  15. public $discount_total_amount = null;
  16. public $discount_vendor_amount = null;
  17. public function __construct($vals=null){
  18. if (!isset(self::$_TSPEC)){
  19. self::$_TSPEC = array(
  20. 1 => array(
  21. 'var' => 'promotion_type'
  22. ),
  23. 2 => array(
  24. 'var' => 'promotion_name'
  25. ),
  26. 3 => array(
  27. 'var' => 'promotion_description'
  28. ),
  29. 4 => array(
  30. 'var' => 'vendor_ratio'
  31. ),
  32. 5 => array(
  33. 'var' => 'discount_total_amount'
  34. ),
  35. 6 => array(
  36. 'var' => 'discount_vendor_amount'
  37. ),
  38. );
  39. }
  40. if (is_array($vals)){
  41. if (isset($vals['promotion_type'])){
  42. $this->promotion_type = $vals['promotion_type'];
  43. }
  44. if (isset($vals['promotion_name'])){
  45. $this->promotion_name = $vals['promotion_name'];
  46. }
  47. if (isset($vals['promotion_description'])){
  48. $this->promotion_description = $vals['promotion_description'];
  49. }
  50. if (isset($vals['vendor_ratio'])){
  51. $this->vendor_ratio = $vals['vendor_ratio'];
  52. }
  53. if (isset($vals['discount_total_amount'])){
  54. $this->discount_total_amount = $vals['discount_total_amount'];
  55. }
  56. if (isset($vals['discount_vendor_amount'])){
  57. $this->discount_vendor_amount = $vals['discount_vendor_amount'];
  58. }
  59. }
  60. }
  61. public function getName(){
  62. return 'Promotion';
  63. }
  64. public function read($input){
  65. $input->readStructBegin();
  66. while(true){
  67. $schemeField = $input->readFieldBegin();
  68. if ($schemeField == null) break;
  69. $needSkip = true;
  70. if ("promotion_type" == $schemeField){
  71. $needSkip = false;
  72. $input->readString($this->promotion_type);
  73. }
  74. if ("promotion_name" == $schemeField){
  75. $needSkip = false;
  76. $input->readString($this->promotion_name);
  77. }
  78. if ("promotion_description" == $schemeField){
  79. $needSkip = false;
  80. $input->readString($this->promotion_description);
  81. }
  82. if ("vendor_ratio" == $schemeField){
  83. $needSkip = false;
  84. $input->readDouble($this->vendor_ratio);
  85. }
  86. if ("discount_total_amount" == $schemeField){
  87. $needSkip = false;
  88. $input->readDouble($this->discount_total_amount);
  89. }
  90. if ("discount_vendor_amount" == $schemeField){
  91. $needSkip = false;
  92. $input->readDouble($this->discount_vendor_amount);
  93. }
  94. if($needSkip){
  95. \Osp\Protocol\ProtocolUtil::skip($input);
  96. }
  97. $input->readFieldEnd();
  98. }
  99. $input->readStructEnd();
  100. }
  101. public function write($output){
  102. $xfer = 0;
  103. $xfer += $output->writeStructBegin();
  104. if($this->promotion_type !== null) {
  105. $xfer += $output->writeFieldBegin('promotion_type');
  106. $xfer += $output->writeString($this->promotion_type);
  107. $xfer += $output->writeFieldEnd();
  108. }
  109. if($this->promotion_name !== null) {
  110. $xfer += $output->writeFieldBegin('promotion_name');
  111. $xfer += $output->writeString($this->promotion_name);
  112. $xfer += $output->writeFieldEnd();
  113. }
  114. if($this->promotion_description !== null) {
  115. $xfer += $output->writeFieldBegin('promotion_description');
  116. $xfer += $output->writeString($this->promotion_description);
  117. $xfer += $output->writeFieldEnd();
  118. }
  119. if($this->vendor_ratio !== null) {
  120. $xfer += $output->writeFieldBegin('vendor_ratio');
  121. $xfer += $output->writeDouble($this->vendor_ratio);
  122. $xfer += $output->writeFieldEnd();
  123. }
  124. if($this->discount_total_amount !== null) {
  125. $xfer += $output->writeFieldBegin('discount_total_amount');
  126. $xfer += $output->writeDouble($this->discount_total_amount);
  127. $xfer += $output->writeFieldEnd();
  128. }
  129. if($this->discount_vendor_amount !== null) {
  130. $xfer += $output->writeFieldBegin('discount_vendor_amount');
  131. $xfer += $output->writeDouble($this->discount_vendor_amount);
  132. $xfer += $output->writeFieldEnd();
  133. }
  134. $xfer += $output->writeFieldStop();
  135. $xfer += $output->writeStructEnd();
  136. return $xfer;
  137. }
  138. }
  139. ?>