Beispiel #1
0
 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;
 }
Beispiel #2
0
 public function actionView()
 {
     $id = wanhunet::$app->request->post('id');
     /** @var Member $member */
     $memberCow = Member::$SELECT_ROW;
     $member = Member::find()->where(['id' => $id])->select($memberCow)->asArray()->one();
     $parentMember = Member::find()->select($memberCow)->where(['invitation' => $member['parent_id']])->asArray()->one();
     $asset = Asset::find()->where(['user_id' => $id])->select(['experience_money_max', 'experience_money_max_inc', 'money', 'bank_card'])->asArray()->one();
     if (!empty($asset['bank_card'])) {
         $bankCards = empty($asset['bank_card']) ? [] : json_decode($asset['bank_card']);
         foreach ($bankCards as $bankCard) {
             $bankCard = unserialize($bankCard);
             if ($bankCard instanceof BankCard) {
                 /* @var \modules\asset\models\BankCard $bankcard */
                 $asset['bank_card'] = ['cardId' => $bankCard->cardId, 'backName' => $bankCard->bankName, 'cardUserName' => $bankCard->cardUserName, 'cardPhone' => $bankCard->cardPhone];
             }
         }
     }
     $asset['experience_money'] = AssetMoney::getExperienceMoney($id);
     /** @var MemberOther[] $memberOther */
     $memberOther = MemberOther::find()->where(['user_id' => $id])->all();
     foreach ($memberOther as $info) {
         if ($info->table == MemberOther::TABLE_JIUXIN) {
             $info->table = '玖信贷';
         } elseif ($info->table == MemberOther::TABLE_WECHAT) {
             $info->table = '微信账号';
         }
     }
     $friends = Member::findOne($id)->findFriends();
     return ['member' => $member, 'parent' => $parentMember, 'asset' => $asset, 'MemberOther' => $memberOther, 'friends' => $friends];
 }
Beispiel #3
0
 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]);
 }
Beispiel #4
0
 /**
  * 首次充钱
  * @param $event
  */
 public function setIncFirstMoney($event)
 {
     $rs = $event->rs;
     $assetOne = AssetMoney::find()->where(['user_id' => $rs['user_id']])->andWhere(['type' => AssetMoney::TYPE_MONEY])->andWhere(['status' => AssetMoney::STATUS_INC])->count();
     if ($assetOne == 1) {
         Debug::add('asset' . $assetOne);
         $assm = new AssetMoney();
         $assm->action = wanhunet::$app->controller->getRoute();
         $assm->step = Config::getInstance()->getProperty('setIncEM.firstMoney');
         $assm->user_id = $rs['user_id'];
         $assm->action_uid = $rs['user_id'];
         $assm->status = AssetMoney::STATUS_INC;
         $assm->type = AssetMoney::TYPE_EXPERIENCE_MONEY;
         $assm->save();
         $assmax = new AssetMoney();
         $assmax->action = wanhunet::$app->controller->getRoute();
         $assmax->step = Config::getInstance()->getProperty('setIncEM.firstMoney');
         $assmax->user_id = $rs['user_id'];
         $assmax->action_uid = $rs['user_id'];
         $assmax->status = AssetMoney::STATUS_INC;
         $assmax->type = AssetMoney::TYPE_EXPERIENCE_MONEY_MAX;
         $assmax->save();
     }
 }
Beispiel #5
0
 /**
  * @return array|AssetMoney[]
  */
 public function getExperienceMoneys()
 {
     return AssetMoney::getExperienceMoneys();
 }
