diff --git a/doc/Role.py b/doc/Role.py index 76769b0..adb6e23 100644 --- a/doc/Role.py +++ b/doc/Role.py @@ -150,7 +150,36 @@ class Role(object): ] }, { - 'desc': 'addGiveMeFive', + 'desc': '获取金币数updateMoney', + 'group': 'Role', + 'url': 'webapp/index.php?c=Role&a=updateMoney', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['data', [ + ['coin_num', 0, '金币数'] + ], '数据'] + ] + }, + { + 'desc': '获取金币和点券数updateMoneyAndLottery', + 'group': 'Role', + 'url': 'webapp/index.php?c=Role&a=updateMoneyAndLottery', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['data', [ + ['coin_num', 0, '金币数'], + ['rmb', 0, '点券数'] + ], '数据'] + ] + }, + { + 'desc': '点赞(该接口貌似没用)addGiveMeFive', 'group': 'NPlayerInfo', 'url': 'webapp/index.php?c=NPlayerInfo&a=addGiveMeFive', 'params': [ diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index 0fd326d..0b076ca 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -564,74 +564,46 @@ class RoleController extends BaseAuthedController { public function updateMoney() { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $sqlStr = "SELECT coin_num FROM user WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) { - error_log("UpdateMoney======".json_encode($row)); - } - else{ - error_log("Test06======="); - } - $this->sendDataToClient(1,"ok",$row[0]); + $userInfo = $this->getUserInfo(array( + 'coin_num' + )); + $this->sendDataToClient(1, "ok", $userInfo); } public function updateMoneyAndLottery() { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $sqlStr = "SELECT coin_num,rmb_num FROM user WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) { - error_log("UpdateMoneyAndLottery======".json_encode($row)); - } - else{ - - } - $this->sendDataToClient(3,"ok",$row[0]); + $userInfo = $this->getUserInfo(array( + 'coin_num', + 'rmb_num' + )); + $this->sendDataToClient(3, "ok", $userInfo); } - private function getGiveMeFive()//获得玩家被点赞的次数 + public function addGiveMeFive() { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); - $giveMeFiveCnt = 0; - $sqlStr = "SELECT give_me_five FROM player_info WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) { - $giveMeFiveCnt = $row["give_me_five"]; - } - //error_log("当前GiveMeFiveCnt===".$giveMeFiveCnt); - return $giveMeFiveCnt; - } - - public function addGiveMeFive()//玩家被点赞一次 - { - //error_log("玩家被点赞===".$this->getAccountId()); - $tmpCnt = $this->getGiveMeFive(); - $tmpCnt ++; - phpcommon\SqlHelper::insertOrUpdate + phpcommon\SqlHelper::upsert ($this->getSelfMysql(), 'player_info', array( 'accountid' => $this->getAccountId() ), array( - 'accountid' => $this->getAccountId(), - 'give_me_five' => $tmpCnt, - 'createtime' => $this->getNowTime(), + 'give_me_five' => function () { + return 'give_me_five + 1'; + }, 'modifytime' => $this->getNowTime() ), array( - 'give_me_five' => $tmpCnt, + 'accountid' => $this->getAccountId(), + 'give_me_five' => 1, + 'createtime' => $this->getNowTime(), 'modifytime' => $this->getNowTime() ) ); $this->sendDataToClient(100,"getGiveMeFiveTest",null); } - public function getPlayerInfo()//获得玩家个人信息 + public function getPlayerInfo() { $account_id = $_REQUEST['acctID'];