Пример #1
0
 /**
  * @param $id
  * @param null $type
  */
 public function actionBilling($id, $type = null)
 {
     $user = UserModel::model()->findByPk($id);
     $billing = new TransModel();
     if ($type == 'import') {
         if (isset($_POST['payment']) && !empty($_POST['payment'])) {
             $billing->user_id = $id;
             $billing->service_id = $_POST['other_payment_type'];
             $billing->summ = $_POST['payment'];
             $billing->status = TransModel::STATUS_PAYMENT;
             $billing->remark = 'Пополнение счета';
             $billing->date_add = date('Y-m-d H:i:s');
             $billing->currency_id = 1;
             $user->balance = $user->balance + $_POST['payment'];
             $user->save(false);
             $billing->save(false);
             Yii::app()->user->setFlash('success', 'Баланс пополнен');
         }
     }
     if ($type == 'export') {
         if (isset($_POST['payment']) && !empty($_POST['payment'])) {
             $balance = $user->balance - $_POST['payment'];
             if ($balance < 0) {
                 Yii::app()->user->setFlash('error', 'Недостаточно денег на счету');
             } else {
                 $billing = new TransModel();
                 $billing->user_id = $id;
                 $billing->service_id = $_POST['other_payment_type'];
                 $billing->summ = $_POST['payment'];
                 $billing->status = TransModel::STATUS_PAYMENT;
                 $billing->remark = 'Вывод средств';
                 $billing->date_add = date('Y-m-d H:i:s');
                 $billing->currency_id = 1;
                 $user->balance = $balance;
                 $user->save(false);
                 $billing->save(false);
                 Yii::app()->user->setFlash('success', 'Успешно!');
             }
         }
     }
     if ($user) {
         $this->render('billing', ['billing' => $billing, 'user' => $user]);
     } else {
         $this->redirect('/');
     }
 }
Пример #2
0
 public function actionWithdrawals()
 {
     $msg = '';
     if (Yii::app()->request->isPostRequest) {
         //	    if( empty($_POST['summ']) || empty($_POST['service']) || intval($_POST['summ']) > 0){
         //		$msg = 'Ошибка входных данных';
         //	    }else{
         $trans = new TransModel();
         $trans->setAttributes(['user_id' => Yii::app()->user->getId(), 'service_id' => new CDbExpression('NULL'), 'summ' => -$_POST['summ'], 'status' => TransModel::STATUS_PAYMENT, 'remark' => $_POST['comments'], 'currency_id' => 1]);
         if ($trans->validate()) {
             $trans->save(FALSE);
             Yii::app()->user->setFlash('notify', 'Ваш запрос отправлен');
             $this->redirect(['billing/']);
         } else {
             $msg = current(current($trans->getErrors()));
         }
         //	    }
     }
     $this->render('withdrawals', ['msg' => $msg]);
 }
