Example #1
0
 public function actionIndex($invitation = null)
 {
     if ($invitation !== null) {
         $_GET['parent'] = $invitation;
     }
     $request = wanhunet::$app->request;
     $wechat = wanhunet::app()->wechat;
     $token = $wechat->getOauth2AccessToken($request->get('code'));
     $refreshToken = $wechat->refreshOauth2AccessToken($token['refresh_token']);
     $info = $wechat->getSnsMemberInfo($refreshToken['openid'], $refreshToken['access_token']);
     if (is_bool($info)) {
         return "请在微信中打开";
     }
     /** @var ShareGift $shareGift */
     if (($shareGift = ShareGift::find()->where(['wechat_id' => $refreshToken['openid']])->one()) === null) {
         $shareGift = new ShareGift();
         $shareGift->wechat_info = json_encode($info);
         $shareGift->wechat_id = $refreshToken['openid'];
         $giftList = explode(',', Config::getInstance()->getProperty("setIncEM.gift"));
         $shareGift->gift_limit = $giftList[rand(0, count($giftList) - 1)];
         if (!is_numeric($shareGift->gift_limit)) {
             return "请在微信中打开";
         }
         $shareGift->save();
     } else {
         if ($shareGift->has_gift == ShareGift::HAS_GIFT) {
             return $this->hasGift($shareGift);
         }
     }
     /** @var Invest $invest */
     $invest = Invest::find()->where(["type" => Invest::TYPE_REG])->one();
     $num = $shareGift->gift_limit * $invest->invest_date * ($invest->rate / 100) / 12;
     $num = sprintf("%.2f", $num);
     return $this->view("index", ['shareGift' => $shareGift, 'num' => $num, 'wechat_id' => $info['openid']]);
 }
Example #2
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;
 }
Example #3
0
 /**
  * @return array
  * @throws \yii\db\Exception
  *
  * verify_success_email        //验证邮箱成功
  * verify_success_phone        //验证手机成功
  * firstMoney                  //第一次充值
  * firstIdcard                 //填写身份证
  * jiuxin                      //绑定玖信账号
  * setIncEM.wechat                      /绑定玖信账号
  * setIncEM.invitationParent            //用户通过邀请码注册父级得分
  * setIncEM.invitationParentConut9      //用户通过邀请码第九个注册父级得分
  * setIncEM.invitationConut9            //用户通过邀请码第九个注册自己得分
  */
 public function actionSetting()
 {
     $request = wanhunet::$app->request;
     if ($request->isGet) {
         $configs = Config::getInstance()->config;
         foreach ($configs as $key => &$config) {
             if (strstr($key, 'setIncEM.')) {
                 $configs[str_replace('setIncEM.', '', $key)] = $config;
                 unset($configs[$key]);
             }
         }
         return json_encode($configs);
     } else {
         $connection = wanhunet::$app->db;
         $rs = [];
         foreach ($request->post() as $key => $value) {
             try {
                 $rs[] = $connection->createCommand()->update('wh_config', ['value' => $value], ['key' => 'setIncEM.' . $key])->execute();
             } catch (\Exception $e) {
             }
         }
         return $rs;
     }
 }
Example #4
0
 /**
  * 首次验证手机
  * @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']));
 }
Example #5
0
 public function setIncExperienceMoneyInc($step = 0)
 {
     $this->experience_money_max_inc += $step;
     $incMax = Config::getInstance()->getProperty('setIncMax.Inc');
     if ($this->experience_money_max_inc > $incMax) {
         $time = (int) ($this->experience_money_max_inc / $incMax);
         $this->experience_money_max_inc = $this->experience_money_max_inc % $incMax;
         $this->setIncExperienceMoneyMax($incMax * $time);
         return $this->saveExperienceMoneyMax();
     }
     return $this->update();
 }
Example #6
0
 /**
  * @throws ErrorException
  */
 private function _sendVcode()
 {
     $vcodeTime = Config::getInstance()->getProperty('setTime.vcode');
     $content = '您的验证码为:' . $this->code . '请在' . $vcodeTime / 60 . '分钟内进行处理';
     if (($old = self::findByField($this->field)) !== null && $old->created_at > time() - $vcodeTime) {
         throw new ErrorException($vcodeTime - (time() - $old->created_at), ErrorCode::Vcode_short_time);
     }
     if ($this->type == self::TYPE_EMAIL) {
         try {
             Utils::sendEmail($this->field, '玖信贷邮箱验证码', $content);
         } catch (\Exception $e) {
             throw new ErrorException('验证码发送错误', ErrorCode::Send_email_error);
         }
     } else {
         if (Utils::sendSMS($this->field, $content) < 0) {
             throw new ErrorException('验证码发送错误', ErrorCode::Send_phone_error);
         }
     }
 }
Example #7
0
                    <div class="shezhi_td_od">
                        <img src="<?php 
