コード例 #1
0
ファイル: AdminCtrl.class.php プロジェクト: Jnnock/myyyk
 public function getAlbumsByAdminId()
 {
     $errors = $this->errors;
     //实例化Model
     $albumModel = new AlbumModel();
     $photosModel = new PhotosModel();
     $commentModel = new CommentModel();
     //某博主的所有相册
     $result = $albumModel->getAlbumByAdminId($_SESSION['admin']['adminId']);
     $resultArr = array();
     foreach ($result as $key => $value) {
         //某相册的相片
         $photos = $photosModel->getPhotos($albumId);
         $photoIds = arrayColumn($photos, 'photoId');
         //根据photoIds获取评论
         $comments = $commentModel->getCommentByArrPhotoId($photoIds);
         $value['commentCount'] = count($comments);
         $resultArr[] = $value;
     }
     $this->assign('albums', $resultArr);
     $this->display();
 }
コード例 #2
0
ファイル: third_bind.php プロジェクト: songhongyu/datecenter
            <div class="valid-status unvalid">未认证</div>
            <a class="whitebtn-new bind" target='_blank' href="<?php 
    echo Url::toRoute(['user/auth', 'authclient' => 'qq']);
    ?>
">添加绑定</a>
            <?php 
}
?>
        </div>
    </div>
    <div class="col-xs-4 blog cf">
        <span class="third-logo fl"></span>
        <div class="bind-info fl">
            <span class="info-title">新浪微博</span>
            <?php 