Beispiel #6
0
 /**
  * 用户名 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 '用户不存在';
     }
 }
Beispiel #7
0
 public function actionPrivilege()
 {
     $investSum = InvestList::find()->where(['status' => InvestList::STATUS_PAYED, 'member_id' => wanhunet::$app->user->getId()])->joinWith(['invest' => function ($query) {
         /** @var \yii\db\ActiveQuery $query */
         $query->andWhere(['type' => Invest::TYPE_MONEY]);
     }])->sum('investment_sum');
     $friends = wanhunet::app()->member->findFriendIds();
     $fInveset = 0;
     if (count($friends) > 0) {
         $ids = [];
         foreach ($friends as $id) {
             $ids[] = $id['id'];
         }
         $fInveset = InvestList::find()->where(['status' => InvestList::STATUS_PAYED, 'member_id' => $ids])->joinWith(['invest' => function ($query) {
             /** @var \yii\db\ActiveQuery $query */
             $query->andWhere(['type' => Invest::TYPE_MONEY]);
         }])->sum('investment_sum');
     }
     $emMaxList = AssetMoney::find()->where(['type' => AssetMoney::TYPE_EXPERIENCE_MONEY_MAX, 'user_id' => wanhunet::$app->user->getId()])->orderBy('id desc')->joinWith(['actionUid'])->limit(50)->all();
     $einvestListModle = InvestList::find()->where(['status' => InvestList::STATUS_PAYED, 'member_id' => wanhunet::$app->user->getId()])->joinWith(['invest' => function ($query) {
         /** @var \yii\db\ActiveQuery $query */
         $query->andWhere(['type' => Invest::TYPE_EXPERIENCE_MONEY]);
     }]);
     $einvestListSum = $einvestListModle->sum('interest');
     $einvestList = $einvestListModle->limit(50)->orderBy('id desc')->all();
     return $this->view('privilege', ['myInveset' => $investSum, 'fInveset' => $fInveset, 'emMaxList' => $emMaxList, 'einvestList' => $einvestList, 'einvestListSum' => $einvestListSum]);
 }
Beispiel #8
0
 public function actionMention()
 {
     try {
         $pass = wanhunet::app()->member->validatePayPass(wanhunet::$app->request->post('paypass'));
         if (!$pass) {
             throw new ErrorException('密码验证错误', ErrorCode::Pay_pass_empty);
         }
         /** @var AssetMoney $order */
         $order = AssetMoney::findOne(wanhunet::$app->getSession()->get("order")[1]);
         $member = wanhunet::app()->member;
         $member->setDecMoney($order->step);
         $member->saveMoney();
         $order->status = AssetMoney::STATUS_ORDER_MADE;
         $order->save();
         wanhunet::$app->getSession()->remove('order');
         return $this->view('mention');
     } catch (\Exception $e) {
         if ($e->getCode() == ErrorCode::Pay_pass_empty) {
             return $this->goBack(['info' => $e->getMessage()], Url::to(['pay/pay-pass']));
         } elseif ($e->getCode() == 0) {
             return $this->goBack(['info' => "请输入密码"], Url::to(['pay/pay-pass']));
         } else {
             return $this->goBack(['info' => $e->getMessage()], Url::to(['pay/pay-pass']));
         }
     }
 }
