Пример #1
0
 /**
  * @author hongye
  *
  * @param int  $supportid 支持人id
  *  测试地址:http://dev.idaiyan.cn/baiying/support?sid=2598
  * @return array
  * */
 public function actionSupport()
 {
     $user = PublicLibrary::is_login();
     if ($user && isset($user['uid']) && $user['uid'] != 'weixin') {
         $uid = isset($user['uid']) ? $user['uid'] : '';
     } else {
         return $this->redirect(['baiying/productlist']);
     }
     $shareid = Yii::$app->request->get('sid');
     $shareid = intval($shareid);
     $models = new BaiyingSupport();
     $res = $models->Supportme($shareid);
     $mbshare = new BaiyingShare();
     $shareone = $mbshare->pk($shareid);
     if ($shareone['uid'] != $uid) {
         return $this->redirect(['baiying/userproduct']);
     }
     $rel_id = $shareone['rel_id'];
     $acti_id = $shareone['acti_id'];
     $product_id = $shareone['product_id'];
     $uid = $shareone['uid'];
     $share_num = $shareone['share_num'];
     //支持数
     $pmodels = new IProductBase();
     $temp = $pmodels->pk($product_id);
     $name = $temp['name'];
     // $mshare = new BaiyingShare();
     $slist = $mbshare->getShareone($rel_id, $uid, ActivityBase::APPLY_BAIYING);
     // print_r($slist);
     // echo '<pre>';
     // print_r($slist);
     // exit;
     // $acprattr_model = new ActivityProductAttrVal();
     // $acprattr = $acprattr_model->getRealAttrVals($rel_id,ActivityBase::APPLY_BAIYING);
     // echo '<pre>';
     // print_r($acprattr);
     // $supply_num = isset($acprattr['supply_num']['val'])?$acprattr['supply_num']['val']:'30';//商品提供
     // echo '<pre>';
     // print_r($supply_num);
     $this->layout = false;
     return $this->render('supportme', ['res' => $res, 'name' => $name, 'share_num' => $share_num, 'slist' => $slist]);
 }
Пример #2
0
 /**
  * 商品生成订单
  * @1.订单id orderno,
  * @提交地址:http://dev.idaiyan.cn/payment/finishpay?orderno=idy20150424163341192185
  * todo 仅仅可以通过某个链接过来。
  */
 public function actionFinishpay()
 {
     //开启缓存
     $session = Yii::$app->session;
     $session->isActive ? '' : $session->open();
     //判断用户有没有登录
     $user = PublicLibrary::is_login();
     if (!$user) {
         return $this->redirect(['product/index']);
         exit;
     }
     $uid = $_SESSION['user']['uid'];
     $parr = Yii::$app->request->get();
     if ($parr) {
         //接收传过来的数据
         $orderno = isset($parr['orderno']) ? strip_tags($parr['orderno']) : '';
         $model_order = new Order();
         $res = $model_order->getByOrderNo($orderno, $uid);
         if (!$res) {
             return $this->redirect(['product/index']);
             exit;
         }
         //支付成功的话跳转到个人中心
         if ($res['ispay']) {
             return $this->redirect(['ucenter/my-order']);
             exit;
         }
         $rel_id = $res['rel_id'];
         $nums = $res['nums'];
         $totalpay = $res['totalpay'];
         $truename = $res['truename'];
         $address = $res['address'];
         $mobile = $res['mobile'];
         $province = $res['province'];
         $city = $res['city'];
         $location = $province . ',' . $city;
         /*
             通过rel_id 查询产品相关的信息
         */
         $pmodel = new ActivityProduct();
         // $product = $pmodel->pk(33104);//33104
         $product = $pmodel->pk($rel_id);
         //33104
         $product_id = $product['product_id'];
         $acti_id = $product['acti_id'];
         $stock = $product['stock'];
         //库存
         //判断需求数和库存数
         if ($nums > $stock) {
             return $this->redirect(['product/index']);
             exit;
         }
         /*
             通过product_id 查询产品相关的信息
         */
         $pmodel = new IProductBase();
         $pres = $pmodel->pk($product_id);
         $name = isset($pres['name']) ? strip_tags($pres['name']) : '';
         //产品名称
         $relpay = $totalpay * 100;
         //价格换算
         $native = Yii::$app->util->weixinnative(1, $name, $orderno);
         //支付宝生成二维码
         $params = ['out_trade_no' => $orderno, 'subject' => $name, 'total_fee' => 0.01, 'body' => $name, 'show_url' => Yii::$app->params['idaiyan'] . '/product/view?id=' . $product_id];
         $formHtml = Yii::$app->alipay->form($params);
         $qrCodeHtml = Yii::$app->alipay->qrcode($params);
         return $this->render('order', ['orderno' => $orderno, 'totalpay' => $totalpay, 'address' => $address, 'location' => $location, 'mobile' => $mobile, 'truename' => $truename, 'native' => $native, 'formHtml' => $formHtml, 'qrCodeHtml' => $qrCodeHtml]);
     } else {
         echo '该页面已经过期啦!';
         exit;
     }
 }