Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
quxiu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冷斌
quxiu
Commits
3eca25a4
Commit
3eca25a4
authored
Apr 14, 2020
by
刘海龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://132.232.91.252:9999/ice/quxiu
parents
25d5e62e
32efbcec
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
87 deletions
+118
-87
api/Appapi/Api/Linkmic.php
+49
-48
api/Appapi/Api/User.php
+3
-2
api/Appapi/Domain/User.php
+2
-2
api/Appapi/Model/Home.php
+3
-3
api/Appapi/Model/Live.php
+20
-25
api/Appapi/Model/User.php
+41
-7
No files found.
api/Appapi/Api/Linkmic.php
View file @
3eca25a4
...
...
@@ -9,31 +9,31 @@ class Api_Linkmic extends PhalApi_Api {
'token'
=>
array
(
'name'
=>
'token'
,
'type'
=>
'string'
,
'require'
=>
true
,
'desc'
=>
'用户Token'
),
'ismic'
=>
array
(
'name'
=>
'ismic'
,
'type'
=>
'int'
,
'require'
=>
true
,
'desc'
=>
'连麦开关,0关1开'
),
),
'isMic'
=>
array
(
'uid'
=>
array
(
'name'
=>
'uid'
,
'type'
=>
'int'
,
'min'
=>
1
,
'require'
=>
true
,
'desc'
=>
'用户ID'
),
'liveuid'
=>
array
(
'name'
=>
'liveuid'
,
'type'
=>
'int'
,
'min'
=>
1
,
'require'
=>
true
,
'desc'
=>
'主播ID'
),
),
'RequestLVBAddrForLinkMic'
=>
array
(
'uid'
=>
array
(
'name'
=>
'uid'
,
'type'
=>
'int'
,
'min'
=>
1
,
'require'
=>
true
,
'desc'
=>
'用户ID'
),
),
'RequestPlayUrlWithSignForLinkMic'
=>
array
(
'RequestPlayUrlWithSignForLinkMic'
=>
array
(
'uid'
=>
array
(
'name'
=>
'uid'
,
'type'
=>
'int'
,
'min'
=>
1
,
'require'
=>
true
,
'desc'
=>
'用户ID'
),
'originStreamUrl'
=>
array
(
'name'
=>
'originStreamUrl'
,
'type'
=>
'string'
,
'require'
=>
true
,
'desc'
=>
'流地址'
),
),
'MergeVideoStream'
=>
array
(
'MergeVideoStream'
=>
array
(
'uid'
=>
array
(
'name'
=>
'uid'
,
'type'
=>
'int'
,
'min'
=>
1
,
'require'
=>
true
,
'desc'
=>
'用户ID'
),
'mergeparams'
=>
array
(
'name'
=>
'mergeparams'
,
'type'
=>
'string'
,
'require'
=>
true
,
'desc'
=>
'混流参数'
),
),
);
}
/**
* 设置连麦开关
* @desc 用于 用户设置当前直播的连麦开关
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string info[].pushurl 推流地址
* @return string info[].timestamp 当前时间
* @return string info[].playurl 播流地址
...
...
@@ -42,7 +42,7 @@ class Api_Linkmic extends PhalApi_Api {
public
function
setMic
()
{
$rs
=
array
(
'code'
=>
0
,
'msg'
=>
''
,
'info'
=>
array
());
$uid
=
$this
->
uid
;
$uid
=
$this
->
uid
;
$token
=
checkNull
(
$this
->
token
);
$ismic
=
checkNull
(
$this
->
ismic
);
...
...
@@ -52,40 +52,40 @@ class Api_Linkmic extends PhalApi_Api {
$rs
[
'msg'
]
=
'您的登陆状态失效,请重新登陆!'
;
return
$rs
;
}
$domain
=
new
Domain_Linkmic
();
$result
=
$domain
->
setMic
(
$uid
,
$ismic
);
$rs
[
'msg'
]
=
'设置成功'
;
return
$rs
;
}
return
$rs
;
}
/**
* 判断主播是否开启连麦
* @desc 用于 判断主播是否开启连麦
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string msg 提示信息
*/
public
function
isMic
()
{
$rs
=
array
(
'code'
=>
0
,
'msg'
=>
''
,
'info'
=>
array
());
$uid
=
checkNull
(
$this
->
uid
);
$liveuid
=
checkNull
(
$this
->
liveuid
);
$configpri
=
getConfigPri
();
$mic_limit
=
$configpri
[
'mic_limit'
];
$userinfo
=
getUserinfo
(
$uid
);
if
(
$mic_limit
&&
$userinfo
[
'level'
]
<
$mic_limit
){
$rs
[
'code'
]
=
1002
;
$rs
[
'msg'
]
=
"用户等级达到
{
$mic_limit
}
级才可与主播连麦哦~"
;
return
$rs
;
}
$domain
=
new
Domain_Linkmic
();
$result
=
$domain
->
isMic
(
$liveuid
);
...
...
@@ -95,14 +95,14 @@ class Api_Linkmic extends PhalApi_Api {
return
$rs
;
}
return
$rs
;
return
$rs
;
}
/**
* 获取连麦推拉流地址
* @desc 用于 获取连麦推拉流地址
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string info[].pushurl 推流地址
* @return string info[].timestamp 当前时间
* @return string info[].playurl 播流地址
...
...
@@ -112,7 +112,7 @@ class Api_Linkmic extends PhalApi_Api {
$rs
=
array
(
'code'
=>
0
,
'msg'
=>
''
,
'info'
=>
array
());
$uid
=
$this
->
uid
;
$configpri
=
getConfigPri
();
$configpri
=
getConfigPri
();
$nowtime
=
time
();
$stream
=
$uid
.
'_'
.
$nowtime
;
$live_sdk
=
$configpri
[
'live_sdk'
];
//live_sdk 0表示金山SDK 1表示腾讯SDK
...
...
@@ -124,7 +124,7 @@ class Api_Linkmic extends PhalApi_Api {
$now_time2
=
$nowtime
+
3
*
60
*
60
;
$txTime
=
dechex
(
$now_time2
);
$live_code
=
$stream
;
$txSecret
=
md5
(
$push_url_key
.
$live_code
.
$txTime
);
...
...
@@ -133,7 +133,7 @@ class Api_Linkmic extends PhalApi_Api {
$push_url
=
"rtmp://"
.
$push
.
"/live/"
.
$live_code
.
"?bizid="
.
$bizid
.
$safe_url
;
$play_url
=
"rtmp://"
.
$pull
.
"/live/"
.
$live_code
.
"?bizid="
.
$bizid
.
$safe_url
;
}
else
if
(
$configpri
[
'cdn_switch'
]
==
5
)
{
$wyinfo
=
PrivateKeyA
(
'rtmp'
,
$stream
,
1
);
...
...
@@ -144,49 +144,49 @@ class Api_Linkmic extends PhalApi_Api {
$push_url
=
PrivateKeyA
(
'rtmp'
,
$stream
,
1
);
$play_url
=
PrivateKeyA
(
'rtmp'
,
$stream
,
0
);
}
$info
=
array
(
"pushurl"
=>
$push_url
,
"timestamp"
=>
$nowtime
,
"timestamp"
=>
$nowtime
,
"playurl"
=>
$play_url
);
$rs
[
'info'
][
0
]
=
$info
;
return
$rs
;
}
return
$rs
;
}
/**
* 获取鉴权流地址
* @desc 用于鉴权流地址
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string info[].streamUrlWithSignature 鉴权地址
* @return string info[].timestamp 当前时间
* @return string msg 提示信息
*/
public
function
RequestPlayUrlWithSignForLinkMic
()
{
$rs
=
array
(
'code'
=>
0
,
'msg'
=>
''
,
'info'
=>
array
());
$uid
=
$this
->
uid
;
$originalUrl
=
checkNull
(
$this
->
originStreamUrl
);
$configpri
=
getConfigPri
();
$configpri
=
getConfigPri
();
$bizid
=
$configpri
[
'tx_bizid'
];
$push_url_key
=
$configpri
[
'tx_push_key'
];
$list1
=
preg_split
(
'/\?/'
,
$originalUrl
);
$originalUrl
=
$list1
[
0
];
$list
=
preg_split
(
'/\//'
,
$originalUrl
);
$url
=
preg_split
(
'/\./'
,
end
(
$list
));
$now_time
=
time
();
$now_time
=
$now_time
+
3
*
60
*
60
;
$txTime
=
dechex
(
$now_time
);
$txSecret
=
md5
(
$push_url_key
.
$url
[
0
]
.
$txTime
);
$safe_url
=
$originalUrl
.
"?txSecret="
.
$txSecret
.
"&txTime="
.
$txTime
.
"&bizid="
.
$bizid
;
$safe_url
=
str_replace
(
".flv"
,
''
,
$safe_url
);
...
...
@@ -194,34 +194,34 @@ class Api_Linkmic extends PhalApi_Api {
$info
=
array
(
"streamUrlWithSignature"
=>
$safe_url
,
"timestamp"
=>
$now_time
,
"timestamp"
=>
$now_time
,
);
$rs
[
'info'
][
0
]
=
$info
;
return
$rs
;
}
return
$rs
;
}
/**
* 连麦混流
* @desc 用于连麦混流
* @return int code 操作码,0表示成功
* @return array info
* @return array info
* @return string msg 提示信息
*/
public
function
MergeVideoStream
()
{
$rs
=
array
(
'code'
=>
0
,
'msg'
=>
''
,
'info'
=>
array
());
$uid
=
$this
->
uid
;
$mergeparams
=
html_entity_decode
(
$this
->
mergeparams
);
$configpri
=
getConfigPri
();
$configpri
=
getConfigPri
();
$appid
=
$configpri
[
'tx_appid'
];
$bizid
=
$configpri
[
'tx_bizid'
];
$push_url_key
=
$configpri
[
'tx_push_key'
];
$call_back_key
=
$configpri
[
'tx_api_key'
];
$t
=
time
()
+
60
;
$sign
=
$md5_val
=
md5
(
$call_back_key
.
strval
(
$t
));;
...
...
@@ -231,8 +231,8 @@ class Api_Linkmic extends PhalApi_Api {
$url
=
'http://fcgi.video.qcloud.com/common_access?appid='
.
$appid
.
'&interface=Mix_StreamV2&t='
.
$t
.
'&sign='
.
$sign
;
$ch
=
curl_init
();
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 跳过证书检查
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
false
);
// 从证书中检查SSL加密算法是否存在
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 跳过证书检查
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
false
);
// 从证书中检查SSL加密算法是否存在
@
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
@
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
@
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
...
...
@@ -244,6 +244,7 @@ class Api_Linkmic extends PhalApi_Api {
);
@
$result
=
curl_exec
(
$ch
);
if
(
curl_errno
(
$ch
)){
//print curl_error($ch);
file_put_contents
(
'./MergeVideoStream.txt'
,
date
(
'y-m-d H:i:s'
)
.
' 提交参数信息 ch:'
.
json_encode
(
curl_error
(
$ch
))
.
"
\r\n
"
,
FILE_APPEND
);
...
...
@@ -258,7 +259,7 @@ class Api_Linkmic extends PhalApi_Api {
return
$rs
;
}
return
$rs
;
}
return
$rs
;
}
}
api/Appapi/Api/User.php
View file @
3eca25a4
...
...
@@ -90,6 +90,7 @@ class Api_User extends PhalApi_Api {
'uid'
=>
array
(
'name'
=>
'uid'
,
'type'
=>
'int'
,
'min'
=>
1
,
'require'
=>
true
,
'desc'
=>
'用户ID'
),
'token'
=>
array
(
'name'
=>
'token'
,
'type'
=>
'string'
,
'require'
=>
true
,
'desc'
=>
'用户token'
),
'id'
=>
array
(
'name'
=>
'id'
,
'type'
=>
'string'
,
'require'
=>
true
,
'desc'
=>
'id'
),
'source'
=>
array
(
'name'
=>
'source'
,
'type'
=>
'int'
,
'require'
=>
true
,
'desc'
=>
'类型,1主播,2邀请,3家族'
),
),
'setCash'
=>
array
(
...
...
@@ -920,7 +921,7 @@ class Api_User extends PhalApi_Api {
}
$domain
=
new
Domain_User
();
$info
=
$domain
->
rechange
(
$this
->
uid
,
$this
->
id
);
$info
=
$domain
->
rechange
(
$this
->
uid
,
$this
->
id
,
$this
->
source
);
if
(
$info
===
1
){
$rs
[
'code'
]
=
1001
;
...
...
@@ -930,7 +931,7 @@ class Api_User extends PhalApi_Api {
if
(
$info
===
2
){
$rs
[
'code'
]
=
1002
;
$rs
[
'msg'
]
=
'
积分
不足'
;
$rs
[
'msg'
]
=
'
魅力值
不足'
;
return
$rs
;
}
...
...
api/Appapi/Domain/User.php
View file @
3eca25a4
...
...
@@ -92,11 +92,11 @@ class Domain_User {
return
$rs
;
}
public
function
rechange
(
$uid
,
$id
)
{
public
function
rechange
(
$uid
,
$id
,
$source
)
{
$rs
=
array
();
$model
=
new
Model_User
();
$rs
=
$model
->
rechange
(
$uid
,
$id
);
$rs
=
$model
->
rechange
(
$uid
,
$id
,
$source
);
return
$rs
;
}
...
...
api/Appapi/Model/Home.php
View file @
3eca25a4
...
...
@@ -73,7 +73,7 @@ class Model_Home extends PhalApi_Model_NotORM {
$result
=
DI
()
->
notorm
->
users_live
->
select
(
"uid,thumb,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway"
)
->
where
(
$where
)
->
order
(
'hotvotes desc,starttime desc'
)
->
order
(
'hotvotes desc,
starttime desc'
)
->
limit
(
$start
,
$pnum
)
->
fetchAll
();
...
...
@@ -603,11 +603,11 @@ class Model_Home extends PhalApi_Model_NotORM {
public
function
getRecommend
(){
$configpri
=
getConfigPri
();
$where
=
"
isrecommend = '1' and islive= '1' and ishot='1'
"
;
$where
=
"
islive= '1'
"
;
$result
=
DI
()
->
notorm
->
users_live
->
select
(
"uid,thumb,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway"
)
->
where
(
$where
)
->
order
(
'starttime desc'
)
->
order
(
'
isrecommend desc,
starttime desc'
)
->
limit
(
50
)
->
fetchAll
();
...
...
api/Appapi/Model/Live.php
View file @
3eca25a4
...
...
@@ -857,12 +857,10 @@ class Model_Live extends PhalApi_Model_NotORM {
$anthor_total
=
floor
(
$anthor_total
*
$jackpotset
[
'luck_anchor'
]
*
0.01
);
}
/* 幸运礼物分成 */
/* 家族分成之后的金额 */
$anthor_total
=
setFamilyDivide
(
$liveuid
,
$anthor_total
);
//主播 经验
$get_gift
=
!
empty
(
$set
[
'get_gift'
])
?
$set
[
'get_gift'
]
:
0
;
$get_gift2
=
!
empty
(
$set
[
'get_gift2'
])
?
$set
[
'get_gift2'
]
:
0
;
...
...
@@ -871,7 +869,6 @@ class Model_Live extends PhalApi_Model_NotORM {
$get_gif3
=
(
int
)(
$total
/
$get_gift
);
$total3
+=
(
$get_gif3
*
$get_gift2
);
}
/* 更新直播 魅力值 累计魅力值 */
$istouid
=
DI
()
->
notorm
->
users
->
where
(
'id = ?'
,
$liveuid
)
...
...
@@ -894,8 +891,6 @@ class Model_Live extends PhalApi_Model_NotORM {
$insert
=
array
(
"type"
=>
$type
,
"action"
=>
$action
,
"uid"
=>
$uid
,
"touid"
=>
$liveuid
,
"giftid"
=>
$giftid
,
"giftcount"
=>
$giftcount
,
"totalcoin"
=>
$totalcoin
,
"showid"
=>
$showid
,
"mark"
=>
$giftinfo
[
'mark'
],
"addtime"
=>
$addtime
);
DI
()
->
notorm
->
users_coinrecord
->
insert
(
$insert
);
/* 更新主播热门 */
// if($giftinfo['mark']==1){
DI
()
->
notorm
->
users_live
...
...
@@ -986,26 +981,26 @@ class Model_Live extends PhalApi_Model_NotORM {
);
DI
()
->
notorm
->
users_coinrecord
->
insert
(
$insert
);
$luckcoin2
=
(
int
)(
$luckcoin
*
0.05
*
100
);
$luckcoin3
=
$luckcoin2
/
100
;
if
(
$luckcoin3
>
0
)
{
DI
()
->
notorm
->
users
->
where
(
'id = ?'
,
$liveuid
)
->
update
(
array
(
'votes'
=>
new
NotORM_Literal
(
"votes +
{
$luckcoin3
}
"
),
'votestotal'
=>
new
NotORM_Literal
(
"votestotal +
{
$luckcoin3
}
"
)
));
$insert
=
array
(
"type"
=>
'income'
,
"action"
=>
'luckgift'
,
"uid"
=>
$liveuid
,
"touid"
=>
$liveuid
,
"giftid"
=>
$giftid
,
"giftcount"
=>
$lucktimes
,
"totalcoin"
=>
$luckcoin
,
"showid"
=>
$showid
,
"mark"
=>
$giftinfo
[
'mark'
],
"addtime"
=>
$addtime
);
DI
()
->
notorm
->
users_coinrecord
->
insert
(
$insert
);
}
//
$luckcoin2 = (int)($luckcoin*0.05 * 100);
//
$luckcoin3 = $luckcoin2 / 100;
//
if ($luckcoin3 > 0) {
//
DI()->notorm->users
//
->where('id = ?', $liveuid)
//
->update( array('votes' => new NotORM_Literal("votes + {$luckcoin3}"),'votestotal' => new NotORM_Literal("votestotal + {$luckcoin3}") ));
//
$insert=array(
//
"type"=>'income',
//
"action"=>'luckgift',
//
"uid"=>$liveuid,
//
"touid"=>$liveuid,
//
"giftid"=>$giftid,
//
"giftcount"=>$lucktimes,
//
"totalcoin"=>$luckcoin,
//
"showid"=>$showid,
//
"mark"=>$giftinfo['mark'],
//
"addtime"=>$addtime
//
);
//
DI()->notorm->users_coinrecord->insert($insert);
//
}
break
;
}
else
{
$rateSum
-=
$ratePre
;
...
...
api/Appapi/Model/User.php
View file @
3eca25a4
...
...
@@ -337,26 +337,60 @@ class Model_User extends PhalApi_Model_NotORM
];
}
public
function
rechange
(
$uid
,
$id
)
public
function
rechange
(
$uid
,
$id
,
$source
)
{
$rechange
=
DI
()
->
notorm
->
recharge_rules
->
where
(
'id=?'
,
$id
)
->
fetchOne
();
if
(
empty
(
$rechange
))
{
return
1
;
}
$cashvotes
=
$rechange
[
'money'
];
$user
=
DI
()
->
notorm
->
users
->
select
(
'votes'
)
->
where
(
'id=?'
,
$uid
)
->
fetchOne
();
if
(
$rechange
[
'money'
]
>
$user
[
'votes'
])
{
if
(
$source
==
1
&&
$cashvotes
>
$user
[
'votes'
])
{
return
2
;
}
if
(
$source
==
2
&&
$cashvotes
>
$user
[
'i_votes'
])
{
return
2
;
}
if
(
$source
==
3
&&
$cashvotes
>
$user
[
'f_votes'
])
{
return
2
;
}
$total
=
$rechange
[
'money'
]
+
$rechange
[
'give'
];
DI
()
->
notorm
->
users
->
where
(
'id = ?'
,
$uid
)
->
update
([
'coin'
=>
new
NotORM_Literal
(
"coin +
{
$total
}
"
),
'votes'
=>
new
NotORM_Literal
(
"votes -
{
$rechange
[
'money'
]
}
"
),
]);
$ifok
=
0
;
return
0
;
if
(
$source
==
1
)
{
$ifok
=
DI
()
->
notorm
->
users
->
where
(
'id = ? and votes>=?'
,
$uid
,
$cashvotes
)
->
update
([
'coin'
=>
new
NotORM_Literal
(
"coin +
{
$total
}
"
),
'votes'
=>
new
NotORM_Literal
(
"votes -
{
$cashvotes
}
"
)
]);
}
if
(
$source
==
2
)
{
$ifok
=
DI
()
->
notorm
->
users
->
where
(
'id = ? and i_votes>=?'
,
$uid
,
$cashvotes
)
->
update
([
'coin'
=>
new
NotORM_Literal
(
"coin +
{
$total
}
"
),
'i_votes'
=>
new
NotORM_Literal
(
"i_votes -
{
$cashvotes
}
"
)
]);
}
if
(
$source
==
3
)
{
$ifok
=
DI
()
->
notorm
->
users
->
where
(
'id = ? and f_votes>=?'
,
$uid
,
$cashvotes
)
->
update
([
'coin'
=>
new
NotORM_Literal
(
"coin +
{
$total
}
"
),
'f_votes'
=>
new
NotORM_Literal
(
"f_votes -
{
$cashvotes
}
"
)
]);
}
// DI()->notorm->users->where('id = ?', $uid)->update([
// 'coin' => new NotORM_Literal("coin + {$total}"),
// 'votes' => new NotORM_Literal("votes - {$rechange['money']}"),
// ]);
return
!
$ifok
?
2
:
0
;
}
/* 关注 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment