Пример #1
0
 /**
  * 现金充值
  */
 public function payAction()
 {
     $config = Wekit::C('pay');
     if (!$config['ifopen']) {
         $this->showError($config['reason']);
     }
     list($credit, $pay, $paymethod) = $this->getInput(array('credit', 'pay', 'paymethod'));
     if (!in_array($paymethod, array('1', '2', '3', '4'))) {
         $this->showError('onlinepay.paymethod.select');
     }
     $onlinepay = Wekit::load('pay.srv.PwPayService')->getPayMethod($paymethod);
     if (($result = $onlinepay->check()) instanceof PwError) {
         $this->showError($result->getError());
     }
     $recharge = Wekit::C('credit', 'recharge');
     $creditBo = PwCreditBo::getInstance();
     if (!isset($recharge[$credit]) || !isset($creditBo->cType[$credit])) {
         $this->showError('CREDIT:pay.type.error');
     }
     $pay = round($pay, 2);
     $min = max(0, $recharge[$credit]['min']);
     if ($pay < $min) {
         $this->showError(array('CREDIT:pay.num.min', array('{min}' => $min)));
     }
     $creditName = $creditBo->cType[$credit];
     $order_no = $onlinepay->createOrderNo();
     Wind::import('SRV:pay.dm.PwOrderDm');
     $dm = new PwOrderDm();
     $dm->setOrderNo($order_no)->setPrice($pay)->setNumber(1)->setState(0)->setPaytype(1)->setBuy($credit)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(Pw::getTime());
     Wekit::load('pay.PwOrder')->addOrder($dm);
     Wind::import('SRV:pay.vo.PwPayVo');
     $vo = new PwPayVo();
     $vo->setOrderNo($order_no)->setFee($pay)->setTitle('积分充值(订单号:' . $order_no . ')')->setBody('购买论坛' . $creditName . '(论坛UID:' . $this->loginUser->uid . ')');
     $this->setOutput(array('url' => $onlinepay->getUrl($vo)), 'data');
     //todo WindUrlHelper 改进
     $this->showMessage('success');
     //$this->showMessage('success', $onlinepay->getUrl($vo));
     //$this->forwardRedirect($onlinepay->getUrl($vo));
 }