本文整理汇总了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;
}