LiveApply.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Db;
  4. /**
  5. * ============================================================================
  6. * DSKMS多用户商城
  7. * ============================================================================
  8. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  9. * 网站地址: http://www.csdeshang.com
  10. * ----------------------------------------------------------------------------
  11. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  12. * 不允许对程序代码以任何形式任何目的的再发布。
  13. * ============================================================================
  14. * 数据层模型
  15. */
  16. class LiveApply extends BaseModel {
  17. public $page_info;
  18. public function getLiveApplyList($condition, $field = '*', $pagesize=10, $order = 'live_apply_id desc') {
  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. $result = Db::name('live_apply')->where($condition)->find();
  37. return $result;
  38. }
  39. /**
  40. * 新增
  41. * @access public
  42. * @author csdeshang
  43. * @param array $data 参数内容
  44. * @return bool 布尔类型的返回结果
  45. */
  46. public function addLiveApply($data) {
  47. $result = Db::name('live_apply')->insertGetId($data);
  48. return $result;
  49. }
  50. /**
  51. * 取商品
  52. * @access public
  53. * @author csdeshang
  54. * @param array $condition 条件
  55. * @return array 数组类型的返回结果
  56. */
  57. public function getLiveApplyGoodsList($condition) {
  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. $result = Db::name('live_apply_goods')->insertAll($data);
  70. return $result;
  71. }
  72. /**
  73. * 更新信息
  74. * @access public
  75. * @author csdeshang
  76. * @param array $data 数据
  77. * @param array $condition 条件
  78. * @return bool
  79. */
  80. public function editLiveApply($data, $condition) {
  81. $result = Db::name('live_apply')->where($condition)->update($data);
  82. return $result;
  83. }
  84. /**
  85. * 删除分类
  86. * @access public
  87. * @author csdeshang
  88. * @param int $condition 记录ID
  89. * @return bool
  90. */
  91. public function delLiveApply($condition) {
  92. return Db::name('live_apply')->where($condition)->delete();
  93. }
  94. function getPushUrl($streamName, $time) {
  95. if (config('ds_config.video_type') == 'aliyun') {
  96. $domain=config('ds_config.aliyun_live_push_domain');
  97. $key=config('ds_config.aliyun_live_push_key');
  98. $rand=rand(10000,99999);
  99. $ext_str='?auth_key='.$time.'-'.$rand.'-0-'.md5('/live/'.$streamName.'-'.$time.'-'.$rand.'-0-'.$key);
  100. } else {
  101. $domain=config('ds_config.live_push_domain');
  102. $key=config('ds_config.live_push_key');
  103. $txTime = strtoupper(base_convert($time, 10, 16));
  104. $txSecret = md5($key . $streamName . $txTime);
  105. $ext_str = "?" . http_build_query(array(
  106. "txSecret" => $txSecret,
  107. "txTime" => $txTime
  108. ));
  109. }
  110. return "rtmp://" . $domain . "/live/" . $streamName . (isset($ext_str) ? $ext_str : "");
  111. }
  112. function getPlayUrl($streamName, $time,$rtmp=false){
  113. if (config('ds_config.video_type') == 'aliyun') {
  114. $domain=config('ds_config.aliyun_live_play_domain');
  115. $key=config('ds_config.aliyun_live_play_key');
  116. $rand=rand(10000,99999);
  117. $ext_str='?auth_key='.$time.'-'.$rand.'-0-'.md5('/live/'.$streamName.'.m3u8'.'-'.$time.'-'.$rand.'-0-'.$key);
  118. }else{
  119. $domain=config('ds_config.live_play_domain');
  120. }
  121. if($rtmp){
  122. return 'rtmp://'.$domain.'/live/'.$streamName . (isset($ext_str) ? $ext_str : "");
  123. }else{
  124. return HTTP_TYPE.$domain.'/live/'.$streamName.'.m3u8' . (isset($ext_str) ? $ext_str : "");
  125. }
  126. }
  127. }