100 lines
3.2 KiB
PHP
100 lines
3.2 KiB
PHP
<?php
|
|
|
|
|
|
namespace models;
|
|
require_once('mt/CircuitTime.php');
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
class CircuitTask extends BaseModel
|
|
{
|
|
|
|
public static function _verifyCondition($season){
|
|
$metas = mt\CircuitTask::getListBySeason($season);
|
|
foreach ($metas as $meta){
|
|
$current = self::getCurrentVal($season,$meta['type']);
|
|
if ($current < $meta['target']){
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static function _verifyLoginToday(){
|
|
$circuitCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
|
$nextCircuitMeta = mt\CircuitTime::getNextCircuit();
|
|
if ($circuitCircuitMeta || !$nextCircuitMeta){
|
|
return false;
|
|
}
|
|
if (myself()->_getNowTime() < strtotime($nextCircuitMeta['task_open_time'])){
|
|
return false;
|
|
}
|
|
$season = $nextCircuitMeta['circuit_season'];
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_circuit_task_value',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'circuit_season' => $season,
|
|
'task_type' => mt\CircuitTask::LOGIN_TIMES_END,
|
|
)
|
|
);
|
|
if ($row){
|
|
if (myself()->_getDaySeconds($row['modifytime']) >= myself()->_getNowDaySeconds()){
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static function incTaskVal($taskType,$value){
|
|
|
|
$circuitCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
|
$nextCircuitMeta = mt\CircuitTime::getNextCircuit();
|
|
if ($circuitCircuitMeta || !$nextCircuitMeta){
|
|
return;
|
|
}
|
|
if (myself()->_getNowTime() < strtotime($nextCircuitMeta['task_open_time'])){
|
|
return;
|
|
}
|
|
$season = $nextCircuitMeta['circuit_season'];
|
|
SqlHelper::upsert(
|
|
myself()->_getSelfMysql(),
|
|
't_circuit_task_value',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'circuit_season' => $season,
|
|
'task_type' => $taskType,
|
|
),
|
|
array(
|
|
'value' => function () use ($value){
|
|
return "value + ${value}";
|
|
},
|
|
'modifytime' => myself()->_getNowTime(),
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'circuit_season' => $season,
|
|
'task_type' => $taskType,
|
|
'value' => $value,
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function getCurrentVal($season,$taskType){
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_circuit_task_value',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'circuit_season' => $season,
|
|
'task_type' => $taskType,
|
|
)
|
|
);
|
|
return $row ? $row['value'] : 0;
|
|
}
|
|
|
|
|
|
} |