1
This commit is contained in:
parent
f82a751dc2
commit
831779bbd5
@ -251,7 +251,7 @@ DROP TABLE IF EXISTS `t_battle_record`;
|
|||||||
CREATE TABLE `t_battle_record` (
|
CREATE TABLE `t_battle_record` (
|
||||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)',
|
||||||
`battle_data` mediumblob COMMENT 'battle_data',
|
`request` mediumblob COMMENT 'request',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
|
|
||||||
require_once('mt/Parameter.php');
|
require_once('mt/Parameter.php');
|
||||||
require_once('mt/Drop.php');
|
|
||||||
require_once('mt/EquipUpgrade.php');
|
|
||||||
require_once('mt/Season.php');
|
require_once('mt/Season.php');
|
||||||
require_once('mt/RankReward.php');
|
|
||||||
require_once('mt/Equip.php');
|
require_once('mt/Equip.php');
|
||||||
|
|
||||||
require_once('services/PropertyChgService.php');
|
require_once('services/PropertyChgService.php');
|
||||||
@ -25,8 +22,19 @@ class BattleController extends BaseAuthedController {
|
|||||||
$this->_rspErr(1, '没有这个玩家1');
|
$this->_rspErr(1, '没有这个玩家1');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$battleDataService = new services\BattleDataService();
|
||||||
|
$battleDataService->updateBattleData();
|
||||||
$this->updateUserBaseInfo($userInfo);
|
$this->updateUserBaseInfo($userInfo);
|
||||||
$this->updateMission($userInfo);
|
SqlHelper::insert(
|
||||||
|
$this->_getSelfMysql(),
|
||||||
|
't_battle_record',
|
||||||
|
array(
|
||||||
|
'account_id' => $this->_getAccountId(),
|
||||||
|
'request' => json_encode($_REQUEST),
|
||||||
|
'createtime' => $this->_getNowTime(),
|
||||||
|
'modifytime' => $this->_getNowTime(),
|
||||||
|
)
|
||||||
|
);
|
||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,9 +42,4 @@ class BattleController extends BaseAuthedController {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateMission($userInfo)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
43
webapp/models/Battle.php
Normal file
43
webapp/models/Battle.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace models;
|
||||||
|
|
||||||
|
use mt;
|
||||||
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
|
class Battle extends BaseModel {
|
||||||
|
|
||||||
|
public static function getMyBattleData()
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_battle',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row ? json_decode($row['battle_data'], true) : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function add($battleData)
|
||||||
|
{
|
||||||
|
SqlHelper::upsert
|
||||||
|
(myself()->_getSelfMysql(),
|
||||||
|
't_battle',
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'battle_data' => $battleData,
|
||||||
|
'modifytime' => myself()->_getNowTime(),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'account_id' => myself()->_getAccountId(),
|
||||||
|
'battle_data' => $battleData,
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -88,7 +88,7 @@ class Season extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update($fieldsKv)
|
public static function update($seasonId, $fieldsKv)
|
||||||
{
|
{
|
||||||
|
|
||||||
SqlHelper::update(
|
SqlHelper::update(
|
||||||
|
@ -68,17 +68,69 @@ namespace services;
|
|||||||
|
|
||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
require_once('mt/Equip.php');
|
require_once('mt/Equip.php');
|
||||||
|
require_once('mt/Season.php');
|
||||||
|
|
||||||
|
require_once('models/Season.php');
|
||||||
|
require_once('models/Battle.php');
|
||||||
|
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
use models\Season;
|
||||||
|
use models\Battle;
|
||||||
|
|
||||||
class BattleDataService extends BaseService {
|
class BattleDataService extends BaseService {
|
||||||
|
|
||||||
private $seasonDb = array();
|
private $seasonDb = array();
|
||||||
private $hisBattleData = array();
|
|
||||||
|
|
||||||
public function updateBattleData()
|
public function updateBattleData()
|
||||||
{
|
{
|
||||||
|
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
||||||
|
if (!$this->currSeasonMeta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||||
|
if (!$this->seasonDb) {
|
||||||
|
Season::add($this->currSeasonMeta['id']);
|
||||||
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
||||||
|
}
|
||||||
|
if (!$this->seasonDb) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$hisBattleData = Battle::getMyBattleData();
|
||||||
|
$this->apply($hisBattleData);
|
||||||
|
Battle::add($hisBattleData);
|
||||||
|
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
||||||
|
if (!isset($seasonBattleData['today_data'])) {
|
||||||
|
$seasonBattleData['today_data'] = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!isset($seasonBattleData['his_week_data'])) {
|
||||||
|
$seasonBattleData['his_week_data'] = array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!isset($seasonBattleData['this_week_data'])) {
|
||||||
|
$seasonBattleData['this_week_data'] = array(
|
||||||
|
'createtime' => myself()->_getNowTime(),
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (myself()->_getDaySeconds($seasonBattleData['today_data']['modifytime']) <
|
||||||
|
myself()->_getNowDaySeconds()) {
|
||||||
|
$seasonBattleData['today_data'] = array(
|
||||||
|
'createtime' => $seasonBattleData['today_data']['createtime'],
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (myself()->_getDaySeconds($seasonBattleData['this_week_data']['modifytime']) <
|
||||||
|
myself()->_getMondaySeconds()) {
|
||||||
|
$seasonBattleData['this_week_data'] = array(
|
||||||
|
'createtime' => $seasonBattleData['this_week_data']['createtime'],
|
||||||
|
'modifytime' => myself()->_getNowTime()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$this->apply($seasonBattleData['today_data']);
|
||||||
|
$this->apply($seasonBattleData['this_week_data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function apply(&$battleData)
|
private function apply(&$battleData)
|
||||||
|
@ -366,18 +366,8 @@ class MissionService extends BaseService {
|
|||||||
//本季度
|
//本季度
|
||||||
//永久
|
//永久
|
||||||
$val = 0;
|
$val = 0;
|
||||||
if ($missionMeta['season_task'] == mt\Task::SEASON_MISSON_FLAG) {
|
$battleData = $this->internalGetBattleData($missionMeta);
|
||||||
if ($missionMeta['type'] == mt\Task::SEASONCARD_MISSON_TYPE &&
|
$val = getXVal($battleData, $key, 0);
|
||||||
$missionMeta['subtype'] == mt\Task::SEASON_WEAKLY_MISSON_SUBTYPE) {
|
|
||||||
$weeklyData = getXVal($this->seasonDb, 'weekly_data', array());
|
|
||||||
$weekDb = getXVal($weeklyData, $missionMeta['week'], array());
|
|
||||||
$val = getXVal($weekDb, $key, 0);
|
|
||||||
} else {
|
|
||||||
$val = getXVal($this->seasonDb, $key, 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$val = getXVal($this->userInfo, $key, 0);
|
|
||||||
}
|
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +375,7 @@ class MissionService extends BaseService {
|
|||||||
{
|
{
|
||||||
$battleData = null;
|
$battleData = null;
|
||||||
if ($missionMeta['type'] == mt\Task::DAILY_MISSON_TYPE) {
|
if ($missionMeta['type'] == mt\Task::DAILY_MISSON_TYPE) {
|
||||||
$battleData = $this->$this->dailyBattleData;
|
$battleData = $this->dailyBattleData;
|
||||||
} else {
|
} else {
|
||||||
if ($missionMeta['season_task'] == mt\Task::SEASON_MISSON_FLAG) {
|
if ($missionMeta['season_task'] == mt\Task::SEASON_MISSON_FLAG) {
|
||||||
if ($missionMeta['type'] == mt\Task::SEASONCARD_MISSON_TYPE &&
|
if ($missionMeta['type'] == mt\Task::SEASONCARD_MISSON_TYPE &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user