From 81e5261dc0764ba113b358587ea745948080db08 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 26 Nov 2021 17:55:04 +0800 Subject: [PATCH] 1 --- doc/Bag.py | 189 +------- doc/Gun.py | 65 +-- doc/_common.py | 11 +- webapp/controller/BagController.class.php | 520 +--------------------- webapp/controller/GunController.class.php | 294 +----------- webapp/models/GunSkin.php | 35 ++ 6 files changed, 97 insertions(+), 1017 deletions(-) create mode 100644 webapp/models/GunSkin.php diff --git a/doc/Bag.py b/doc/Bag.py index c149ac1..5a2b8a3 100644 --- a/doc/Bag.py +++ b/doc/Bag.py @@ -6,180 +6,17 @@ class Bag(object): def __init__(self): self.apis_ = [ - { - 'desc': 'getBagInfo', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=getBagInfo', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'exchangeBagItem', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=exchangeBagItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'downItem', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=downItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'downItemColor', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=downItemColor', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'tryItem', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=tryItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'freeGetItem', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=freeGetItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'updateWeizhuang', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=updateWeizhuang', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'deleteItem', - 'group': 'Bag', - 'url': 'webapp/index.php?c=Bag&a=deleteItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'testPhpFunc', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=testPhpFunc', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'addItemToDB', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=addItemToDB', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'saleItem', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=saleItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'useItem', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=useItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'updateBag', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=updateBag', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'getAllItem', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=getAllItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'getAllYokeItem', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=getAllYokeItem', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'testPhpFunc2', - 'group': 'NBag', - 'url': 'webapp/index.php?c=NBag&a=testPhpFunc2', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, + { + 'name': 'itemList', + 'desc': '获取背包物品列表', + 'group': 'Bag', + 'url': 'webapp/index.php?c=Bag&a=itemList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!item_list', _common.Item, '物品列表'] + ] + }, ] diff --git a/doc/Gun.py b/doc/Gun.py index ff6c2e6..7fc2bcb 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -6,56 +6,17 @@ class Gun(object): def __init__(self): self.apis_ = [ - { - 'desc': '获取枪支信息-getGunInfo', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=getGunInfo', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!data', [_common.GunInfo()], '枪支信息列表'] - ] - }, - { - 'desc': '升级枪支技能等级skillLvUp', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=skillLvUp', - 'params': [ - _common.ReqHead(), - ['skill_id', 0, '天赋id'], - ['skill_type_id', 0, '枪支类型'], - ], - 'response': [ - _common.RspHead(), - ['data', _common.GunInfo(), '枪支信息'] - ] - }, - { - 'desc': '获取枪支和皮肤信息getGunAndSkinInfo', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=getGunAndSkinInfo', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!data', _common.GunSkinInfo(), '枪支皮肤信息'] - ] - }, - { - 'desc': '装备枪支皮肤equipGunSkin', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=equipGunSkin', - 'params': [ - _common.ReqHead(), - ['gun_id', 0, '枪支id'], - ['skin_id', 0, '皮肤id'], - ], - 'response': [ - _common.RspHead(), - ['data', _common.GunSkinInfo(), '枪支皮肤信息'] - ] - }, + { + 'name': 'skinList', + 'desc': '获取枪械皮肤列表', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=skinList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!skin_list', _common.GunSkin, '枪械皮肤列表'] + ] + }, ] diff --git a/doc/_common.py b/doc/_common.py index 0b808aa..c669274 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -16,16 +16,7 @@ class RspHead(object): ['errmsg', '', '错误描述'], ] -class GunInfo(object): - - def __init__(self): - self.fields = [ - ['gun_type_id', 0, '枪支类型'], - ['skill_id', 0, '技能id'], - ['skill_lv', 0, '技能等级'], - ] - -class GunSkinInfo(object): +class GunSkin(object): def __init__(self): self.fields = [ diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index 775a5ef..b4fda39 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -1,515 +1,31 @@ bagTableCache == null) { - $this->bagTableCache = require('../res/bag@bag.php'); - } - $bag_conf = getBagConfig($this->bagTableCache, $bag_id); - $b = array( - 'id' => $bag_conf['id'], - 'name' => $bag_conf['name'], - 'fuction' => $bag_conf['fuction'], + $itemList = array(); + SqlHelper::ormSelect( + $this->_getSelfMysql(), + 't_bag', + array( + 'accountid' => $this->_getAccountId() + ), + function ($row) use(&$itemList) { + array_push($itemList, Bag::toDto($row)); + } ); - return $b; - } - - public function getBagInfo() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->_getMysql($account_id); - $bag_list = array(); - $rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:account_id;', - array( - ':account_id' => $account_id - )); - if ($rows) { - foreach ($rows as $row){ - $active_time = 0; - $color_id = 0; - $status = $row['status']; - if (phpcommon\getNowTime() >= $row['active_time'] && $row['active_time'] != 0) { - $ret = $conn->execScript('UPDATE bag SET active_time=0, color_id=0, status=2, modify_time=:modify_time ' . - ' WHERE accountid=:account_id AND id=:id;', - array( - ':account_id' => $account_id, - ':id' => $row['id'], - ':modify_time' => phpcommon\getNowTime() - )); - if (!$ret) { - die(); - return; - } - $active_time = 0; - $color_id = 0; - $status = 2; - } else { - if ($row['active_time'] != 0) { - $active_time = $row['active_time']; - } - $color_id = $row['color_id']; - $status = $row['status']; - } - array_push($bag_list, array( - 'id' => $row['id'], - 'active_time' => $active_time, - 'status' => $status, - 'color_id' => $color_id, - 'num' => $row['num'], - )); - } - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'bag_list' => $bag_list + $this->_rspData(array( + 'item_list' => $itemList )); } - public function exchangeBagItem() { - $account_id = $_REQUEST['account_id']; - $item_id = $_REQUEST['item_id']; - $color_id = $_REQUEST['color_id']; - $conn = $this->_getMysql($account_id); - $b = $this->getBag($item_id); - $bag_meta_table = require('../res/bag@bag.php'); - //正在装备的道具 - if ($b['fuction'] != 5 && $b['fuction'] != 6) { - foreach ($bag_meta_table as $bag_info) { - $id = $bag_info['id']; - $bag = $this->getBag($id); - if ($bag['fuction'] != $b['fuction']) { - continue; - } - $row = $conn->execQueryOne('SELECT status, active_time FROM bag WHERE accountid=:accountid AND id=:id;', - array( - ':accountid' => $account_id, - ':id' => $id, - )); - if ($row['status'] != 0 || !$row) { - continue; - } - $status = 2; - if ($row['active_time'] == 0) { - $status = 1; - } - $using_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' . - ' WHERE accountid = :account_id AND id = :id;', - array( - ':account_id' => $account_id, - ':id' => $id, - ':status' => $status, - ':modify_time' => phpcommon\getNowTime() - )); - if(!$using_ret){ - die(); - return; - } - } - } - //要装备的道具 - $row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:accountid AND id=:id;', - array( - ':accountid' => $account_id, - ':id' => $item_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); - return; - } - - $exchange_ret = $conn->execScript('UPDATE bag SET status=0, color_id=:color_id, modify_time=:modify_time ' . - ' WHERE accountid = :account_id AND id = :id;', - array( - ':account_id' => $account_id, - ':id' => $item_id, - ':color_id' => $color_id, - ':modify_time' => phpcommon\getNowTime() - )); - if(!$exchange_ret){ - die(); - return; - } - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_id' => $item_id, - 'color_id' => $color_id - )); - } - - public function downItem() - { - $account_id = $_REQUEST['account_id']; - $item_id = $_REQUEST['item_id']; - $conn = $this->_getMysql($account_id); - $b = $this->getBag($item_id); - - $row = $conn->execQueryOne('SELECT status,active_time FROM bag WHERE accountid=:accountid AND id=:id;', - array( - ':accountid' => $account_id, - ':id' => $item_id, - )); - if (!$row) { - phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具'); - return; - } - $status = 2; - if ($row['active_time'] == 0) { - $status = 1; - } - $exchange_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' . - ' WHERE accountid = :account_id AND id = :id;', - array( - ':account_id' => $account_id, - ':id' => $item_id, - ':status' => $status, - ':modify_time' => phpcommon\getNowTime() - )); - if(!$exchange_ret){ - die(); - return; - } - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_id' => $item_id, - 'color_id' => 0 - )); - } - - public function downItemColor() - { - $account_id = $_REQUEST['account_id']; - $item_id = $_REQUEST['item_id']; - $conn = $this->_getMysql($account_id); - $exchange_ret = $conn->execScript('UPDATE bag SET color_id=0, modify_time=:modify_time ' . - ' WHERE accountid = :account_id AND id = :id;', - array( - ':account_id' => $account_id, - ':id' => $item_id, - ':modify_time' => phpcommon\getNowTime() - )); - if(!$exchange_ret){ - die(); - return; - } - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_id' => $item_id, - 'color_id' => 0 - )); - } - - public function tryItem() - { - $account_id = $_REQUEST['account_id']; - $item_id = $_REQUEST['item_id']; - $conn = $this->_getMysql($account_id); - $addreward = new classes\AddReward(); - $ptime = mt\Parameter::getOldParam(RECOMMEND_TIME); - $addreward->addReward($item_id, 1, $account_id, $ptime['param_value'], 0); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_id' => $item_id, - 'color_id' => 0 - )); - } - - public function freeGetItem() - { - $account_id = $_REQUEST['account_id']; - $arr = $_REQUEST['arr']; - $delim = ','; - $item_multiply = explode($delim, $arr); - $all_item_list = array(); - $item_list = array(); - $addreward = new classes\AddReward(); - $random = Rand(0, 10000); - $time = 1; - $p = mt\Parameter::getOldParam(RECOMMEND_FOREVER_WEIGHT); - $ptime = mt\Parameter::getOldParam(RECOMMEND_TIME); - if ($random < $p['param_value']) { - $time = 0; - } else { - $time = $ptime['param_value']; - } - foreach ($item_multiply as $i) { - array_push($item_list, array( - 'item_id' => $i, - 'item_num' => 1, - 'time' => 1, - )); - $items = $addreward->addReward($i, 1, $account_id, $time, 1); - foreach($items as $it) { - array_push($all_item_list, array( - 'item_id' => $it['item_id'], - 'item_num' => $it['item_num'], - 'time' => $it['time'], - )); - } - } - $num = $addreward->getDiamondNum($account_id); - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'item_list' => $item_list, - 'diamond_nums' => $num, - 'all_item_list' => $all_item_list - )); - } - - public function updateWeizhuang() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->_getMysql($account_id); - $arr = json_decode($_REQUEST['arr'], true); - foreach ($arr as $a) { - $row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:account_id AND id=:id;', - array( - ':account_id' => $account_id, - ':id' => $a['id'] - )); - if (!$row) { - continue; - } - $status = $row['status']; - if ($a['count'] == 0) { - $status = 2; - } - $ret = $conn->execScript('UPDATE bag SET status=:status, num=:num, modify_time=:modify_time ' . - ' WHERE accountid = :account_id AND id = :id;', - array( - ':account_id' => $account_id, - ':id' => $a['id'], - ':status' => $status, - ':num' => $a['count'], - ':modify_time' => phpcommon\getNowTime() - )); - if(!$ret){ - die(); - return; - } - } - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - )); - } - - public function deleteItem() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->_getMysql($account_id); - $id = $_REQUEST['id']; - $row = $conn->execQueryOne('SELECT num, status FROM bag WHERE accountid=:account_id AND id=:id;', - array( - ':account_id' => $account_id, - ':id' => $id - )); - if (!$row || $row['num'] - 1 < 0) { - phpcommon\sendError(ERR_USER_BASE + 2, '道具不足'); - return; - } - $status = $row['status']; - if ($row['num'] - 1 <= 0) { - $status = 2; - } - $ret = $conn->execScript('UPDATE bag SET status=:status, num=:num, modify_time=:modify_time ' . - ' WHERE accountid = :account_id AND id = :id;', - array( - ':account_id' => $account_id, - ':id' => $id, - ':status' => $status, - ':num' => $row['num'] - 1, - ':modify_time' => phpcommon\getNowTime() - )); - if(!$ret){ - die(); - return; - } - - echo json_encode(array( - 'errcode' => 0, - 'errmsg' => '', - 'id' => $id, - 'num' => $row['num'] - 1 - )); - } - - public function addItemToDB() - { - // $itemArr = [10101,10102,10103,10104,10105,10106,10200,10201, - // 10202,10203,10204,10205,10206,10207,10208,12100,12102,12103,12104, - // 12105,12106,12107,12119,12120,12121]; - $itemIDArr = array(10101,10102,10103,10104,10105,10106,10200,10201,10202,10203,10204,10205,10206,10207,10208,12100,12102,12103,12104, - 12105,12106,12107,12119,12120,12121,1006,1005,1004,1003,1002,1001,17004); - $len = count($itemIDArr); - $itemArr = array(); - for($i = 0; $i< $len; $i++) - { - $itemN = rand(2,6); - if($itemIDArr[$i] == "17004") - { - $itemN = 30; - } - $itemData = array("item_id"=>$itemIDArr[$i],"item_num"=>$itemN); - array_push($itemArr,$itemData); - error_log("itemTest=01====".$itemIDArr[$i]."==".$itemN); - } - $this->_addItem($itemArr); - $this->sendDataToClient(1,"test03",null); - } - public function saleItem() - { - $newItemCfg = require('../res/newitem@newitem.php'); - $itemArr = array(); - $itemID = $_REQUEST['itemID']; - $itemNum = $_REQUEST['itemNum']; - $itemCfg = $newItemCfg[$itemID]; - $singlePrice = $itemCfg["sell_price"]; - //error_log("NewItemCfg=03=====".$itemID."===".$itemNum."==".$singlePrice); - - $deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum); - array_push($itemArr,$deleteItem); - $code = $this->_deleteItem($deleteItem); - //error_log("准备删除道具======".$code); - if($code == 100) - { - $this->_decItem($itemArr); - $this->_addGold($singlePrice*$itemNum); - - } - $resultArr = array('saleMoney'=>$singlePrice*$itemNum,'itemID'=>$itemID,'itemNum'=>$itemNum); - $this->sendDataToClient($code,"ok",$resultArr); - } - public function useItem() - { - $newItemCfg = require('../res/newitem@newitem.php'); - $itemID = $_REQUEST['itemID']; - $itemNum = $_REQUEST['itemNum']; - $itemCfg = $newItemCfg[$itemID]; - $dropID = $itemCfg["drop"]; - //error_log("掉落道具======".$dropID); - $item_list = array(); - $itemArr = array(); - $deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum); - array_push($itemArr,$deleteItem); - $code = $this->_deleteItem($deleteItem); - if($code == 100) - { - $this->_decItem($itemArr); - //合并打开礼包的获得的道具开始-- - if($dropID >0) - { - for($i = 0 ; $i < $itemNum; $i++) - { - $dropItemArr = metatable\getDropListById($dropID); - $dropItemLen = count($dropItemArr); - for($j = 0; $j < $dropItemLen ; $j++) - { - $itemID = $dropItemArr[$j]["item_id"]; - $itemListLen = count($item_list); - $isUpdate = 0; - for($k = 0; $k < $itemListLen; $k++) - { - if($item_list[$k]["item_id"] == $itemID) - { - $item_list[$k]["item_num"] += $dropItemArr[$j]["item_num"]; - $isUpdate = 1; - break; - } - } - if($isUpdate == 0) - { - array_push($item_list,$dropItemArr[$j]); - } - } - } - //合并打开礼包的获得的道具结束-- - $resultDropItemLen = count($item_list); - if($resultDropItemLen >0) - { - $this->_addItem($item_list); - } - - } - } - // error_log("dropInfo=======".json_encode($item_list)); - // error_log("使用道具=====".json_encode($itemCfg)); - $resultArr = array('itemID'=>$itemID,'itemNum'=>$itemNum,"dropItem"=>$item_list); - $this->sendDataToClient($code,"ok",$resultArr); - } - public function updateBag() - { - $this->getAllItem(); - } - public function getAllItem() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->_getMysql($account_id); - $sqlStr = "SELECT * FROM bag WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) { - - } - $this->sendDataToClient(0,"test03",$row); - } - public function getAllYokeItem() - { - $account_id = $_REQUEST['account_id']; - $conn = $this->_getMysql($account_id); - $sqlStr = "SELECT * FROM bag WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - $allYokeItem = array(); - $newItemCfg = require('../res/newitem@newitem.php'); - if($row) { - $len = count($row); - for($i = 0; $i < $len ; $i++) - { - $itemID = $row[$i]["id"]; - $itemNum = $row[$i]["num"]; - //error_log("Item=====".json_encode($row[$i])); - if(isset($newItemCfg[$itemID])) - { - $itemCfg = $newItemCfg[$itemID]; - if($itemCfg) - { - if($itemCfg["type"] == 10) - { - $itemData = array("item_id"=>$itemID,"item_num"=>$itemNum); - array_push($allYokeItem,$itemData); - } - - } - else - { - error_log("未定义======".$itemID."==".$len."==".$i); - } - } - - } - - } - else{ - error_log("GetYokeItem======="); - } - $this->sendDataToClient(100,"allYokeItem",$allYokeItem); - } - } diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index c9add83..16b77ff 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -4,288 +4,28 @@ require_once('mt/NewShop.php'); require_once('mt/GunTalentLv.php'); require_once('mt/GunTalent.php'); +require_once('models/GunSkin.php'); + +use phpcommon\SqlHelper; +use models\GunSkin; + class GunController extends BaseAuthedController { - public function getGunInfo() + public function skinList() { - $data = array(); - phpcommon\SqlHelper::select - ($this->_getSelfMysql(), - 'gun_intensify', - array( - 'gun_type_id', - 'skill_id', - 'skill_lv' - ), - array( - 'accountid' => $this->_getAccountId() - ), - function ($row) use(&$data) { - array_push($data, array( - 'gun_type_id' => $row['gun_type_id'], - 'skill_id' => $row['skill_id'], - 'skill_lv' => $row['skill_lv'], - )); - } - ); - $this->_rspDataOld($data); - } - - public function skillLvUp() - { - $talentId = $_REQUEST['skill_id']; - $gunTypeId = $_REQUEST['skill_type_id']; - $talentLvMeta = mt\GunTalentLv::get($talentId); - if (!$talentLvMeta) { - $this->_rspErr(99, "技能不存在"); - return; - } - $gunTalentMeta = mt\GunTalentLv::get($gunTypeId); - if (!$gunTalentMeta) { - $this->_rspErr(1, "参数错误"); - return; - } - if (!mt\GunTalentLv::isValidTalent($gunTypeId, $talentId)) { - $this->_rspErr(1, "参数错误"); - return; - } - $talentLv = $this->_getTalentLv($talentId, $gunTypeId); - if (mt\GunTalentLv::isFullLv($talentLvMeta, $talentLv)) { - $this->_rspErr(98, "已满级"); - return; - } - $nextLvMeta = mt\GunTalentLv::getByLv($meta, $talentLv + 1); - if (!$nextLvMeta) { - $this->_rspErr(2, "配置表错误"); - return; - } - $costList = mt\GunTalentLv::getCostList($nextLvMeta); - $lackItem = array(); - if (!$this->_hasEnoughItemsEx($costItem, $lackItem)) { - switch ($lackItem['item_id']) { - case V_ITEM_GOLD: - { - $this->_rspErr(97, "金币不足"); - } - break; - case V_ITEM_DIAMOND: - { - $this->_rspErr(96, "钻石不足"); - } - break; - default: - { - $this->_rspErr(95, "道具不足"); - } - break; - } - return; - } - ++$talentLv; - phpcommon\SqlHelper::upsert - ($this->_getSelfMysql(), - 'gun_intensify', - array( - 'accountid' => $this->_getAccountId(), - 'gun_type_id' => $gunTypeId, - 'skill_id' => $talentId - ), - array( - 'skill_lv' => $talentLv, - 'modifytime' => $this->_getNowTime() - ), - array( - 'accountid' => $this->_getAccountId(), - 'gun_type_id' => $gunTypeId, - 'skill_id' => $talentId, - 'skill_lv' => $talentLv, - 'createtime' => $this->_getNowTime(), - 'modifytime' => $this->_getNowTime() - ) - ); - $this->_rspRawData(array( - 'errcode' => 100, - 'errmsg' => '', - 'data' => array( - 'gun_type_id' => $gunTypeId, - 'skill_id' => $talentId, - 'skill_lv' => $talentLv, - ) - )); - } - - public function getGunAndSkinInfo() - { - $data = array(); - phpcommon\SqlHelper::select - ($this->_getSelfMysql(), - 'gun', - array( - 'gun_id', - 'skin_id' - ), - array( - 'accountid' => $this->_getAccountId() - ), - function ($row) use(&$data) { - array_push($data, array( - 'gun_id' => $row['gun_id'], - 'skin_lv' => $row['skin_id'], - )); - } - ); - phpcommon\SqlHelper::select - ($this->_getSelfMysql(), - 'gun_skin', - array( - 'gun_id', - 'skin_id' - ), - array( - 'accountid' => $this->_getAccountId() - ), - function ($row) use(&$data) { - array_push($data, array( - 'gun_id' => $row['gun_id'], - 'skin_lv' => $row['skin_id'], - )); - } - ); - $this->_rspRawData(array( - 'errcode' => 100, - 'errmsg' => '', - 'data' => $data - )); - } - - public function equipGunSkin() - { - $gunId = $_REQUEST['gun_id']; - $skinId = $_REQUEST['skin_id']; - - phpcommon\SqlHelper::upsert - ($this->_getSelfMysql(), - 'gun', - array( - 'accountid' => $this->_getAccountId(), - 'gun_id' => $gunId - ), - array( - ), - array( - 'accountid' => $this->_getAccountId(), - 'gun_id' => $gunId, - 'skin_id' => $skinId, - 'trytime' => 0, - 'createtime' => $this->_getNowTime(), - 'modifytime' => $this->_getNowTime() - ) - ); - $this->_rspRawData(array( - 'errcode' => 100, - 'errmsg' => '', - 'data' => array( - 'gun_id' => $gunId, - 'skin_id' => $skinId - ) - )); - } - - public function buyGunSkin() - { - $account_id = $_REQUEST['account_id']; - $gunId = $_REQUEST['gun_id']; - $skinId = $_REQUEST['skin_id']; - $goodsId = $_REQUEST['goodsID']; - - $shopMeta = mt\NewShop::getShopItemById(3); - if (!$shopMeta) { - $this->_rspErr(1, "参数错误"); - return; - } - $goodsInfo = mt\NewShop::getGoodsInfo($shopMeta, $goodsId); - if (!$goodsInfo) { - $this->_rspErr(1, "参数错误"); - return; - } - $costList = array( + $skinList = array(); + SqlHelper::ormSelect( + $this->_getSelfMysql(), + 't_gun_skin', array( - 'item_id' => $goodsInfo['costItemId'], - 'item_num' => $goodsInfo['costItemNum'], - ) + 'accountid' => $this->_getAccountId() + ), + function ($row) use(&$skinList) { + array_push($skinList, GunSkin::toDto($row)); + } ); - $lackItem = array(); - if (!$this->_hasEnoughItemsEx($costItem, $lackItem)) { - switch ($lackItem['item_id']) { - case V_ITEM_GOLD: - { - $this->_rspErr(88, "金币不足"); - } - break; - case V_ITEM_DIAMOND: - { - $this->_rspErr(87, "钻石不足"); - } - break; - default: - { - $this->_rspErr(86, "道具不足"); - } - break; - } - return; - } - { - phpcommon\SqlHelper::upsert - ($this->_getSelfMysql(), - 'gun_skin', - array( - 'accountid' => $this->_getAccountId(), - 'gun_id' => $gunId, - 'skin_id' => $skinId - ), - array( - 'trytime' => 0, - 'modifytime' => $this->_getNowTime() - ), - array( - 'accountid' => $this->_getAccountId(), - 'gun_id' => $gunId, - 'skin_id' => $skinId, - 'trytime' => 0, - 'createtime' => $this->_getNowTime(), - 'modifytime' => $this->_getNowTime() - ) - ); - - phpcommon\SqlHelper::upsert - ($this->_getSelfMysql(), - 'gun', - array( - 'accountid' => $this->_getAccountId(), - 'gun_id' => $gunId - ), - array( - 'skin_id' => $skinId, - 'modifytime' => $this->_getNowTime() - ), - array( - 'accountid' => $this->_getAccountId(), - 'gun_id' => $gunId, - 'skin_id' => $skinId, - 'trytime' => 0, - 'createtime' => $this->_getNowTime(), - 'modifytime' => $this->_getNowTime() - ) - ); - } - $this->_rspRawData(array( - 'errcode' => 100, - 'errmsg' => '', - 'data' => array( - 'gun_id' => $gunId, - 'skin_id' => $skinid - ) + $this->_rspData(array( + 'skin_list' => $skinList )); } diff --git a/webapp/models/GunSkin.php b/webapp/models/GunSkin.php new file mode 100644 index 0000000..687aa4c --- /dev/null +++ b/webapp/models/GunSkin.php @@ -0,0 +1,35 @@ +_getSelfMysql(), + 't_gun_skin', + array( + 'accountid' => myself()->_getAccountId(), + 'skin_id' => $skinId + ) + ); + return $row; + } + + public static function toDto($row) + { + return array( + 'skin_id' => $row['skin_id'], + 'skin_state' => $row['skin_state'], + 'try_expire_at' => $row['try_expire_at'], + ); + } + +}