game2006api/webapp/models/SeasonCard.php
aozhiwei 2830888059 1
2021-12-08 18:00:57 +08:00

93 lines
2.3 KiB
PHP

<?php
namespace models;
require_once('mt/Item.php');
use mt;
use phpcommon\SqlHelper;
class SeasonCard extends BaseModel {
const NORMAL_PACKAGE_ID = 1;
const VIP_PACKAGE_ID = 2;
const VIP_PACKAGE_ITEM_ID = 20005;
public static function find($seasonId, $type, $cardLv)
{
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_season',
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
'type' => $type,
'card_lv' => $cardLv,
)
);
return $row;
}
public static function toDto($row)
{
return array(
);
}
public static function all($seasonId)
{
$rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_season_card',
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
)
);
return array_map(function($row) {
$nowDaySeconds = myself()->_getNowDaySeconds();
$mondaySeconds = myself()->_getMondaySeconds();
return $row;
}, $rows);
}
public static function allHash($seasonId, $type)
{
$cardHash = array();
foreach (self::all($seasonId) as $row) {
if ($row['type'] == $type) {
$cardHash[$row['card_lv']] = $row;
}
}
return $cardHash;
}
public function add($seasonId, $type, $cardLv)
{
$initSeasonCard = mt\SeasonCard::getInitCard();
SqlHelper::upsert(
myself()->_getSelfMysql(),
't_season_card',
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
'type' => $type,
'card_lv' => $cardLv,
),
array(
),
array(
'account_id' => myself()->_getAccountId(),
'season_id' => $seasonId,
'type' => $type,
'card_lv' => $cardLv,
'reward_received' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
);
}
}