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]); }