1
This commit is contained in:
parent
d2ddba89a2
commit
d82b9163e4
@ -7,40 +7,49 @@ class Additem(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.apis = [
|
self.apis = [
|
||||||
{
|
{
|
||||||
'desc': 'additem',
|
'desc': '添加道具additem',
|
||||||
'group': 'Additem',
|
'group': 'Additem',
|
||||||
'url': 'webapp/index.php?c=Additem&a=additem',
|
'url': 'webapp/index.php?c=Additem&a=additem',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
|
['item_id', 0, '道具id'],
|
||||||
|
['item_num', 0, '道具数量'],
|
||||||
|
['time', 0, '时间'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'desc': 'addDiamond',
|
'desc': '添加钻石addDiamond',
|
||||||
'group': 'Additem',
|
'group': 'Additem',
|
||||||
'url': 'webapp/index.php?c=Additem&a=addDiamond',
|
'url': 'webapp/index.php?c=Additem&a=addDiamond',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
|
['item_id', 0, '道具id'],
|
||||||
|
['item_num', 0, '道具数量'],
|
||||||
|
['time', 0, '时间'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'desc': 'addCoin',
|
'desc': '添加金币addCoin',
|
||||||
'group': 'Additem',
|
'group': 'Additem',
|
||||||
'url': 'webapp/index.php?c=Additem&a=addCoin',
|
'url': 'webapp/index.php?c=Additem&a=addCoin',
|
||||||
'params': [
|
'params': [
|
||||||
_common.ReqHead(),
|
_common.ReqHead(),
|
||||||
|
['item_id', 0, '道具id'],
|
||||||
|
['item_num', 0, '道具数量'],
|
||||||
|
['time', 0, '时间'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'desc': 'getCoin',
|
'desc': '获取金币getCoin',
|
||||||
'group': 'Additem',
|
'group': 'Additem',
|
||||||
'url': 'webapp/index.php?c=Additem&a=getCoin',
|
'url': 'webapp/index.php?c=Additem&a=getCoin',
|
||||||
'params': [
|
'params': [
|
||||||
|
@ -23,7 +23,28 @@ class AdditemController extends BaseAuthedController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($it['type'] == 12) {
|
if ($it['type'] == 12) {
|
||||||
$this->addEquip($item_id, $item_num, $time, $this->getAccountId());
|
$usingId = emptyReplace($this->getUsingEquipId(), $item_id);
|
||||||
|
phpcommon\SqlHelper::upsert
|
||||||
|
($this->getSelfMysql(),
|
||||||
|
'equip',
|
||||||
|
array(
|
||||||
|
'accountid' => $this->getAccountId(),
|
||||||
|
'id' => $item_id,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => $this->getAccountId(),
|
||||||
|
'id' => $item_id,
|
||||||
|
'active_time' => 0,
|
||||||
|
'create_time' => phpcommon\getNowTime(),
|
||||||
|
'modify_time' => phpcommon\getNowTime(),
|
||||||
|
'sub_time' => 0,
|
||||||
|
'using_id' => $usingId,
|
||||||
|
'lv' => 0,
|
||||||
|
'exp' => 0,
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
phpcommon\SqlHelper::upsert
|
phpcommon\SqlHelper::upsert
|
||||||
($this->getSelfMysql(),
|
($this->getSelfMysql(),
|
||||||
@ -62,16 +83,16 @@ class AdditemController extends BaseAuthedController {
|
|||||||
$this->rspOk();
|
$this->rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加钻石
|
|
||||||
public function addDiamond()
|
public function addDiamond()
|
||||||
{
|
{
|
||||||
|
if (SERVER_ENV == _ONLINE) {
|
||||||
|
$this->rspOk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
$item_id = $_REQUEST['item_id'];
|
$item_id = $_REQUEST['item_id'];
|
||||||
$item_num = $_REQUEST['item_num'];
|
$item_num = $_REQUEST['item_num'];
|
||||||
$accountid = $_REQUEST['account_id'];
|
$accountid = $_REQUEST['account_id'];
|
||||||
$time = $_REQUEST['time'];
|
$time = $_REQUEST['time'];
|
||||||
// if (phpcommon\getIPv4() != '124.78.1.111') {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
if ($_REQUEST['passwd'] != 'kingsome') {
|
if ($_REQUEST['passwd'] != 'kingsome') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -87,10 +108,7 @@ class AdditemController extends BaseAuthedController {
|
|||||||
':diamond_num' => $item_num + $row['diamond_num'],
|
':diamond_num' => $item_num + $row['diamond_num'],
|
||||||
':modify_time' => phpcommon\getNowTime()
|
':modify_time' => phpcommon\getNowTime()
|
||||||
));
|
));
|
||||||
if (!$ret) {
|
$this->rspOk();
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加金币
|
//添加金币
|
||||||
@ -123,7 +141,6 @@ class AdditemController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//兑换金币
|
|
||||||
public function getCoin()
|
public function getCoin()
|
||||||
{
|
{
|
||||||
$accountid = $_REQUEST['account_id'];
|
$accountid = $_REQUEST['account_id'];
|
||||||
@ -164,48 +181,5 @@ class AdditemController extends BaseAuthedController {
|
|||||||
'coin_nums' => $addnum + $row['coin_num'],
|
'coin_nums' => $addnum + $row['coin_num'],
|
||||||
'rmb_nums' => $row['rmb_num'] - $num
|
'rmb_nums' => $row['rmb_num'] - $num
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function addEquip($id, $num, $time, $accountid)
|
|
||||||
{
|
|
||||||
$item_id = $id;
|
|
||||||
$conn = $this->getMysql($accountid);
|
|
||||||
$row = $conn->execQueryOne('SELECT id FROM equip WHERE accountid=:accountid AND id=:id;',
|
|
||||||
array(
|
|
||||||
':accountid' => $accountid,
|
|
||||||
':id' => $item_id,
|
|
||||||
));
|
|
||||||
//没有装备解锁装备
|
|
||||||
$item_list = array();
|
|
||||||
if (!$row) {
|
|
||||||
$rows = $conn->execQuery('SELECT using_id FROM equip WHERE accountid=:accountid;',
|
|
||||||
array(
|
|
||||||
':accountid' => $accountid,
|
|
||||||
));
|
|
||||||
$using_id = $item_id;
|
|
||||||
if ($rows) {
|
|
||||||
foreach ($rows as $r) {
|
|
||||||
$using_id = $r['using_id'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$ret = $conn->execScript('INSERT INTO equip(accountid, id, lv, active_time, sub_time, create_time, modify_time, using_id, exp) ' .
|
|
||||||
' VALUES(:account_id, :id, 0, :active_time, :sub_time, :create_time, :modify_time, :using_id, :exp) ' .
|
|
||||||
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, lv=0, active_time=:active_time, sub_time=:sub_time, modify_time=:modify_time, using_id=:using_id, exp=:exp;',
|
|
||||||
array(
|
|
||||||
':account_id' => $accountid,
|
|
||||||
':id' => $item_id,
|
|
||||||
':active_time' => 0,
|
|
||||||
':create_time' => phpcommon\getNowTime(),
|
|
||||||
':modify_time' => phpcommon\getNowTime(),
|
|
||||||
':sub_time' => 0,
|
|
||||||
':using_id' => $using_id,
|
|
||||||
':exp' => 0,
|
|
||||||
));
|
|
||||||
if(!$ret){
|
|
||||||
die();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,4 +591,18 @@ class BaseAuthedController extends BaseController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getUsingEquipId()
|
||||||
|
{
|
||||||
|
$row = phpcommon\SqlHelper::selectOne
|
||||||
|
($this->getSelfMysql(),
|
||||||
|
'equip',
|
||||||
|
array(
|
||||||
|
'using_id',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'accountid' => $this->getAccountId(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row ? $row['using_id'] : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user