public function actionDelete($id)
 {
     $this->checkLogin();
     $pay = Pay::model()->findByPk((int) $id);
     if ($pay) {
         if ($pay->delete()) {
             $this->redirect(array('Index'));
         }
     }
 }
 public function actionParams()
 {
     $id = $this->iGet('id');
     $isMobile = $this->iRequest('is_mobile');
     $channel = $this->sRequest('channel');
     $model = Pay::model()->findByPk($id);
     if ($model === null || $model->user_id !== Yii::app()->user->id) {
         throw new CHttpException(401, 'Unauthorized Access');
     }
     $params = array();
     if ($model->isPaid()) {
         switch ($model->type) {
             case Pay::TYPE_REGISTRATION:
                 $competition = $model->competition;
                 $params['url'] = $competition->getUrl('registration');
                 break;
         }
     } else {
         $params = $model->generateParams($isMobile, $channel);
     }
     $this->ajaxOk($params);
 }
Beispiel #3
0
private function paystate($criteria)
{	
                    if($this->state_pay==1)
                  {
                     $payment_table   = Pay::model()->tableName();
                   $paid_status_sql = "(select CASE WHEN (select sum(amount) from $payment_table where $payment_table.exp_id = t.id) >0 THEN 1 ELSE 0 END)";
                  }
                   else if($this->state_pay==2)
                  {
                    $payment_table   = Pay::model()->tableName();
                      $paid_status_sql = "(select CASE WHEN ((t.amount>(select sum(amount) from $payment_table where $payment_table.exp_id = t.id))OR((select sum(amount) from $payment_table where $payment_table.exp_id = t.id)IS NULL)) THEN 2 ELSE 0 END)";
                  }
                  else if($this->state_pay==3)
                  {
                     $payment_table   = Inv::model()->tableName();
                     $paid_status_sql = "(select CASE WHEN (select sum(amount) from $payment_table where $payment_table.exp_id = t.id) >0 THEN 3 ELSE 0 END)";
                  }
                   else if($this->state_pay==4)
                  {
                    $payment_table   = Inv::model()->tableName();
                       $paid_status_sql = "(select CASE WHEN ((t.amount>(select sum(amount) from $payment_table where $payment_table.exp_id = t.id))OR((select sum(amount) from $payment_table where $payment_table.exp_id = t.id)IS NULL)) THEN 4 ELSE 0 END)";
                  }
 
                   $criteria->select = array(
                        '*',
                        $paid_status_sql." as state_pay",
                    );
//                        $criteria->addCondition(" (".$paid_status_sql.") =".$this->state_pay);
                      $criteria->compare($paid_status_sql, $this->state_pay); 
}
Beispiel #4
0
 /**
  * IOS IAP 支付验证
  * $uid
  * $token
  * $item_id
  * $receipt
  */
 public function actionIosVerify()
 {
     // error_log(json_encode($_POST));
     if (!isset($_REQUEST['receipt']) || !isset($_REQUEST['uid']) || !isset($_REQUEST['token']) || !isset($_REQUEST['trade_no'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     /*沙盒测试开关,正式发布时,需置为false**********************************/
     $isSandbox = true;
     /********************************************************************/
     $receipt = Yii::app()->request->getParam('receipt');
     $uid = trim(Yii::app()->request->getParam('uid'));
     $token = trim(Yii::app()->request->getParam('token'));
     $trade_no = Yii::app()->request->getParam('trade_no');
     $now = date('Y-m-d H:i:s');
     if (!Token::model()->verifyToken($uid, $token, $GLOBALS['__APPID'])) {
         $this->_return('MSG_ERR_TOKEN');
         //#token 错误
     }
     $param = array('uid' => $uid, 'receipt' => $receipt, 'create_ts' => $now, 'trade_no' => $trade_no);
     $trade_info = Pay::model()->getTradeInfo($trade_no);
     if ($trade_info['uid'] != $uid || $trade_info['status'] != 0) {
         Pay::model()->recordIOSIAPInfo($param);
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, "无效或重复的订单");
         $this->_return('MSG_ISO_PAY_WRONG');
     }
     if ($isSandbox) {
         $endpoint = 'https://sandbox.itunes.apple.com/verifyReceipt';
     } else {
         $endpoint = 'https://buy.itunes.apple.com/verifyReceipt';
     }
     $postData = json_encode(array('receipt-data' => $receipt));
     $ch = curl_init($endpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     //curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     //这两行一定要加,不加会报SSL 错误
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     $response = curl_exec($ch);
     $errno = curl_errno($ch);
     $errmsg = curl_error($ch);
     curl_close($ch);
     if ($errno != 0) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, trade_no, $errno . ">" . $errmsg);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_WRONG');
     }
     $param['verify_data'] = $response;
     $data = json_decode($response);
     if (!is_object($data)) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, '不能解析返回数据>' . $response);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_WRONG');
         //throw new Exception('Invalid response data');
     }
     if (!isset($data->status) || $data->status != 0) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_FAIL', $now, $trade_no);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_FAIL');
     }
     $add_coin = $trade_info['coin'] + $trade_info['free'];
     Pay::model()->iosPaySuccess($uid, $trade_no, $add_coin);
     Pay::model()->recordIOSIAPInfo($param);
     Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_OK', $now, $trade_no);
     $res = array('gold' => $add_coin);
     $this->_return('MSG_SUCCESS', $res);
 }
