Channel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Channel.php UTF-8
  4. * Channel信息
  5. *
  6. * @date : 2018/1/19 15:27
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\request;
  13. use ads\Agent;
  14. use huo\logic\agent\AgentGameLogic;
  15. class Channel {
  16. private $ch = ''; /* 渠道编号 */
  17. private $sub_ch = ''; /* 子渠道编号 */
  18. private $agent_id = 0;
  19. private $agent_game = '';
  20. public function __construct($data = []) {
  21. if (!empty($data)) {
  22. $this->setData($data);
  23. }
  24. }
  25. /**
  26. * 设置数据
  27. *
  28. * @param array $data
  29. */
  30. public function setData($data = []) {
  31. if (empty($data)) {
  32. return;
  33. }
  34. $this->setAgentId(get_val($data, 'ch'));
  35. /*解析传入的agent_game*/
  36. $_agent_game = get_val($data, 'sub_ch');
  37. $_agent_game_id = (new Agent())->getIdByCode($_agent_game); //解析成功返回agent_game_id 解析不成功返回0
  38. if (!empty($_agent_game_id)) { //成功获取agent_game
  39. $_agent_game = (new AgentGameLogic())->getAgentGameById($_agent_game_id);
  40. }
  41. $this->setAgentGame($_agent_game);
  42. }
  43. /**
  44. * @return string
  45. */
  46. public function getCh() {
  47. return $this->ch;
  48. }
  49. /**
  50. * @param string $ch
  51. */
  52. public function setCh($ch) {
  53. $this->ch = $ch;
  54. }
  55. /**
  56. * @return string
  57. */
  58. public function getSubCh() {
  59. return $this->sub_ch;
  60. }
  61. /**
  62. * @param string $sub_ch
  63. */
  64. public function setSubCh($sub_ch) {
  65. $this->sub_ch = $sub_ch;
  66. }
  67. /**
  68. * @return int
  69. */
  70. public function getAgentId() {
  71. return $this->agent_id;
  72. }
  73. /**
  74. * @param int $agent_id
  75. */
  76. public function setAgentId($agent_id) {
  77. $this->agent_id = $agent_id;
  78. }
  79. /**
  80. * @return string
  81. */
  82. public function getAgentGame() {
  83. return $this->agent_game;
  84. }
  85. /**
  86. * @param string $agent_game
  87. */
  88. public function setAgentGame($agent_game) {
  89. $this->agent_game = $agent_game;
  90. }
  91. public function toArray() {
  92. // TODO: wuyonghong 2018/4/24 添加Array
  93. return [];
  94. }
  95. }