Example #1
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];
 }
Example #2
0
 public function setInterest(Event $event)
 {
     /** @var InvestList $investList */
     $investList = $event->sender;
     $investList->interest = $this->_calculatedInterest($investList);
     $investList->interest_status = InvestList::STATUS_ORDER_MADE;
     $invest = $investList->getInvestModel();
     $invest_date = $invest->invest_date;
     $date = date('Y-m-d H:i:s ', $investList->pay_time);
     $investList->interest_time = strtotime($date . $invest_date . 'month');
     //体验金上限增长
     if ($investList->getType() == Invest::TYPE_MONEY) {
         $member = wanhunet::app()->member;
         $member->setIncExperienceMoneyInc($investList->investment_sum);
         if (($parent = $member->getParentModel()) !== null) {
             Asset::findOne($parent->id)->setIncExperienceMoneyInc($investList->investment_sum);
         }
     }
 }
Example #3
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();
     }
 }
Example #4
0
 public function getAsset()
 {
     return $this->hasOne(Asset::className(), ['user_id' => 'id']);
 }
Example #5
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]]];
Example #6
0
 public function finishPay(Event $event)
 {
     /** @var \wanhunet\components\PayEvent $event */
     $data = $event->rs;
     $notifyResp = $data['notifyResp'];
     Debug::add($notifyResp);
     $this->status = self::STATUS_INC;
     $this->save();
     /** @var Asset $asset */
     $asset = Asset::find()->where(['user_id' => $this->user_id])->one();
     if ($asset !== null) {
         $asset->money = $this->step + $asset->money;
         $asset->saveMoney();
     }
     $event->rs['user_id'] = $this->user_id;
     $this->trigger(self::EVENT_FINISH_PAY, $event);
 }