Exemplo n.º 1
0
 /**
  * 产品详情页
  *
  * @param array $_GET['id'] 对应产品id号
  */
 public function actionView()
 {
     $params = Yii::$app->request->get();
     $id = isset($params['id']) ? intval($params['id']) : 0;
     if ($id) {
         $mIProductBase = new IProductBase();
         $detail = $mIProductBase->getAllTypesByIds($id);
         if (isset($detail['city'])) {
             //获取产品省市
             $mDistrict = new District();
             $dist = $mDistrict->getBycity($detail['city']);
         }
         return $this->render('view', ['detail' => $detail, 'dist' => $dist ? $dist : '']);
     }
 }
Exemplo n.º 2
0
 public function getDistricts()
 {
     return @$this->hasOne(District::className(), ['DISTRICT_ID' => 'province']);
 }
Exemplo n.º 3
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.º 4
0
 /**
  * Action Index
  */
 public function actionIndex()
 {
     //$this->layout = false;
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     $session->remove('backurl');
     $session->remove('form');
     $mPageBlock = new PageCustomBlock();
     $slideOption['customId'] = PageCustomBlock::MAIN_PAGE_SLIDE;
     $speechesOption['customId'] = PageCustomBlock::MAIN_PAGE_SPEECHES;
     $newsOption['customId'] = PageCustomBlock::MAIN_PAGE_NEWS;
     $productsOption['customId'] = PageCustomBlock::MAIN_PAGE_PRODUCTS;
     // $slide = $mPageBlock->block(PageCustomBlock::MAIN_PAGE_SLIDE);
     // $speeches = $mPageBlock->block(PageCustomBlock::MAIN_PAGE_SPEECHES);
     // $products = $mPageBlock->block(PageCustomBlock::MAIN_PAGE_PRODUCTS);
     $slide = $mPageBlock->block($slideOption);
     $speeches = $mPageBlock->block($speechesOption);
     $news = $mPageBlock->block($newsOption);
     $products = $mPageBlock->block($productsOption);
     // print_r($news);exit;
     //获取产品类型
     $product_type = new IProductType();
     $product_type = $product_type->product_type_list();
     //获取活动
     $aproduct = new ActivityBase();
     $aproduct = $aproduct->getByStatus();
     // //zhanglu
     // print_r($aproduct);exit;
     $data = [];
     //zhanglu
     //为了获取产品想过活动信息
     $mActivityProduct = new ActivityProduct();
     foreach ($aproduct as $key => $value0) {
         $data[$value0['id']] = $value0;
     }
     $reg['slide'] = $slide;
     $reg['speeches'] = $speeches;
     $reg['products'] = $products;
     $reg['product_type'] = $product_type;
     // echo "<pre>";
     // print_r($reg['products']);
     // echo "<pre>";
     // print_r($reg['aproduct']);
     //获取活动详细信息
     // print_r($data);exit;
     foreach ($reg['products'] as $key => $value) {
         // print_r($value);exit;
         //zhanglu
         $ap = $mActivityProduct->getActivitiseById($value['id']);
         // print_r($ap);exit;
         // print_r($value);exit;
         foreach ($value['aproduct'] as $key1 => $value1) {
             foreach ($data as $key2 => $value2) {
                 if ($value1['acti_id'] == $value2['id']) {
                     $reg['products'][$key]['aproduct'][$key1]['activity'] = $data[$key2];
                     //zhanglu
                     $reg['products'][$key]['aproduct'][$key1]['apstat'] = $ap[$key1]['apstat'];
                     // $reg['products'][$key]['activity'][$key1]['order']= $key1;
                 }
                 //zhanglu
                 // $reg['products'][$key]['activity'][$key1]['apstat']= $ap[$key1]['apstat'];
             }
         }
         // print_r($reg);exit;
         //获取用户所在省市
         // var_dump($value['user'][province]);
         // var_dump($value['user'][city]);
         if ($value['user']['province'] && $value['user']['city']) {
             $district = new District();
             $province = $district->getById(intval($value['user']['province']));
             $reg['products'][$key]['user']['province'] = $province['name'];
             $city = $district->getById(intval($value['user']['city']));
             $reg['products'][$key]['user']['city'] = $city['name'];
         }
     }
     // echo "<pre>";
     // // print_r($reg);exit;
     //  var_dump($reg['products']);die;
     //return $this->render('index',['slide' => $slide,'speeches' => $speeches,'products' => $products,'product_type' => $product_type]);
     $reg['news'] = $news;
     return $this->render('index', $reg);
 }