echo $root;
?>
images/to2.png" alt="">
                    </div>
                    <div class="shezhi_td_d">
                        <p>绑定玖信账号</p>
                    </div>
                    <div class="shezhi_td_th">
                        <p>
                            <?php 
if (($memberOther = $member->getOtherInfo(\modules\member\models\MemberOther::TABLE_JIUXIN)) !== null) {
    echo '已认证';
} else {
    echo '认证获' . \common\models\Config::getInstance()->getProperty('setIncEM.jiuxin') . '体验金';
}
?>
                        </p>
                    </div>
                </div>
            </aside>
        </a>
        <a href="<?php 
echo \yii\helpers\Url::to(['site/recharge']);
?>
">
            <aside class="shezhi_aside">
                <div class="shezhi_div">
                    <div class="shezhi_td_od">
                        <img src="<?php 
Example #8
0
 public function actionEmailCaptcha()
 {
     $request = wanhunet::$app->request;
     $params = [];
     if ($request->isPost) {
         $email = $request->post('email');
         $params['email'] = $email;
         try {
             $vcode = new VerificationCode();
             $vcode->field = $email;
             $vcode->save();
             $params['info'] = '发送成功';
             $params['min'] = Config::getInstance()->getProperty('setTime.vcode');
         } catch (\ErrorException $e) {
             if ($e->getCode() == ErrorCode::Vcode_short_time) {
                 $params['min'] = $e->getMessage();
                 $params['info'] = '时间间隔过短';
             } else {
                 $params['info'] = $e->getMessage();
             }
         }
     }
     return $this->goBack($params, Url::to(['site/email']));
 }
Example #9
0
 public static function getAlreadyBuyCount(Invest $invest)
 {
     $id = $invest->id;
     $config = Config::getInstance();
     $isset = $config->hasProperty('setTime.' . self::NAME_ORDER_EXPIRE);
     $timeExpire = $isset ? $config->getProperty('setTime.' . self::NAME_ORDER_EXPIRE) : 30 * 3600;
     return $ordersCount = self::find()->where('invest_id=:invest_id and status=:status_payed', [':invest_id' => $id, ':status_payed' => self::STATUS_PAYED])->count();
 }
Example #10
0
 /**
  * 用户注册之后事件
  * @param $event
  */
 public function memberAfterInsert($event)
 {
     $member = $event->sender;
     /** @var \modules\member\models\Member $member */
     $asset = new \modules\asset\models\Asset();
     $asset->user_id = $member->id;
     $asset->pay_pass = $member->password_hash;
     $asset->experience_money_max = Config::getInstance()->getProperty("setIncEM.initEmMax");
     $asset->save();
 }
Example #11
0
 public function getActionName()
 {
     $config = Config::getInstance();
     $actions = $config->getProperty('assetLog');
     return isset($actions[$this->action]) ? $actions[$this->action] : "赠送";
 }
Example #12
0
 /**
  * 通过用户请求生成订单
  * @param Order $order
  * @return InvestList
  * @throws ErrorException
  */
 public function markOrder(Order $order)
 {
     $price = $order->getPrice();
     $orderSum = InvestList::getAlreadyBuy($this);
     if (Config::getInstance()->getProperty('Invest.sumConfig') == 'both') {
         $sum = $orderSum[InvestList::STATUS_PAYED] + $orderSum[InvestList::STATUS_UNPAYED];
     } else {
         //TODO 可能出现问题由于这个是计算的已付的金额
         $sum = $orderSum[InvestList::STATUS_PAYED];
     }
     $rest = $this->amount - $sum;
     $eachMax = $this->each_max == 0 ? $this->amount : $this->each_max;
     $eachMin = $rest < $this->each_min ? $rest : $this->each_min;
     if ($price > $rest || $price > $eachMax) {
         throw new ErrorException('您购买的金额超出最大购买量', ErrorCode::Buy_each_max);
     }
     if ($price < $eachMin) {
         throw new ErrorException('您购买的金额小于最少购买量', ErrorCode::Buy_each_min);
     }
     if (time() > $this->buy_time_end || time() < $this->buy_time_start) {
         throw new ErrorException('您购买的不在购买时间内', ErrorCode::Buy_out_time);
     }
     if ($this->type == self::TYPE_EXPERIENCE_MONEY) {
         if ($price > wanhunet::app()->member->getExperienceMoneyMax()) {
             throw new ErrorException('您购买的金额超出您个人最大体验金购买量', ErrorCode::Buy_experience_money_max);
         }
     }
     /*if (InvestList::hasBuy(wanhunet::app()->member->getId(), $this->id)) {
           throw new ErrorException('您已经买过了', ErrorCode::Buy_has_buy);
       }*/
     //TODO 这个[[wanhunet::app()->member->getId()]] 应该动态配置
     $order->setUserId(wanhunet::app()->member->getId());
     $order->setProductId($this->id);
     $saveOrder = $order->saveOrder();
     if ($saveOrder) {
         $this->afterMarkOrder();
     }
     return $order;
 }