Device.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?php
  2. /**
  3. * Device.php UTF-8
  4. * device信息
  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 huo\controller\request;
  13. use huolib\constant\GameConst;
  14. class Device {
  15. private $device_id = ''; /* 设备唯一号 安卓为ime */
  16. private $mac = ''; /* 设备的mac 苹果为idfv */
  17. private $ip = ''; /* 设备网络IP地址 */
  18. private $brand = ''; /* 设备的品牌 */
  19. private $model = ''; /* 机型 */
  20. private $os = ''; /* 设备的平台(android、 */
  21. private $os_version = ''; /* 操作系统版本 */
  22. private $screen = ''; /* 分辨率 */
  23. private $net = ''; /* 设备的联网方式 3G,4G */
  24. private $imsi = ''; /* 设备的imsi */
  25. private $longitude = ''; /* 经度 */
  26. private $latitude = ''; /* 纬度 */
  27. private $userua = ''; /* 用户代理 */
  28. private $open_cnt = 0; /* 用户打开应用次数 */
  29. private $from = GameConst::GAME_ANDROID; /* 打开应用来源 3 ANDROID、4 IOS、5 H5 */
  30. private $from_device = '';
  31. private $device_type = '';
  32. public function __construct($data = []) {
  33. if (!empty($data)) {
  34. $this->setData($data);
  35. }
  36. }
  37. /**
  38. * 设置数据
  39. *
  40. * @param array $data
  41. */
  42. public function setData($data = []) {
  43. if (empty($data)) {
  44. return;
  45. }
  46. $this->setDeviceId(get_val($data, 'device_id'));
  47. $this->setMac(get_val($data, 'mac'));
  48. $this->setIp(get_val($data, 'ip'));
  49. $this->setBrand(get_val($data, 'brand'));
  50. $this->setModel(get_val($data, 'model'));
  51. $this->setOs(get_val($data, 'os'));
  52. $this->setOsVersion(get_val($data, 'os_version'));
  53. $this->setScreen(get_val($data, 'screen'));
  54. $this->setNet(get_val($data, 'net'));
  55. $this->setImsi(get_val($data, 'imsi'));
  56. $this->setLongitude(get_val($data, 'longitude'));
  57. $this->setLatitude(get_val($data, 'latitude'));
  58. $this->setUserua(get_val($data, 'userua'));
  59. }
  60. /**
  61. * @return string
  62. */
  63. public function getDeviceId() {
  64. return $this->device_id;
  65. }
  66. /**
  67. * @param string $device_id
  68. */
  69. public function setDeviceId($device_id) {
  70. $this->device_id = $device_id;
  71. }
  72. /**
  73. * 苹果为idfv
  74. *
  75. * @return string
  76. */
  77. public function getMac() {
  78. return $this->mac;
  79. }
  80. /**
  81. * @param string $mac
  82. */
  83. public function setMac($mac) {
  84. $this->mac = $mac;
  85. }
  86. /**
  87. * @return string
  88. */
  89. public function getIp() {
  90. return $this->ip;
  91. }
  92. /**
  93. * @param string $ip
  94. */
  95. public function setIp($ip) {
  96. $this->ip = $ip;
  97. }
  98. /**
  99. * @return string
  100. */
  101. public function getBrand() {
  102. return $this->brand;
  103. }
  104. /**
  105. * @param string $brand
  106. */
  107. public function setBrand($brand) {
  108. $this->brand = $brand;
  109. }
  110. /**
  111. * @return string
  112. */
  113. public function getModel() {
  114. return $this->model;
  115. }
  116. /**
  117. * @param string $model
  118. */
  119. public function setModel($model) {
  120. $this->model = $model;
  121. }
  122. /**
  123. * @return string
  124. */
  125. public function getOs() {
  126. return $this->os;
  127. }
  128. /**
  129. * @param string $os
  130. */
  131. public function setOs($os) {
  132. $this->os = $os;
  133. }
  134. /**
  135. * @return string
  136. */
  137. public function getOsVersion() {
  138. return $this->os_version;
  139. }
  140. /**
  141. * @param string $os_version
  142. */
  143. public function setOsVersion($os_version) {
  144. $this->os_version = $os_version;
  145. }
  146. /**
  147. * @return string
  148. */
  149. public function getScreen() {
  150. return $this->screen;
  151. }
  152. /**
  153. * @param string $screen
  154. */
  155. public function setScreen($screen) {
  156. $this->screen = $screen;
  157. }
  158. /**
  159. * @return string
  160. */
  161. public function getNet() {
  162. return $this->net;
  163. }
  164. /**
  165. * @param string $net
  166. */
  167. public function setNet($net) {
  168. $this->net = $net;
  169. }
  170. /**
  171. * @return string
  172. */
  173. public function getImsi() {
  174. return $this->imsi;
  175. }
  176. /**
  177. * @param string $imsi
  178. */
  179. public function setImsi($imsi) {
  180. $this->imsi = $imsi;
  181. }
  182. /**
  183. * @return string
  184. */
  185. public function getLongitude() {
  186. return $this->longitude;
  187. }
  188. /**
  189. * @param string $longitude
  190. */
  191. public function setLongitude($longitude) {
  192. $this->longitude = $longitude;
  193. }
  194. /**
  195. * @return string
  196. */
  197. public function getLatitude() {
  198. return $this->latitude;
  199. }
  200. /**
  201. * @param string $latitude
  202. */
  203. public function setLatitude($latitude) {
  204. $this->latitude = $latitude;
  205. }
  206. /**
  207. * @return string
  208. */
  209. public function getUserua() {
  210. return $this->userua;
  211. }
  212. /**
  213. * @param string $userua
  214. */
  215. public function setUserua($userua) {
  216. $this->userua = $userua;
  217. }
  218. /**
  219. * @return int
  220. */
  221. public function getOpenCnt() {
  222. return $this->open_cnt;
  223. }
  224. /**
  225. * @param int $open_cnt
  226. */
  227. public function setOpenCnt($open_cnt) {
  228. $this->open_cnt = $open_cnt;
  229. }
  230. /**
  231. * @return int
  232. */
  233. public function getFrom() {
  234. return $this->from;
  235. }
  236. /**
  237. * @param int $from
  238. */
  239. public function setFrom($from) {
  240. $this->from = $from;
  241. }
  242. /**
  243. * @return string
  244. */
  245. public function getFromDevice() {
  246. return $this->from_device;
  247. }
  248. /**
  249. * @param string $from_device
  250. */
  251. public function setFromDevice($from_device) {
  252. $this->from_device = $from_device;
  253. }
  254. public function toArray() {
  255. $_data = [
  256. 'device_id' => $this->getDeviceId(),
  257. 'mac' => $this->getMac(),
  258. 'ip' => $this->getIp(),
  259. 'brand' => $this->getBrand(),
  260. 'model' => $this->getModel(),
  261. 'os' => $this->getOs(),
  262. 'os_version' => $this->getOsVersion(),
  263. 'screen' => $this->getScreen(),
  264. 'net' => $this->getNet(),
  265. 'imsi' => $this->getImsi(),
  266. 'longitude' => $this->getLongitude(),
  267. 'latitude' => $this->getLatitude(),
  268. 'userua' => $this->getUserua(),
  269. 'open_cnt' => $this->getOpenCnt(),
  270. 'from' => $this->getFrom(),
  271. 'from_device' => $this->getFromDevice(),
  272. ];
  273. return $_data;
  274. }
  275. /**
  276. * @return string
  277. */
  278. public function getDeviceType() {
  279. return $this->device_type;
  280. }
  281. /**
  282. * @param string $device_type
  283. */
  284. public function setDeviceType($device_type) {
  285. $this->device_type = $device_type;
  286. }
  287. }