64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace models;
|
|
|
|
require_once('mt/Hero.php');
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
|
|
class HeroSkin extends BaseModel {
|
|
|
|
const GETED_STATE = 0;
|
|
const TRY_USING_STATE = 1;
|
|
|
|
public static function find($skinId)
|
|
{
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_hero_skin',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'skin_id' => $skinId
|
|
)
|
|
);
|
|
return $row;
|
|
}
|
|
|
|
public static function toDto($row)
|
|
{
|
|
return array(
|
|
'skin_id' => $row['skin_id'],
|
|
'skin_state' => $row['skin_state'],
|
|
'try_expire_at' => $row['try_expire_at'],
|
|
);
|
|
}
|
|
|
|
public static function addSkin($itemMeta)
|
|
{
|
|
SqlHelper::upsert(
|
|
myself()->_getSelfMysql(),
|
|
't_hero_skin',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'skin_id' => $itemMeta['id']
|
|
),
|
|
array(
|
|
'skin_state' => 3,
|
|
'modifytime' => myself()->_getNowTime()
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'skin_id' => $itemMeta['id'],
|
|
'skin_state' => 0,
|
|
'get_from' => 0,
|
|
'consume_num' => 0,
|
|
'try_expire_at' => 0,
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime()
|
|
)
|
|
);
|
|
}
|
|
|
|
}
|