LiveApply.php 4.8 KB

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