Пример #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
 /**
  * 推荐产品管理页面
  */
 public function actionRecommend()
 {
     //菜单权限检测
     Yii::$app->util->adminAuth() ? '' : $this->redirect('/admin/login');
     $params = Yii::$app->request->get();
     $params = array_map('trim', $params);
     $params = array_map('intval', $params);
     $mIProductBase = new IProductBase();
     $options = ['page' => isset($params['page']) ? $params['page'] : 1, 'time_status' => isset($params['time_status']) ? $params['time_status'] : 0, 'type' => isset($params['type']) ? $params['type'] : 0, 'order_by' => isset($params['order_by']) ? $params['order_by'] : 0];
     $products = $mIProductBase->search($options, false);
     $pages = new Pagination(['totalCount' => $products->count(), 'pageSize' => IProductBase::PAGE_SIZE]);
     $products = $products->asArray()->all();
     //推荐新品数据
     $mPageCustomBlock = new PageCustomBlock();
     $data = $mPageCustomBlock->block(['customId' => 'product_list_products', 'page' => 1]);
     $data = $data->asArray()->all();
     // $ids = ArrayHelper::getColumn($data, 'id');
     // print_r($ids);
     // print_r($data);exit;
     // $data = ArrayHelper::multisort($data, 'id', $ids);
     // print_r($data);exit;
     //产品分类map
     $mIProductType = new IProductType();
     $typeMap = $mIProductType->getTypeMap();
     return $this->render('recommend', ['pages' => $pages, 'products' => $products, 'options' => $options, 'data' => $data, 'type' => $typeMap]);
 }