121 lines
3.0 KiB
PHP
121 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace models;
|
|
|
|
require_once('mt/SeasonCard.php');
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
|
|
class Season extends BaseModel {
|
|
|
|
public static function find($seasonId)
|
|
{
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_season',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'season_id' => $seasonId,
|
|
)
|
|
);
|
|
return $row;
|
|
}
|
|
|
|
public static function toDto($row)
|
|
{
|
|
return array(
|
|
);
|
|
}
|
|
|
|
public static function add($seasonId)
|
|
{
|
|
$initSeasonCard = mt\SeasonCard::getInitCard();
|
|
SqlHelper::upsert(
|
|
myself()->_getSelfMysql(),
|
|
't_season',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'season_id' => $seasonId,
|
|
),
|
|
array(
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'season_id' => $seasonId,
|
|
'card_lv' => $initSeasonCard ? $initSeasonCard['lv'] : 1,
|
|
'card_exp' => $initSeasonCard ? $initSeasonCard['min_exp'] : 0,
|
|
'kills_modifytime' => myself()->_getNowTime(),
|
|
'score_modifytime' => myself()->_getNowTime(),
|
|
'best_rank_modifytime' => myself()->_getNowTime(),
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime()
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function getHistorySeasons($targetId)
|
|
{
|
|
$rows = SqlHelper::ormSelect(
|
|
myself()->_getMysql($targetId),
|
|
't_season',
|
|
array(
|
|
'account_id' => $targetId,
|
|
)
|
|
);
|
|
return $rows;
|
|
}
|
|
|
|
public static function updateGiftPackageState($seasonId, $packageId)
|
|
{
|
|
if (in_array($packageId, array(
|
|
1,
|
|
2
|
|
))) {
|
|
SqlHelper::update(
|
|
myself()->_getSelfMysql(),
|
|
't_season',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'season_id' => $seasonId,
|
|
),
|
|
array(
|
|
"gift_state${packageId}" => 1,
|
|
"gift_buytime${packageId}" => myself()->_getNowTime()
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
public static function updateCardLv($seasonId, $cardLv)
|
|
{
|
|
|
|
SqlHelper::update(
|
|
myself()->_getSelfMysql(),
|
|
't_season',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'season_id' => $seasonId,
|
|
),
|
|
array(
|
|
"card_lv" => $cardLv,
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function update($seasonId, $fieldsKv)
|
|
{
|
|
|
|
SqlHelper::update(
|
|
myself()->_getSelfMysql(),
|
|
't_season',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'season_id' => $seasonId,
|
|
),
|
|
$fieldsKv
|
|
);
|
|
}
|
|
|
|
}
|