Order.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?php
  2. /**
  3. * Order.php UTF-8
  4. * 订单信息
  5. *
  6. * @date : 2018/1/19 14:59
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huolib\queue\request;
  13. class Order extends Request {
  14. private $order_id = '';
  15. private $payway = ''; /* 支付方式 */
  16. private $currency = 'CNY';
  17. private $cp_order_id = '';
  18. private $product_cnt = 1;
  19. private $product_id = '';
  20. private $product_price = 0.00;
  21. private $product_name = '';
  22. private $product_desc = '';
  23. private $status = 1;
  24. private $pay_time = 0; /* 支付时间 */
  25. public function __construct($data = []) {
  26. if (!empty($data)) {
  27. $this->setData($data);
  28. }
  29. }
  30. /**
  31. * 设置订单数据
  32. *
  33. * @param array $data
  34. */
  35. public function setData($data = []) {
  36. if (empty($data)) {
  37. return;
  38. }
  39. $this->setOrderId(get_val($data, 'order_id'));
  40. $this->setPayway(get_val($data, 'payway'));
  41. $this->setCurrency(get_val($data, 'currency', 'CNY'));
  42. $this->setCpOrderId(get_val($data, 'cp_order_id'));
  43. $this->setProductPrice(get_val($data, 'product_price', 0.00));
  44. $this->setProductId(get_val($data, 'product_id'));
  45. $this->setProductCnt(get_val($data, 'product_cnt', 1));
  46. $this->setProductName(get_val($data, 'product_name'));
  47. $this->setProductDesc(get_val($data, 'product_desc'));
  48. $this->setStatus(get_val($data, 'status'));
  49. }
  50. /**
  51. * 变量转数组
  52. *
  53. * @return array
  54. */
  55. public function toArray() {
  56. $_data = [
  57. 'order_id' => $this->getOrderId(),
  58. 'payway' => $this->getPayway(),
  59. 'currency' => $this->getCurrency(),
  60. 'cp_order_id' => $this->getCpOrderId(),
  61. 'product_price' => $this->getProductPrice(),
  62. 'product_id' => $this->getProductId(),
  63. 'product_cnt' => $this->getProductCnt(),
  64. 'product_name' => $this->getProductName(),
  65. 'product_desc' => $this->getProductPrice(),
  66. 'status' => $this->getStatus(),
  67. ];
  68. return $_data;
  69. }
  70. /**
  71. * 校验订单参数合法性
  72. */
  73. public function check() {
  74. // TODO: wuyonghong 2018/5/30 校验角色参数合法性
  75. return true;
  76. }
  77. /**
  78. * @return string
  79. */
  80. public function getOrderId() {
  81. return $this->order_id;
  82. }
  83. /**
  84. * @param string $order_id
  85. */
  86. public function setOrderId($order_id) {
  87. $this->order_id = $order_id;
  88. }
  89. /**
  90. * @return string
  91. */
  92. public function getCurrency() {
  93. return $this->currency;
  94. }
  95. /**
  96. * @param string $currency
  97. */
  98. public function setCurrency($currency) {
  99. $this->currency = $currency;
  100. }
  101. /**
  102. * @return string
  103. */
  104. public function getCpOrderId() {
  105. return $this->cp_order_id;
  106. }
  107. /**
  108. * @param string $cp_order_id
  109. */
  110. public function setCpOrderId($cp_order_id) {
  111. $this->cp_order_id = $cp_order_id;
  112. }
  113. /**
  114. * @return float
  115. */
  116. public function getProductPrice() {
  117. return $this->product_price;
  118. }
  119. /**
  120. * @param float $product_price
  121. */
  122. public function setProductPrice($product_price) {
  123. $this->product_price = $product_price;
  124. }
  125. /**
  126. * @return string
  127. */
  128. public function getProductId() {
  129. return $this->product_id;
  130. }
  131. /**
  132. * @param string $product_id
  133. */
  134. public function setProductId($product_id) {
  135. $this->product_id = $product_id;
  136. }
  137. /**
  138. * @return int
  139. */
  140. public function getProductCnt() {
  141. return $this->product_cnt;
  142. }
  143. /**
  144. * @param int $product_cnt
  145. */
  146. public function setProductCnt($product_cnt) {
  147. $this->product_cnt = $product_cnt;
  148. }
  149. /**
  150. * @return string
  151. */
  152. public function getProductName() {
  153. return $this->product_name;
  154. }
  155. /**
  156. * @param string $product_name
  157. */
  158. public function setProductName($product_name) {
  159. $this->product_name = $product_name;
  160. }
  161. /**
  162. * @return string
  163. */
  164. public function getProductDesc() {
  165. return $this->product_desc;
  166. }
  167. /**
  168. * @param string $product_desc
  169. */
  170. public function setProductDesc($product_desc) {
  171. $this->product_desc = $product_desc;
  172. }
  173. /**
  174. * @return string
  175. */
  176. public function getPayway() {
  177. return $this->payway;
  178. }
  179. /**
  180. * @param string $payway
  181. */
  182. public function setPayway($payway) {
  183. $this->payway = $payway;
  184. }
  185. /**
  186. * @return int
  187. */
  188. public function getStatus() {
  189. return $this->status;
  190. }
  191. /**
  192. * @param int $status
  193. */
  194. public function setStatus($status) {
  195. $this->status = $status;
  196. }
  197. /**
  198. * @return int
  199. */
  200. public function getPayTime() {
  201. return $this->pay_time;
  202. }
  203. /**
  204. * @param int $pay_time
  205. */
  206. public function setPayTime($pay_time) {
  207. $this->pay_time = $pay_time;
  208. }
  209. }