本文整理匯總了PHP中common\models\User::getAnonymousId方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getAnonymousId方法的具體用法?PHP User::getAnonymousId怎麽用?PHP User::getAnonymousId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\User
的用法示例。
在下文中一共展示了User::getAnonymousId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionSave
/**
* 保存意見反饋信息
* @return type
*/
public function actionSave()
{
$request = \Yii::$app->request;
$data = $request->_get();
$userCode = $request->get('userCode', 0);
if ($userCode) {
$data['anonymousId'] = User::getAnonymousId($userCode);
}
$model = new Feedback();
if ($model->load($data, '') && $model->validate() && $model->saveInfo()) {
return ['code' => 0, 'msg' => '反饋成功'];
}
$errors = $model->getErrors();
$error = '';
foreach ($errors as $v) {
$error = $v[0];
}
return ['code' => 3, 'msg' => $error];
}
示例2: saveCilck
/**
* 保存用戶對產品的點擊數量;僅對匿名用戶有效;
* @param int $pid 產品ID
* @param string $userIdentity 用戶識別碼
*/
public static function saveCilck($pid, $userIdentity = '')
{
if (!intval($pid)) {
return false;
}
$gapTime = \Yii::$app->params['gapTime'];
$isInsert = false;
$uid = User::getAnonymousId($userIdentity);
if ($uid) {
$sql = "SELECT IF( ( UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(createTime) ) >" . $gapTime . " , 'true', 'false' ) as result FROM product_click WHERE userId=" . $uid . " AND userType='anonymous' ORDER BY createTime DESC LIMIT 1";
$resData = static::getDb()->createCommand($sql)->queryScalar();
if ($resData != 'false') {
$isInsert = true;
}
}
$pownId = Product::getOwnId($pid);
if ($isInsert && $pownId) {
static::getDb()->createCommand()->insert(static::tableName(), array('productId' => $pid, 'userId' => $uid, 'userType' => 'anonymous'))->execute();
MiaoCoin::updateClickM(static::getDb()->getLastInsertID(), $pownId);
User::updateCacheMcoin(User::getSoreId($pownId), 1, 'output');
return true;
}
return false;
}
示例3: actionRemovefavorite
/**
* 刪除收藏
* @return multitype:number string
*/
public function actionRemovefavorite()
{
$usercode = \Yii::$app->request->get('userCode', '0');
$pid = \Yii::$app->request->get('code', 0);
$pid = EasyHelpers::pidDecrypt($pid);
if ($usercode && $pid) {
$uid = User::getAnonymousId($usercode);
if (Favorite::removeFavorite($pid, $uid)) {
$res = ['code' => 0, 'msg' => '刪除成功'];
} else {
$res = ['code' => 5, 'msg' => '刪除失敗'];
}
} else {
$res = ['code' => 4, 'msg' => '參數錯誤'];
}
return $res;
}