/** * @return SMSCode */ public static function getCopy($phone) { $o = parent::getCopy(array('phone' => $phone)); $o->load(); return $o; }
public static function getCopy($code) { return parent::getCopy(['code' => $code]); }
/** * * @return LogStorage */ public static function getCopy($guid) { return parent::getCopy(array('logGuid' => $guid)); }
/** * @return AccountStorage */ public static function getCopy($accountId) { return parent::getCopy(array('accountId' => $accountId)); }
/** * @return AccountAlias */ public static function getCopy($loginName, $cameFrom) { return parent::getCopy(array('loginName' => $loginName, 'cameFrom' => $cameFrom)); }
public static function getCopy($refreshToken) { return parent::getCopy(['refreshToken' => $refreshToken]); }
/** * client getCopy * @param string $clientId 客户端ID * @param string $clientSecret 客户端密钥 * @return \Sooh\DB\Base\KVObj */ public static function getCopy($clientId) { return parent::getCopy(['id' => $clientId]); }
/** * * @param string $userIdentifier * @return \Prj\Data\ShopPointLog */ public static function getCopy($userIdentifier) { return parent::getCopy(array('userIdentifier' => $userIdentifier, 'ShopPointOSN' => 0)); }
/** * * @param string $type [idfa|imei|md5|mac] * @param string $sn * @param string $phone * @param string $userIdentifier * @param string $contractId * @param array $extraData * @return \PrjLib\DataDig\Log\Device */ public static function ensureOne($type, $sn, $phone = null, $userIdentifier = null, $contractId = null, $extraData = null) { $dt = \Sooh\Base\Time::getInstance(); $deviceId = self::guidMaker($type, $sn); $ddd = \Yaf_Dispatcher::getInstance()->getRequest(); error_log("trace device->ensure(" . $ddd->getModuleName() . '/' . $ddd->getControllerName() . '/' . $ddd->getActionName() . ") " . $deviceId . " phone:{$phone} user:{$userIdentifier}"); $sys = parent::getCopy(array('deviceId' => $deviceId)); try { \Sooh\DB\Broker::errorMarkSkip(\Sooh\DB\Error::tableNotExists); $sys->load(); } catch (\ErrorException $e) { if (\Sooh\DB\Broker::errorIs($e, \Sooh\DB\Error::tableNotExists)) { $sys->createTable(); } } $fields = array('ip' => \Sooh\Base\Tools::remoteIP(), 'ymd' => $dt->YmdFull, 'hhiiss' => $dt->his); try { if ($sys->exists() === false) { foreach ($fields as $k => $v) { $sys->setField($k, $v); } $sys->setField('phone', empty($phone) ? '0' : $phone); $sys->setField('userIdentifier', empty($userIdentifier) ? '' : $userIdentifier); $sys->setField('extraData', empty($extraData) ? '' : json_encode($extraData)); $sys->setField('extraRet', ''); $sys->setField('contractId', empty($contractId) ? '0' : $contractId); try { \Sooh\DB\Broker::errorMarkSkip(\Sooh\DB\Error::duplicateKey); $sys->update(); $sys->flgNewCreate = true; return $sys; } catch (\ErrorException $e) { $sys->reload(); if ($sys->exists() === false) { error_log('error create new device log:' . $e->getMessage() . "\n" . $e->getTraceAsString()); return $sys; } } } $oldPhone = $sys->getField('phone', true); $oldUser = $sys->getField('userIdentifier', true); $oldContractId = $sys->getField('contractId', true); if (!empty($phone) && !empty($oldPhone) && $phone != $oldPhone || !empty($oldUser) && !empty($userIdentifier) && $oldUser != $userIdentifier || !empty($oldContractId) && !empty($contractId) && $oldContractId != $contractId) { $extraDataOld = $sys->getField('extraData', true); $extraRetOld = $sys->getField('extraRet', true); $extraRetOld = is_scalar($extraRetOld) === false ? json_encode($extraRetOld) : $extraRetOld; \Sooh\DB\Broker::getInstance(\PrjLib\Tbname::db_rpt)->addRecord(\PrjLib\Tbname::tb_device_log, array('deviceId' => $deviceId, 'dtChange' => $dt->YmdFull . sprintf('%06d', $dt->his), 'phoneOld' => $oldPhone, 'userIdentifierOld' => $oldUser, 'extraDataOld' => is_scalar($extraDataOld) === false ? json_encode($extraDataOld) : $extraDataOld, 'extraRetOld' => $extraRetOld, 'contractIdOld' => $oldContractId, 'phoneNew' => $phone, 'userIdentifierNew' => $userIdentifier, 'extraDataNew' => empty($extraData) ? '' : json_encode($extraData), 'extraRetNew' => $extraRetOld, 'contractIdNew' => empty($contractId) ? '0' : $contractId, 'ipOld' => $sys->getField('ip', true), 'ipNew' => $fields['ip'])); } foreach ($fields as $k => $v) { $sys->setField($k, $v); } if (!empty($extraData)) { $sys->setField('extraData', empty($extraData) ? '' : json_encode($extraData)); } if (!empty($phone)) { $sys->setField('phone', $phone); } if (!empty($userIdentifier)) { $sys->setField('userIdentifier', $userIdentifier); } //$sys->setField('extraRet', ''); if (!empty($contractId)) { $sys->setField('contractId', $contractId); } $sys->update(); //var_log($sys->dump(),'======================log->filled for '.$sys->tbname()); \Sooh\DB\Broker::errorMarkSkip(\Sooh\DB\Error::tableNotExists); } catch (\ErrorException $e) { error_log("error: on ensure-device:" . $e->getMessage() . "\n" . $e->getTraceAsString()); } return $sys; }
/** * * @param string $imei * @return \Sooh\DB\Cases\AppDeviceTrace */ public static function startAndroid($imei) { $pkey = array('appType' => 'android', 'pkey' => $imei, 'skey' => ''); $tmp = parent::getCopy($pkey); return $tmp; }
/** * 获取tb_oauth_token * @param string $token * @return \Sooh\DB\Base\KVObj */ public static function getCopy($token) { return parent::getCopy(['accessToken' => $token]); }
/** * 说明getCopy实际返回的类,同时对于只有一个主键的,可以简化写法 * @return \Sooh\DB\Cases\SessionStorage */ public static function getCopy($sessionId) { return parent::getCopy(array('sessionId' => $sessionId)); }