public static function toHelpAjax($giftbox_id, $gh_id, $openid) { $helping = self::findOne(['giftbox_id' => $giftbox_id, 'helper_ghid' => $gh_id, 'helper_openid' => $openid]); if (empty($helping) || MGh::GH_XIANGYANGUNICOM_OPENID_YJHU == $openid || MGh::GH_XIANGYANGUNICOM_OPENID_KZENG == $openid) { $giftbox = GiftboxClaimed::findOne(['id' => $giftbox_id]); if (GiftboxClaimed::STATUS_COMPLETED == $giftbox->status) { return \yii\helpers\Json::encode(['code' => 0]); } $helping = new self(); $helping->giftbox_id = $giftbox_id; $helping->helper_ghid = $gh_id; $helping->helper_openid = $openid; $helping->helping_time = time(); $helping->save(false); return \yii\helpers\Json::encode(['code' => 0]); } else { return \yii\helpers\Json::encode(['code' => -1, 'errmsg' => '您已经帮抢了一次。']); } }
public function actionYaoyiyao() { $this->layout = false; $gh_id = U::getSessionParam('gh_id'); $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'); } $giftbox_id = \Yii::$app->request->get('giftbox_id'); if (empty($giftbox_id)) { $giftbox = \app\models\GiftboxClaimed::findOne(['claimer_ghid' => $gh_id, 'claimer_openid' => $openid]); if (empty($giftbox)) { 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]); } else { $giftbox = new \app\models\GiftboxClaimed(); $giftbox->claimer_ghid = $gh_id; $giftbox->claimer_openid = $openid; $giftbox->claiming_time = time(); $giftbox->status = \app\models\GiftboxClaimed::STATUS_UNDERWAY; $giftbox->save(false); $giftbox_helping = new \app\models\GiftboxHelped(); $giftbox_helping->giftbox_id = $giftbox->id; $giftbox_helping->helper_ghid = $gh_id; $giftbox_helping->helper_openid = $openid; $giftbox_helping->helping_time = time(); $giftbox_helping->save(false); } } } else { $giftbox = \app\models\GiftboxClaimed::findOne(['id' => $giftbox_id]); } return $this->render('yaoyiyao', ['observer' => $wx_user, 'giftbox' => $giftbox]); }
</ul> </div> </div> <div id='claimers' class='modal'> <header class="bar bar-nav"> <a class="icon icon-close pull-right" href="#claimers"></a> <h1 class='title'>已经抢了礼盒的Ta</h1> </header> <div class="content"> <ul class="table-view"> <?php $claimed_giftboxes = \app\models\GiftboxClaimed::find()->orderBy(['claiming_time' => SORT_DESC])->limit(20)->all(); foreach ($claimed_giftboxes as $claimed_giftbox) { ?> <li class="table-view-cell media"> <a data-ignore='push' class="navigate-right" href="<?php echo Url::to(['yaoyiyao', 'giftbox_id' => $claimed_giftbox->id, 'gh_id' => $observer->gh_id, 'openid' => $observer->openid]); ?> "> <img class="media-object pull-left" src="<?php echo $claimed_giftbox->claimer->headImgUrl; ?> " width="64" height="64"> <div class="media-body"> <!--粉丝昵称--> <?php