Beispiel #9
0
 public function actionReturnRateMonth()
 {
     $id = wanhunet::$app->request->post('id');
     /** @var InvestMonth[] $investMonths */
     $investMonths = InvestMonth::find()->joinWith(['investList' => function ($query) {
         /** @var \yii\db\ActiveQuery $query */
         $query->joinWith(['member' => function ($query) {
             /** @var \yii\db\ActiveQuery $query */
             $query->select(Member::$SELECT_ROW);
         }, 'invest']);
     }])->orderBy('id desc')->where(['m_status' => InvestMonth::STATUS_ACTIVE])->andWhere([InvestMonth::tableName() . '.id' => $id])->andWhere(['<=', 'm_time', time()])->asArray()->all();
     $members = [];
     $assetMoneys = [];
     $ims = [];
     $investOver = [];
     foreach ($investMonths as $investMonth) {
         $memberId = $investMonth['investList']['member']['id'];
         if (isset($members[$memberId])) {
             $memberAsset =& $members[$memberId];
         } else {
             $asset = $asset = Asset::find()->where(['user_id' => $memberId])->asArray()->one();
             $members[$memberId] = $asset['money'];
             $memberAsset =& $members[$memberId];
         }
         if (InvestMonth::find()->where(['invest_list_id' => $investMonth['invest_list_id'], 'm_status' => InvestMonth::STATUS_ACTIVE])->count() == 1) {
             $investOver[] = $investMonth['investList']['id'];
             $step = $investMonth['investList']['investment_sum'] + $investMonth['m_step'];
         } else {
             $step = $investMonth['m_step'];
         }
         $memberAsset += $step;
         $assetMoneys[] = [$memberId, $step, AssetMoney::STATUS_INC, AssetMoney::TYPE_MONEY, wanhunet::$app->controller->getRoute(), $memberId, json_encode([mb_substr($investMonth['investList']['invest']['title'], 0, 5, 'utf-8') . '第' . $investMonth['m_date'] . '个月的返息']), time(), time()];
         $ims[$investMonth['id']] = ['m_status' => InvestMonth::STATUS_DELETED];
     }
     $batchInsertRows = ['user_id', 'step', 'status', 'type', 'action', 'action_uid', 'llinfo', 'created_at', 'updated_at'];
     $connection = wanhunet::$app->db;
     foreach ($members as $user_id => $amemberAsset) {
         $connection->createCommand()->update(Asset::tableName(), ['money' => $amemberAsset], ['user_id' => $user_id])->execute();
     }
     foreach ($ims as $im_id => $im) {
         $connection->createCommand()->update(InvestMonth::tableName(), $im, ['id' => $im_id])->execute();
     }
     foreach ($investOver as $in) {
         $connection->createCommand()->update(InvestList::tableName(), ['status' => InvestList::STATUS_ORDER_TRIAL], ['id' => $in])->execute();
     }
     if (count($assetMoneys) > 0) {
         $connection->createCommand()->batchInsert(AssetMoney::tableName(), $batchInsertRows, $assetMoneys)->execute();
     }
 }
Beispiel #10
0
<?php

/** @var \wanhunet\base\View $this */
if (($order = \wanhunet\wanhunet::$app->getSession()->get('order')) !== null) {
    if (is_array($order)) {
        $price = \modules\asset\models\AssetMoney::findOne($order[1])->getPrice();
        $action = \yii\helpers\Url::to(['pay/mention']);
    } else {
        $price = \modules\invest\models\InvestList::findOne($order)->getPrice();
        $action = \yii\helpers\Url::to(['pay/pay-with-balance']);
    }
}
?>
    <section class="login_bt divoi wh-addpage" style="padding:20px 8px 0;">
        <form class="wh-addform" id="form" action="<?php 
echo $action;
?>
" method="post">
            <div class="divoi_odi">
                <div class="login_td login-fall">
                    <input style="text-align:center;" type="password" name="paypass" placeholder="请输入交易密码"/>
                </div>
            </div>
            <p class="font-s16 wh-addptop mb10">为了保证资金安全,请输入您的交易密码,默认为登录密码</p>

            <p class="font-s16 mt20 mb10">支付金额:<span
                    class="hui8">
                <?php 
echo $price;
?>
                    元</span></p>
Beispiel #11
0
<?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]]];
Beispiel #12
0
 public function actionMentionPost()
 {
     $member = wanhunet::app()->member;
     $request = wanhunet::$app->request;
     $assetMoney = new AssetMoney();
     $assetMoney->step = $request->post('step');
     $assetMoney->status = AssetMoney::STATUS_MONEY_UNPAYED;
     $assetMoney->type = AssetMoney::TYPE_MENTION;
     $assetMoney->user_id = $member->getId();
     if ($assetMoney->saveOrder()) {
         wanhunet::$app->getSession()->set('order', ['asset', $assetMoney->id]);
         return $this->redirect(Url::to(['pay/pay-pass']));
     } else {
         return $this->goBack(['info' => '请输入提现金额'], Url::to(['invest/mention']));
     }
 }