/** * * @param \Sooh\DB\Base\KVObj $obj * @param int $retry */ public function markInstalled($obj, $retry) { $obj->setField('callbackRetry', 1); }
/** * * @param callable $funcSend * @param string $msgFormat * @param string $code * @throws Exception on update-db failed or send sms failed * @return boolean return false on too many times */ public function sendCode($funcSend, $msgFormat, $code = null) { $sentCounterInHour = sizeof($this->dat['codes']); if ($sentCounterInHour > self::$maxCounterPerHour) { return false; } if ($code === null) { $code = substr(uniqid(), -6); } $this->dat['codes'][$code] = $this->dt->timestamp(); parent::setField('dat', $this->dat); $this->update(); $msgFormat = str_replace('{code}', $code, $msgFormat); if (is_array($funcSend) || is_string($funcSend)) { $ret = call_user_func($funcSend, current($this->pkey), $msgFormat); } else { $ret = $funcSend(current($this->pkey), $msgFormat); } if ($ret === false) { throw new \ErrorException('send sms failed:' . $msgFormat); } return true; }
public function setSessionData($arr) { parent::setField('accountId', $arr['accountId']); parent::setField('sessionData', json_encode($arr)); }