<?php

/**
 * 同步登录记录表（MeetOne侧链
 * User: solu
 */
class Sync_LoginLogMeetOne extends Sync_Base {
    protected $dbKey = 'dw_chat';
    protected $frequency = 1;
    protected $index = 3;

    protected $dataField = ['account', 'trx_id', 'memo', 'update_time_int'];

    /**
     * 清除数据的时间间隔
     * @var int
     */
    protected $clearTtl = 600;
    protected $clearAction = 'clearlogin';

    public function __construct() {
        ENV === ENV_FORMAL && $GLOBALS['eosUrl'] = $GLOBALS['eosxURL']; // 改为MeetOne侧链

        parent::__construct('login_log', 'id', 'update_time_int', 'loginlog', $GLOBALS['codeMeeMO'], ['net_id' => Eos::NET_MEETONE]);
    }

    protected function addNewRows($newRows) {
        foreach ($newRows as $k => $row) {
            $row['create_time'] = $this->formatDateTime($row['create_time']);
            $row['net_id'] = Eos::NET_MEETONE;

            $newRows[$k] = $row;
        }
        parent::addNewRows($newRows);
    }

    protected function updateRow($row, $priValue, $dbRow) {
        $row['create_time'] = $this->formatDateTime($row['create_time']);
        parent::updateRow($row, $priValue, $dbRow);
    }


}
