1
This commit is contained in:
parent
6a31c180f8
commit
a49918b880
@ -420,7 +420,7 @@ class HeroController extends BaseAuthedController {
|
||||
}
|
||||
$response = services\BlockChainService::gameItemMallBuy(
|
||||
Transaction::RESET_HERO_LEVEL_TYPE, services\BlockChainService::formatCurrency($price), V_ITEM_RESET_CARD, 1);
|
||||
$this->_setV(TN_DAILY_RESET_HERO_LEVEL_STATE, $hero_unnid, 1);
|
||||
$this->_setV(TN_DAILY_RESET_HERO_LEVEL_STATE, intval($hero_unnid), 1);
|
||||
BcOrder::upsert($response['trans_id'], array(
|
||||
'item_id' => V_ITEM_RESET_CARD,
|
||||
'item_num' => 1,
|
||||
|
@ -69,7 +69,7 @@ class BuyPassCbService
|
||||
'hero_unnid' => json_decode($order['ext_data']),
|
||||
)),
|
||||
));
|
||||
$this->_resetHeroLevel($order);
|
||||
$this->_resetHeroLevel($order,$itemService);
|
||||
error_log("callback resetHeroLevel address: {$order['address']}, order_id: {$order['order_id']}, item_id: {$order['item_id']}, item_num: {$order['item_num']}");
|
||||
$itemService->addGameLog($order['address'],"resetHero","end",array(
|
||||
'param1' => $order['order_id'],
|
||||
@ -86,7 +86,7 @@ class BuyPassCbService
|
||||
}
|
||||
}
|
||||
|
||||
private function _resetHeroLevel($order){
|
||||
private function _resetHeroLevel($order,$addItemService){
|
||||
$heroDb = SqlHelper::ormSelectOne(
|
||||
myself()->_getMysql($order['address']),
|
||||
't_hero',
|
||||
@ -122,35 +122,12 @@ class BuyPassCbService
|
||||
'rand_attr' => $heroDb['base_attr'],
|
||||
)
|
||||
);
|
||||
$conn = myself()->_getMysql($order['address']);
|
||||
$this->_addBagItem($conn,$order['account_id'],$piece_item_id,$piece);
|
||||
$this->_addBagItem($conn,$order['account_id'],V_ITEM_HERO_META,$serum);
|
||||
$this->_addBagItem($conn,$order['account_id'],V_ITEM_GOLD,$gold);
|
||||
$addItemService->addItem($order['address'],$piece_item_id,$piece);
|
||||
$addItemService->addItem($order['address'],V_ITEM_HERO_META,$serum);
|
||||
$addItemService->addItem($order['address'],V_ITEM_GOLD,$gold);
|
||||
$this->_updateDynData($order,TN_DAILY_RESET_HERO_LEVEL_STATE,json_decode($order['ext_data']));
|
||||
}
|
||||
|
||||
private function _addBagItem($conn,$accountId,$itemId,$itemNum){
|
||||
SqlHelper::upsert
|
||||
($conn,
|
||||
't_bag',
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'item_id' => $itemId
|
||||
),
|
||||
array(
|
||||
'item_num' => function () use($itemNum) { return "item_num + {$itemNum}";},
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
),
|
||||
array(
|
||||
'account_id' => $accountId,
|
||||
'item_id' => $itemId,
|
||||
'item_num' => $itemNum,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _activateUser($address){
|
||||
SqlHelper::update
|
||||
(myself()->_getMysql($address),
|
||||
@ -209,6 +186,8 @@ class BuyPassCbService
|
||||
}
|
||||
|
||||
private function _updateDynData($user,$x,$y){
|
||||
$x = intval($x) ;
|
||||
$y = intval($y) ;
|
||||
SqlHelper::update
|
||||
( myself()->_getMysql($user['address']),
|
||||
't_dyndata',
|
||||
|
@ -40,31 +40,36 @@ class ShopAddItemService
|
||||
}
|
||||
$accountId = $this->getAccountId($address);
|
||||
$conn = myself()->_getMysql($address);
|
||||
if (\mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) {
|
||||
$this->internalAddBag($conn,$itemId,$itemNum,$accountId);
|
||||
if ($this->_isVirtualItem($itemId)) {
|
||||
$this->_addVirtualItem($conn,$accountId,$itemId, $itemNum);
|
||||
}else{
|
||||
for ($i = 0; $i < $itemNum; $i++) {
|
||||
switch ($itemMeta['type']){
|
||||
case \mt\Item::HERO_TYPE : {
|
||||
$this->internalAddHero($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::GUN_TYPE : {
|
||||
$this->internalAddGun($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::CHIP_TYPE : {
|
||||
$this->internalAddChip($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::HERO_SKIN_TYPE : {
|
||||
$this->internalAddHeroSkin($conn,$itemMeta,$accountId);
|
||||
if (\mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) {
|
||||
$this->internalAddBag($conn,$itemId,$itemNum,$accountId);
|
||||
}else{
|
||||
for ($i = 0; $i < $itemNum; $i++) {
|
||||
switch ($itemMeta['type']){
|
||||
case \mt\Item::HERO_TYPE : {
|
||||
$this->internalAddHero($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::GUN_TYPE : {
|
||||
$this->internalAddGun($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::CHIP_TYPE : {
|
||||
$this->internalAddChip($conn,$itemMeta,$accountId);
|
||||
}
|
||||
break;
|
||||
case \mt\Item::HERO_SKIN_TYPE : {
|
||||
$this->internalAddHeroSkin($conn,$itemMeta,$accountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function getAccountId($address){
|
||||
@ -220,4 +225,37 @@ class ShopAddItemService
|
||||
return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG,V_ITEM_STAR));
|
||||
}
|
||||
|
||||
private function _addVirtualItem($conn,$accountId,$itemId,$itemNum){
|
||||
if ($itemNum <= 0){
|
||||
return;
|
||||
}
|
||||
switch ($itemId) {
|
||||
case V_ITEM_GOLD:
|
||||
{
|
||||
$this->_updateUserInfo($conn,$accountId,array(
|
||||
'gold' => function () use($itemNum) {
|
||||
return "gold + ${itemNum}";
|
||||
}
|
||||
));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function _updateUserInfo($conn,$accountId,$fieldsKv)
|
||||
{
|
||||
SqlHelper::update
|
||||
($conn,
|
||||
't_user',
|
||||
array(
|
||||
'account_id' => $accountId
|
||||
),
|
||||
$fieldsKv
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user