Commit 04708fd3 by 冷斌

fix bug

parent 1e042ba4
......@@ -7,7 +7,7 @@ class Model_Game extends PhalApi_Model_NotORM {
->where('id=?',$liveuid)
->fetchOne();
if($userinfo['token']!=$token || $userinfo['expiretime']<time()){
return 700;
return 700;
}
$game=DI()->notorm->game
->select("*")
......@@ -15,20 +15,20 @@ class Model_Game extends PhalApi_Model_NotORM {
->fetchOne();
if($game)
{
return 1000;
return 1000;
}
$rs=DI()->notorm->game
->insert(array("liveuid"=>$liveuid,"stream"=>$stream,'action'=>$action,'state'=>'0','result'=>$result,"starttime"=>$time,"bankerid"=>$bankerid,"banker_card"=>$bankercrad) );
->insert(array("liveuid"=>$liveuid,"stream"=>$stream,'action'=>$action,'state'=>'0','result'=>$result,"starttime"=>$time,"bankerid"=>$bankerid,"banker_card"=>$bankercrad) );
if(!$rs)
{
return 1001;
return 1001;
}
DI()->notorm->users_live
->where('uid=?',$liveuid)
->update(array("game_action"=>$action));
return $rs;
return $rs;
}
public function endGame($liveuid,$gameid,$type,$ifset)
{
......@@ -37,14 +37,14 @@ class Model_Game extends PhalApi_Model_NotORM {
->where('uid=?',$liveuid)
->update(array("game_action"=>0));
/* 主播关闭游戏,清楚庄家列表,返还余额 */
/* $key='banker_'.$action.'_'.$stream;
$uidlist=array();
$list=DI()->redis -> hVals($key);
foreach($list as $v){
$bankerinfo=json_decode($v,true);
} */
}
//file_put_contents('./zhifu.txt',date('y-m-d H:i:s').' 提交参数信息 endGame:'.$liveuid.'--'.$gameid.'--'.$type."\r\n",FILE_APPEND);
$game=DI()->notorm->game
......@@ -63,12 +63,12 @@ class Model_Game extends PhalApi_Model_NotORM {
$bankerid=$game['bankerid'];
$banker_profit=0;
$isintervene=0;
$gameToken=$game['stream']."_".$action."_".$game['starttime']."_Game";
$gameinfo=DI()->redis -> Get($gameToken);
$gameinfo=json_decode($gameinfo,1);
DI()->redis->delete($gameToken);
if($type==2 ||$type==3)
{
$total=DI()->notorm->users_gamerecord
......@@ -81,30 +81,31 @@ class Model_Game extends PhalApi_Model_NotORM {
->where('id = ?', $v['uid'])
->update(array('coin' => new NotORM_Literal("coin + {$v['total']}")));
delcache('userinfo_'.$v['uid']);
$insert=array("type"=>'income',"action"=>'game_return',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$v['total'],"showid"=>0,"addtime"=>$addtime );
$u = DI()->notorm->users->select('coin')->where('id = ' . $v['uid'])->fetchOne();
$insert=array('coin' => $u['coin'], "type"=>'income',"action"=>'game_return',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$v['total'],"showid"=>0,"addtime"=>$addtime );
DI()->notorm->users_coinrecord->insert($insert);
}
/* 下庄处理 */
//$action=4;
if($action==4){
$key='banker_'.$action.'_'.$game['stream'];
$list=DI()->redis->hGetAll($key);
foreach($list as $k=>$v){
$data=json_decode($v,true);
$uid=$k;
DI()->notorm->users
->where('id = ?', $uid)
->update(array('coin' => new NotORM_Literal("coin + {$data['deposit']}")));
delcache('userinfo_'.$uid);
$addtime=time();
$insert=array("type"=>'income',"action"=>'deposit_return',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$data['deposit'],"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>'income',"action"=>'deposit_return',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$data['deposit'],"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
DI()->notorm->users_coinrecord->insert($insert);
}
}
}else{
......@@ -122,7 +123,7 @@ class Model_Game extends PhalApi_Model_NotORM {
if($action==4){
/* 开心牛仔 */
$intervene=rand(0,99);
if($bankerid>0){
/* 用户坐庄 */
if($intervene >= $configpri['game_odds_u']){
......@@ -134,7 +135,7 @@ class Model_Game extends PhalApi_Model_NotORM {
$isintervene=1;
}
}
if($isintervene){
$data[1]=$gameinfo[0][9];
$data[2]=$gameinfo[1][9];
......@@ -142,25 +143,25 @@ class Model_Game extends PhalApi_Model_NotORM {
$data[4]=$gameinfo[3][9];
$pos = array_search(max($data), $data);
if($pos!=4){
/* 庄的牌面不是最大的 */
$zhuang=$gameinfo[$pos-1];
$tihuan=$gameinfo[3];
/* 调整数据 */
$tihuan[7]='0';
$tihuan[8]=$zhuang[8];
$zhuang[7]='2';
$zhuang[8]='0';
$gameinfo[$pos-1]=$tihuan;
$gameinfo[3]=$zhuang;
}
$result='1,1,1';
}
$coin='';
//file_put_contents('./endGame.txt',date('y-m-d H:i:s').' 提交参数信息 game_result:'.json_encode($result)."\r\n",FILE_APPEND);
......@@ -186,16 +187,16 @@ class Model_Game extends PhalApi_Model_NotORM {
foreach( $total as $k=>$v){
$gamecoin=$v['total'] + floor( $v['total'] * ( 100 - $game_pump ) * 0.01 );
//file_put_contents('./endGame.txt',date('y-m-d H:i:s').' 提交参数信息 gamecoin:'.json_encode($gamecoin)."\r\n",FILE_APPEND);
$win+=$v['total']*2;
$win+=$v['total']*2;
DI()->notorm->users
->where('id = ?', $v['uid'])
->update(array('coin' => new NotORM_Literal("coin + {$gamecoin}")));
delcache('userinfo_'.$v['uid']);
$insert=array("type"=>'income',"action"=>'game_win',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$gamecoin,"showid"=>0,"addtime"=>$addtime ,"game_action"=>$action,"game_banker"=>$bankerid );
$u = DI()->notorm->users->select('coin')->where('id = ' . $v['uid'])->fetchOne();
$insert=array('coin' => $u['coin'], "type"=>'income',"action"=>'game_win',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$gamecoin,"showid"=>0,"addtime"=>$addtime ,"game_action"=>$action,"game_banker"=>$bankerid );
DI()->notorm->users_coinrecord->insert($insert);
}
}
//file_put_contents('./endGame.txt',date('y-m-d H:i:s').' 提交参数信息 win:'.json_encode($win)."\r\n",FILE_APPEND);
$banker_profit-= $win;
......@@ -208,18 +209,18 @@ class Model_Game extends PhalApi_Model_NotORM {
$key='banker_'.$action.'_'.$stream;
$isexist=DI()->redis->hGet($key,$bankerid);
$bankerinfo=json_decode($isexist,1);
$bankerinfo['deposit']=$bankerinfo['deposit']+$banker_profit;
$bankerinfo['coin']=NumberFormat($bankerinfo['deposit']);
DI()->redis->hSet($key,$bankerid,json_encode($bankerinfo));
/* DI()->notorm->users
->where('id = ?', $bankerid)
->update(array('coin' => new NotORM_Literal("coin + {$banker_profit}")));
$insert=array("type"=>'income',"action"=>'game_banker',"uid"=>$bankerid,"touid"=>$bankerid,"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$banker_profit,"showid"=>0,"addtime"=>$addtime,"game_action"=>$action,"game_banker"=>$bankerid ); */
}else{
DI()->notorm->users_live
->where('uid = ?', $liveuid)
......@@ -228,14 +229,14 @@ class Model_Game extends PhalApi_Model_NotORM {
}else{
/* 其他游戏 */
$data=array();
/* 干预 */
$intervene=rand(0,99);
if($intervene > $configpri['game_odds']){
$isintervene=1;
}
if($isintervene){
/* 进行干预 */
if($action==1){
......@@ -260,7 +261,7 @@ class Model_Game extends PhalApi_Model_NotORM {
$data[2]=$gameinfo[1][5];
$data[3]=$gameinfo[2][5];
}
$pos = array_search(min($data), $data);
if($pos!=$result){
/* 当前中奖位置不是下注最少的位置 */
......@@ -276,7 +277,7 @@ class Model_Game extends PhalApi_Model_NotORM {
$gameinfo[$pos-1]=$max;
$result=$pos;
}
}else if($action==3){
$max=$gameinfo[$result];
$gameinfo[$result]=$gameinfo[$pos];
......@@ -293,9 +294,9 @@ class Model_Game extends PhalApi_Model_NotORM {
$gameinfo[$pos-1]=$max;
$result=$pos;
}
}
}
$coin="coin_".$result;
......@@ -311,27 +312,27 @@ class Model_Game extends PhalApi_Model_NotORM {
->where('id = ?', $v['uid'])
->update(array('coin' => new NotORM_Literal("coin + {$gamecoin}")));
delcache('userinfo_'.$v['uid']);
$insert=array("type"=>'income',"action"=>'game_win',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$gamecoin,"showid"=>0,"addtime"=>$addtime ,"game_action"=>$action,"game_banker"=>$bankerid );
$u = DI()->notorm->users->select('coin')->where('id = ' . $v['uid'])->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>'income',"action"=>'game_win',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$gamecoin,"showid"=>0,"addtime"=>$addtime ,"game_action"=>$action,"game_banker"=>$bankerid );
DI()->notorm->users_coinrecord->insert($insert);
}
}
$banker_profit-= $win;
}
}
}
$gameToken=$game['stream']."_".$game['action']."_".$game['starttime']."_Game";
DI()->redis->delete($gameToken);
DI()->notorm->game
->where('id = ? and liveuid =?', $gameid,$liveuid)
->update(array('state' =>$type,'result' =>$result,'banker_profit' =>$banker_profit,'isintervene' =>$isintervene,'endtime' => time() ) );
DI()->notorm->users_gamerecord
->where('gameid=?',$gameid)
->update(array('status'=>'1'));
return $gameinfo;
}
public function gameBet($uid,$gameid,$coin,$action,$grade)
......@@ -350,13 +351,13 @@ class Model_Game extends PhalApi_Model_NotORM {
{
return 1001;
}
$bankerid=$game['bankerid'];
/* 下注总额 */
$total=DI()->notorm->users_gamerecord
->where('action = ? and uid=? and gameid=? and liveuid=?',$action,$uid,$gameid,$game['liveuid'])
->sum("coin_1 + coin_2 + coin_3 + coin_4 + coin_5 + coin_6");
......@@ -368,11 +369,11 @@ class Model_Game extends PhalApi_Model_NotORM {
$total_all=DI()->notorm->users_gamerecord
->where('action = ? and gameid=? and liveuid=?',$action,$gameid,$game['liveuid'])
->sum("coin_1 + coin_2 + coin_3 + coin_4 + coin_5 + coin_6");
$total_all=$total_all+$coin;
$total_all=$total_all+$coin;
$key='banker_'.$action.'_'.$game['stream'];
$bankerinfo=DI()->redis->hget($key,$bankerid);
$bankerinfo_a=json_decode($bankerinfo,1);
if($total_all > $bankerinfo_a['deposit']){
return 1003;
......@@ -382,7 +383,7 @@ class Model_Game extends PhalApi_Model_NotORM {
if($total > 500000){
return 1003;
}
$ifok=DI()->notorm->users
->where('id = ? and coin >=?', $uid,$coin)
->update(array('coin' => new NotORM_Literal("coin - {$coin}"),'consumption' => new NotORM_Literal("consumption + {$coin}")));
......@@ -390,55 +391,55 @@ class Model_Game extends PhalApi_Model_NotORM {
if(!$ifok){
return 1000;
}
$gamerecord=DI()->notorm->users_gamerecord
->select('id')
->where('action = ? and uid=? and gameid=? and liveuid=?',$action,$uid,$gameid,$game['liveuid'])
->fetchOne();
//file_put_contents('./gameBet.txt',date('Y-m-d H:i:s').' 提交参数信息 gamerecord:'.json_encode($gamerecord)."\r\n",FILE_APPEND);
$field='coin_'.$grade;
if($gamerecord)
{
$users_game=DI()->notorm->users_gamerecord
->where('id = ? ',$gamerecord['id'])
->update(array($field => new NotORM_Literal("{$field} + {$coin}")));
->update(array($field => new NotORM_Literal("{$field} + {$coin}")));
//file_put_contents('./gameBet.txt',date('Y-m-d H:i:s').' 提交参数信息 更新 field:'.json_encode($field). '----coin:'.json_encode($coin)."\r\n",FILE_APPEND);
}else{
$users_game=DI()->notorm->users_gamerecord
->insert(array("action"=>$action,"uid"=>$uid,'gameid'=>$gameid,'liveuid'=>$game['liveuid'],$field=>$coin,"addtime"=>time()) );
//file_put_contents('./gameBet.txt',date('Y-m-d H:i:s').' 提交参数信息 新增 field:'.json_encode($field). '----coin:'.json_encode($coin)."\r\n",FILE_APPEND);
}
//file_put_contents('./gameBet.txt',date('Y-m-d H:i:s').' 提交参数信息 users_game:'.json_encode($users_game)."\r\n",FILE_APPEND);
if(!$users_game)
{
return 1002;
return 1002;
}
$addtime=time();
$giftid=$game['id'];
$insert=array("type"=>'expend',"action"=>'game_bet',"uid"=>$uid,"touid"=>$uid,"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$coin,"showid"=>0,"addtime"=>$addtime );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>'expend',"action"=>'game_bet',"uid"=>$uid,"touid"=>$uid,"giftid"=>$giftid,"giftcount"=>1,"totalcoin"=>$coin,"showid"=>0,"addtime"=>$addtime );
DI()->notorm->users_coinrecord->insert($insert);
delcache('userinfo_'.$uid);
$info=DI()->notorm->users
->select('coin')
->where('id = ?', $uid)
->fetchOne();
->fetchOne();
$rs['uid']=$uid;
$rs['coin']=$info['coin'];
$rs['gametime']=$game['starttime'];
$rs['stream']=$game['stream'];
return $rs;
return $rs;
}
public function checkGame($liveuid,$stream,$uid)
{
......@@ -458,7 +459,7 @@ class Model_Game extends PhalApi_Model_NotORM {
->select("*")
->where('liveuid=? and stream=? and state=?',$liveuid,$stream,0)
->fetchOne();
if($game)
{
$action=$game["action"];
......@@ -475,7 +476,7 @@ class Model_Game extends PhalApi_Model_NotORM {
$data[]=$brand[0][8];
$data[]=$brand[1][8];
$data[]=$brand[2][8];
}else if($action==3){
$data[]=$brand[1];
$data[]=$brand[2];
......@@ -490,7 +491,7 @@ class Model_Game extends PhalApi_Model_NotORM {
$data[]=$brand[1][5];
$data[]=$brand[2][5];
}
$rs['brand']=$data;
$time=30-(time()-$game['starttime'])+3;
if($time<0)
......@@ -500,11 +501,11 @@ class Model_Game extends PhalApi_Model_NotORM {
$rs['time']=(string)$time;
$rs['id']=(string)$game["id"];
$rs['bankerid']=(string)$game["bankerid"];
if($game["bankerid"]>0){
$key='banker_'.$action.'_'.$stream;
$isexist=DI()->redis->hGet($key,$game["bankerid"]);
$bankerinfo=json_decode($isexist,1);
$rs['banker_name']=$bankerinfo['user_nicename'];
......@@ -517,11 +518,11 @@ class Model_Game extends PhalApi_Model_NotORM {
->fetchOne();
$rs['banker_coin']=NumberFormat($userinfo['banker_coin']);
}
$rs['action']=(string)$action;
/* DI()->redis -> set($BetToken,json_encode($data)); */
/* 用户下注信息 */
$userbet=DI()->notorm->users_gamerecord
->select("sum(coin_1) as bet1,sum(coin_2) as bet2,sum(coin_3) as bet3,sum(coin_4) as bet4")
......@@ -547,7 +548,7 @@ class Model_Game extends PhalApi_Model_NotORM {
->fetchOne();
$rs['banker_coin']=NumberFormat($userinfo['banker_coin']);
}
return $rs;
return $rs;
}
/* 计算用户收益 */
public function settleGame($uid,$gameid)
......@@ -565,7 +566,7 @@ class Model_Game extends PhalApi_Model_NotORM {
$total=DI()->notorm->users_gamerecord
->where('gameid=? and uid=?',$gameid,$uid)
->sum('coin_1 + coin_2 + coin_3 + coin_4 ');
$action=$game['action'];
$result=$game['result'];
$bankerid=$game['bankerid'];
......@@ -594,18 +595,18 @@ class Model_Game extends PhalApi_Model_NotORM {
}
$settle['gamecoin']=(string)$total_win;
$banker_profit=$game['banker_profit'];
if($banker_profit>=0){
$banker_profit='+'.$banker_profit;
}
$settle['banker_profit']=(string)$banker_profit;
$settle['bankerid']=$bankerid;
$settle['isshow']='0';
/* 庄家处理 */
$stream=$game['stream'];
$key='banker_'.$action.'_'.$stream;
......@@ -623,20 +624,20 @@ class Model_Game extends PhalApi_Model_NotORM {
$this->quietBanker($uid,$bankerinfo);
DI()->redis->hdel($key,$uid);
}
}
$userinfo=DI()->notorm->users
->select("coin")
->where('id=?',$uid)
->fetchOne();
$settle['coin']=(string)$userinfo['coin'];
//file_put_contents('./settleGame.txt',date('y-m-d H:i:s').' 提交参数信息 settle:'.json_encode($settle)."\r\n",FILE_APPEND);
return $settle;
return $settle;
}
/* 游戏记录 */
public function getGameRecord($action,$stream){
$result=array();
......@@ -651,7 +652,7 @@ class Model_Game extends PhalApi_Model_NotORM {
if($action==3){
$rs=array('0','0','0','0');
}
if($action==4){
$result_a=explode(",",$v['result']);
foreach($result_a as $k=>$v){
......@@ -662,14 +663,14 @@ class Model_Game extends PhalApi_Model_NotORM {
}else{
$rs[$v['result']-1]='1';
}
$result[]=$rs;
}
return $result;
}
/* 庄家流水 */
public function getBankerProfit($bankerid,$action,$stream){
......@@ -680,7 +681,7 @@ class Model_Game extends PhalApi_Model_NotORM {
->limit(0,30)
->fetchAll();
return $list;
}
/* 平台庄家 */
......@@ -694,14 +695,14 @@ class Model_Game extends PhalApi_Model_NotORM {
}else{
$platform_coin=NumberFormat(10000000);
}
$rs=array(
'id'=>'0',
'user_nicename'=>'吕布',
'avatar'=>'',
'coin'=>$platform_coin,
);
return $rs;
}
/* 上庄 */
......@@ -721,13 +722,14 @@ class Model_Game extends PhalApi_Model_NotORM {
->update(array('coin' => new NotORM_Literal("coin - {$deposit}")));
delcache('userinfo_'.$uid);
$addtime=time();
$insert=array("type"=>'expend',"action"=>'set_deposit',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$deposit,"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'], "type"=>'expend',"action"=>'set_deposit',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$deposit,"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
DI()->notorm->users_coinrecord->insert($insert);
$info=DI()->notorm->users
->select('coin')
->where('id = ?', $uid)
->fetchOne();
->fetchOne();
return $info;
}
......@@ -739,9 +741,10 @@ class Model_Game extends PhalApi_Model_NotORM {
->update(array('coin' => new NotORM_Literal("coin + {$data['deposit']}")));
delcache('userinfo_'.$uid);
$addtime=time();
$insert=array("type"=>'income',"action"=>'deposit_return',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$data['deposit'],"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>'income',"action"=>'deposit_return',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$data['deposit'],"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
DI()->notorm->users_coinrecord->insert($insert);
return 1;
}
}
\ No newline at end of file
}
......@@ -147,8 +147,8 @@ class Model_Guard extends PhalApi_Model_NotORM {
$showid=0;
}
}
$insert=array("type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>'1',"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'], "type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>'1',"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
DI()->notorm->users_coinrecord->insert($insert);
$endtime=$addtime + $guardinfo['length_time'];
......
......@@ -147,11 +147,11 @@ class Model_Live extends PhalApi_Model_NotORM {
->group('uid')
->fetchAll();
foreach($total as $k=>$v){
$u = DI()->notorm->users
DI()->notorm->users
->where('id = ?', $v['uid'])
->update(array('coin' => new NotORM_Literal("coin + {$v['total']}")));
delcache('userinfo_'.$v['uid']);
$u = DI()->notorm->users->select('coin')->where('id = ' . $v['uid'])->fetchOne();
$insert=array('coin' => $u['coin'], "type"=>'income',"action"=>'game_return',"uid"=>$v['uid'],"touid"=>$v['uid'],"giftid"=>$game['id'],"giftcount"=>1,"totalcoin"=>$v['total'],"showid"=>0,"addtime"=>$nowtime );
DI()->notorm->users_coinrecord->insert($insert);
}
......@@ -178,7 +178,8 @@ class Model_Live extends PhalApi_Model_NotORM {
->update(array('coin' => new NotORM_Literal("coin + {$data['deposit']}")));
delcache('userinfo_'.$uid);
$addtime=time();
$insert=array("type"=>'income',"action"=>'deposit_return',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$data['deposit'],"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>'income',"action"=>'deposit_return',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$data['deposit'],"showid"=>0,"addtime"=>$addtime ,"game_action"=>4,"game_banker"=>0 );
DI()->notorm->users_coinrecord->insert($insert);
}
......@@ -402,10 +403,10 @@ class Model_Live extends PhalApi_Model_NotORM {
'addtime'=>time(),
];
DI()->notorm->users_voterecord->insert($insert_votes);
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
/* 更新直播 映票 累计映票 */
DI()->notorm->users_coinrecord
->insert(array("type"=>'expend',"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime ));
->insert(array('coin' => $u['coin'],"type"=>'expend',"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime ));
$userinfo2=DI()->notorm->users
->select('coin')
......@@ -555,7 +556,7 @@ class Model_Live extends PhalApi_Model_NotORM {
$showid=$stream2[1];
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array("type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"mark"=>$giftinfo['mark'],"addtime"=>$addtime );
$insert=array('coin' => $u['coin'], "type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"mark"=>$giftinfo['mark'],"addtime"=>$addtime );
DI()->notorm->users_coinrecord->insert($insert);
......@@ -630,6 +631,7 @@ class Model_Live extends PhalApi_Model_NotORM {
DI()->notorm->users
->where('id = ?', $uid)
->update( array('coin' => new NotORM_Literal("coin + {$luckcoin}") ));
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array(
"type"=>'income',
"action"=>'luckgift',
......@@ -640,7 +642,8 @@ class Model_Live extends PhalApi_Model_NotORM {
"totalcoin"=>$luckcoin,
"showid"=>$showid,
"mark"=>$giftinfo['mark'],
"addtime"=>$addtime
"addtime"=>$addtime,
'coin' => $u['coin'],
);
DI()->notorm->users_coinrecord->insert($insert);
break;
......@@ -730,7 +733,9 @@ class Model_Live extends PhalApi_Model_NotORM {
DI()->notorm->users
->where('id = ?', $uid)
->update( array('coin' => new NotORM_Literal("coin + {$wincoin2}") ));
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array(
'coin' => $u['coin'],
"type"=>'income',
"action"=>'jackpotwin',
"uid"=>$uid,
......@@ -842,7 +847,8 @@ class Model_Live extends PhalApi_Model_NotORM {
}
/* 写入记录 或更新 */
$insert=array("type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$liveuid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
$isup=DI()->notorm->users_coinrecord->insert($insert);
$userinfo2 =DI()->notorm->users
......
......@@ -99,7 +99,7 @@ class Model_Login extends PhalApi_Model_NotORM {
}
$uid=$rs['id'];
if($reg_reward>0){
$insert=array("type"=>'income',"action"=>'reg_reward',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$reg_reward,"showid"=>0,"addtime"=>time() );
$insert=array('coin' => $data['coin'], "type"=>'income',"action"=>'reg_reward',"uid"=>$uid,"touid"=>$uid,"giftid"=>0,"giftcount"=>1,"totalcoin"=>$reg_reward,"showid"=>0,"addtime"=>time() );
DI()->notorm->users_coinrecord->insert($insert);
}
$code=$this->createCode();
......
......@@ -3,9 +3,9 @@
class Model_Red extends PhalApi_Model_NotORM {
/* 发布红包 */
public function sendRed($data) {
$rs = array('code' => 0, 'msg' => '发送成功', 'info' => array());
$uid=$data['uid'];
$total=$data['coin'];
$ifok=DI()->notorm->users
......@@ -13,18 +13,18 @@ class Model_Red extends PhalApi_Model_NotORM {
->update(array('coin' => new NotORM_Literal("coin - {$total}") ,'consumption' => new NotORM_Literal("consumption + {$total}") ) );
if(!$ifok){
$rs['code']=1009;
$rs['msg']='余额不足';
$rs['msg']='余额不足';
return $rs;
}
$result= DI()->notorm->red->insert($data);
if(!$result){
$rs['code']=1009;
$rs['msg']='发送失败,请重试';
$rs['msg']='发送失败,请重试';
return $rs;
}
$type='expend';
$action='sendred';
$uid=$data['uid'];
......@@ -33,15 +33,14 @@ class Model_Red extends PhalApi_Model_NotORM {
$total=$data['coin'];
$showid=$data['showid'];
$addtime=$data['addtime'];
$insert=array("type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$uid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$uid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
DI()->notorm->users_coinrecord->insert($insert);
$rs['info']=$result;
return $rs;
}
}
/* 红包列表 */
public function getRedList($liveuid,$showid){
$list=DI()->notorm->red
......@@ -63,15 +62,15 @@ class Model_Red extends PhalApi_Model_NotORM {
$showid=$data['showid'];
$addtime=$data['addtime'];
unset($data['showid']);
$insert=array("type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$uid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
$insert=array('coin' => $u['coin'],"type"=>$type,"action"=>$action,"uid"=>$uid,"touid"=>$uid,"giftid"=>$giftid,"giftcount"=>$giftcount,"totalcoin"=>$total,"showid"=>$showid,"addtime"=>$addtime );
DI()->notorm->users_coinrecord->insert($insert);
$result= DI()->notorm->red_record->insert($data);
DI()->notorm->users
->where('id = ?', $uid)
->update(array('coin' => new NotORM_Literal("coin + {$total}") ) );
......@@ -80,7 +79,7 @@ class Model_Red extends PhalApi_Model_NotORM {
->where('id = ?', $giftid)
->update(array('coin_rob' => new NotORM_Literal("coin_rob + {$total}") ,'nums_rob' => new NotORM_Literal("nums_rob + 1") ) );
return $result;
}
}
/* 抢红包列表 */
public function getRedRobList($redid){
......@@ -91,7 +90,7 @@ class Model_Red extends PhalApi_Model_NotORM {
->fetchAll();
return $list;
}
/* 红包信息 */
public function getRedInfo($redid){
$redinfo=DI()->notorm->red
......@@ -106,6 +105,6 @@ class Model_Red extends PhalApi_Model_NotORM {
unset($redinfo['status']);
}
return $redinfo;
}
}
......@@ -854,9 +854,9 @@ class Model_User extends PhalApi_Model_NotORM {
DI()->notorm->users
->where('id=?',$uid)
->update(array( "coin"=>new NotORM_Literal("coin + {$coin}"), "consumption" => new NotORM_Literal("consumption + {$loginCoin}") ));
$u = DI()->notorm->users->select('coin')->where('id = ' . $uid)->fetchOne();
/* 记录 */
$insert=array("type"=>'income',"action"=>'loginbonus',"uid"=>$uid,"touid"=>$uid,"giftid"=>$bonus_day,"giftcount"=>'0',"totalcoin"=>$coin,"showid"=>'0',"addtime"=>$nowtime );
$insert=array('coin' => $u['coin'],"type"=>'income',"action"=>'loginbonus',"uid"=>$uid,"touid"=>$uid,"giftid"=>$bonus_day,"giftcount"=>'0',"totalcoin"=>$coin,"showid"=>'0',"addtime"=>$nowtime );
DI()->notorm->users_coinrecord->insert($insert);
}
$rs=1;
......
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