game2006api/webapp/models/ExchangeCode.php
2023-12-21 17:02:53 +08:00

92 lines
2.2 KiB
PHP

<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class ExchangeCode extends BaseModel
{
public static function find($code){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_exchange_code',
array(
'exchangecode'=> $code
)
);
if (!$row){
return null;
}
return $row;
}
public static function updateExchangeCode($code){
SqlHelper::update
(myself()->_getSelfMysql(),
't_exchange_code',
array(
'exchangecode'=> $code
),
array(
'usetimes' => function(){
return "usetimes + 1";
},
"last_usetime" => myself()->_getNowTime(),
"last_useuser" => myself()->_getAccountId(),
)
);
}
public static function getRecordByCode($code){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_exchange_record',
array(
'exchangecode'=> $code
)
);
if (!$row){
return null;
}
return $row;
}
public static function findRecordByCode($code){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_exchange_record',
array(
'account_id'=> myself()->_getAccountId(),
'exchangecode'=> $code,
)
);
if (!$row){
return null;
}
return $row;
}
public static function findRecordByPackage($package){
$row = SqlHelper::ormSelectOne(
myself()->_getSelfMysql(),
't_exchange_record',
array(
'account_id'=> myself()->_getAccountId(),
'packageno'=> $package,
)
);
if (!$row){
return null;
}
return $row;
}
public static function insetRecord($fieldKv){
SqlHelper::insert
(myself()->_getSelfMysql(),
't_exchange_record',
$fieldKv
);
}
}