Exemplo n.º 5
0
 /**
  * 定义与District的关联关系获取省
  */
 public function getMycity()
 {
     return $this->hasMany(District::className(), ['id' => 'city']);
 }
Exemplo n.º 6
0
 public function actionCity()
 {
     $model = new District();
     var_dump($model->getByCity(306));
 }
Exemplo n.º 7
0
 /**
  * 定义与 Province 的关联关系
  */
 public function getProvince()
 {
     return $this->hasOne(District::className(), ['id' => 'upid']);
 }
Exemplo n.º 8
0
 /**
  * 收货地址管理
  *
  *
  *
  * */
 public function actionHarvest()
 {
     $user = PublicLibrary::is_login();
     if (isset($user['uid'])) {
         $uid = $user['uid'];
     } else {
         return $this->redirect(['product/index']);
         exit;
     }
     //收货地址
     $mharaddr = new HarvestAddress();
     $addresslist = $mharaddr->getByUid($uid);
     $mDistrict = new District();
     $prolist = $mDistrict->getByLevel();
     //         echo 'Mmm';
     //         exit;
     $this->layout_data = 'uc';
     return $this->render('harvest', ['addresslist' => $addresslist, 'prolist' => $prolist]);
 }
Exemplo n.º 9
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']]);
     }
 }
Exemplo n.º 10
0
 /**
  * 选择地址确认付款页面
  * @param
  *
  * @return
  * */
 public function actionHarvest()
 {
     $user = PublicLibrary::is_login();
     if (isset($user['uid'])) {
         $uid = $user['uid'];
     } else {
         return $this->redirect(['product/index']);
         exit;
     }
     if (Yii::$app->request->isPost) {
         $date = Yii::$app->request->post();
         $rel_id = intval($date['rel_id']);
         $num = intval($date['num']);
         if (empty($rel_id) || empty($num)) {
             return $this->redirect(['product/index']);
             exit;
         }
         $session = Yii::$app->session;
         $session->isActive ? '' : $session->open();
         $product = $session->get('product');
         //查询 活动产品id 是否是 上一步 存在session中,如果存在 把键值中的 活动价格取出
         $actprice = $session->get('activityprice');
         if (isset($actprice[$rel_id])) {
             $product['activity_price'] = $actprice[$rel_id];
         } else {
             return $this->redirect(['product/index']);
             exit;
         }
         $product['num'] = $num;
         $product['rel_id'] = $rel_id;
         $mActivityProduct = new ActivityProduct();
         $productActivity = $mActivityProduct->getByIdAndStatus($rel_id);
         $product['product_id'] = $productActivity['product_id'];
         $number = $productActivity['stock'];
         //Todo....
         $couldPay = false;
         if ($productActivity['acti_id'] == 8) {
             $mBaiyingShare = new BaiyingShare();
             $result = $mBaiyingShare->getCouldPay($rel_id, $uid, 8);
             if ($result && $number > 0) {
                 $couldPay = 1;
             }
         } else {
             if ($number >= $num) {
                 $couldPay = 1;
             }
         }
         //库存不足
         if ($couldPay != 1) {
             return $this->redirect(['support/choose-activity', 'pid' => $productActivity['product_id']]);
         }
         //收货地址
         $mharaddr = new HarvestAddress();
         $addresslist = $mharaddr->getByUid($uid);
         $mDistrict = new District();
         $prolist = $mDistrict->getByLevel();
         $mVolume = new Volume();
         $voluelist = $mVolume->getByUid($uid, '', Volume::COUPONSTATUS_CANUSE);
         $code = mt_rand(0, 1000000);
         $_SESSION['fsess'] = $code;
         return $this->render('harvest', ['addresslist' => $addresslist, 'prolist' => $prolist, 'voluelist' => $voluelist, 'product' => $product, 'code' => $code]);
     } else {
         return $this->redirect(['product/index']);
     }
 }