Exemplo n.º 1
0
 public function actionCity()
 {
     $model = new District();
     var_dump($model->getByCity(306));
 }
Exemplo n.º 2
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]);
 }
Exemplo n.º 3
0
 /**
  * 产品修改(显示修改页面)
  * @param  [int] $id [产品id]
  * @return  [array] $product [产品相关信息]
  * @return  [int] $type [所有产品类型]
  * @return  [string] $url [地址]
  * @return  [string] $pcity [该产品省市信息]
  * @return  [string] $provinces [所有省信息]
  * @return  [string] $citys [该省城市信息]
  * @return  [string] $pcity [省市信息]
  * @return  [string] $formhash [哈希值验证]
  */
 public function actionEdit($id)
 {
     $id = intval($id);
     $user = PublicLibrary::is_login();
     // echo '<pre>';
     // print_r($user);
     //判断是否登陆
     if (!$user) {
         $this->redirect(['user/login', 'act' => base64_encode("home-page/lists")]);
     }
     //判断产品是否是该用户的
     $mIProductBase = new IProductBase();
     if (!$mIProductBase->isMyProduct($user['uid'], $id)) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         exit;
     }
     $product = $mIProductBase->getAllTypesByIds([$id]);
     $url = Yii::$app->request->baseurl;
     if (isset($product['status']) && ($product['status'] == IProductBase::STATUS_INVALID || $product['status'] == IProductBase::STATUS_FIRST || $product['status'] == IProductBase::STATUS_VERIFEND || $product['status'] == IProductBase::STATUS_VERIFING)) {
         //生成hash
         $formHash = PublicLibrary::makeFormhash();
         //查询类别
         $type = IProductType::find()->orderBy('order_num asc')->asArray()->all();
         //显示省份
         $district_model = new District();
         $provinces = $district_model->getByLevel();
         //获取产品地址
         $pcity = $district_model->getByCity($product['city']);
         $this->layout_data = 'uc';
         //对人群进行处理
         // $user_oriented_age = $product['user_oriented_age'] + 10000;
         // $user_oriented_age = strval($user_oriented_age);
         // $user_oriented_age = substr($user_oriented_age, 1);
         // $product['user_oriented_age'] = $user_oriented_age;
         $product['album'] = $product['album'];
         $product['user_oriented_age'] = str_pad($product['user_oriented_age'], 4, '0', STR_PAD_LEFT);
         return $this->render('productrevise', ['product' => $product, 'pcity' => $pcity, 'type' => $type, 'id' => $id, 'url' => $url, 'provinces' => $provinces, 'formhash' => $formHash]);
     } else {
         $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
     }
 }