Exemplo n.º 1
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.º 2
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.º 3
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']);
     }
 }