/** * Finds user by [[username]] * * @return Member|null */ public function getUser() { if ($this->_user === false) { $this->_user = Member::findByUsername($this->username); } return $this->_user; }
private function rechargeList($startTime = 0, $endTime = 0, $where = []) { $endTime = $endTime == 0 ? time() : $endTime; $assetMoneys = AssetMoney::find()->joinWith(['member' => function ($query) { /** @var \yii\db\ActiveQuery $query */ $query->select(Member::$SELECT_ROW); }])->andWhere(ArrayHelper::merge(['type' => AssetMoney::TYPE_MENTION], $where))->andWhere(['>=', 'wh_asset_money.created_at', $startTime])->andWhere(['<=', 'wh_asset_money.created_at', $endTime])->orderBy('id desc')->asArray()->all(); $actions = Config::getInstance()->getProperty('assetLog'); foreach ($assetMoneys as &$assetMoney) { $assetMoney['action'] = isset($actions[$assetMoney['action']]) ? $actions[$assetMoney['action']] : "赠送"; $assetMoney['created_at'] = date('Y-m-d', $assetMoney['created_at']); $assetMoney['updated_at'] = date('Y-m-d', $assetMoney['updated_at']); $assetMoney['type'] = AssetMoney::get_type($assetMoney['type']); $assetMoney['status'] = AssetMoney::get_status($assetMoney['status']); if (isset($assetMoney['member'])) { $assetMoney['member']['idcard_status'] = Member::get_auth_status($assetMoney['member']['idcard_status']); $assetMoney['member']['email_status'] = Member::get_auth_status($assetMoney['member']['email_status']); $assetMoney['member']['status'] = Member::get_record_status($assetMoney['member']['status']); $assetMoney['member']['created_at'] = date('Y-m-d', $assetMoney['member']['created_at']); foreach ($assetMoney['member'] as $key => &$memberInfo) { $assetMoney['member_' . $key] = $memberInfo; } unset($assetMoney['member']); } } return $assetMoneys; }
/** * Signs user up. * * @return Member|null the saved model or null if saving fails */ public function signup() { if ($this->validate()) { $user = new Member(); $user->username = $this->username; $user->phone = $this->username; $user->parent_id = $this->parent; $user->invitation = substr($this->username, -8, 8); $user->phone_status = Member::STATUS_HAVE_AUTH; $user->setPassword($this->password); $user->generateAuthKey(); if ($user->save()) { return $user; } } return null; }
private function hasGift(ShareGift $shareGift) { $wechat_info = json_decode($shareGift->wechat_info, true); $emAction = ['site/idcard', 'site/email', 'site/setjiuxin', 'site/recharge']; $emCount = AssetMoney::find()->where(['user_id' => $shareGift->user_id, "action" => $emAction])->count(); $emshareCount = AssetMoney::find()->where(['user_id' => $shareGift->user_id, 'action' => 'site/signup-verify'])->andWhere(['<>', "action_uid", $shareGift->user_id])->count(); if ($emshareCount > 0) { $emCount += 1; } $emCount = 5 - $emCount; $members = []; if (($parent_id = Member::findOne($shareGift->user_id)->parent_id) !== null) { $members = Member::find()->where(['parent_id' => $parent_id])->asArray()->select(['id', 'created_at'])->limit(10)->orderBy("id desc")->all(); } $url = wanhunet::$app->urlManager->createAbsoluteUrl(['share/index/' . Member::findOne($shareGift->user_id)->invitation]); $url = wanhunet::app()->wechat->getOauth2AuthorizeUrl($url, 'authorize', 'snsapi_userinfo'); return $this->view("has_gift", ['wechat_info' => $wechat_info, 'emCount' => $emCount, 'members' => $members, 'url' => $url]); }
/** * 首次验证手机 * @param $event */ public function setIncPhone($event) { /** @var Event $event */ /** @var \modules\member\models\Member $member */ $member = wanhunet::app()->member; if (($parentModel = Member::findByInvitation($member->parent_id)) !== null) { $asset = new Asset(['userId' => $parentModel->id]); $config = Config::getInstance(); $asset->setIncExperienceMoney($config->getProperty('setIncEM.invitationParent'), 'site/invitationParent'); if ($parentModel->findFriends(true) == 9) { $asset->setIncExperienceMoney($config->getProperty('setIncEM.invitationParentConut9'), 'site/invitationParentConut9'); $this->setIncEM(new Event(['name' => 'invitationConut9'])); } $asset->saveExperienceMoney(); } $this->setIncEM(new Event(['name' => 'verify_success_phone'])); $this->setIncEMMax(new Event(['name' => 'verify_success_phone'])); }
public function getMember() { return $this->hasOne(Member::className(), ['id' => 'user_id']); }
/** * 用户名 username input * 金额 step input_int * 金额状态 status radio 选项::增长:20; 减少:30 * * @return string|bool */ public function actionNewEm() { $request = wanhunet::$app->request; $memberModel = Member::findByUsername($request->post('username')); $status = [AssetMoney::STATUS_INC, AssetMoney::STATUS_DEC]; if ($memberModel !== null) { $assetMoneyModel = new AssetMoney(); $assetMoneyModel->action = ''; $assetMoneyModel->user_id = $memberModel->id; $assetMoneyModel->step = $request->post('step'); $assetMoneyModel->status = in_array($request->post('status'), $status) ? $request->post('status') : 0; $assetMoneyModel->type = AssetMoney::TYPE_EXPERIENCE_MONEY; $assetMoneyModel->action_uid = $memberModel->id; if ($assetMoneyModel->save()) { return true; } else { return current($assetMoneyModel->getFirstErrors()); } } else { return '用户不存在'; } }
public function actionIdcard() { $request = wanhunet::$app->request; if ($request->isPost) { $member = wanhunet::app()->member; try { $member->idcard = $request->post('idcard'); if (Member::find()->where(['idcard' => $request->post('idcard')])->count() > 0) { throw new \ErrorException('该身份证号已存在'); } $member->idcard_name = $request->post('idcard_name'); $member->saveIdcard(); return $this->goBack(['info' => '认证成功'], Url::to(['setup'])); } catch (\ErrorException $e) { return $this->goBack(['info' => $e->getMessage(), 'idcard' => $request->post('idcard'), 'idcard_name' => $request->post('idcard_name')], Url::to(['idcard'])); } } return $this->view('idcard'); }
private function makeView(&$investList) { $investList['created_at'] = Utils::dateFormat('Y-m-d H:i:s', $investList['created_at']); $investList['updated_at'] = Utils::dateFormat('Y-m-d H:i:s', $investList['updated_at']); $investList['interest_time'] = Utils::dateFormat('Y-m-d H:i:s', $investList['interest_time']); $investList['pay_time'] = Utils::dateFormat('Y-m-d H:i:s', $investList['pay_time']); $investList['status'] = InvestList::get_status($investList['status']); $investList['interest_status'] = InvestList::get_status($investList['interest_status']); if ($investList['status'] == '终审通过') { $investList['interest_status'] = '已返息'; } if (isset($investList['member'])) { $investList['member']['idcard_status'] = Member::get_auth_status($investList['member']['idcard_status']); $investList['member']['email_status'] = Member::get_auth_status($investList['member']['email_status']); $investList['member']['status'] = Member::get_record_status($investList['member']['status']); $investList['member']['created_at'] = Utils::dateFormat('Y-m-d', $investList['member']['created_at']); foreach ($investList['member'] as $key => &$memberInfo) { $investList['member_' . $key] = $memberInfo; } unset($investList['member']); } if (isset($investList['invest'])) { $investList['invest']['invest_status'] = InvestList::get_record_status($investList['invest']['invest_status']); $investList['invest']['created_at'] = Utils::dateFormat('Y-m-d', $investList['invest']['created_at']); $investList['invest']['updated_at'] = Utils::dateFormat('Y-m-d', $investList['invest']['updated_at']); $investList['invest']['buy_time_start'] = Utils::dateFormat('Y-m-d', $investList['invest']['buy_time_start']); $investList['invest']['buy_time_end'] = Utils::dateFormat('Y-m-d', $investList['invest']['buy_time_end']); $investList['invest']['type'] = Invest::get_type($investList['invest']['type']); foreach ($investList['invest'] as $key => &$investInfo) { $investList['invest_' . $key] = $investInfo; } unset($investList['invest']); } }
public function findFriendIds() { return Member::find()->where(['parent_id' => $this->invitation])->asArray()->select(['id'])->all(); }
public function actionView() { $id = wanhunet::$app->request->post('id'); return Member::find()->select(Member::$SELECT_ROW)->where(['id' => $id])->one(); }
<?php use modules\asset\behaviors\ExperienceMoney; return ['adminEmail' => '*****@*****.**', 'behaviors' => [\modules\member\models\VerificationCode::className() => ['assetExperienceMoney' => ['class' => ExperienceMoney::className()]], \modules\member\models\Member::className() => ['asset' => ['class' => \modules\asset\behaviors\Asset::className(), 'assetConfig' => \modules\asset\models\Asset::className()], 'assetExperienceMoney' => ['class' => ExperienceMoney::className()]], \modules\asset\models\Asset::className() => ['asset_log' => ['class' => \modules\asset\behaviors\Log::className()], 'assetExperienceMoney' => ['class' => ExperienceMoney::className()]], \modules\invest\models\InvestList::className() => ['payedFinish' => \modules\invest\behaviors\InvestListPayed::className()], \modules\asset\models\AssetMoney::className() => [\modules\asset\behaviors\Log::className()], \modules\member\models\MemberOther::className() => [ExperienceMoney::className()]], 'events' => [\modules\asset\behaviors\Asset::className() => [\modules\member\models\Member::EVENT_AFTER_INSERT => \modules\asset\behaviors\Asset::FUNCTION_MEMBER_AFTER_INSERT], \modules\asset\behaviors\ExperienceMoney::className() => [\modules\member\models\VerificationCode::EVENT_VERIFY_SUCCESS_EMAIL => ExperienceMoney::FUNCTION_INC_EMAIL, \modules\member\models\VerificationCode::EVENT_VERIFY_SUCCESS_PHONE => ExperienceMoney::FUNCTION_INC_PHONE, \modules\asset\models\AssetMoney::EVENT_FINISH_PAY => ExperienceMoney::FUNCTION_INC_FIRST_MONEY, \modules\member\models\Member::EVENT_BEFORE_SAVE_IDCARD => ExperienceMoney::FUNCTION_INC_FIRST_IDCARD, \modules\member\models\MemberOther::EVENT_AFTER_INSERT => ExperienceMoney::FUNCTION_INT_BANGDING], \modules\invest\behaviors\InvestListPayed::className() => [\modules\invest\models\InvestList::EVENT_BEFORE_FINISH_PAY => \modules\invest\behaviors\InvestListPayed::FUNCTION_SET_INTEREST, \modules\invest\models\InvestList::EVENT_AFTER_FINISH_PAY => \modules\invest\behaviors\InvestListPayed::FUNCTION_SET_INTEREST_M], \modules\asset\behaviors\Log::className() => [\modules\asset\models\AssetMoney::EVENT_BEFORE_INSERT => \modules\asset\behaviors\Log::FUNCTION_BEFORE_INSERT]]];
public function actionUnlock() { $request = wanhunet::$app->request; return Member::updateAll(['status' => Member::STATUS_ACTIVE], ['id' => $request->post("id")]); }
/** * @return null|static|Member */ public function getActionIdModel() { return Member::findOne($this->action_uid); }
<?php $params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'); return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'frontend\\controllers', 'components' => ['user' => ['identityClass' => 'modules\\member\\models\\Member', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'member' => function () { return \modules\member\models\Member::findIdentity(\wanhunet\wanhunet::$app->user->getId()); }, 'view' => ['class' => 'wanhunet\\base\\View'], 'pay' => ['class' => 'wanhunet\\components\\llPayComponent', 'llpay_config' => ['oid_partner' => '201408071000001543', 'key' => '201408071000001543test_20140812', 'valid_order' => '10080'], 'risk_item' => '{\\"user_info_bind_phone\\":\\"13958069593\\",\\"user_info_dt_register\\":\\"20131030122130\\",\\"risk_state\\":\\"1\\",\\"frms_ware_category\\":\\"1009\\"}', 'busi_partner' => '101001'], 'urlManager' => ['class' => 'yii\\web\\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => ["text/<alias:\\w+>" => "text/view", "share/index/<invitation:\\w+>" => "share/index"]], 'wechat' => ['class' => 'callmez\\wechat\\sdk\\Wechat', 'appId' => 'wx747621d124836f6f', 'appSecret' => '6d245164dc7079e70abf7a4ad008b482', 'token' => 'mtlxny1410483192']], 'params' => $params];