當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::getAnonymousId方法代碼示例

本文整理匯總了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];
 }
開發者ID:BlackCodes,項目名稱:Mymine,代碼行數:23,代碼來源:FeedbackController.php

示例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;
 }
開發者ID:BlackCodes,項目名稱:Mymine,代碼行數:29,代碼來源:ProductClick.php

示例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;
 }
開發者ID:BlackCodes,項目名稱:Mymine,代碼行數:21,代碼來源:GetproductController.php


注:本文中的common\models\User::getAnonymousId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。