Commit 3eca25a4 by 刘海龙

Merge branch 'master' of http://132.232.91.252:9999/ice/quxiu

parents 25d5e62e 32efbcec
...@@ -9,31 +9,31 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -9,31 +9,31 @@ class Api_Linkmic extends PhalApi_Api {
'token' => array('name' => 'token', 'type' => 'string','require' => true, 'desc' => '用户Token'), 'token' => array('name' => 'token', 'type' => 'string','require' => true, 'desc' => '用户Token'),
'ismic' => array('name' => 'ismic', 'type' => 'int', 'require' => true, 'desc' => '连麦开关,0关1开'), 'ismic' => array('name' => 'ismic', 'type' => 'int', 'require' => true, 'desc' => '连麦开关,0关1开'),
), ),
'isMic' => array( 'isMic' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'liveuid' => array('name' => 'liveuid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '主播ID'), 'liveuid' => array('name' => 'liveuid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '主播ID'),
), ),
'RequestLVBAddrForLinkMic' => array( 'RequestLVBAddrForLinkMic' => array(
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), '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'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'originStreamUrl' => array('name' => 'originStreamUrl', 'type' => 'string', 'require' => true, 'desc' => '流地址'), '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'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'mergeparams' => array('name' => 'mergeparams', 'type' => 'string', 'require' => true, 'desc' => '混流参数'), 'mergeparams' => array('name' => 'mergeparams', 'type' => 'string', 'require' => true, 'desc' => '混流参数'),
), ),
); );
} }
/** /**
* 设置连麦开关 * 设置连麦开关
* @desc 用于 用户设置当前直播的连麦开关 * @desc 用于 用户设置当前直播的连麦开关
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].pushurl 推流地址 * @return string info[].pushurl 推流地址
* @return string info[].timestamp 当前时间 * @return string info[].timestamp 当前时间
* @return string info[].playurl 播流地址 * @return string info[].playurl 播流地址
...@@ -42,7 +42,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -42,7 +42,7 @@ class Api_Linkmic extends PhalApi_Api {
public function setMic() { public function setMic() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$token=checkNull($this->token); $token=checkNull($this->token);
$ismic=checkNull($this->ismic); $ismic=checkNull($this->ismic);
...@@ -52,40 +52,40 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -52,40 +52,40 @@ class Api_Linkmic extends PhalApi_Api {
$rs['msg'] = '您的登陆状态失效,请重新登陆!'; $rs['msg'] = '您的登陆状态失效,请重新登陆!';
return $rs; return $rs;
} }
$domain = new Domain_Linkmic(); $domain = new Domain_Linkmic();
$result = $domain->setMic($uid,$ismic); $result = $domain->setMic($uid,$ismic);
$rs['msg']='设置成功'; $rs['msg']='设置成功';
return $rs; return $rs;
} }
/** /**
* 判断主播是否开启连麦 * 判断主播是否开启连麦
* @desc 用于 判断主播是否开启连麦 * @desc 用于 判断主播是否开启连麦
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function isMic() { public function isMic() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=checkNull($this->uid); $uid=checkNull($this->uid);
$liveuid=checkNull($this->liveuid); $liveuid=checkNull($this->liveuid);
$configpri=getConfigPri(); $configpri=getConfigPri();
$mic_limit=$configpri['mic_limit']; $mic_limit=$configpri['mic_limit'];
$userinfo=getUserinfo($uid); $userinfo=getUserinfo($uid);
if($mic_limit && $userinfo['level']<$mic_limit){ if($mic_limit && $userinfo['level']<$mic_limit){
$rs['code'] = 1002; $rs['code'] = 1002;
$rs['msg'] = "用户等级达到{$mic_limit}级才可与主播连麦哦~"; $rs['msg'] = "用户等级达到{$mic_limit}级才可与主播连麦哦~";
return $rs; return $rs;
} }
$domain = new Domain_Linkmic(); $domain = new Domain_Linkmic();
$result = $domain->isMic($liveuid); $result = $domain->isMic($liveuid);
...@@ -95,14 +95,14 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -95,14 +95,14 @@ class Api_Linkmic extends PhalApi_Api {
return $rs; return $rs;
} }
return $rs; return $rs;
} }
/** /**
* 获取连麦推拉流地址 * 获取连麦推拉流地址
* @desc 用于 获取连麦推拉流地址 * @desc 用于 获取连麦推拉流地址
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].pushurl 推流地址 * @return string info[].pushurl 推流地址
* @return string info[].timestamp 当前时间 * @return string info[].timestamp 当前时间
* @return string info[].playurl 播流地址 * @return string info[].playurl 播流地址
...@@ -112,7 +112,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -112,7 +112,7 @@ class Api_Linkmic extends PhalApi_Api {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$configpri = getConfigPri(); $configpri = getConfigPri();
$nowtime=time(); $nowtime=time();
$stream=$uid.'_'.$nowtime; $stream=$uid.'_'.$nowtime;
$live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK $live_sdk=$configpri['live_sdk']; //live_sdk 0表示金山SDK 1表示腾讯SDK
...@@ -124,7 +124,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -124,7 +124,7 @@ class Api_Linkmic extends PhalApi_Api {
$now_time2 = $nowtime + 3*60*60; $now_time2 = $nowtime + 3*60*60;
$txTime = dechex($now_time2); $txTime = dechex($now_time2);
$live_code = $stream ; $live_code = $stream ;
$txSecret = md5($push_url_key . $live_code . $txTime); $txSecret = md5($push_url_key . $live_code . $txTime);
...@@ -133,7 +133,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -133,7 +133,7 @@ class Api_Linkmic extends PhalApi_Api {
$push_url = "rtmp://" . $push . "/live/" . $live_code . "?bizid=" . $bizid .$safe_url; $push_url = "rtmp://" . $push . "/live/" . $live_code . "?bizid=" . $bizid .$safe_url;
$play_url = "rtmp://" . $pull . "/live/" .$live_code. "?bizid=" . $bizid .$safe_url; $play_url = "rtmp://" . $pull . "/live/" .$live_code. "?bizid=" . $bizid .$safe_url;
}else if($configpri['cdn_switch']==5) }else if($configpri['cdn_switch']==5)
{ {
$wyinfo=PrivateKeyA('rtmp',$stream,1); $wyinfo=PrivateKeyA('rtmp',$stream,1);
...@@ -144,49 +144,49 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -144,49 +144,49 @@ class Api_Linkmic extends PhalApi_Api {
$push_url=PrivateKeyA('rtmp',$stream,1); $push_url=PrivateKeyA('rtmp',$stream,1);
$play_url=PrivateKeyA('rtmp',$stream,0); $play_url=PrivateKeyA('rtmp',$stream,0);
} }
$info=array( $info=array(
"pushurl" => $push_url, "pushurl" => $push_url,
"timestamp" => $nowtime, "timestamp" => $nowtime,
"playurl" => $play_url "playurl" => $play_url
); );
$rs['info'][0]=$info; $rs['info'][0]=$info;
return $rs; return $rs;
} }
/** /**
* 获取鉴权流地址 * 获取鉴权流地址
* @desc 用于鉴权流地址 * @desc 用于鉴权流地址
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string info[].streamUrlWithSignature 鉴权地址 * @return string info[].streamUrlWithSignature 鉴权地址
* @return string info[].timestamp 当前时间 * @return string info[].timestamp 当前时间
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function RequestPlayUrlWithSignForLinkMic() { public function RequestPlayUrlWithSignForLinkMic() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$originalUrl=checkNull($this->originStreamUrl); $originalUrl=checkNull($this->originStreamUrl);
$configpri = getConfigPri(); $configpri = getConfigPri();
$bizid = $configpri['tx_bizid']; $bizid = $configpri['tx_bizid'];
$push_url_key = $configpri['tx_push_key']; $push_url_key = $configpri['tx_push_key'];
$list1 = preg_split ('/\?/', $originalUrl); $list1 = preg_split ('/\?/', $originalUrl);
$originalUrl=$list1[0]; $originalUrl=$list1[0];
$list = preg_split ('/\//', $originalUrl); $list = preg_split ('/\//', $originalUrl);
$url = preg_split ('/\./', end($list)); $url = preg_split ('/\./', end($list));
$now_time = time(); $now_time = time();
$now_time = $now_time + 3*60*60; $now_time = $now_time + 3*60*60;
$txTime = dechex($now_time); $txTime = dechex($now_time);
$txSecret = md5($push_url_key . $url[0] . $txTime); $txSecret = md5($push_url_key . $url[0] . $txTime);
$safe_url = $originalUrl."?txSecret=" . $txSecret ."&txTime=" .$txTime ."&bizid=".$bizid; $safe_url = $originalUrl."?txSecret=" . $txSecret ."&txTime=" .$txTime ."&bizid=".$bizid;
$safe_url=str_replace(".flv",'',$safe_url); $safe_url=str_replace(".flv",'',$safe_url);
...@@ -194,34 +194,34 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -194,34 +194,34 @@ class Api_Linkmic extends PhalApi_Api {
$info=array( $info=array(
"streamUrlWithSignature" => $safe_url, "streamUrlWithSignature" => $safe_url,
"timestamp" => $now_time, "timestamp" => $now_time,
); );
$rs['info'][0]=$info; $rs['info'][0]=$info;
return $rs; return $rs;
} }
/** /**
* 连麦混流 * 连麦混流
* @desc 用于连麦混流 * @desc 用于连麦混流
* @return int code 操作码,0表示成功 * @return int code 操作码,0表示成功
* @return array info * @return array info
* @return string msg 提示信息 * @return string msg 提示信息
*/ */
public function MergeVideoStream() { public function MergeVideoStream() {
$rs = array('code' => 0, 'msg' => '', 'info' => array()); $rs = array('code' => 0, 'msg' => '', 'info' => array());
$uid=$this->uid; $uid=$this->uid;
$mergeparams=html_entity_decode($this->mergeparams); $mergeparams=html_entity_decode($this->mergeparams);
$configpri = getConfigPri(); $configpri = getConfigPri();
$appid = $configpri['tx_appid']; $appid = $configpri['tx_appid'];
$bizid = $configpri['tx_bizid']; $bizid = $configpri['tx_bizid'];
$push_url_key = $configpri['tx_push_key']; $push_url_key = $configpri['tx_push_key'];
$call_back_key = $configpri['tx_api_key']; $call_back_key = $configpri['tx_api_key'];
$t=time()+60; $t=time()+60;
$sign=$md5_val = md5($call_back_key . strval($t));; $sign=$md5_val = md5($call_back_key . strval($t));;
...@@ -231,8 +231,8 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -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; $url='http://fcgi.video.qcloud.com/common_access?appid='.$appid.'&interface=Mix_StreamV2&t='.$t.'&sign='.$sign;
$ch = curl_init (); $ch = curl_init ();
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在 @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
@curl_setopt($ch, CURLOPT_URL, $url); @curl_setopt($ch, CURLOPT_URL, $url);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@curl_setopt($ch, CURLOPT_POST, 1); @curl_setopt($ch, CURLOPT_POST, 1);
...@@ -244,6 +244,7 @@ class Api_Linkmic extends PhalApi_Api { ...@@ -244,6 +244,7 @@ class Api_Linkmic extends PhalApi_Api {
); );
@$result = curl_exec($ch); @$result = curl_exec($ch);
if(curl_errno($ch)){ if(curl_errno($ch)){
//print curl_error($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); 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 { ...@@ -258,7 +259,7 @@ class Api_Linkmic extends PhalApi_Api {
return $rs; return $rs;
} }
return $rs; return $rs;
} }
} }
...@@ -90,6 +90,7 @@ class Api_User extends PhalApi_Api { ...@@ -90,6 +90,7 @@ class Api_User extends PhalApi_Api {
'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'), 'uid' => array('name' => 'uid', 'type' => 'int', 'min' => 1, 'require' => true, 'desc' => '用户ID'),
'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'), 'token' => array('name' => 'token', 'type' => 'string', 'require' => true, 'desc' => '用户token'),
'id' => array('name' => 'id', 'type' => 'string', 'require' => true, 'desc' => 'id'), 'id' => array('name' => 'id', 'type' => 'string', 'require' => true, 'desc' => 'id'),
'source' => array('name' => 'source', 'type' => 'int', 'require' => true, 'desc' => '类型,1主播,2邀请,3家族'),
), ),
'setCash' => array( 'setCash' => array(
...@@ -920,7 +921,7 @@ class Api_User extends PhalApi_Api { ...@@ -920,7 +921,7 @@ class Api_User extends PhalApi_Api {
} }
$domain = new Domain_User(); $domain = new Domain_User();
$info = $domain->rechange($this->uid, $this->id); $info = $domain->rechange($this->uid, $this->id, $this->source);
if($info === 1){ if($info === 1){
$rs['code']=1001; $rs['code']=1001;
...@@ -930,7 +931,7 @@ class Api_User extends PhalApi_Api { ...@@ -930,7 +931,7 @@ class Api_User extends PhalApi_Api {
if($info === 2){ if($info === 2){
$rs['code']=1002; $rs['code']=1002;
$rs['msg']='积分不足'; $rs['msg']='魅力值不足';
return $rs; return $rs;
} }
......
...@@ -92,11 +92,11 @@ class Domain_User { ...@@ -92,11 +92,11 @@ class Domain_User {
return $rs; return $rs;
} }
public function rechange($uid, $id) { public function rechange($uid, $id, $source) {
$rs = array(); $rs = array();
$model = new Model_User(); $model = new Model_User();
$rs = $model->rechange($uid, $id); $rs = $model->rechange($uid, $id, $source);
return $rs; return $rs;
} }
......
...@@ -73,7 +73,7 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -73,7 +73,7 @@ class Model_Home extends PhalApi_Model_NotORM {
$result=DI()->notorm->users_live $result=DI()->notorm->users_live
->select("uid,thumb,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway") ->select("uid,thumb,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway")
->where($where) ->where($where)
->order('hotvotes desc,starttime desc') ->order('hotvotes desc, starttime desc')
->limit($start,$pnum) ->limit($start,$pnum)
->fetchAll(); ->fetchAll();
...@@ -603,11 +603,11 @@ class Model_Home extends PhalApi_Model_NotORM { ...@@ -603,11 +603,11 @@ class Model_Home extends PhalApi_Model_NotORM {
public function getRecommend(){ public function getRecommend(){
$configpri=getConfigPri(); $configpri=getConfigPri();
$where=" isrecommend = '1' and islive= '1' and ishot='1' "; $where="islive= '1'";
$result=DI()->notorm->users_live $result=DI()->notorm->users_live
->select("uid,thumb,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway") ->select("uid,thumb,title,city,stream,pull,thumb,isvideo,type,type_val,game_action,goodnum,anyway")
->where($where) ->where($where)
->order('starttime desc') ->order(' isrecommend desc, starttime desc')
->limit(50) ->limit(50)
->fetchAll(); ->fetchAll();
......
...@@ -857,12 +857,10 @@ class Model_Live extends PhalApi_Model_NotORM { ...@@ -857,12 +857,10 @@ class Model_Live extends PhalApi_Model_NotORM {
$anthor_total=floor($anthor_total*$jackpotset['luck_anchor']*0.01); $anthor_total=floor($anthor_total*$jackpotset['luck_anchor']*0.01);
} }
/* 幸运礼物分成 */ /* 幸运礼物分成 */
/* 家族分成之后的金额 */ /* 家族分成之后的金额 */
$anthor_total=setFamilyDivide($liveuid,$anthor_total); $anthor_total=setFamilyDivide($liveuid,$anthor_total);
//主播 经验 //主播 经验
$get_gift = !empty($set['get_gift']) ? $set['get_gift'] : 0; $get_gift = !empty($set['get_gift']) ? $set['get_gift'] : 0;
$get_gift2 = !empty($set['get_gift2']) ? $set['get_gift2'] : 0; $get_gift2 = !empty($set['get_gift2']) ? $set['get_gift2'] : 0;
...@@ -871,7 +869,6 @@ class Model_Live extends PhalApi_Model_NotORM { ...@@ -871,7 +869,6 @@ class Model_Live extends PhalApi_Model_NotORM {
$get_gif3 = (int)($total / $get_gift); $get_gif3 = (int)($total / $get_gift);
$total3 += ($get_gif3 * $get_gift2); $total3 += ($get_gif3 * $get_gift2);
} }
/* 更新直播 魅力值 累计魅力值 */ /* 更新直播 魅力值 累计魅力值 */
$istouid =DI()->notorm->users $istouid =DI()->notorm->users
->where('id = ?', $liveuid) ->where('id = ?', $liveuid)
...@@ -894,8 +891,6 @@ class Model_Live extends PhalApi_Model_NotORM { ...@@ -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 ); $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); DI()->notorm->users_coinrecord->insert($insert);
/* 更新主播热门 */ /* 更新主播热门 */
// if($giftinfo['mark']==1){ // if($giftinfo['mark']==1){
DI()->notorm->users_live DI()->notorm->users_live
...@@ -986,26 +981,26 @@ class Model_Live extends PhalApi_Model_NotORM { ...@@ -986,26 +981,26 @@ class Model_Live extends PhalApi_Model_NotORM {
); );
DI()->notorm->users_coinrecord->insert($insert); DI()->notorm->users_coinrecord->insert($insert);
$luckcoin2 = (int)($luckcoin*0.05 * 100); // $luckcoin2 = (int)($luckcoin*0.05 * 100);
$luckcoin3 = $luckcoin2 / 100; // $luckcoin3 = $luckcoin2 / 100;
if ($luckcoin3 > 0) { // if ($luckcoin3 > 0) {
DI()->notorm->users // DI()->notorm->users
->where('id = ?', $liveuid) // ->where('id = ?', $liveuid)
->update( array('votes' => new NotORM_Literal("votes + {$luckcoin3}"),'votestotal' => new NotORM_Literal("votestotal + {$luckcoin3}") )); // ->update( array('votes' => new NotORM_Literal("votes + {$luckcoin3}"),'votestotal' => new NotORM_Literal("votestotal + {$luckcoin3}") ));
$insert=array( // $insert=array(
"type"=>'income', // "type"=>'income',
"action"=>'luckgift', // "action"=>'luckgift',
"uid"=>$liveuid, // "uid"=>$liveuid,
"touid"=>$liveuid, // "touid"=>$liveuid,
"giftid"=>$giftid, // "giftid"=>$giftid,
"giftcount"=>$lucktimes, // "giftcount"=>$lucktimes,
"totalcoin"=>$luckcoin, // "totalcoin"=>$luckcoin,
"showid"=>$showid, // "showid"=>$showid,
"mark"=>$giftinfo['mark'], // "mark"=>$giftinfo['mark'],
"addtime"=>$addtime // "addtime"=>$addtime
); // );
DI()->notorm->users_coinrecord->insert($insert); // DI()->notorm->users_coinrecord->insert($insert);
} // }
break; break;
} else { } else {
$rateSum -= $ratePre; $rateSum -= $ratePre;
......
...@@ -337,26 +337,60 @@ class Model_User extends PhalApi_Model_NotORM ...@@ -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(); $rechange = DI()->notorm->recharge_rules->where('id=?', $id)->fetchOne();
if (empty($rechange)) { if (empty($rechange)) {
return 1; return 1;
} }
$cashvotes = $rechange['money'];
$user = DI()->notorm->users->select('votes')->where('id=?', $uid)->fetchOne(); $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; return 2;
} }
$total = $rechange['money'] + $rechange['give']; $total = $rechange['money'] + $rechange['give'];
DI()->notorm->users->where('id = ?', $uid)->update([ $ifok = 0;
'coin' => new NotORM_Literal("coin + {$total}"),
'votes' => new NotORM_Literal("votes - {$rechange['money']}"),
]);
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;
} }
/* 关注 */ /* 关注 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment