Пример #1
0
 /**
  * 用户产品列表
  *
  * 个人中心产品列表显示
  *
  * @param int $uid 用户的id号
  *
  * @return array 个人中心产品列表页渲染所有数据
  */
 public function actionLists()
 {
     // print_r($_GET);exit;
     $uid = Yii::$app->request->get('uid');
     $uid = intval($uid);
     $self = false;
     //表示身份
     $login = PublicLibrary::is_login() ? PublicLibrary::is_login() : '';
     //异常默认uid
     if (empty($uid) && PublicLibrary::is_login()) {
         $uid = $login['uid'];
     }
     //判断是否登录
     if ($login !== '' && $login['uid'] == $uid) {
         $self = true;
     }
     //用户信息
     $member = new Member();
     $user = $member->getByUid($uid);
     // print_r($user);exit;
     //完善用户信息
     if (!$user) {
         //是否存在该用户
         return $this->redirect(['product/index']);
     } else {
         $user['renqi'] = isset($user['memberstar']) && is_array($user['memberstar']) ? array_sum($user['memberstar']) : 0;
         //用户位置信息
         $dist = new District();
         if (!empty($user['city'])) {
             $user['address'] = $dist->getByCity($user['city']['id']);
         } else {
             // $user['address'] = $dist->getByCity(40);
             $user['address'] = ['name' => '不详', 'province' => '地址'];
         }
         //获取用户头像
         $user['avatar'] = PublicLibrary::getBigAvatar($user['avatar']);
         //获取用户发布产品个数数据
         $iProductBase = new IProductBase();
         $user['pub_num'] = $iProductBase->getCountByUid($uid);
     }
     //筛选map
     $activeMap = ['0' => '全部', '1' => '即将开始', '2' => '预定中', '3' => '已结束'];
     //游客和自己可以看的map是不同的
     if ($self) {
         //筛选参数处理
         $statusMap = ['0' => '全部', '2' => '待发布', '3' => '审核中', '4' => '发布中', '6' => '审核未通过'];
         $orderMap = ['0' => '全部', '1' => '最新发布', '2' => '支持最多', '3' => '最新更新'];
     } else {
         //筛选参数处理
         $statusMap = ['0' => '全部', '2' => '待发布'];
         $orderMap = ['0' => '默认', '1' => '最新发布', '2' => '支持最多', '3' => '最新更新'];
     }
     $params = [];
     $type = Yii::$app->request->get('type') ? Yii::$app->request->get('type') : 0;
     $type = intval($type);
     in_array($type, array_keys($statusMap)) ? $params['type'] = $type : ($params['type'] = 0);
     $stat = Yii::$app->request->get('stat') ? Yii::$app->request->get('stat') : 0;
     $stat = intval($stat);
     in_array($stat, array_keys($activeMap)) ? $params['stat'] = $stat : ($params['stat'] = 0);
     $order = Yii::$app->request->get('order') ? Yii::$app->request->get('order') : 0;
     $order = intval($order);
     in_array($order, array_keys($orderMap)) ? $params['order'] = $order : ($params['order'] = 0);
     $iProductBase = new IProductBase();
     $list = $iProductBase->choose($uid, $type, $stat, $order);
     //获取用户没有删除的产品总数
     $user['count'] = $iProductBase->hasCountByUid($uid);
     // print_r($user['count']);exit;
     //修该 $list便于模板展示
     //未填第二步发布信息,提示信息map
     $map = ['roles' => ['1' => '创始人', '2' => '合伙人', '3' => '分销推广代表', '4' => '投资人', '5' => '股东', '6' => '企业法人', '7' => '继承人', '8' => '投资人', '9' => '股东', '10' => '企业法人', '11' => '继承人'], 'ages' => ['1' => '0-15周岁', '10' => '16-30周岁', '100' => '30-60周岁', '1000' => '60周岁以上'], 'gender' => ['0' => '全部', '1' => '男', '2' => '女']];
     //活动map
     $activityBase = new ActivityBase();
     $activesMap = $activityBase->getActivityMap();
     //休整$list——便于显示
     //        print_r($list);exit;
     foreach ($list as $k => $v) {
         if ($v['status'] == IProductBase::STATUS_VERIFEND) {
             //产品都是发布成功的——状态为4
             //功能判断标志
             $rendMark = ['del' => 1, 'update' => 1, 'apply' => 1];
             //产品发布天数
             $days = floor((time() - $v['create_time']) / 86400);
             $list[$k]['days'] = $days;
             if (!empty($v['aproduct'])) {
                 //有活动
                 //到期时间——默认为true到期
                 $endTime = true;
                 //活动计数
                 $num = 0;
                 foreach ($v['aproduct'] as $ki => $vi) {
                     // print_r(!$self);exit;
                     //当游客看时 取出不合格的活动信息
                     if ($self) {
                         if ($vi['acti_id'] == ActivityBase::FANS_FESTIVAL) {
                             unset($list[$k]['aproduct'][$ki]);
                             continue;
                         }
                     } else {
                         if ($vi['acti_id'] == ActivityBase::FANS_FESTIVAL || $vi['status'] != ActivityProduct::STATUS_VERIFY_THROUGH) {
                             unset($list[$k]['aproduct'][$ki]);
                             continue;
                         }
                     }
                     $num++;
                     if ($vi['end_time'] > time()) {
                         $endTime = false;
                     }
                     //删除功能
                     if ($vi['status'] == ActivityProduct::STATUS_VERIFYING || $vi['status'] == ActivityProduct::STATUS_VERIFY_THROUGH) {
                         //审核中或有通过审核的
                         $rendMark['del'] = 0;
                     }
                     //编辑功能
                     if ($vi['status'] == ActivityProduct::STATUS_VERIFYING) {
                         $rendMark['update'] = 0;
                     }
                     //活动申请
                     if ($num == 4 || $vi['status'] == ActivityProduct::STATUS_VERIFYING || $vi['status'] == ActivityProduct::STATUS_VERIFY_NOTTHROUGH || $vi['status'] == ActivityProduct::STATUS_SAVE) {
                         $rendMark['apply'] = 0;
                     }
                     //状态显示
                     $map1 = ['flow' => '', 'now' => time()];
                     if ($vi['status'] == ActivityProduct::STATUS_SAVE) {
                         $map1['flow'] = '保存中';
                     } else {
                         if ($vi['status'] == ActivityProduct::STATUS_VERIFYING) {
                             $map1['flow'] = '审核中';
                         } else {
                             if ($vi['status'] == ActivityProduct::STATUS_VERIFY_NOTTHROUGH) {
                                 $map1['flow'] = '审核未通过';
                             } else {
                                 if ($vi['status'] == ActivityProduct::STATUS_VERIFY_THROUGH) {
                                     if (!empty($vi['start_time']) || !empty($vi['end_time'])) {
                                         $start = $vi['start_time'];
                                         $end = $vi['end_time'];
                                     } else {
                                         $start = $activesMap[$vi['acti_id']]['start_time'];
                                         $end = $activesMap[$vi['acti_id']]['end_time'];
                                     }
                                     // $start = $vi['start_time'];
                                     // $end = $vi['end_time'];
                                     $now = time();
                                     if ($now < $start) {
                                         $map1['flow'] = '即将开始';
                                     } else {
                                         if ($end > $now && $now >= $start) {
                                             $map1['flow'] = '进行中';
                                         } else {
                                             if ($now >= $end) {
                                                 $map1['flow'] = '已结束';
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     $list[$k]['aproduct'][$ki]['map'] = $map1;
                     //页面只显示四个活动 多的数据清除掉
                     if ($num > 4) {
                         unset($list[$k]['aproduct'][$ki]);
                     }
                 }
                 if ($endTime) {
                     $rendMark['del'] = 1;
                 }
             }
             $list[$k]['rendMark'] = $rendMark;
         } else {
             if ($v['status'] == IProductBase::STATUS_FIRST || $v['status'] == IProductBase::STATUS_INVALID) {
                 //状态为5 只发布第一步 或状态为99 预览 显示信息拼凑
                 $list[$k]['apply_role'] = $map['roles'][$v['apply_role']];
                 $rand = str_split(str_pad($v['user_oriented_age'], 4, 0, STR_PAD_LEFT));
                 $ages = '';
                 $rand[3] ? $ages .= $map['ages']['1'] . ' 、' : ($ages = $ages);
                 $rand[2] ? $ages .= $map['ages']['10'] . ' 、' : ($ages = $ages);
                 $rand[1] ? $ages .= $map['ages']['100'] . ' 、' : ($ages = $ages);
                 $rand[0] ? $ages .= $map['ages']['1000'] . ' 、' : ($ages = $ages);
                 $list[$k]['user_oriented_age'] = trim($ages, '、');
                 $list[$k]['user_oriented_gender'] = $map['gender'][$v['user_oriented_gender']];
                 $iProductType = new IProductType();
                 $typeMap = $iProductType->getTypeMap();
                 $list[$k]['type'] = $typeMap[$v['type']];
             }
         }
     }
     // print_r($list);exit;
     // //活动map
     // $activityBase = new ActivityBase();
     // $activesMap = $activityBase->getActivityMap();
     // print_r($activesMap);exit;
     //调用个人中心的布局
     $this->layout = '@app/views/layouts/main.php';
     //        return $this->render(
     //            'index',
     //            [
     //                'list' => $list,
     //                'user' => $user,
     //                'self' => $self,
     //                'activesMap' => $activesMap
     //            ]
     //        );
     // print_r($list);exit;
     //user 数据添加
     $mMerberStat = new MemberStat();
     $user['stat'] = $mMerberStat->getByUid($uid);
     // print_r($list);exit;
     $refresh = isset($_GET['pid']) ? $_GET['pid'] : '';
     return $this->render('homepage', ['user' => $user, 'self' => $self, 'list' => $list, 'params' => $params, 'statusMap' => $statusMap, 'orderMap' => $orderMap, 'activesMap' => $activesMap, 'activeMap' => $activeMap, 'refresh' => $refresh]);
 }
Пример #2
0
<?php

use yii\helpers\Url;
use frontend\models\UserThirdPartyLogin;
//用户第三方登录模型
use frontend\models\Member;
//用户模型
$session = Yii::$app->session;
$session->isActive ? '' : $session->open();
$user = $session->get('user');
$tplogin = isset($user['third_party_login']) ? $user['third_party_login'] : false;
if ($user['uid'] == UserThirdPartyLogin::NOT_BOUND_USERID) {
    $user['avatar'] = $tplogin['profile']['avatar'];
} elseif (!empty($user)) {
    $member_model = new Member();
    $user = $member_model->getByUid($user['uid']);
    // var_dump($user);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>一呼百应</title>
    <!--
            @require "styles/lib/normalize.css"
            @require "styles/activity_365.less"
            @require "styles/common.css"
            @require "styles/special-yihubaiying.less"
        -->
<link rel="stylesheet" type="text/css" href="<?php 
Пример #3
0
 /**
  * Action Detail
  * @param $id int 资讯id
  */
 public function actionDetail($id)
 {
     //增加总访问量
     $mPostAttrStat = new PostAttrStat();
     $mPostAttrStat->modify('attr_stat_view_num', intval($id), 1, true);
     //访问日志
     $mViewsLog = new ViewsLog();
     $mViewsLog->modify(intval($id), ViewsLog::ARTICLE_TYPE);
     //增加周访问量,月访问量
     $week_num = $mViewsLog->ViewsNum(intval($id), ViewsLog::ARTICLE_TYPE, 7);
     $month_num = $mViewsLog->ViewsNum(intval($id), ViewsLog::ARTICLE_TYPE, 30);
     $mPostAttrStat->modifyviewnum('week_views_num', intval($id), $week_num);
     $mPostAttrStat->modifyviewnum('month_views_num', intval($id), $month_num);
     //获取资讯详情信息
     $mNewsMessage = new Post();
     $mNewsMessage = $mNewsMessage->getNewsDetail($id);
     if (!empty($mNewsMessage[0]['news_video_url'])) {
         $url = preg_match_all('/http:\\/\\/(.*?)?\\.(.*?)?\\.com\\/(.*)/', $mNewsMessage[0]['news_video_url'], $types);
         if (!empty($types) && !empty($types[2]) && $types[2][0] == "youku") {
             $mNewsMessage[0]['news_video_url'] = Yii::$app->util->generalVideo($mNewsMessage[0]['news_video_url']);
             //视频地址处理
         } else {
             $mNewsMessage[0]['news_video_url'] = "";
         }
     }
     // echo "<pre>";
     // var_dump($mNewsMessage[0]);die;
     //获取热门产品
     $mProductStat = new IProductStat();
     $HotProducts = $mProductStat->getHotProduct();
     // echo "<pre>";
     // var_dump($HotProducts);die;
     //获取热门文章
     $mPostStat = new PostAttrStat();
     $HotArticles = $mPostStat->getHotArticle();
     // echo "<pre>";
     // var_dump($HotArticles);die;
     //获取相关用户
     $mPostMember = new PostAttrVal();
     $similarMember = $mPostMember->getSimilarMember($id);
     // echo "<pre>";
     // var_dump($HotArticles);die;
     //获取相关文章
     $mPostNews = new PostAttrVal();
     $similarNews = $mPostNews->getSimilarNews($id);
     // echo "<pre>";
     // var_dump($HotArticles);die;
     //登录用户获取用户信息
     $follow = ['follow' => false, 'like' => false];
     if ($user = Yii::$app->util->isLogin()) {
         $mMember = new Member();
         $re = $mMember->getByUid($user['uid']);
         $user['avatar'] = $re['avatar'];
         // 获取用户是否喜欢/Like
         $mFollow = new Follow();
         $follow['follow'] = $mFollow->getUserFollow($id, $user['uid']);
         $follow['like'] = $mFollow->getUserLike($id, $user['uid']);
     }
     //评论
     $mComment = new Comment();
     $comment = $mComment->getCommentsByNewsId($id, false, 0, Comment::NEWS_COMMENT_PAGESIZE);
     $total = $mComment->getCommentsByNewsId($id, true);
     // print_r($comment);exit;
     // print_r($total);exit;
     if (isset($mNewsMessage[0])) {
         return $this->render('detail', ['detail' => $mNewsMessage[0], 'products' => $HotProducts, 'article' => $HotArticles, 'similarMember' => $similarMember, 'similarNews' => $similarNews, 'user' => $user ? $user : '', 'comment' => $comment, 'total' => $total, 'follow' => $follow]);
     } else {
         return $this->redirect(['news/index']);
         //跳转到资讯首页
     }
 }
Пример #4
0
 /**
  * 用户投票接口
  * @author shimeixia (1796573650@qq.com)
  * @param option_id int 投票选项ID
  * @return json
  * 访问接口:http://www.idaiyan-website.cn/goodproduct/vote?option_id=1
  */
 public function actionVote()
 {
     if (yii::$app->util->isAjax()) {
         $user = yii::$app->util->isLogin();
         // if (1) {
         //     $user = array('uid' => 19397);
         if ($user) {
             $experts = array(18601068804, 13701675260, 13816889322, 18616806116, 13901371168, 15910687353, 13816790990, 18600669356, 13601207501);
             $data = Yii::$app->request->post();
             $mMember = new Member();
             $userMessage = $mMember->getByUid($user['uid']);
             //投票选项信息
             $mPollOption = new PollOption();
             // if (empty($data['option_id'])) {
             //     echo Yii::$app->util->formatResEncode('3004', '数据格式不对', []);
             //     exit;
             // }
             //$data['option_id'] = json_decode($data['option_id']);
             if (is_array($data['option_id']) && !empty($data['option_id'])) {
                 $option_id = $data['option_id'][0];
             } else {
                 echo Yii::$app->util->formatResEncode('3004', '数据格式不对', []);
                 exit;
             }
             $optionMessage = $mPollOption->getById($option_id);
             if (empty($optionMessage)) {
                 echo Yii::$app->util->formatResEncode('3005', '此产品投票已结束', []);
                 exit;
             }
             if (time() < $optionMessage[0]['poll']['poll_start_date'] || time() > $optionMessage[0]['poll']['poll_expire_date']) {
                 echo Yii::$app->util->formatResEncode('3001', '投票阶段不符', []);
                 exit;
             }
             //投票选项信息
             // $mPollOption = new PollOption();
             $optionids = $mPollOption->getOptionIds($optionMessage[0]['poll_id']);
             foreach ($optionids as $key => $value) {
                 $PollOptionIds[] = $value;
             }
             //获取最大允许投票数
             $mPoll = new Poll();
             $PollMessage = $mPoll->getByPollid($optionMessage[0]['poll_id']);
             //该用户是否已经投票
             $mPollVoter = new PollVoter();
             $isPoll = $mPollVoter->isVote($user['uid'], $optionMessage[0]['poll_id']);
             if ($isPoll) {
                 if (in_array($userMessage['mobile'], $experts)) {
                     if ($optionMessage[0]['poll']['poll_role'] != "role_judge") {
                         echo Yii::$app->util->formatResEncode('3002', '此阶段不允许专家投票', []);
                         exit;
                     }
                     $number = count($isPoll);
                     if (intval($number) < $PollMessage[0]['poll_max_choices']) {
                         //$data['option_id'] = json_decode($data['option_id']);
                         $sum = $PollMessage[0]['poll_max_choices'] - $number;
                         if (is_array($data['option_id']) && count($data['option_id']) <= $sum) {
                             if (!empty($user['uid']) && !empty($optionMessage[0]['poll_id']) && !empty($data['option_id'])) {
                                 // foreach ($data['option_id'] as $key => $value) {
                                 $poll_data = array('user_id' => intval($user['uid']), 'poll_id' => intval($optionMessage[0]['poll_id']), 'poll_type_id' => intval($PollMessage[0]['poll_type_id']), 'option_id' => array_map('intval', $data['option_id']), 'voter_ipaddress' => $_SERVER['SERVER_ADDR'], 'voter_useragent' => $_SERVER['HTTP_USER_AGENT'], 'optionids' => $PollOptionIds);
                                 $result = $mPollVoter->votestore($poll_data);
                                 // }
                                 if (is_array($result)) {
                                     foreach ($result as $key => $value) {
                                         $step = 1;
                                         $mPollOption->addVoteNum($value, $step);
                                     }
                                     echo Yii::$app->util->formatResEncode('0', '投票成功', []);
                                     exit;
                                 } else {
                                     echo Yii::$app->util->formatResEncode('1', '投票失败', []);
                                     exit;
                                 }
                             } else {
                                 echo Yii::$app->util->formatResEncode('4003', '参数不全', []);
                                 exit;
                             }
                         } else {
                             echo Yii::$app->util->formatResEncode('4001', '参数错误', []);
                             exit;
                         }
                     } else {
                         echo Yii::$app->util->formatResEncode('2001', '您已完成投票', []);
                         exit;
                     }
                 } else {
                     // echo Yii::$app->util->formatResEncode('2002', '该用户已完成投票', []);
                     // exit;
                     if ($optionMessage[0]['poll']['poll_role'] != "role_member") {
                         echo Yii::$app->util->formatResEncode('3003', '此阶段只允许专家投票', []);
                         exit;
                     }
                     if (!empty($user['uid']) && !empty($optionMessage[0]['poll_id']) && !empty($option_id)) {
                         $poll_data = array('user_id' => intval($user['uid']), 'poll_id' => intval($optionMessage[0]['poll_id']), 'poll_type_id' => intval($PollMessage[0]['poll_type_id']), 'option_id' => intval($option_id), 'voter_ipaddress' => $_SERVER['SERVER_ADDR'], 'voter_useragent' => $_SERVER['HTTP_USER_AGENT'], 'optionids' => $PollOptionIds);
                         $result = $mPollVoter->votestore($poll_data);
                         if ($result && $result != 0) {
                             $step = 1;
                             $mPollOption->addVoteNum($data['option_id'], $step);
                             //$mPollOption->AddVotes($data['option_id']);
                             echo Yii::$app->util->formatResEncode('0', '投票成功', []);
                             exit;
                         } else {
                             if ($result === 0) {
                                 echo Yii::$app->util->formatResEncode('2', '您已经投过此产品', []);
                                 exit;
                             } else {
                                 echo Yii::$app->util->formatResEncode('1', '投票失败', []);
                                 exit;
                             }
                         }
                     } else {
                         echo Yii::$app->util->formatResEncode('4003', '参数不全', []);
                         exit;
                     }
                 }
             } else {
                 // if (is_array($data['option_id'])) {
                 // if ($optionMessage[0]['poll']['poll_role'] != "role_judge") {
                 //         echo Yii::$app->util->formatResEncode('3002', '投票角色不对', []);
                 //         exit;
                 // }
                 //$data['option_id'] = json_decode($data['option_id']);
                 if (in_array($userMessage['mobile'], $experts)) {
                     if ($optionMessage[0]['poll']['poll_role'] != "role_judge") {
                         echo Yii::$app->util->formatResEncode('3002', '此阶段不允许专家投票', []);
                         exit;
                     }
                     if (count($data['option_id']) < intval($PollMessage[0]['poll_max_choices']) + 1) {
                         if (!empty($user['uid']) && !empty($optionMessage[0]['poll_id']) && !empty($data['option_id'])) {
                             // foreach ($data['option_id'] as $key => $value) {
                             $poll_data = array('user_id' => intval($user['uid']), 'poll_id' => intval($optionMessage[0]['poll_id']), 'poll_type_id' => intval($PollMessage[0]['poll_type_id']), 'option_id' => array_map('intval', $data['option_id']), 'voter_ipaddress' => $_SERVER['SERVER_ADDR'], 'voter_useragent' => $_SERVER['HTTP_USER_AGENT'], 'optionids' => $PollOptionIds);
                             $result = $mPollVoter->votestore($poll_data);
                             // }
                             // var_dump($result);die;
                             if (is_array($result)) {
                                 foreach ($result as $key => $value) {
                                     $step = 1;
                                     $mPollOption->addVoteNum($value, $step);
                                 }
                                 echo Yii::$app->util->formatResEncode('0', '投票成功', []);
                                 exit;
                             } else {
                                 echo Yii::$app->util->formatResEncode('1', '投票失败', []);
                                 exit;
                             }
                         } else {
                             echo Yii::$app->util->formatResEncode('4003', '参数不全', []);
                             exit;
                         }
                     } else {
                         echo Yii::$app->util->formatResEncode('2004', '您投票大于规定数量', []);
                         exit;
                     }
                     // } else {
                     //     echo Yii::$app->util->formatResEncode('2003', '该用户不是专家', []);
                     //     exit;
                     // }
                 } else {
                     if ($optionMessage[0]['poll']['poll_role'] != "role_member") {
                         echo Yii::$app->util->formatResEncode('3003', '此阶段只允许专家投票', []);
                         exit;
                     }
                     if (!empty($user['uid']) && !empty($optionMessage[0]['poll_id']) && !empty($option_id)) {
                         $poll_data = array('user_id' => intval($user['uid']), 'poll_id' => intval($optionMessage[0]['poll_id']), 'poll_type_id' => intval($PollMessage[0]['poll_type_id']), 'option_id' => intval($option_id), 'voter_ipaddress' => $_SERVER['SERVER_ADDR'], 'voter_useragent' => $_SERVER['HTTP_USER_AGENT'], 'optionids' => $PollOptionIds);
                         $result = $mPollVoter->votestore($poll_data);
                         if ($result) {
                             $step = 1;
                             $mPollOption->addVoteNum($option_id, $step);
                             //$mPollOption->AddVotes($data['option_id']);
                             echo Yii::$app->util->formatResEncode('0', '投票成功', []);
                             exit;
                         } else {
                             echo Yii::$app->util->formatResEncode('1', '投票失败', []);
                             exit;
                         }
                     } else {
                         echo Yii::$app->util->formatResEncode('4003', '参数不全', []);
                         exit;
                     }
                 }
             }
         } else {
             echo Yii::$app->util->formatResEncode('1001', '用户未登录', []);
             exit;
         }
     } else {
         echo Yii::$app->util->formatResEncode('1002', '不是Ajax请求', []);
         exit;
     }
 }
Пример #5
0
 /**
  * [账号绑定页]
  * @author song
  */
 public function actionBindin()
 {
     //判断登陆
     if (PublicLibrary::is_login()) {
         $user = PublicLibrary::is_login();
     } else {
         echo "<script>alert('请先登录!'),window.location.href='/user/login';</script>";
         exit;
     }
     $member_model = new Member();
     $member = $member_model->getByUid($user['uid']);
     // $LoginThird_model = new LoginThird();
     // $thirdQQ = $LoginThird_model->getByUid($user['uid'],1);
     // $thirdweixin = $LoginThird_model->getByUid($user['uid'],2);
     // $thirdweibo = $LoginThird_model->getByUid($user['uid'],3);
     //$this->layout = '@app/views/layouts/ucenter.php';  //调用个人中心的布局
     $this->layout_data = 'uc';
     return $this->render('bindin', ['member' => $member]);
 }
Пример #6
0
 public function actionCheckticode()
 {
     $params = Yii::$app->request->post();
     // 联调时需要改成post
     $sid = isset($params['sid']) ? intval($params['sid']) : '';
     $user = PublicLibrary::is_login();
     if (!$user) {
         $output['status'] = 1000;
         $output['res'] = '';
         $output['info'] = 'no login';
         $backurl = Yii::$app->params['idaiyan'] . "/baiying/gamestar?sid=" . $sid;
         $backurl = Publiclibrary::encode_callback($backurl);
         $output['url'] = '/baiying/auth?backurl=' . $backurl;
         $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['url']);
         // var_dump($output);
         echo $output;
         exit;
     }
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     $output = array();
     if ($params) {
         $mobile = intval($params['mobile']);
         $rel_id = isset($params['rel_id']) ? intval($params['rel_id']) : '';
         $truename = isset($params['truename']) ? strip_tags($params['truename']) : '';
         $openid = $_SESSION['user']['openid'];
         // $openid = 'oKeG4jqOTo-wyqSqXAA4hfTFvtZI';
         if (empty($mobile) || empty($openid)) {
             $output['status'] = 1000;
             $output['res'] = '';
             $output['info'] = 'no login';
             $backurl = Yii::$app->params['idaiyan'] . "/baiying/gamestar?sid=" . $sid;
             $backurl = Publiclibrary::encode_callback($backurl);
             $output['url'] = '/baiying/auth?backurl=' . $backurl;
             $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['url']);
             // var_dump($output);
             echo $output;
             exit;
         }
         $mutpl = new UserThirdPartyLogin();
         $thirdone = $mutpl->getByOpenId($openid);
         $member_model = new Member();
         $userone = $member_model->getByUserName($mobile);
         //通过手机号查询用户信息
         if ($thirdone) {
             $userone = $member_model->getByUid($thirdone['user_id']);
         }
         if (!empty($userone)) {
             //ru guo
             $output['status'] = 1001;
             $output['res'] = $userone;
             if ($thirdone) {
                 $output['info'] = '该微信号已被绑定!';
             } else {
                 $output['info'] = '是注册,请输入密码或者验证码';
             }
             $output['url'] = '';
         } else {
             $output['status'] = 1002;
             $output['res'] = '';
             $output['info'] = '验证通过,登录成功!';
             $output['url'] = '';
             //注册
             $usercontent = array("mobile" => $mobile, "truename" => $truename, "address" => '', "comefrom" => '一呼百应');
             $member = new Member();
             $res = $member->registration($usercontent);
             if ($res['userid']) {
                 // $_SESSION['user']['nickname'] = 'hongye';
                 // $_SESSION['user']['headimgurl'] = 'http://wx.qlogo.cn/mmopen/Q3auHgzwzM6LiaSic2iaLbgGGQMadoac3M6g3vfEd7CLQVPyWficA679jxbI2OZwVxxExA8ibKopLO4EHKFvnx6yy8IFP2PmiaL8laJHAtw3wiaWNU/0';
                 //绑定第三方信息
                 $thirdone = $mutpl->getByOpenId($openid);
                 if (!$thirdone) {
                     $wxarr['nickname'] = $_SESSION['user']['nickname'];
                     $wxarr['headimgurl'] = $_SESSION['user']['headimgurl'];
                     $thirdcontent['open_id'] = $openid;
                     $thirdcontent['user_id'] = $res['userid'];
                     $thirdcontent['type'] = 'weixin';
                     $thirdcontent['profile_info'] = json_encode($wxarr);
                     $thirdcontent['status'] = 1;
                     $mutpl->store($thirdcontent);
                 }
                 //设置登录状态
                 $_SESSION['user']['uid'] = $res['userid'];
                 $_SESSION['user']['mobile'] = $mobile;
                 $_SESSION['user']['truename'] = $truename;
                 $_SESSION['user']['admin'] = 0;
                 //普通用户登录
                 // $sms_model = new Sms();
                 // $sms_model->mobile = $mobile;
                 // $sms_model->content = '您的密码是'.$res['password'].',您可以使用手机号:'.$mobile.'登录i代言官网,如非本人操作请及时联系客服人员。【i代言】';
                 // $sms_model->from = 'findpassword';  //调用来源
                 // $return = $sms_model->SoapSend();
                 $sms = Yii::$app->dcSMS;
                 $userID = $res['userid'];
                 $data = ['uid' => $userID, 'mobile' => $mobile, 'business' => 'H_AUTO_REG', 'tplno' => 1, 'password' => $res['password'], 'mobile' => $mobile];
                 $resp = $sms->send($data);
             }
         }
     } else {
         $output['status'] = 1003;
         $output['res'] = '';
         $output['info'] = '签名验证出错!';
         $output['url'] = '';
     }
     $output = PublicLibrary::format_res_encode($output['status'], $output['info'], $output['url']);
     // var_dump($output);
     echo $output;
 }
Пример #7
0
 /**
  * [关注]
  * @param  [int] $product_id [产品id]
  * @param  [int] $rel_id 活动产品ID  如果存在则是 更新活动产品统计
  * @param  [int] $type [1,2]
  * 1 关注     2 取消关注
  *
  * @return [json_encode]     [0,1]
  * 0 执行成功 1001 参数错误 1002 系统繁忙
  * 关注接口:http://idaiyan_new.cn/frontend/web/index.php?r=product/user_id=24&product=4291&type=1
  * 取消接口:http://idaiyan_new.cn/frontend/web/index.php?r=product/user_id=24&product=4302&type=2
  */
 public function actionFollow()
 {
     //判断登陆
     $user = PublicLibrary::is_login();
     if ($user && PublicLibrary::is_ajax()) {
         $uid = $user['uid'];
     } else {
         echo PublicLibrary::format_res_encode('1002', 'login or not ajax error !');
         exit;
     }
     // $uid = 25;
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     $form = Yii::$app->request->post();
     $id = isset($form['id']) ? intval($form['id']) : '';
     $product_id = isset($form['product_id']) ? intval($form['product_id']) : $id;
     $type = isset($form['type']) ? intval($form['type']) : '';
     $rel_id = isset($form['rel_id']) ? intval($form['rel_id']) : '';
     //活动产品id
     //用活动产品id 获取活动ID 产品ID
     if ($rel_id) {
         $pactivity_model = new ActivityProduct();
         $pactivity = $pactivity_model->pk($rel_id);
         $activity_id = $pactivity->acti_id ? $pactivity->acti_id : 0;
         $product_id = $pactivity->product_id ? $pactivity->product_id : 0;
     }
     //用户不能关注自己产品
     if (!isset($product_id)) {
         $mActivityProduct = new ActivityProduct();
         $result = $mActivityProduct->pk($rel_id);
         $product_id = $result->product_id;
     }
     $productBase = new IProductBase();
     if ($productBase->isMyProduct($uid, $product_id)) {
         echo PublicLibrary::format_res_encode('1004', '自己不能关注自己的产品');
         exit;
     }
     $pbase = IProductBase::findOne($product_id);
     $pbaseuid = $pbase['uid'];
     // $rel_id = 24576;
     // $type = 2;
     // //用活动产品id 获取活动ID 产品ID
     // if ($rel_id) {
     //     $pactivity_model = new ActivityProduct();
     //     $pactivity = $pactivity_model->pk($rel_id);
     //     $activity_id = $pactivity->acti_id ? $pactivity->acti_id : 0;
     //     $product_id = $pactivity->product_id ? $pactivity->product_id : 0;
     // }
     if (empty($product_id)) {
         echo PublicLibrary::format_res_encode('1003', 'param error !');
         exit;
     }
     $model_Base = new ProductFollow();
     $Mpfollow = new ProductFollow();
     //对follow_num增减
     $follow_num = new IProductStat();
     $Mapstar = new ActivityProductStat();
     $Mmemberstat = new MemberStat();
     if ($type == ProductFollow::API_FOLLOW) {
         if ($rel_id) {
             //设置关注的产品id集 session
             $follow_activ_product = $session['follow_activ_product'] ? $session['follow_activ_product'] : array();
             array_push($follow_activ_product, $rel_id);
             $session['follow_activ_product'] = $follow_activ_product;
             $activityfollow = $Mpfollow->activityfollow($rel_id, $product_id, $activity_id, $uid);
             if ($activityfollow == ProductFollow::FOLLOW_OP_SUCC) {
                 $Mapstar->incr($rel_id, 'follow_num');
             }
         }
         // //设置关注的产品id集 session
         // $follow_productids = $session['follow_product'];
         // array_push($follow_productids, $product_id);
         // $session['follow_product'] = $follow_productids;
         $follow = $model_Base->follow($product_id, $uid);
         if ($follow === ProductFollow::FOLLOW_OP_SUCC || $follow === true) {
             //设置关注的产品id集 session
             $follow_productids = $session['follow_product'] ? $session['follow_product'] : array('');
             array_push($follow_productids, $product_id);
             $session['follow_product'] = $follow_productids;
             $follow_num = $follow_num->modify('follow_num', $product_id);
             //增加 产品统计表 该产品关注数
             $Mmemberstat->incr($pbaseuid, 'pfollow_allnum');
             //增加 用户统计表 产品关注总数字段
         } else {
             if ($follow === ProductFollow::FOLLOW_OP_EXISTS) {
                 // 获取该产品关注数
                 $follow_num = count($model_Base->getFollowUsers($product_id));
             }
         }
     } else {
         if ($rel_id) {
             //设置关注的产品id集 session
             $follow_activ_product = $session['follow_activ_product'] ? $session['follow_activ_product'] : array();
             $key = array_search($rel_id, $follow_activ_product);
             unset($follow_activ_product[$key]);
             $session['follow_activ_product'] = $follow_activ_product;
             $follow = $activityunfollow = $Mpfollow->activityunfollow($rel_id, $product_id, $activity_id, $uid);
             //var_dump($activityunfollow);die;
             if ($activityunfollow === true) {
                 $Mapstar->decr($rel_id, 'follow_num');
             }
             $follow_num = count($model_Base->getFollowUsers($product_id));
         } else {
             // //设置关注的产品id集 session
             // $follow_productids = $session['follow_product'];
             // $key = array_search($product_id, $follow_productids);
             // unset($follow_productids[$key]);
             // $session['follow_product'] = $follow_productids;
             $follow = $model_Base->unfollow($product_id, $uid);
             if ($follow === ProductFollow::FOLLOW_OP_SUCC || $follow === true) {
                 //设置关注的产品id集 session
                 $follow_productids = $session['follow_product'] ? $session['follow_product'] : array('');
                 $key = array_search($product_id, $follow_productids);
                 unset($follow_productids[$key]);
                 $session['follow_product'] = $follow_productids;
                 $follow_num = $follow_num->modify('follow_num', $product_id, 1, FALSE);
                 //减少该产品关注数
                 $Mmemberstat->decr($pbaseuid, 'pfollow_allnum');
                 //减少 用户统计表 产品关注总数字段
             } else {
                 if ($follow === ProductFollow::FOLLOW_OP_CANCELLED) {
                     //设置关注的产品id集 session
                     $follow_productids = $session['follow_product'] ? $session['follow_product'] : array('');
                     $key = array_search($product_id, $follow_productids);
                     unset($follow_productids[$key]);
                     $session['follow_product'] = $follow_productids;
                     // 获取该产品关注数
                     $follow_num = count($model_Base->getFollowUsers($product_id));
                 }
             }
         }
     }
     if ($follow) {
         //用户信息
         $member = new Member();
         $user = $member->getByUid($pbaseuid);
         $pfollow_allnum = $user['memberstar']['pfollow_allnum'];
         //被关注商品数
         $pfollow_num = $user['memberstar']['follow_num'];
         $renqi = isset($user['memberstar']) && is_array($user['memberstar']) ? array_sum($user['memberstar']) : 0;
         echo PublicLibrary::format_res_encode('0', 'success', array('follow_num' => $follow_num, 'renqi' => $renqi, 'pfollow_allnum' => $pfollow_allnum));
         //echo PublicLibrary::format_res_encode('0', 'success', array('follow_num'=> json_encode($session['follow_product'])));
     } else {
         echo PublicLibrary::format_res_encode('1001', 'params error');
     }
 }
Пример #8
0
 /**
  * 获取评论数据
  *
  * @return void
  * @author niancode
  **/
 public function getCommentsByNewsId($news_id, $count = false, $offset = 0, $limit = null)
 {
     $params = [':attr_id' => 7, ':news_id' => $news_id];
     // Conditions
     $conditions = ['limit' => '', 'field' => ''];
     $conditions['field'] = $count ? 'count(*)' : 'cmt.cmt_reply_num AS reply_count,cmt.cmt_like_num,user.avatar, user.uid, cmt.cmt_id, cmt.cmt_name, FROM_UNIXTIME(cmt.created_at) AS created_at, IF (cmt.owner_id is null or cmt.owner_id = "", "匿名", user.nickname) as nickname';
     if (!is_null($limit)) {
         $params[':limit'] = $limit;
         $params[':offset'] = $offset;
         $conditions['limit'] = 'LIMIT :offset, :limit';
     }
     // SQL
     $command = $this->db->createCommand("SELECT {$conditions['field']} \n            FROM {{%news}} AS news \n            LEFT JOIN {{%news_attr_value}} AS attr_value USING(news_id)\n            LEFT JOIN {{%comment}} AS cmt ON cmt.cmt_id = attr_value.attr_value_text \n            LEFT JOIN {{%member}} AS user ON user.uid = cmt.owner_id\n            WHERE news_id = :news_id And attr_value.attr_id = :attr_id AND cmt.cmt_active = 0 ORDER BY cmt.created_at DESC {$conditions['limit']}")->bindValues($params);
     $result = $count ? $command->queryScalar() : $command->queryAll();
     // print_r($result);exit;
     if (is_array($result) && count($result) > 0) {
         foreach ($result as $key => $value) {
             $field = 'cmt.*,rel.cmt_id AS rel_cmt_id, rel.user_id, member.nickname, member.mobile, member.email, member.avatar';
             $limit = 'LIMIT 0, 1';
             $params = [':parent_id' => $value['cmt_id']];
             $command = $this->db->createCommand("SELECT {$field} FROM {{%comment}} AS cmt \n                    LEFT JOIN {{%rel_comment_with_user}} AS rel USING(cmt_id)\n                    LEFT JOIN {{%member}} AS member ON member.uid = cmt.owner_id\n                    WHERE parent_id = :parent_id  AND cmt.cmt_active = 0 ORDER BY cmt.created_at DESC {$limit}")->bindValues($params);
             $re = $command->queryOne();
             if (is_array($re) && count($re) > 0) {
                 $name = '';
                 if (!empty($re['user_id'])) {
                     //名字处理
                     $reply = empty($re['nickname']) ? $re['mobile'] : $re['nickname'];
                     $reply = empty($reply) ? $re['email'] : $reply;
                     $reply = Yii::$app->util->cmtName($reply);
                     //名字格式处理
                     $name = '回复' . Html::a($reply, Url::to(['home-page/lists', 'uid' => $re['user_id']], true)) . '&nbsp;';
                 }
                 $mMember = new Member();
                 $member = $mMember->getByUid($re['owner_id']);
                 $tmp = empty($member['nickname']) ? $member['mobile'] : $member['nickname'];
                 $tmp = empty($tmp) ? $member['email'] : $tmp;
                 $re['owner_name'] = Yii::$app->util->cmtName($tmp);
                 $re['created_at'] = date('Y-m-d H:i:s', $re['created_at']);
                 $re['cmt_name'] = $name . $re['cmt_name'];
                 $result[$key]['reply'] = $re;
             }
         }
     }
     // print_r($result);exit;
     return $result;
 }
Пример #9
0
 /**
  * 评论回复写入接口
  */
 public function actionReply()
 {
     $params = Yii::$app->request->post();
     //判断登录
     $user = Yii::$app->util->isLogin();
     if (!$user) {
         echo Yii::$app->util->formatResEncode('1001', '没有登录,请登录');
         return;
     }
     //参数判断
     if (!isset($params['parent_id']) || !is_numeric($params['parent_id']) || !isset($params['cmt_name']) || empty($params['cmt_name'])) {
         echo Yii::$app->util->formatResEncode('1002', '参数异常');
         return;
     }
     $mComment = new Comment();
     //回复数加1
     $mComment->addNum(['cmt_id' => $params['parent_id']]);
     $params['owner_id'] = $user['uid'];
     $params['cmt_type_id'] = 1;
     //获取头像
     $mMember = new Member();
     $member = $mMember->getByUid($user['uid']);
     $name = '';
     if (isset($params['user_id'])) {
         $memberx = $mMember->getByUid($params['user_id']);
         //名字获取
         $reply = empty($memberx['nickname']) ? $memberx['mobile'] : $memberx['nickname'];
         $reply = empty($reply) ? $memberx['email'] : $reply;
         $reply = Yii::$app->util->cmtName($reply);
         //名字格式处理
         $name = '回复' . Html::a($reply, Url::to(['home-page/lists', 'uid' => $memberx['uid']], true)) . '&nbsp;';
         // $name = '回复' . Html::a($reply, ['home-page/lists', 'uid' => $memberx['uid']]) . '&nbsp;';
     }
     $nickname = empty($user['nickname']) ? $user['mobile'] : $user['nickname'];
     $nickname = empty($nickname) ? $user['email'] : $nickname;
     $nickname = Yii::$app->util->cmtName($nickname);
     if ($mComment->saveStore($params)) {
         $data = ['avatar' => $member['avatar'], 'parent_id' => $params['parent_id'], 'uid' => $user['uid'], 'nickname' => $nickname, 'cmt_name' => $name . $params['cmt_name'], 'created_at' => date("Y-m-d H:i:s", time())];
         echo Yii::$app->util->formatResEncode('0', '成功', $data);
         return;
     } else {
         echo Yii::$app->util->formatResEncode('1003', '保存错误');
         return;
     }
 }