Пример #3
0
 public function actionAdd()
 {
     /**
      * @var CWebApplication $app
      * @var Document $costDocument
      */
     if (Yii::app()->user->isGuest) {
         Yii::app()->user->setFlash('error', 'Заказать документ может только зарегестрированный пользователь');
         $this->redirect($this->createUrl('site/index'));
     }
     $app = Yii::app();
     $view = 'document';
     $id = $app->user->getState('document_id');
     $model = null;
     $user = UserModel::model()->findByPk($app->user->id);
     if (!$id) {
         $document = new Document();
         if (!empty($_POST['Document'])) {
             $document->attributes = $_POST['Document'];
             $image = CUploadedFile::getInstance($document, 'file');
             $document->user_id = Yii::app()->user->id;
             $document->status = 0;
             if ($document->save()) {
                 if ($image) {
                     if (!is_dir('uploads/document/images')) {
                         mkdir('uploads/document/images', 0777, true);
                     }
                     $ext = explode('.', $image->name);
                     $document->file = Yii::app()->user->id . '_' . md5(time()) . '.' . $ext[1];
                     $image->saveAs('uploads/document/images/' . $document->file);
                     $document->save(false);
                 }
                 $app->user->setState('document_id', $document->id);
                 $view = 'document_user_info';
                 $document = new DocumentUser();
             }
         }
         $model = $document;
     } elseif (null !== ($document = Document::model()->findByPk($id)) && !$document->document_user) {
         $document_user = new DocumentUser();
         $view = 'document_user_info';
         if (!empty($_POST['DocumentUser'])) {
             $document_user->attributes = $_POST['DocumentUser'];
             $document_user->document_id = $document->id;
             if ($document_user->save()) {
                 $view = 'document_pay';
                 $document_user = $user;
             }
         }
         $model = $document_user;
     } else {
         $model = $user;
         if (isset($_POST['payment']) && !empty($_POST['payment'])) {
             $balance = $model->balance - $_POST['payment'];
             if ($balance < 0) {
                 Yii::app()->user->setFlash('error', 'Недостаточно денег на счету');
             } else {
                 $billing = new TransModel();
                 $billing->user_id = $id;
                 $billing->service_id = $_POST['other_payment_type'];
                 $billing->summ = $_POST['payment'];
                 $billing->status = TransModel::STATUS_PAYMENT;
                 $billing->remark = 'Вывод средств';
                 $billing->date_add = date('Y-m-d H:i:s');
                 $billing->currency_id = 1;
                 $model->balance = $balance;
                 $model->save(false);
                 $billing->save(false);
                 $documentId = $app->user->getState('document_id');
                 $costDocument = Document::model()->findByPk($documentId);
                 $costDocument->cost = $_POST['payment'];
                 $costDocument->save(false);
                 Yii::app()->user->setFlash('success', 'Успешно! Ожидайте юрист с вами свяжется!');
                 $app->user->setState('document_id', null);
                 $this->refresh();
             }
         }
         $view = 'document_pay';
     }
     $this->render($view, ['model' => $model]);
 }
Пример #4
0
 public function seConfirmTrans($job, $data)
 {
     $errCode = 0;
     $transOrder = TransModel::find($data['id'])->first();
     do {
         if (!$transOrder || $transOrder->status != TransModel::STATUS_DEFAULT) {
             $errCode = 1;
             break;
         }
         if (!$transOrder->gateway || !$transOrder->channel) {
             $errCode = 2;
             break;
         }
         if (false === ($channel = ChannelUtil::calculateAccountChannel($transOrder->channel))) {
             $errCode = 3;
             break;
         }
         $gatewayObj = gatewayUtil::getGatewayObj($transOrder->gateway);
         if (!$gatewayObj) {
             $errCode = 4;
             break;
         }
         if (!method_exists($gatewayObj, 'transQuery')) {
             $errCode = 5;
             break;
         }
     } while (0);
     if ($errCode == 0) {
         $order = ['channel' => $channel, 'gateway' => $transOrder->gateway, 'batch_no' => $transOrder->batch_no, 'mer_trans_no' => $transOrder->mer_trans_no];
         $notice = $gatewayObj->transQuery($order);
         $ret = SerNotifyBiz::getInstance()->payNotify($notice, 'trans');
         if ($ret->is_success == 'T') {
             $job->delete();
         } else {
             $job->release(60 * 60);
         }
     } else {
         $job->delete();
     }
 }
Пример #5
0
</td>
	    </tr>
	    <tr>
		<td><hr></td>
	    </tr>
	    <tr>
		<td>Ожидается: <?php 
echo Yii::app()->user->getBlockBalance();
?>
</td>
	    </tr>
	</tbody>
    </table>
</div>
<div style="width: 70%; float: right;">
    <?php 
echo CHtml::link('Пополнить счет', ['billing/refill']);
?>
    <?php 
echo CHtml::link('Вывод средств', ['billing/withdrawals']);
?>
</div>
<div style="width: 100%; clear: both;">
    <span>История платежей:</span>
    
    <?php 
foreach (TransModel::model()->current()->findAll() as $row) {
    echo '<div class="clear:both;">' . $row->date_add . 'Сумма: ' . $row->summ . $row->remark . '</div>';
}
?>
</div>
Пример #6
0
 public function getWaitBalance()
 {
     return TransModel::model()->getBalance(TransModel::STATUS_WAIT);
 }