Device.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <?php
  2. /**
  3. * Device.php UTF-8
  4. * 设备信息
  5. *
  6. * @date : 2018/1/19 15:30
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huolib\queue\request;
  13. class Device extends Request {
  14. private $device_id = ''; /* 设备唯一号 安卓为ime */
  15. private $mac = ''; /* 设备的mac */
  16. private $ip = ''; /* 设备网络IP地址 */
  17. private $brand = ''; /* 设备的品牌 */
  18. private $model = ''; /* 机型 */
  19. private $os = ''; /* 设备的平台(android、 */
  20. private $os_version = ''; /* 操作系统版本 */
  21. private $screen = ''; /* 分辨率 */
  22. private $net = ''; /* 设备的联网方式 3G,4G */
  23. private $imsi = ''; /* 设备的imsi */
  24. private $longitude = ''; /* 经度 */
  25. private $latitude = ''; /* 纬度 */
  26. private $userua = ''; /* 用户代理 */
  27. public function __construct($data = []) {
  28. if (!empty($data)) {
  29. $this->setData($data);
  30. }
  31. }
  32. /**
  33. * 设置数据
  34. *
  35. * @param array $data
  36. */
  37. public function setData($data = []) {
  38. if (empty($data)) {
  39. return;
  40. }
  41. $this->setDeviceId(get_val($data, 'device_id', ''));
  42. $this->setMac(get_val($data, 'mac', ''));
  43. $this->setIp(get_val($data, 'ip', ''));
  44. $this->setBrand(get_val($data, 'brand', ''));
  45. $this->setModel(get_val($data, 'model', ''));
  46. $this->setOs(get_val($data, 'os', ''));
  47. $this->setOsVersion(get_val($data, 'os_version', ''));
  48. $this->setScreen(get_val($data, 'screen', ''));
  49. $this->setNet(get_val($data, 'net', ''));
  50. $this->setImsi(get_val($data, 'imsi', ''));
  51. $this->setLongitude(get_val($data, 'longitude', ''));
  52. $this->setLatitude(get_val($data, 'latitude', ''));
  53. $this->setUserua(get_val($data, 'userua', ''));
  54. }
  55. /**
  56. * 变量转数组
  57. *
  58. * @return array
  59. */
  60. public function toArray() {
  61. $_data = [
  62. 'device_id' => $this->getDeviceId(),
  63. 'mac' => $this->getMac(),
  64. 'ip' => $this->getIp(),
  65. 'brand' => $this->getBrand(),
  66. 'model' => $this->getModel(),
  67. 'os' => $this->getOs(),
  68. 'os_version' => $this->getOsVersion(),
  69. 'screen' => $this->getScreen(),
  70. 'net' => $this->getNet(),
  71. 'imsi' => $this->getImsi(),
  72. 'longitude' => $this->getLongitude(),
  73. 'latitude' => $this->getLatitude(),
  74. 'userua' => $this->getUserua(),
  75. ];
  76. return $_data;
  77. }
  78. /**
  79. * 校验参数合法性
  80. */
  81. public function check() {
  82. // TODO: wuyonghong 2018/5/30 校验设备参数合法性
  83. return true;
  84. }
  85. /**
  86. * @return string
  87. */
  88. public function getDeviceId() {
  89. return $this->device_id;
  90. }
  91. /**
  92. * @param string $device_id
  93. */
  94. public function setDeviceId($device_id) {
  95. $this->device_id = $device_id;
  96. }
  97. /**
  98. * @return string
  99. */
  100. public function getMac() {
  101. return $this->mac;
  102. }
  103. /**
  104. * @param string $mac
  105. */
  106. public function setMac($mac) {
  107. $this->mac = $mac;
  108. }
  109. /**
  110. * @return string
  111. */
  112. public function getIp() {
  113. return $this->ip;
  114. }
  115. /**
  116. * @param string $ip
  117. */
  118. public function setIp($ip) {
  119. $this->ip = $ip;
  120. }
  121. /**
  122. * @return string
  123. */
  124. public function getBrand() {
  125. return $this->brand;
  126. }
  127. /**
  128. * @param string $brand
  129. */
  130. public function setBrand($brand) {
  131. $this->brand = $brand;
  132. }
  133. /**
  134. * @return string
  135. */
  136. public function getModel() {
  137. return $this->model;
  138. }
  139. /**
  140. * @param string $model
  141. */
  142. public function setModel($model) {
  143. $this->model = $model;
  144. }
  145. /**
  146. * @return string
  147. */
  148. public function getOs() {
  149. return $this->os;
  150. }
  151. /**
  152. * @param string $os
  153. */
  154. public function setOs($os) {
  155. $this->os = $os;
  156. }
  157. /**
  158. * @return string
  159. */
  160. public function getOsVersion() {
  161. return $this->os_version;
  162. }
  163. /**
  164. * @param string $os_version
  165. */
  166. public function setOsVersion($os_version) {
  167. $this->os_version = $os_version;
  168. }
  169. /**
  170. * @return string
  171. */
  172. public function getScreen() {
  173. return $this->screen;
  174. }
  175. /**
  176. * @param string $screen
  177. */
  178. public function setScreen($screen) {
  179. $this->screen = $screen;
  180. }
  181. /**
  182. * @return string
  183. */
  184. public function getNet() {
  185. return $this->net;
  186. }
  187. /**
  188. * @param string $net
  189. */
  190. public function setNet($net) {
  191. $this->net = $net;
  192. }
  193. /**
  194. * @return string
  195. */
  196. public function getImsi() {
  197. return $this->imsi;
  198. }
  199. /**
  200. * @param string $imsi
  201. */
  202. public function setImsi($imsi) {
  203. $this->imsi = $imsi;
  204. }
  205. /**
  206. * @return string
  207. */
  208. public function getLongitude() {
  209. return $this->longitude;
  210. }
  211. /**
  212. * @param string $longitude
  213. */
  214. public function setLongitude($longitude) {
  215. $this->longitude = $longitude;
  216. }
  217. /**
  218. * @return string
  219. */
  220. public function getLatitude() {
  221. return $this->latitude;
  222. }
  223. /**
  224. * @param string $latitude
  225. */
  226. public function setLatitude($latitude) {
  227. $this->latitude = $latitude;
  228. }
  229. /**
  230. * @return string
  231. */
  232. public function getUserua() {
  233. return $this->userua;
  234. }
  235. /**
  236. * @param string $userua
  237. */
  238. public function setUserua($userua) {
  239. $this->userua = $userua;
  240. }
  241. }