Пример #1
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]);
 }
Пример #2
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']);
     }
 }