if (in_array(UserThirdPartyLogin::BIND_TYPE_WEIBO, arrayColumn($thirds, 'type'))) {
    ?>
            <div class="valid-status hasvalid">已认证</div> 
            <a class="whitebtn-new bind unbind" type='weibo' href="<?php 
    echo Url::toRoute(['user/unbind'], true);
    ?>
" mark='0'>解除绑定</a>
            <?php 
} else {
    ?>
            <div class="valid-status unvalid">未认证</div>
            <a class="whitebtn-new bind" target='_blank' href="<?php 
    echo Url::toRoute(['user/auth', 'authclient' => 'weibo']);
    ?>
">添加绑定</a>
            <?php 
コード例 #3
0
 public function actionSafety()
 {
     $userBaseInfo = new UserBaseInfo();
     $address = new Address();
     $userTB = new UserThirdPartyLogin();
     $this->layout = 'uc';
     if (!$userBaseInfo->islogin()) {
         return $this->redirect(array('user/login'));
     } else {
         // 获取用户密码信息
         // $cookie = Yii::$app->getRequest()->cookies;
         // $cookieId = $cookie[UserBaseInfo::COOKIE_KEY_ID]->value;
         $session = Yii::$app->session[UserBaseInfo::SESSION_KEY_USER];
         $userId = isset($session['id']) && $session['id'] ? $session['id'] : 0;
         $inforMation = $userBaseInfo->getUserById($userId);
         $addr = $address->getAddress($userId);
         $thirds = $userTB->getBindByUser($userId, UserThirdPartyLogin::BIND_WEB_CHANNEL) ? $userTB->getBindByUser($userId, UserThirdPartyLogin::BIND_WEB_CHANNEL) : [];
         foreach ($thirds as $key => $value) {
             $thirds[$key]['type'] = strtoupper($thirds[$key]['type']);
         }
         $level = 0;
         $item = 5;
         if ($thirds) {
             $level += count($thirds) * 10;
             $item -= count($thirds);
         }
         if ($inforMation['mobile']) {
             $level += 40;
             $item -= 1;
         }
         if ($inforMation['email']) {
             $level += 30;
             $item -= 1;
         }
         $inforMation['level'] = $level;
         $inforMation['item'] = $item;
         $inforMation['addrNum'] = count($addr);
         $inforMation['thirds'] = arrayColumn($thirds, 'type');
         return $this->render('safety', $inforMation);
     }
 }
コード例 #4
0
 /**
  * 用户支付页面
  */
 public function actionOrderPay()
 {
     /**
      * 获取第三方绑定token
      * $url = 'http://test-api.chuangyejia.com/v1/token?app_id=100003&app_key=f8d80e9a';
      * $res = do_request($url);
      * p($token = $res['data']['ret']['access_token']);die;
      *
      * do_request 获取借口信息
      * $request = Yii::$app->getRequest();
      * $get = $request->get();
      * $data   = [
      *     'open_id' => $open_id,
      *     'add_order_sn' => $get['app_order_sn'],
      *     'access_token' => $token,
      * ];
      * $url = 'adfadfaf';
      * $orderInfo = do_request($url, $data);
      * $orderInfo = json_decode($orderInfo, true);
      * if ($orderInfo['code'] == 1101) {
      *      return '订单不存在';
      * }
      * if ($orderInfo['code'] == 1201) {
      *      return '用户不存在';
      * }
      * if ($orderInfo['code'] == 1301) {
      *      return ...
      * }
      * if (!isset($_SERVER['HTTP_REFERER']) || !$_SERVER['HTTP_REFERER']) {
      *     $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=非法请求');
      *     return '非法请求';
      * }
      */
     $mBind = new PayBinding();
     $payMethods = new PayMethod();
     $mOrder = new Order();
     $mAddress = new Address();
     $mApp = new ApplicationBaseInfo();
     $request = Yii::$app->getRequest();
     $get = $request->get();
     $session = Yii::$app->getSession();
     $cookie = $request->cookies->getValue('open_id');
     $openId = $session[UserBaseInfo::SESSION_KEY_USER]['open_id'] ?: $cookie;
     $order = '';
     //没有第三方传值 暂时默认 app_id = 100002, app_order_sn = 554892031231322
     $appId = isset($get['app_id']) && $get['app_id'] ? $get['app_id'] : '100002';
     if (!$appId) {
         return '应用id失效';
     }
     $appOrderSn = isset($get['app_order_sn']) && $get['app_order_sn'] ? $get['app_order_sn'] : '555892131' . mt_rand(100000, 999999);
     if (!$appOrderSn) {
         // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=因无订单号为空');
         return '订单号为空';
     }
     if (isset($get['order_sn']) && $get['order_sn']) {
         $order = Order::getByOrderSn($get['order_sn']);
         if (!$order) {
             return $this->redirect(Url::toRoute('order/index'));
         }
         $appId = $order['app_id'];
         $appOrderSn = $order['app_order_sn'];
         if (!$appId || !$appOrderSn) {
             $order = '';
         }
     }
     if (!isset($get['order_sn']) || !$get['order_sn'] || !$order) {
         $order = $mOrder->getByAppOrderSn($appOrderSn, $appId);
     }
     // 伪代码 访问应用接口返回data数据
     // if ($data['open_id'] != $openId) {
     //     return '非法请求';
     // }
     $payIds = $mBind->getByAppId($appId);
     if (!$payIds) {
         // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=应用未绑定任何支付方式');
         return '应用未绑定任何支付方式';
     }
     $appUrls = arrayColumn($payIds, 'app_url');
     $appUrls = array_unique($appUrls);
     $returnUrl = array_pop($appUrls);
     $app = $mApp->getByAppId($appId);
     $app = ['app_order_sn' => $appOrderSn, 'origin' => $app['app_name']];
     $time = time();
     $orderSn = Yii::$app->util->orderSn();
     if (!$order) {
         try {
             // TODO:: 通过接口获取应用生成的订单信息
             $orderInfo = ['open_id' => $openId, 'product_id' => '1', 'product_name' => 'Young K' . mt_rand(100000, 999999), 'order_sn' => $orderSn, 'turnover' => '0.01', 'app_order_title' => '黑马大赛报名' . mt_rand(100000, 999999), 'create_time' => $time, 'expires_time' => $time + 24 * 3600, 'address_id' => 1, 'app_id' => $appId];
             $data = $this->wxQrCode($orderInfo);
             $app['address_id'] = $orderInfo['address_id'];
             $app['app_id'] = $orderInfo['app_id'];
             $orderId = $mOrder->add(array_merge($app, $data));
             if (empty($orderId)) {
                 // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=生成订单失败');
                 return '生成订单失败';
             }
             $address = $mAddress->getById($orderInfo['address_id']);
         } catch (\Exception $e) {
             return $e->getMessage();
         }
     } else {
         if ($order['expires_time'] < $time) {
             // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=订单过期');
             return '订单过期';
         }
         if ($order['open_id'] != $openId) {
             return '不具备操作该订单权限';
         }
         if ($order['pay_status'] == Order::ORDER_PAID_STATUS) {
             // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=该订单已完成交易');
             return '该订单已完成交易';
         }
         if ($order['pay_status'] == Order::ORDER_REFUND_STATUS) {
             // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=该订单已退款');
             return '该订单已退款';
         }
         if ($order['pay_status'] == Order::ORDER_INVALID_STATUS) {
             // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=该订单已失效');
             return '该订单已失效';
         }
         if ($order['pay_status'] == Order::ORDER_CANCLE_STATUS) {
             // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=已取消订单');
             return '已取消订单';
         }
         $data = $this->wxQrCode($order);
         $address = $mAddress->getById($order['address_id']);
     }
     $address['county'] = isset($address['county']) && $address['county'] ? District::getRegionById($address['county']) : '';
     $alipayForm = $this->genAlipayForm($data);
     $alipayQrcode = $this->genAlipayQrcode($data);
     $sig = $this->wxCodeSig($data);
     $data['signature'] = $sig;
     $methods = $payMethods->getById(arrayColumn($payIds, 'pay_id'), true);
     if (!$methods) {
         // $this->redirect($_SERVER['HTTP_REFERER'] . '?fileInfo=未找到支付方式');
         return '未找到支付方式';
     }
     $this->layout = 'main';
     return $this->render('order_pay', ['methods' => $methods, 'data' => $data, 'appOrderSn' => $appOrderSn, 'address' => $address, 'returnUrl' => $returnUrl, 'alipayForm' => $alipayForm, 'alipayQrcode' => $alipayQrcode]);
 }