public static function toupiaoAjax($author_openid, $vote_openid, $score) { $zhongqiu_vote = self::findOne(['vote_openid' => $vote_openid]); //U::W("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); //U::W($zhongqiu_vote); //U::W($author_openid); //U::W($vote_openid); //U::W($score); if (empty($zhongqiu_vote)) { $zhongqiu_vote = new \app\models\MZhongqiuVote(); } else { //已经投过一次票了,提示用户已投过票,只能每人只能投一次票哟 return \yii\helpers\Json::encode(['code' => 11]); } $zhongqiu_vote->author_openid = $author_openid; $zhongqiu_vote->vote_openid = $vote_openid; $zhongqiu_vote->vote_score = $score; $zhongqiu_vote->save(false); //写入到投票表中; $zhongqiu_score = \app\models\MZhongqiuScore::findOne(['author_openid' => $author_openid]); //U::W("++++++++++++++++++++++++++++++++++++++++++"); //U::W($zhongqiu_score); if (empty($zhongqiu_score)) { $zhongqiu_score = new \app\models\MZhongqiuScore(); } $zhongqiu_score->author_openid = $author_openid; $zhongqiu_score->score = $zhongqiu_score->score + $score; $zhongqiu_score->status = 0; //$zhongqiu_score->create_time = $qa->create_time; $zhongqiu_score->save(false); return \yii\helpers\Json::encode(['code' => 0]); }
public function actionZhongqiuVote() { /* $this->layout = false; $id = $_GET["id"]; //$gh_id = U::getSessionParam('gh_id'); $gh_id = 'gh_03a74ac96138'; $openid = U::getSessionParam('openid'); $wx_user = \app\models\MUser::findOne([ 'gh_id' => $gh_id, 'openid' => $openid, ]); if (empty($wx_user) || $wx_user->subscribe === 0) { return $this->render('need_subscribe'); } $qingshi_author = \app\models\MQingshiAuthor::findOne([ 'id' => $id, ]); return $this->render('qingshi-vote', [ 'observer' => $wx_user, 'qingshi_author' => $qingshi_author, ]); */ $this->layout = false; //$gh_id = U::getSessionParam('gh_id'); $gh_id = 'gh_03a74ac96138'; $openid = U::getSessionParam('openid'); $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]); if (empty($wx_user) || $wx_user->subscribe === 0) { return $this->render('need_subscribe'); } if (empty($wx_user->openidBindMobiles)) { $url = \yii\helpers\Url::to(); \Yii::$app->getSession()->set('RETURN_URL', $url); return $this->redirect(['wap/addbindmobile', 'gh_id' => $gh_id, 'openid' => $openid]); } if (isset($_GET["id"])) { $id = $_GET["id"]; $zhongqiu_score = \app\models\MZhongqiuScore::findOne(['author_openid' => $id]); } else { $zhongqiu_score = \app\models\MZhongqiuScore::findOne(['author_openid' => $openid]); } if (empty($zhongqiu_score)) { $zhongqiu_score = new \app\models\MZhongqiuScore(); $zhongqiu_score->author_openid = $openid; $zhongqiu_score->score = 0; $zhongqiu_score->save(false); } return $this->render('zhongqiu-vote', ['observer' => $wx_user, 'zhongqiu_score' => $zhongqiu_score]); }