LiveApply.php 4.7 KB

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