HeroUpgradeQuality

This commit is contained in:
hujiabin 2022-11-09 17:32:44 +08:00
parent 296f5b45b2
commit db02106d81
7 changed files with 268 additions and 31 deletions

View File

@ -111,6 +111,35 @@ class Hero(object):
'desc': '升阶',
'group': 'Hero',
'url': 'webapp/index.php?c=Hero&a=upgradeQuality',
'params': [
_common.ReqHead(),
['trans_id', 0, 'transId'],
['token_id1', 0, '英雄token'],
['token_id2', 0, '耗材英雄token'],
],
'response': [
_common.RspHead(),
]
},
{
'name': 'receiveUpgradeQuality',
'desc': '领取升阶',
'group': 'Hero',
'url': 'webapp/index.php?c=Hero&a=receiveUpgradeQuality',
'params': [
_common.ReqHead(),
['trans_id', 0, 'transId'],
['token_id', 0, '英雄token'],
],
'response': [
_common.RspHead(),
]
},
{
'name': 'upgradeQualityOld',
'desc': '升阶',
'group': 'Hero',
'url': 'webapp/index.php?c=Hero&a=upgradeQualityOld',
'params': [
_common.ReqHead(),
['hero_uniid', 0, '英雄唯一id'],

View File

@ -278,8 +278,10 @@ class QualityingHero(object):
def __init__(self):
self.fields = [
['info', Hero(), '英雄信息'],
['countdown', 0, '倒计时'],
['trans_id', 0, 'transId'],
['state', 0, '0升阶中1可领取'],
['heroInfo', Hero(), '升阶英雄信息'],
['costHeroInfo', Hero(), '材料英雄信息'],
]
class HeroSkin(object):

View File

@ -832,3 +832,23 @@ CREATE TABLE `t_nft_up_event` (
UNIQUE KEY `trans_id` (`trans_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `t_nft_up_receive`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t_nft_up_receive` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
`trans_id` varchar(255) NOT NULL DEFAULT '' COMMENT '事务id',
`token_id1` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id1',
`token_id2` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id2',
`state` int(11) NOT NULL DEFAULT '0' COMMENT '0进阶中,1可领取',
`token_type` int(11) NOT NULL DEFAULT '0' COMMENT '1英雄,2枪械',
`from_data` int(11) NOT NULL DEFAULT '0' COMMENT '0本地,1链',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
PRIMARY KEY (`idx`),
UNIQUE KEY `trans_id` (`trans_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;

View File

@ -14,6 +14,7 @@ require_once('models/Hero.php');
require_once('models/Gun.php');
require_once('models/Chip.php');
require_once('models/DynData.php');
require_once('models/NftUpReceive.php');
require_once('phpcommon/bchelper.php');
@ -27,6 +28,7 @@ use models\Hero;
use models\Gun;
use models\Chip;
use models\DynData;
use models\NftUpReceive;
class CallbackController extends BaseController {
private $accountId;
@ -150,8 +152,9 @@ class CallbackController extends BaseController {
public function heroUpgradeQuality(){
$transId = getReqVal('trans_id', '0');
$tokenId = getReqVal('token_id', '0');
if (!$transId || !$tokenId){
$tokenId1 = getReqVal('token_id1', '0');
$tokenId2 = getReqVal('token_id2', '0');
if (!$transId || !$tokenId1){
myself()->_rspErr(1, 'param error');
return;
}
@ -163,7 +166,7 @@ class CallbackController extends BaseController {
myself()->_getMysql($this->accountId),
't_hero',
array(
'token_id' => $tokenId,
'token_id' => $tokenId1,
)
);
if ( !$heroDb ){
@ -172,7 +175,7 @@ class CallbackController extends BaseController {
}
$nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']+1);
if (! $nextQualityMeta){
$this->_rspErr(1, 'quality is full');
myself()->_rspOk();
return;
}
@ -184,27 +187,35 @@ class CallbackController extends BaseController {
( myself()->_getMysql($this->accountId),
't_hero',
array(
'token_id' => $tokenId,
'token_id' => $tokenId1,
),
array(
'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili),
'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'],
'quality' => $heroDb['quality']+1,
'advanced_count' => $heroDb['advanced_count'] + 1,
'lock_type' => 0,
'unlock_time' => 0,
// 'lock_type' => 0,
// 'unlock_time' => 0,
'labour' => 0,
)
);
NftUpEvent::add($this->accountId,
array(
'trans_id' => $transId,
'token_id' => $tokenId,
'token_id' => $tokenId1,
'value' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
$param = array(
'trans_id'=>$transId,
'token_id1'=>$tokenId1,
'token_id2'=>$tokenId2,
'token_type'=>1,
);
NftUpReceive::upsert($this->accountId,$param);
if ($heroDb['quality'] + 1 > $this->_getDynDataV(TN_HERO_MAX_QUALITY, 0)) {
$this->_setDynDataV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1);
}
@ -237,7 +248,7 @@ class CallbackController extends BaseController {
}
$nextQualityMeta = mt\GunQuality::getByQuality($gunDb['quality']+1);
if (!$nextQualityMeta) {
$this->_rspErr(1, 'quality is full');
myself()->_rspOk();
return;
}
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($gunDb['quality']);

View File

@ -15,6 +15,7 @@ require_once('models/Hero.php');
require_once('models/Bag.php');
require_once('models/HeroSkin.php');
require_once('models/Chip.php');
require_once('models/NftUpReceive.php');
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
@ -28,6 +29,7 @@ use models\Hero;
use models\Bag;
use models\HeroSkin;
use models\Chip;
use models\NftUpReceive;
use services\LogService;
class HeroController extends BaseAuthedController {
@ -205,22 +207,46 @@ class HeroController extends BaseAuthedController {
public function getUpgradeQualityList()
{
$infos = array();
for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
$heroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i);
$info = null;
if ($heroUniId) {
$heroDb = Hero::find($heroUniId);
if ($heroDb) {
$heroDto = Hero::toDto($heroDb);
$info = array(
'info' => $heroDto,
'countdown' => $heroDto['unlock_lefttime']
);
// $infos = array();
// for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
// $heroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i);
// $info = null;
// if ($heroUniId) {
// $heroDb = Hero::find($heroUniId);
// if ($heroDb) {
// $heroDto = Hero::toDto($heroDb);
// $info = array(
// 'info' => $heroDto,
// 'countdown' => $heroDto['unlock_lefttime']
// );
// }
// }
// array_push($infos, $info);
// }
// $this->_rspData(array(
// 'infos' => $infos
// ));
$list = NftUpReceive::all(myself()->_getAccountId(),1);
$infos = array();
foreach ($list as $value){
if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data']){
$hero = Hero::findByTokenId2($value['token_id1']);
$costHero = Hero::findByTokenId2($value['token_id2']);
$heroDto = null;
$costHeroDto = null;
if ($hero && $costHero){
$heroDto = Hero::toDto($hero);
$costHeroDto = Hero::toDto($costHero);
}
$info = array(
'trans_id'=>$value['trans_id'],
'state'=>$value['state'],
'heroInfo'=>$heroDto,
'costHeroInfo'=>$costHeroDto,
);
array_push($infos,$info);
}
array_push($infos, $info);
}
}
$this->_rspData(array(
'infos' => $infos
));
@ -617,7 +643,7 @@ class HeroController extends BaseAuthedController {
));
}
public function upgradeQuality()
public function upgradeQualityOld()
{
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
$heroUniId = getReqVal('hero_uniid', 0);
@ -821,5 +847,61 @@ class HeroController extends BaseAuthedController {
}
public function upgradeQuality(){
$tokenId1 = getReqVal('token_id1', '');
$tokenId2 = getReqVal('token_id2', '');
$transId = getReqVal('trans_id', '');
if (!$tokenId1 || !$tokenId2 || !$transId){
$this->_rspErr(1, ' error param');
return;
}
if (NftUpReceive::find(myself()->_getAccountId(),$transId)){
$this->_rspErr(1, ' error param trans_id ');
return;
}
Hero::updateByTokenId($tokenId1,
array(
'lock_type' => Hero::QUALITY_LOCK,
'unlock_time' => $this->_getNowTime() + 3600 * 24,
)
);
Hero::updateByTokenId($tokenId2,
array(
'lock_type' => Hero::COST_LOCK,
'unlock_time' => $this->_getNowTime() + 3600 * 24,
)
);
NftUpReceive::add(
myself()->_getAccountId(),
array(
'account_id' => myself()->_getAccountId(),
'trans_id' => $transId,
'token_id1' => $tokenId1,
'token_id2' => $tokenId2,
'state' => 0,
'token_type' => 1,
'from_data' => 0,
'createtime' => $this->_getNowTime(),
'modifytime' => $this->_getNowTime()
)
);
myself()->_rspOk();
}
public function receiveUpgradeQuality(){
$transId = getReqVal('trans_id', '');
$tokenId = getReqVal('token_id', '');
if (!$tokenId || !$transId){
$this->_rspErr(1, ' error param');
return;
}
Hero::updateByTokenId($tokenId,
array(
'lock_type' => Hero::NO_LOCK,
'unlock_time' => 0,
)
);
NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId);
myself()->_rspOk();
}
}

View File

@ -63,6 +63,18 @@ class Hero extends BaseModel {
return $row;
}
public static function findByTokenId2($tokenId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($tokenId),
't_hero',
array(
'token_id' => $tokenId,
)
);
return $row;
}
private static function internalFind($accountId, $heroUniId)
{
$row = SqlHelper::ormSelectOne(
@ -174,14 +186,14 @@ class Hero extends BaseModel {
$lockType = 0;
$unlockTime = 0;
/*if ($row['lock_type'] != 0 && $row['unlock_time'] - myself()->_getNowTime() > 0) {
$lockType = $row['lock_type'];
$unlockTime = $row['unlock_time'];
}*/
{
if ($row['lock_type'] != 0 && $row['unlock_time'] - myself()->_getNowTime() > 0) {
$lockType = $row['lock_type'];
$unlockTime = $row['unlock_time'];
}
// {
// $lockType = $row['lock_type'];
// $unlockTime = $row['unlock_time'];
// }
$qualityMeta = mt\HeroQuality::getByQuality($row['quality']);
$todayGetGold = $row['today_get_gold'];

View File

@ -0,0 +1,81 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class NftUpReceive extends BaseModel
{
public static function find($accountId,$transId)
{
$row = SqlHelper::ormSelectOne(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'trans_id' => $transId,
)
);
return $row;
}
public static function add($accountId,$fieldKv){
return SqlHelper::insert(
myself()->_getMysql($accountId),
't_nft_up_receive',
$fieldKv
);
}
public static function all($accountId,$tokenType)
{
$row = SqlHelper::ormSelect(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'account_id' => $accountId,
'token_type' => $tokenType,
)
);
return $row;
}
public static function upsert($accountId,$data){
SqlHelper::upsert(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'trans_id' => $data['trans_id']
),
array(
'state' => 1,
'modifytime' => myself()->_getNowTime()
),
array(
'account_id' => $accountId,
'trans_id' => $data['trans_id'],
'token_id1' => $data['token_id1'],
'token_id2' => $data['token_id2'],
'state' => 0,
'token_type' => $data['token_type'],
'from_data' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
public static function setAccountIdNull($accountId,$transId){
SqlHelper::update(
myself()->_getMysql($accountId),
't_nft_up_receive',
array(
'trans_id' => $transId,
),
array(
'account_id' => '',
)
);
}
}