This commit is contained in:
aozhiwei 2021-11-23 16:42:46 +08:00
parent d2ddba89a2
commit d82b9163e4
3 changed files with 54 additions and 57 deletions

View File

@ -7,40 +7,49 @@ class Additem(object):
def __init__(self):
self.apis = [
{
'desc': 'additem',
'desc': '添加道具additem',
'group': 'Additem',
'url': 'webapp/index.php?c=Additem&a=additem',
'params': [
_common.ReqHead(),
['item_id', 0, '道具id'],
['item_num', 0, '道具数量'],
['time', 0, '时间'],
],
'response': [
_common.RspHead(),
]
},
{
'desc': 'addDiamond',
'desc': '添加钻石addDiamond',
'group': 'Additem',
'url': 'webapp/index.php?c=Additem&a=addDiamond',
'params': [
_common.ReqHead(),
['item_id', 0, '道具id'],
['item_num', 0, '道具数量'],
['time', 0, '时间'],
],
'response': [
_common.RspHead(),
]
},
{
'desc': 'addCoin',
'desc': '添加金币addCoin',
'group': 'Additem',
'url': 'webapp/index.php?c=Additem&a=addCoin',
'params': [
_common.ReqHead(),
['item_id', 0, '道具id'],
['item_num', 0, '道具数量'],
['time', 0, '时间'],
],
'response': [
_common.RspHead(),
]
},
{
'desc': 'getCoin',
'desc': '获取金币getCoin',
'group': 'Additem',
'url': 'webapp/index.php?c=Additem&a=getCoin',
'params': [

View File

@ -23,7 +23,28 @@ class AdditemController extends BaseAuthedController {
return;
}
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 {
phpcommon\SqlHelper::upsert
($this->getSelfMysql(),
@ -62,16 +83,16 @@ class AdditemController extends BaseAuthedController {
$this->rspOk();
}
//添加钻石
public function addDiamond()
{
if (SERVER_ENV == _ONLINE) {
$this->rspOk();
return;
}
$item_id = $_REQUEST['item_id'];
$item_num = $_REQUEST['item_num'];
$accountid = $_REQUEST['account_id'];
$time = $_REQUEST['time'];
// if (phpcommon\getIPv4() != '124.78.1.111') {
// return;
// }
if ($_REQUEST['passwd'] != 'kingsome') {
return;
}
@ -87,10 +108,7 @@ class AdditemController extends BaseAuthedController {
':diamond_num' => $item_num + $row['diamond_num'],
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
$this->rspOk();
}
//添加金币
@ -123,7 +141,6 @@ class AdditemController extends BaseAuthedController {
}
}
//兑换金币
public function getCoin()
{
$accountid = $_REQUEST['account_id'];
@ -164,48 +181,5 @@ class AdditemController extends BaseAuthedController {
'coin_nums' => $addnum + $row['coin_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;
}
}
}
}

View File

@ -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;
}
}