Beispiel #5
0
 public function actionAjaxReq()
 {
     $val1 = $_POST['val_id'];
     sscanf($val1, "js:_id=%d;_pay=%d;", $id, $pay);
     if ($id == null) {
         echo "R:" . $val1;
         return;
     }
     $ret .= "";
     //		$ret.="<div id='mydialog_buts'>".CHtml::link('Новый платеж',array('pay/createID','id'=>$id), array('target'=>'_blank','class'=>'menuitem'))."</div>";
     $dataReader = Pay::model()->findAll('exp_id=:id', array(':id' => $id));
     $ret .= "<table class='acctable'>";
     $ret .= "<tr>" . "<th>№</th>" . "<th>Инфо.</th>" . "<th>Дата</th>" . "<th>Получен</th>" . "<th>Сумма</th>" . "</tr>";
     $res = 0;
     foreach ($dataReader as $row) {
         $ret .= "<tr><td>" . $row['id'] . "</td><td>" . $row['name'] . "</td>\n";
         $ret .= "<td>" . Yii::app()->dateFormatter->formatDateTime($row['date'], 'short', null) . "</td>\n";
         $ret .= "<td>" . Yii::app()->dateFormatter->formatDateTime($row['date_g'], 'short', null) . "</td>\n";
         //	$ret.="<td>".$row->account['name']."</td>\n";
         //	$ret.="<td style='text-align:right;'>".Yii::app()->numberFormatter->formatCurrency($row['amount'], '')."</td></tr>\n";
         //         if( Yii::app()->Controller->permit>2)
         $ret .= "<td style='text-align:right;'>" . CHtml::link(Yii::app()->numberFormatter->formatCurrency($row['amount'], ''), array('pay/update', 'id' => $row['id'], 'ret' => 1)) . "</td></tr>";
         //            $ret.="<td style='text-align:right;'>".CHtml::link(Yii::app()->numberFormatter->formatCurrency($row['amount'], ''),array('pay/update','id'=>$row['id']),array('target'=>'_blank'))."</td></tr>";
         //         else
         //           $ret.="<td style='text-align:right;'>".Yii::app()->numberFormatter->formatCurrency($row['amount'], '')."</td></tr>";
         $res += $row['amount'];
     }
     $ret .= "<tr><td colspan='4'>Оплачено:</td><td style='font-weight: bold;text-align:right;'>" . Yii::app()->numberFormatter->formatCurrency($res, '') . "</td></tr>\n";
     $ret .= "</table>\n";
     echo $ret;
 }
Beispiel #6
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Pay the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Pay::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }