Exemplo n.º 1
0
 /**
  * 设置活动开始结束时间接口
  *  @param int  $rel_id  活动产品id
  *  @param str  $start_time 开始时间
  *
  * @return json
  * */
 public function actionSetdate()
 {
     $form = Yii::$app->request->post();
     $rel_id = isset($form['rel_id']) ? intval($form['rel_id']) : '';
     $uid = isset($form['uid']) ? intval($form['uid']) : '';
     $start_time = isset($form['start_time']) ? $form['start_time'] : '';
     if (empty($rel_id) || empty($start_time) || empty($uid)) {
         echo PublicLibrary::format_res_encode('1001', 'param error!');
         exit;
     }
     $mactpro = new ActivityProduct();
     if ($mactpro->searchStartime($start_time)) {
         echo PublicLibrary::format_res_encode('1002', 'start_time error!');
     } else {
         $activitymoedel = new ActivityBase();
         $activity = $activitymoedel->pk(7);
         $component = new BaseAttribute();
         $result = $component->save($rel_id, $uid, 13, $start_time, $activity['config']);
         if ($result) {
             echo PublicLibrary::format_res_encode('0', 'success');
         } else {
             echo PublicLibrary::format_res_encode('1003', 'save error');
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @author shimeixia <*****@*****.**>
  * @param $pid 产品id
  * @param $aid 活动id
  *
  * @return
  */
 public function actionApplybaiyingDiy()
 {
     $user = PublicLibrary::is_login() ? PublicLibrary::is_login() : $this->redirect(['user/login']);
     $parr = Yii::$app->request->get();
     $pid = isset($parr['pid']) ? intval($parr['pid']) : '';
     $aid = intval(ActivityBase::APPLY_BAIYING);
     if (empty($pid) || empty($aid)) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到完善信息
     }
     //判断是否存在该活动
     $mActiBase = new ActivityBase();
     $activity = $mActiBase->pk($aid);
     if (!$activity) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //查询是不是该用户发布的产品
     $model = new IProductBase();
     $res = $model->isMyProduct($user['uid'], $pid);
     if (!$res) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //$session->set('acti_config', $activity['config']);
     //查询该商品有没有参加过该活动
     $mactivitypdt = new ActivityProduct();
     $one = $mactivitypdt->isinActivity($user['uid'], $aid, $pid);
     //$one = $mactivitypdt ->applyWay($user['uid'],$aid,$pid,0);
     // echo '<pre>';
     // var_dump($one);die;
     //活动属性map
     $mArag = new ActivityRelAttrGroup();
     $attrMap = $mArag->getAttrMapping($aid);
     if (!$one) {
         //入库
         $apdata = ['product_id' => $pid, 'acti_id' => $aid, 'user_id' => $user['uid'], 'status' => ActivityProduct::STATUS_SAVE, 'apply_way' => 0];
         $rel_id = $mactivitypdt->store($apdata);
         //插入到活动产品统计表
         $apstart = new ActivityProductStat();
         $data = ['rel_id' => $rel_id, 'acti_id' => $aid, 'product_id' => $pid];
         $apstart->store($data);
     } else {
         // //判断是否是官方申请
         // $model = $mactivitypdt->pk($one['id']);
         // $model->apply_way == 1 ? '' : $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         $rel_id = $one['id'];
         if ($one['apply_way'] == 1) {
             $apdata = ['id' => $rel_id, 'apply_way' => 0];
             $mactivitypdt->store($apdata);
         }
         if ($one['status'] == ActivityProduct::STATUS_VERIFYING) {
             //审核中
             return $this->redirect(['home-page/lists', 'uid' => $_SESSION['user']['uid']]);
             //跳转到完善信息
         } else {
             $ActivityProductAttrVal = new ActivityProductAttrVal();
             $attrval = $ActivityProductAttrVal->getRealAttrVals($rel_id, $aid);
             $attrval = array_merge($attrMap, $attrval);
             // echo '<pre>';
             // print_r($attrval);
             if (isset($attrval['album']['val']) && is_array($attrval['album']['val'])) {
                 foreach ($attrval['album']['val'] as $key => $value) {
                     if ($value['type'] == ProductImage::TYPE_CATIONFIRST) {
                         $fourpimag[] = $value;
                     }
                     if ($value['type'] == ProductImage::TYPE_CATIONINDE) {
                         $fivepimag[] = $value;
                     }
                 }
             }
         }
     }
     //查询左侧菜单
     $ActivityAttrGroup = new ActivityAttrGroup();
     $menu = $ActivityAttrGroup->getCompleteStatus($rel_id);
     //echo '<pre>';
     //print_r($attrval);
     // exit;
     $this->layout_data = 'uc';
     return $this->render('applybaiyingdiy', ['price' => $res[0]['price'], 'attrs' => isset($attrval) ? $attrval : '', 'pid' => $pid, 'rel_id' => $rel_id, 'menu' => $menu, 'attrMap' => $attrMap]);
 }
Exemplo n.º 3
0
 /**
  * 活动产品关联搜索
  * @param  array  $options 搜索条件
  * [
  *     'page' => '页码',
  *     'product_name' => '产品名',
  *     'user_name' => '发布人姓名',
  *     'nickname' => '发布人昵称',
  *     'mobile' => '电话',
  *     'status' => '活动状态',
  *     'activity' => '活动',
  * ]
  * @return [type]          [description]
  */
 public function search($options = [])
 {
     $df = ['page' => 1, 'product_name' => '', 'user_name' => '', 'nickname' => '', 'mobile' => '', 'status' => 0, 'activity' => 0];
     $options = array_merge($df, $options);
     $statusFields = [self::STATUS_SAVE, self::STATUS_VERIFYING, self::STATUS_VERIFY_THROUGH, self::STATUS_VERIFY_NOTTHROUGH];
     $activitiesFields = ['7' => '365', '8' => '一呼百应', '9' => '中国好产品'];
     $activitiesFields = array_keys($activitiesFields);
     $options['status'] = in_array($options['status'], $statusFields) ? $options['status'] : 0;
     $options['activity'] = in_array($options['activity'], $activitiesFields) ? $options['activity'] : 0;
     $choose = [self::tableName() . '.status ' => $options['status'], self::tableName() . '.acti_id ' => $options['activity']];
     $choose = array_filter($choose);
     $offset = ($options['page'] - 1) * self::ACT_PAGESIZE;
     $data = self::find()->joinWith(['member' => function ($query) {
         $query->select([Member::tableName() . '.uid', Member::tableName() . '.truename', Member::tableName() . '.nickname', Member::tableName() . '.mobile', Member::tableName() . '.email']);
     }, 'activity' => function ($query) {
         $query->select([ActivityBase::tableName() . '.id', ActivityBase::tableName() . '.subject', ActivityBase::tableName() . '.summary']);
     }, 'product' => function ($query) {
         $query->select([IProductBase::tableName() . '.id', IProductBase::tableName() . '.name']);
     }])->where(self::tableName() . '.status != :del', [':del' => self::STATUS_INVALID])->andFilterWhere(['like', IProductBase::tableName() . '.name', $options['product_name']])->andFilterWhere(['like', Member::tableName() . '.truename', $options['user_name']])->andFilterWhere(['like', Member::tableName() . '.nickname', $options['nickname']])->andFilterWhere(['like', Member::tableName() . '.mobile', $options['mobile']])->andFilterWhere($choose)->offset($offset)->limit(self::ACT_PAGESIZE)->orderBy([self::tableName() . '.id' => SORT_DESC]);
     return $data;
 }
Exemplo n.º 4
0
 /**
  *      * 定义与ActivityBase的关联关系
  *           */
 public function getActivity()
 {
     return $this->hasOne(ActivityBase::className(), ['id' => 'acti_id']);
 }
Exemplo n.º 5
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.º 6
0
 /**
  * @author shimeixia <*****@*****.**>
  * @param $pid 产品id
  *
  * @return
  */
 public function actionGoodProduct()
 {
     $user = yii::$app->util->isLogin() ? yii::$app->util->isLogin() : $this->redirect(['user/login']);
     $parr = Yii::$app->request->get();
     $pid = isset($parr['pid']) ? intval($parr['pid']) : '';
     $aid = ActivityBase::GOOD_PRODUCT;
     if (empty($pid) || empty($aid)) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到完善信息
     }
     //判断是否存在该活动
     $mActiBase = new ActivityBase();
     $activity = $mActiBase->pk($aid);
     if (!$activity) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //查询是不是该用户发布的产品
     $model = new IProductBase();
     $res = $model->isMyProduct($user['uid'], $pid);
     if (!$res) {
         return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
         //跳转到用户主页
     }
     //查询该商品有没有参加过该活动
     $mactivitypdt = new ActivityProduct();
     $one = $mactivitypdt->isinActivity($user['uid'], $aid, $pid);
     //属性Map
     $mArag = new ActivityRelAttrGroup();
     $attrMap = $mArag->getAttrMapping($aid);
     if (!$one) {
         //入库
         $apdata = ['product_id' => $pid, 'acti_id' => $aid, 'user_id' => $user['uid'], 'status' => ActivityProduct::STATUS_SAVE, 'apply_way' => 1];
         $rel_id = $mactivitypdt->store($apdata);
         //插入到活动产品统计表
         $apstart = new ActivityProductStat();
         $data = ['rel_id' => $rel_id, 'acti_id' => $aid, 'product_id' => $pid];
         $apstart->store($data);
         //赛区数据入库
         $mbaseattr = new BaseAttribute();
         $value = $mbaseattr->save($rel_id, $user['uid'], 15, ActivityBase::GOODPRODUCT_CITY, false, 1);
         $value = $mbaseattr->save($rel_id, $user['uid'], 18, time(), false, 1);
     } else {
         $rel_id = $one['id'];
         if ($one['status'] == ActivityProduct::STATUS_VERIFYING) {
             //审核中
             return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
             //跳转到完善信息
         }
     }
     //查询左侧菜单
     $ActivityAttrGroup = new ActivityAttrGroup();
     $menu = $ActivityAttrGroup->getCompleteStatus($rel_id);
     // echo "<pre>";
     // var_dump($menu);die;
     $ActivityProductAttrVal = new ActivityProductAttrVal();
     $attrval = $ActivityProductAttrVal->getRealAttrVals($rel_id, $aid);
     $attrval = array_merge($attrMap, $attrval);
     if (isset($attrval['pokedex']['val']) && is_array($attrval['pokedex']['val'])) {
         foreach ($attrval['pokedex']['val'] as $key => $value) {
             if ($value['type'] == ProductImage::TYPE_GOODPRODUCT) {
                 $image[] = $value;
             }
         }
     }
     $this->layout_data = 'uc';
     return $this->render('goodproduct', ['pid' => $pid, 'rel_id' => $rel_id, 'menu' => $menu, 'attrs' => isset($attrval) ? $attrval : "", 'attrMap' => $attrMap, 'image' => isset($image) ? $image : " ", 'goodproduct_city' => ActivityBase::GOODPRODUCT_CITY]);
 }
Exemplo n.º 7
0
 public function actionAb()
 {
     $component = new BaseAttribute();
     $mActivity = new ActivityBase();
     $acti = $mActivity->pk(7);
     $component->save(28846, 241639, 13, time(), $acti['config']);
     // $component->save(28841, 241573, time(), '');
     // var_dump($component->save(28841, 241573, 2, time()));
     // var_dump($component->val(28843, 10));
 }
Exemplo n.º 8
0
 /**
  * Action ChooseActivity
  *
  */
 public function actionChooseActivity()
 {
     $user = yii::$app->util->isLogin();
     if (yii::$app->util->isAjax()) {
         $pid = Yii::$app->request->get('pid') ? Yii::$app->request->get('pid') : '';
         $rel_id = Yii::$app->request->get('rel_id') ? Yii::$app->request->get('rel_id') : '';
         if ($user) {
             if ($pid) {
                 $url = '/support/choose-activity?pid=' . $pid;
             } else {
                 $url = '/support/choose-activity?rel_id=' . $rel_id;
             }
             $data['url'] = $url;
             echo yii::$app->util->formatResEncode('0', '该用户已经登录', $data);
             exit;
         } else {
             echo yii::$app->util->formatResEncode('1', '该用户没有登录');
             exit;
         }
     }
     if (Yii::$app->request->get('pid') || Yii::$app->request->get('rel_id')) {
         $rel_id = Yii::$app->request->get('rel_id');
         if ($rel_id) {
             $mActivityProduct = new ActivityProduct();
             $productActivity = $mActivityProduct->getByIdAndStatus($rel_id);
             $pid = intval($productActivity['product_id']);
         } else {
             $pid = Yii::$app->request->get('pid');
         }
         $mProductBase = new IProductBase();
         $myproduct = $mProductBase->isMyProduct($user['uid'], $pid);
         // $myproduct = '';
         if (!$myproduct) {
             $mProductBase = new IProductBase();
             $mActivityBase = new ActivityBase();
             $mActivityProductAttrVal = new ActivityProductAttrVal();
             $result = $mProductBase->getAllById(intval($pid));
             //查询活动
             $activity = $mActivityBase->getByFeature();
             foreach ($activity as $key => $val) {
                 $key = $val['id'];
                 $activity[$key] = $val;
             }
             //var_dump($result['aproduct']);die;
             //产品对应活动和价格
             if (!empty($result['aproduct'])) {
                 foreach ($result['aproduct'] as $key => $value) {
                     $attr[] = $mActivityProductAttrVal->getRealAttrVals($value['id'], $value['acti_id']);
                     // echo "<pre>";
                     // var_dump($attr[$key]['discount_price']['val']['price']);die;
                     $result['aproduct'][$key]['attr'] = isset($attr[$key]['discount_price']['val']) ? $attr[$key]['discount_price']['val'] : 0;
                     $result['aproduct'][$key]['num'] = isset($attr[$key]['supply_num']['val']) ? $attr[$key]['supply_num']['val'] : 0;
                     $price[$value['id']] = isset($attr[$key]['discount_price']['val']['price']) ? $attr[$key]['discount_price']['val']['price'] : 0;
                     // $price[] = array($value['id'] => $attr[$key]['discount_price']['val']['price']);
                     // // $price[$value['id']] = $attr[$key]['discount_price']['val']['price'];
                     //var_dump($price);die;
                     if (!empty($activity[$value['acti_id']])) {
                         $result['aproduct'][$key]['activity'] = $activity[$value['acti_id']];
                     }
                 }
             } else {
                 return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
                 //跳转到完善信息
             }
             $productData = array('pid' => $pid, 'name' => $result['name'], 'summary' => $result['extra']['summary'], 'album' => $result['album'], 'price' => $result['price']);
             $session = Yii::$app->session;
             $session->isActive ? '' : $session->open();
             $session->set('product', $productData);
             if (isset($price)) {
                 $session->set('activityprice', $price);
             }
             //$session->set('activityprice',$price);
             // echo "<pre>";
             // //var_dump($productActivity['acti_id']);
             // var_dump($result);die;
             $this->layout = '@app/views/layouts/main.php';
             //调用个人中心的布局
             if ($result) {
                 return $this->render('chooseactivity', ['data' => isset($result) ? $result : '', 'acti_id' => isset($productActivity) ? $productActivity['acti_id'] : '']);
             }
         } else {
             return $this->redirect(['home-page/lists', 'uid' => $user['uid']]);
             //跳转到完善信息
         }
     } else {
         return $this->redirect('/product/index');
         //跳转到完善信息
     }
 }
Exemplo n.º 9
0
 /**
  * 我的订单
  * @param int $page 当前页数
  * @param int $ispay 是否支付
  */
 public function actionMyOrder($page = 1, $urlispay = '')
 {
     //判断登陆
     $user = PublicLibrary::is_login();
     if (empty($user)) {
         echo "<script>window.location.href='/user/login';</script>";
         exit;
     }
     //查询当前用户信息
     $memberModel = new Member();
     $member = $memberModel->getByUid($user['uid']);
     //获取活动名称
     $activityModel = new ActivityBase();
     $activity = $activityModel->getActivityMap();
     //查询当前用户订单
     $data = [];
     $orderModel = new Order();
     $year = intval(date('Y'));
     $ordertime = array('0' => 3, '1' => $year, '2' => $year - 1, '3' => $year - 2, '4' => $year - 3, '5' => -($year - 3));
     $message = Yii::$app->request->get();
     if ($urlispay !== '') {
         $OrderNumber = '';
         $productName = '';
         $ispay = intval($urlispay);
         $message['urlispay'] = 100;
         $actiName = '';
         $createTime = '';
     } else {
         $OrderNumber = '';
         $productName = '';
         $ispay = '';
         $actiName = '';
         $createTime = '';
     }
     // if (!empty($message)) {
     //     //$search = $message['keywords'];
     //     if (!empty($message['keywords'])) {
     //         if (intval($message['keywords']) !== 0 || count(intval($message['keywords'])) == 12 ) {
     //             $OrderNumber = $message['keywords'];
     //         } else {
     //             $productName = $message['keywords'];
     //         }
     //     }
     //     $createTime = $message['create_time'] ? $message['create_time'] : '';
     //     $ispay = $message['ispay'] ? $message['ispay'] : '';
     //     $actiName = $message['acti_name'] ? $message['acti_name'] : '';
     //     if ($createTime) {
     //         $status['create_time'] = $this -> TimeTo($createTime);
     //     } else {
     //         $status['create_time'] = '';
     //     }
     // }
     if (!empty($message['keywords'])) {
         if (intval($message['keywords']) !== 0 && (strlen($message['keywords']) == 12 || strlen($message['keywords']) == 20)) {
             $OrderNumber = $message['keywords'];
         } else {
             $productName = $message['keywords'];
         }
     }
     if (!empty($message['create_time'])) {
         $createTime = $message['create_time'];
         $status['create_time'] = $this->TimeTo($createTime);
     } else {
         $status['create_time'] = '';
     }
     if (!empty($message['ispay'])) {
         $ispay = intval($message['ispay']) - 1;
     }
     if (!empty($message['acti_id'])) {
         $actiName = $message['acti_id'];
     }
     $status['product_name'] = $productName;
     $status['ispay'] = $ispay;
     $status['acti_id'] = $actiName;
     $status['orderno'] = $OrderNumber;
     //var_dump($status);die;
     $option['ispay'] = 0;
     $number = $orderModel->getCount($user['uid'], $option);
     //获取特定状态订单总数
     // $cache =  Yii::$app->cache;
     // $number = $cache->get($key);
     // if ($number === false) {
     //     // $number 在缓存中没有找到,则重新计算它的值
     //     // 将 $number 存放到缓存供下次使用
     //     $number = $orderModel->getCount($user['uid'],$option); //获取特定状态订单总数
     //     $cache->set($key, $number,1800);
     // }
     $order = $orderModel->getSearch($page, $user['uid'], $status, false);
     $pages = new Pagination(['totalCount' => $order->count(), 'pageSize' => Order::PAGE_SIZE]);
     $data = $order->all();
     $this->layout_data = 'uc';
     // echo "<pre>";
     // var_dump($data);die;
     //$this->layout = '@app/views/layouts/ucenter.php';  //调用个人中心的布局
     return $this->render('myorder', ['number' => $number, 'orders' => $data, 'ordertime' => $ordertime, 'pages' => $pages, 'activity' => $activity, 'search' => $message]);
 }
Exemplo n.º 10
0
 /**
  * [产品详情]
  * @param  int $id 产品id
  * @return array     产品信息渲染到页面view
  */
 public function actionView($id)
 {
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     //判断产品是否发布
     $base = IProductBase::find()->select('status,uid')->where('id = :id', [':id' => $id])->asArray()->one();
     if (!empty($_SESSION['user'])) {
         if ($base['status'] != IProductBase::STATUS_VERIFEND) {
             if ($base['uid'] != $_SESSION['user']['uid']) {
                 return $this->redirect(['index']);
                 //跳转到完善信息
             }
         }
     } else {
         if ($base['status'] != IProductBase::STATUS_VERIFEND) {
             return $this->redirect(['index']);
             //跳转到完善信息
         }
     }
     //增加总访问量
     $mProductStat = new IProductStat();
     $mProductStat->modify('page_views', $id, 1, true);
     //访问日志
     $mViewsLog = new ViewsLog();
     $mViewsLog->modify($id, ViewsLog::PRODUCT_TYPE);
     //增加周访问量,月访问量
     $week_num = $mViewsLog->ViewsNum($id, ViewsLog::PRODUCT_TYPE, 7);
     $month_num = $mViewsLog->ViewsNum($id, ViewsLog::PRODUCT_TYPE, 30);
     $mProductStat->modifyviewnum('week_views', $id, $week_num);
     $mProductStat->modifyviewnum('month_views', $id, $month_num);
     //基础数据和扩展数据查询
     $re = IProductBase::find()->With('extra', 'stat')->where(IProductBase::tableName() . '.id = :id', [':id' => $id])->asArray()->one();
     //该产品用户共发布产品数
     $presentNum = IProductBase::find()->where(['uid' => $re['uid'], 'status' => IProductBase::STATUS_VERIFEND])->count();
     //喜欢此产品用户
     $model = new ProductFollow();
     $loves = $model->getFollowUsers($id);
     //产品发布人头像及姓名
     $model = new Member();
     $user = $model->find()->select(['avatar', 'nickname'])->where(['uid' => $re['uid']])->asArray()->one();
     //参加活动
     $model = new ActivityProduct();
     //        print_r($id);exit;
     $actives = $model->getActivityDetail($id);
     // $actives = $model->getActivitiseById($id);
     // print_r($actives);exit;
     foreach ($actives as $key => $value) {
         if ($value['acti_id'] == 8) {
             $mBaiyingShare = new BaiyingShare();
             $number = $mBaiyingShare->getShareNum($value['id']);
         }
         if ($value['acti_id'] == 9) {
             $rel_id = $value['id'];
         }
     }
     //活动map
     $activityBase = new ActivityBase();
     $activesMap = $activityBase->getActivityMap();
     if (isset($rel_id)) {
         //投票信息
         $city = "上海";
         $poll_type_id = PollType::GOODPRODUCT_TYPE;
         $mpoll = new poll();
         $pollone = $mpoll->getPollByCity($city, $poll_type_id);
         //投票项信息
         $moption = new polloption();
         $optione = $moption->getOptionByowner($pollone['poll_id'], $rel_id);
     }
     return $this->render('view', ['re' => $re, 'present_num' => $presentNum, 'actives' => $actives, 'now' => time(), 'number' => isset($number) ? intval($number) : '', 'loves' => $loves, 'user' => $user, 'activesMap' => $activesMap, 'optione' => isset($optione) ? $optione : '']);
 }