LiveApply.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * DSKMS多用户商城
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 数据层模型
  10. */
  11. class LiveApply extends BaseModel
  12. {
  13. public $page_info;
  14. public function getLiveApplyList($condition, $field = '*', $pagesize = 10, $order = 'live_apply_id desc')
  15. {
  16. if ($pagesize) {
  17. $result = Db::name('live_apply')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
  18. $this->page_info = $result;
  19. return $result->items();
  20. } else {
  21. $result = Db::name('live_apply')->field($field)->where($condition)->order($order)->select()->toArray();
  22. return $result;
  23. }
  24. }
  25. /**
  26. * 取单个内容
  27. * @access public
  28. * @author csdeshang
  29. * @param int $id 分类ID
  30. * @return array 数组类型的返回结果
  31. */
  32. public function getLiveApplyInfo($condition)
  33. {
  34. $result = Db::name('live_apply')->where($condition)->find();
  35. return $result;
  36. }
  37. /**
  38. * 新增
  39. * @access public
  40. * @author csdeshang
  41. * @param array $data 参数内容
  42. * @return bool 布尔类型的返回结果
  43. */
  44. public function addLiveApply($data)
  45. {
  46. $result = Db::name('live_apply')->insertGetId($data);
  47. return $result;
  48. }
  49. /**
  50. * 取商品
  51. * @access public
  52. * @author csdeshang
  53. * @param array $condition 条件
  54. * @return array 数组类型的返回结果
  55. */
  56. public function getLiveApplyGoodsList($condition)
  57. {
  58. $result = Db::name('live_apply_goods')->where($condition)->select()->toArray();
  59. return $result;
  60. }
  61. /**
  62. * 新增
  63. * @access public
  64. * @author csdeshang
  65. * @param array $data 参数内容
  66. * @return bool 布尔类型的返回结果
  67. */
  68. public function addLiveApplyGoodsAll($data)
  69. {
  70. $result = Db::name('live_apply_goods')->insertAll($data);
  71. return $result;
  72. }
  73. /**
  74. * 更新信息
  75. * @access public
  76. * @author csdeshang
  77. * @param array $data 数据
  78. * @param array $condition 条件
  79. * @return bool
  80. */
  81. public function editLiveApply($data, $condition)
  82. {
  83. $result = Db::name('live_apply')->where($condition)->update($data);
  84. return $result;
  85. }
  86. /**
  87. * 删除分类
  88. * @access public
  89. * @author csdeshang
  90. * @param int $condition 记录ID
  91. * @return bool
  92. */
  93. public function delLiveApply($condition)
  94. {
  95. return Db::name('live_apply')->where($condition)->delete();
  96. }
  97. function getPushUrl($streamName, $time)
  98. {
  99. if (config('ds_config.video_type') == 'aliyun') {
  100. $domain = config('ds_config.aliyun_live_push_domain');
  101. $key = config('ds_config.aliyun_live_push_key');
  102. $rand = rand(10000, 99999);
  103. $ext_str = '?auth_key=' . $time . '-' . $rand . '-0-' . md5('/live/' . $streamName . '-' . $time . '-' . $rand . '-0-' . $key);
  104. } else {
  105. $domain = config('ds_config.live_push_domain');
  106. $key = config('ds_config.live_push_key');
  107. $txTime = strtoupper(base_convert($time, 10, 16));
  108. $txSecret = md5($key . $streamName . $txTime);
  109. $ext_str = "?" . http_build_query(array(
  110. "txSecret" => $txSecret,
  111. "txTime" => $txTime
  112. ));
  113. }
  114. return "rtmp://" . $domain . "/live/" . $streamName . (isset($ext_str) ? $ext_str : "");
  115. }
  116. function getPlayUrl($streamName, $time, $rtmp = false)
  117. {
  118. if (config('ds_config.video_type') == 'aliyun') {
  119. $domain = config('ds_config.aliyun_live_play_domain');
  120. $key = config('ds_config.aliyun_live_play_key');
  121. $rand = rand(10000, 99999);
  122. $ext_str = '?auth_key=' . $time . '-' . $rand . '-0-' . md5('/live/' . $streamName . '.m3u8' . '-' . $time . '-' . $rand . '-0-' . $key);
  123. } else {
  124. $domain = config('ds_config.live_play_domain');
  125. }
  126. if ($rtmp) {
  127. return 'rtmp://' . $domain . '/live/' . $streamName . (isset($ext_str) ? $ext_str : "");
  128. } else {
  129. return HTTP_TYPE . $domain . '/live/' . $streamName . '.m3u8' . (isset($ext_str) ? $ext_str : "");
  130. }
  131. }
  132. }