public function actionProcess($id = null) { /* @var $payment Payment */ $payment = Payment::model()->findByPk($id); if ($payment && $payment->module) { $paymentSystem = Yii::app()->paymentManager->getPaymentSystemObject($payment->module); if ($paymentSystem) { $paymentSystem->processCheckout($payment, Yii::app()->getRequest()); } } else { throw new CHttpException(404); } }
/** * @param null $id * @throws CException * @throws CHttpException */ public function actionProcess($id = null) { /* @var $payment Payment */ $payment = Payment::model()->findByPk($id); if (!$payment && !$payment->module) { throw new CHttpException(404); } /** @var PaymentSystem $paymentSystem */ if ($paymentSystem = Yii::app()->paymentManager->getPaymentSystemObject($payment->module)) { $result = $paymentSystem->processCheckout($payment, Yii::app()->getRequest()); if ($result instanceof Order) { $this->redirect(['/order/order/view', 'url' => $result->url]); } } }
/** * @param null $id * @throws CException * @throws CHttpException */ public function actionProcess($id = null) { /* @var $payment Payment */ $payment = Payment::model()->findByPk($id); if (null === $payment && !$payment->module) { throw new CHttpException(404); } /** @var PaymentSystem $paymentSystem */ if ($paymentSystem = Yii::app()->paymentManager->getPaymentSystemObject($payment->module)) { $result = $paymentSystem->processCheckout($payment, Yii::app()->getRequest()); if ($result instanceof Order) { Yii::app()->getUser()->setFlash(YFlashMessages::SUCCESS_MESSAGE, Yii::t('PaymentModule.payment', 'Success get pay info!')); $this->redirect(['/order/order/view', 'url' => $result->url]); } } }
public function getPaymentList() { $map = array('is_valid' => 1); $list = Payment::model()->findAllByAttributes($map); if (empty($list)) { return false; } $newList = array(); foreach ($list as $row) { if ($row['is_plat'] == 1) { $newList['plat'][] = $row->getAttributes(); } else { $newList['bank'][] = $row->getAttributes(); } } return $newList; }
public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Delivery'])) { $model->attributes = $_POST['Delivery']; if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('DeliveryModule.delivery', 'Record updated!')); if (!isset($_POST['submit-type'])) { $this->redirect(['update', 'id' => $model->id]); } else { $this->redirect([$_POST['submit-type']]); } } } $payments = Payment::model()->published()->findAll(['order' => 'position']); $this->render('update', ['model' => $model, 'payments' => $payments]); }
/** * 订单确认页面 */ public function actionCheckout() { $userId = $this->user_id; if (empty($userId)) { $this->redirect('/user/login'); } $addList = Address::model()->getUserAddressList($userId); $payList = Payment::model()->getPaymentList(); $plist = Cart::model()->getCartList($userId); $couponlist = Coupon::model()->getUserUsingCouponList($userId); if (empty($plist['list'])) { $this->redirect('/?from=no_deal'); } $viewData = array(); $viewData['addList'] = $addList; $viewData['list'] = $plist['list']; $viewData['total'] = $plist['total']; $viewData['couponlist'] = $couponlist; $viewData['payList'] = $payList; $this->render('cart/checkout', $viewData); }
public function actionChangeStatus() { $res = array('statusCode' => 200, 'message' => '修改成功!'); try { if (empty($_REQUEST['id'])) { throw new Exception("数据错误,id不能为空!", 1); } $info = Payment::model()->findByPk($_REQUEST['id']); if (empty($info)) { throw new Exception('该支付记录不存在'); } if ($info->is_valid != $_REQUEST['is_valid']) { $info->is_valid = $_REQUEST['is_valid']; $flag = $info->save(); if (!$flag) { throw new exception('修改失败'); } } } catch (Exception $e) { $res['statusCode'] = 300; $res['message'] = '修改失败【' . $e->getMessage() . '】'; } $res['callbackType'] = 'reloadTab'; $res['forwardUrl'] = '/manage/payment/index'; $this->ajaxDwzReturn($res); }
public static function BalancedCallback($post) { Yii::import('application.extensions.vendor.autoload', true); Httpful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = Yii::app()->params['balancedAPISecret']; $log = "Received callback... \n"; try { $data = json_decode($post); if (!isset($data->type)) { $log .= "Error parsing data: \n"; $log .= "Raw post: \n" . $post . "\n"; $log .= "Parsed data: \n" . print_r($data, true) . "\n"; throw new Exception("Error parsing data"); } if ($data->type == 'debit.succeeded') { try { $log .= "Customer debit succeeded. Paying the host...\n"; $paymentID = $data->entity->meta->Payment_ID; $log .= "Payment_ID: {$paymentID}\n"; $payment = Payment::model()->findByPk($paymentID); $hostAmount = $payment->Amount * Yii::app()->params['HostPercentage']; $log .= "Host's share is \${$hostAmount}\n"; // Convert to cents $hostAmount *= 100; $hostBankAccount = Balanced\BankAccount::get($payment->bankAccount->URI); $credit = $hostBankAccount->credit($hostAmount); $log .= 'Sent credit, response is: ' . print_r($credit, true) . "\n"; } catch (Exception $e) { Mail::Instance()->Alert("Error crediting host account", print_r($e)); throw $e; } } else { $log .= print_r($data, true) . "\n"; } } catch (Exception $e) { $log .= "\n" . print_r($e, true); } Yii::log($log, 'info', 'BalancedCallback'); }
public function process() { // States list request from sales site if ($this->wsType == 'st') { // set headers AF::setJsonHeaders('json'); // country_id has already been verified as set $states = State::model()->getStatesByCID($this->post['country_id']); // return json state list if present Message::echoJsonSuccess(array('message' => $states)); exit; } // CRM Order if ($this->wsType == 'x1') { // EXISTING CUSTOMER CHECK if (!$this->newCustomer) { $this->customer = Customer::model()->fillFromDbPk($this->post['customer_id']); $this->shippingAddress = Address::model()->fillFromDbPk($this->post['address_id']); $this->billingAddress = Address::model()->fillFromDbPk($this->post['billing_address_id']); } // if customer already built then check for blacklist $this->buildCustomer(); // EXISTING ORDER Check - DON'T NEED THIS I THINK $this->order = new Order(); /*if (!$this->newCustomer && $this->order->fillFromDbPk($this->customer->getCustomerOkOrder($this->campaign->campaign_id))) $this->apiError('An "OK" order already exists for this customer. Order ID ' . $this->order->order_id);*/ // addresses if (!isset($this->shippingAddress) || !$this->shippingAddress->getPkvalue()) { $this->buildAddress(); if ($this->post['billingSameAsShipping']) { $this->billingAddress = $this->shippingAddress; } else { $this->buildAddress('billing'); } } // payment before order. if no payment specified allow order to still be built if ($this->isPayment && isset($this->post['payment_id']) && $this->post['payment_id']) { $this->payment = Payment::model()->fillFromDbPk($this->post['payment_id']); } if ($this->isPayment) { $this->buildPayment(); } // order $this->buildOrder(); // pay or return if ($this->isPayment) { $this->webPayment(); } else { $this->order->status = 'ok'; $this->order->addFlags('paid'); // this needs to be set in order to have the order get sent to fulfillment $this->order->amount_product = '0.00'; $this->order->amount_shipping = '0.00'; $this->order->save(); } $this->apiSuccess('Order ' . $this->order->order_id . ' created'); } // Build prospect, click and customer info if (in_array($this->wsType, array('p', 'l'))) { $this->customer = new Customer(); $this->order = new Order(); $this->prospect = new Prospect(); // EXISTING ORDER/CUSTOMER CHECK - make sure there isn't already an order for this campaign and email if ($this->customer->getCustomerByEmail($this->post['email']) && $this->customer->getCustomerOkOrder($this->campaign->campaign_id) && $this->order->fillFromDbPk($this->customer->getCustomerOkOrder($this->campaign->campaign_id))) { $this->thankYou(true); } // BlueSnap Pending Order Check // Has an order already been submitted to the gateway and is pending final approval? If so, redirect to the thankyou page if (isset($this->customer->customer_id) && $this->order->orderPendingAttemptExists($this->campaign->campaign_id, $this->customer->customer_id)) { $this->thankYou(true); } // Existing Prospect check if customer already exists. If no prospect, build click if ($this->customer->getPkValue()) { if (!$this->prospect->prospectExists($this->customer->customer_id, $this->campaign->campaign_id)) { $this->buildClick(); } else { //prospect already exists. let's update the updated column $this->prospect->created = 'NOW():sql'; //date("Y-m-d H:i:s"); $this->prospect->save(); // check the click info. if its new then we need to double check it all $this->buildClick($this->prospect->click_id); } } else { $this->buildClick(); } $this->buildCustomer(); $this->buildAddress(); $this->buildProspect(); // if this is not a lastchance request, then redirect the user to the order page if ($this->wsType != 'l') { // build return object. SET TO HTTPS WHEN TESTING IS COMPLETE $url = $this->campaign->order_url . '?tempOrderId=' . $this->prospect->getPkValue(); $this->apiSuccess($url); } } // Build Order if (in_array($this->wsType, array('o', 'l'))) { if ($this->wsType == 'o') { // load objects $this->prospect = new Prospect(); if (!$this->prospect->fillFromDbPk($this->post['tempOrderId'])) { $this->apiError('Error:12 - This temporary transaction is invalid'); } $this->shippingAddress = new Address(); if (!$this->shippingAddress->fillFromDbPk($this->prospect->address_id)) { $this->apiError('Error:12 - This temporary transaction is invalid'); } $this->customer = new Customer(); if (!$this->customer->fillFromDbPk($this->prospect->customer_id)) { $this->apiError('Error:12 - This temporary transaction is invalid'); } } $this->buildOrder(); } // Upsell if (in_array($this->wsType, array('u'))) { // load objects $this->order = new Order(); if (!$this->order->fillFromDbPk($this->post['tempOrderId'])) { $this->apiError('Error:12 - This transaction is invalid'); } // already processed? if so send to TY page, unless there's been a decline/error if (!in_array($this->order->status, array('new', 'error'))) { $this->thankYou(true); } // check for test order if ($this->order->isFlag('test')) { $this->setTest(); } $this->upsellProcess(); } // 1Click if (in_array($this->wsType, array('c'))) { // add some time to the request to give the payment gateway rest time sleep(2); $this->customer = new Customer(); $existingOrder = new Order(); // EXISTING ORDER/CUSTOMER CHECK - make sure there isn't already an order for this campaign and email if ($this->customer->getCustomerByEmail($this->order->customer->email) && $this->customer->getCustomerOkOrder($this->campaign->campaign_id) && $existingOrder->fillFromDbPk($this->order->customer->getCustomerOkOrder($this->campaign->campaign_id))) { $this->thankYou(); } // BlueSnap Pending Order Check // Has an order already been submitted to the gateway and is pending final approval? If so, redirect to the thankyou page if ($this->order->orderPendingAttemptExists($this->campaign->campaign_id, $this->order->customer->customer_id)) { $this->thankYou(true); } // load/build objects $this->buildClick(); // order already built in isValid() $this->customer = Customer::model()->fillFromDbPk($this->order->customer_id); $this->payment = Payment::model()->fillFromDbPk($this->order->payment_id); $this->shippingAddress = Address::model()->fillFromDbPk($this->order->address_id); $this->billingAddress = Address::model()->fillFromDbPk($this->order->billing_address_id); $this->post['ps'] = $this->order->gateway->system_code; $this->buildOrder(); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { if (isset($_GET['sid'])) { // Меняем статус, ajax $sid = $_GET['sid']; $model = $this->loadModel($id); $model->status = $sid; $model->save(); Yii::app()->end(); } if (Yii::app()->request->isAjaxRequest) { //echo 'test'; $data = Yii::app()->request->getRestParams(); $field = str_replace('Zakaz_', '', $data['elid']); if (is_array($data)) { $model = $this->loadModel($data['id']); echo json_encode($model->{$field} = $data['data']); echo json_encode($model->save()); echo json_encode($model->errors); Yii::app()->end(); } $this->renderPartial('_order_list_update'); Yii::app()->end(); } Yii::app()->session['project_id'] = $id; $model = $this->loadModel($id); if (Yii::app()->request->getParam('close') == 'yes') { $model->old_status = $model->status; $model->status = 5; $model->save(false); $user = User::model()->findByPk($model->user_id); if ($user->pid) { $payed = Payment::model()->exists('order_id = :p1 AND payment_type = :p2', array(':p1' => $model->id, ':p2' => Payment::OUTCOMING_WEBMASTER)); if (!$payed) { // Only first time $webmaster = User::model()->with('profile')->findByPk($user->pid); $openlog = WebmasterLog::model()->findByAttributes(array('order_id' => $model->id), 'action = :p1 OR action = :p2', array(':p1' => WebmasterLog::FIRST_ORDER, ':p2' => WebmasterLog::NON_FIRST_ORDER)); $webmasterlog = new WebmasterLog(); $webmasterlog->pid = $user->pid; $webmasterlog->uid = $user->id; $webmasterlog->date = date("Y-m-d"); $webmasterlog->order_id = $model->id; if ($openlog->action == WebmasterLog::FIRST_ORDER) { $webmasterlog->action = WebmasterLog::FINISH_FIRST_ORDER_SUCCESS; } elseif ($openlog->action == WebmasterLog::NON_FIRST_ORDER) { $webmasterlog->action = WebmasterLog::FINISH_NON_FIRST_ORDER_SUCCESS; } $webmasterlog->save(); // Pament for webmaster ~~~~~~~~~~~~~~~~~~~~~~~~~~ $payment = ProjectPayments::model()->find('order_id = :ORDER_ID', array(':ORDER_ID' => $model->id)); $manag = User::model()->findByPk(Yii::app()->user->id); $buh = new Payment(); $buh->order_id = $model->id; $buh->receive_date = date('Y-m-d'); $buh->theme = $model->title; $buh->user = $webmaster->email; $buh->details_ya = $webmaster->profile->yandex; $buh->details_wm = $webmaster->profile->wmr; $buh->details_bank = $webmaster->profile->bank_account; $buh->payment_type = Payment::OUTCOMING_WEBMASTER; $buh->manager = $manag->email; //$buh->approve = 0; $buh->method = 'Cash or Bank'; if ($openlog->action == WebmasterLog::FIRST_ORDER) { $buh->summ = (double) $payment->project_price * Company::getWebmasterFirstOrderRate(); } elseif ($openlog->action == WebmasterLog::NON_FIRST_ORDER) { $buh->summ = (double) $payment->project_price * Company::getWebmasterSecondOrderRate(); } $buh->save(); } } $this->redirect(array('update', 'id' => $model->id)); } elseif (Yii::app()->request->getParam('open') == 'yes') { $model->status = $model->old_status; $model->save(false); $this->redirect(array('update', 'id' => $model->id)); } elseif (Yii::app()->request->getParam('refound') == 'yes') { $model->old_status = $model->status; $model->status = 5; $model->save(false); $user = User::model()->findByPk($model->user_id); // Refound ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $manag = User::model()->findByPk(Yii::app()->user->id); $payment = ProjectPayments::model()->find('order_id = :ORDER_ID', array(':ORDER_ID' => $model->id)); if ($payment && $payment->received > 0) { $refound = $payment->received; $payment->received = 0; $payment->save(); $buh = new Payment(); $buh->order_id = $model->id; $buh->receive_date = date('Y-m-d'); $buh->theme = $model->title; $buh->user = $user->email; $buh->summ = (double) $refound; $buh->payment_type = Payment::OUTCOMING_CUSTOMER; $buh->manager = $manag->email; //$buh->approve = 0; $buh->method = 'Cash or Bank'; $buh->save(); } if ($user->pid) { $webmasterlog = new WebmasterLog(); $webmasterlog->pid = $user->pid; $webmasterlog->uid = $user->id; $webmasterlog->date = date("Y-m-d"); $webmasterlog->order_id = $model->id; $openlog = WebmasterLog::model()->findByAttributes(array('order_id' => $model->id), 'action = :p1 OR action = p2', array(':p1' => WebmasterLog::FIRST_ORDER, ':p2' => WebmasterLog::NON_FIRST_ORDER)); if ($openlog->action == WebmasterLog::FIRST_ORDER) { $webmasterlog->action = WebmasterLog::FINISH_FIRST_ORDER_FAILURE; } elseif ($openlog->action == WebmasterLog::NON_FIRST_ORDER) { $webmasterlog->action = WebmasterLog::FINISH_NON_FIRST_ORDER_FAILURE; } else { echo 'Somthing wrong...'; Yii::app()->end(); } $webmasterlog->save(); } $this->redirect(array('update', 'id' => $model->id)); } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Zakaz'])) { $model->attributes = $_POST['Zakaz']; if (isset($_POST['Zakaz']['dbdate'])) { $model->dbdate = $_POST['Zakaz']['dbdate']; } $projectFields = $model->getFields(); if ($projectFields) { foreach ($projectFields as $field) { if ($field->field_type == "TIMESTAMP") { // ---------------------------------------------------- $tmp = $field->varname; if (isset($_POST['Zakaz'][$tmp])) { $model->{$tmp} = $_POST['Zakaz'][$tmp]; $model->timestampInput($field); } } } } if ($model->save()) { if (Yii::app()->request->getParam('accepted') && User::model()->isCorrector()) { EventHelper::correctorAccepted($model->id); } $role = User::model()->getUserRole(); if ($role != 'Manager' && $role != 'Admin') { // где-то есть дублрующий вызов записи события, поэтому этот комментируем // oldbadger 09.10.2015 // EventHelper::editOrder($model->id); //$view = 'orderInModerate'; $this->redirect(array("../project/chat?orderId={$id}")); } else { // $this->redirect(array('project/chat','orderId'=>$model->id)); $this->redirect(array('update', 'id' => $model->id)); } } } $managerlog = new ManagerLog(); $managerlog->uid = Yii::app()->user->id; $managerlog->action = ManagerLog::ORDER_PAGE_VIEW; $managerlog->datetime = date('Y-m-d H:i:s'); $managerlog->order_id = $model->id; $managerlog->save(); $hints = Templates::model()->getTemplateList(4); $view = 'update'; $isModified = false; $this->render($view, array('model' => $model, 'hints' => $hints, 'isModified' => $isModified)); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Payment::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
</div> <div class="row"> <div class="col-sm-12"> <div class="panel panel-default"> <div class="panel-heading"> <span class="panel-title"><?php echo Yii::t('OrderModule.order', 'Payment'); ?> </span> </div> <div class="panel-body"> <div class="row"> <div class="col-sm-4"> <?php echo $form->dropDownListGroup($model, 'payment_method_id', ['widgetOptions' => ['data' => CHtml::listData(Payment::model()->published()->findAll(), 'id', 'name'), 'htmlOptions' => ['empty' => Yii::t('OrderModule.order', 'Not selected')]]]); ?> </div> <div class="col-sm-2"> <br/> <?php echo $form->checkBoxGroup($model, 'paid'); ?> </div> <div class="col-sm-6 text-right"> <br/> <h4> <?php echo Yii::t('OrderModule.order', 'Total'); ?> : <?php
public static function getLogsSumm($pid, $start_date, $finish_date) { $sql_dates = "select * from \n\t\t\t(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) `date` from\n\t\t\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,\n\t\t\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,\n\t\t\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,\n\t\t\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,\n\t\t\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v\n\t\t\twhere `date` between '{$start_date}' and '{$finish_date}'"; $sql_unigue = 'SELECT date as date0, COUNT(*) AS `unique` FROM ' . self::staticTableName() . ' WHERE pid = :pid AND action = ' . self::PARTNER_UNIQUE . ' AND date >= :start_date AND date <= :finish_date GROUP BY date'; $sql_sales_first = 'SELECT date as date1, COUNT(*) AS `sales_first` FROM ' . self::staticTableName() . ' WHERE pid = :pid AND action = ' . self::FULL_PAYMENT_4_FIRST_ORDER . ' AND date >= :start_date AND date <= :finish_date GROUP BY date'; $sql_sales_repeat = 'SELECT date as date2, COUNT(*) AS `sales_repeat` FROM ' . self::staticTableName() . ' WHERE pid = :pid AND action = ' . self::FULL_PAYMENT_4_NON_FIRST_ORDER . ' AND date >= :start_date AND date <= :finish_date GROUP BY date'; $sql_completed_first = 'SELECT date as date3, COUNT(*) AS `completed_first` FROM ' . self::staticTableName() . ' WHERE pid = :pid AND action = ' . self::FINISH_FIRST_ORDER_SUCCESS . ' AND date >= :start_date AND date <= :finish_date GROUP BY date'; $sql_completed_repeat = 'SELECT date as date4, COUNT(*) AS `completed_repeat` FROM ' . self::staticTableName() . ' WHERE pid = :pid AND action = ' . self::FINISH_NON_FIRST_ORDER_SUCCESS . ' AND date >= :start_date AND date <= :finish_date GROUP BY date'; $sql_profit = 'SELECT date as date5, SUM(summ) as `profit` FROM ' . self::staticTableName() . ' t51 LEFT OUTER JOIN ' . Payment::model()->tableName() . ' t52 ON t51.order_id = t52.order_id WHERE pid = :pid AND action = ' . self::FINISH_NON_FIRST_ORDER_SUCCESS . ' AND date >= :start_date AND date <= :finish_date AND payment_type = ' . Payment::OUTCOMING_WEBMASTER . ' GROUP BY date'; $sql = 'SELECT `date`, `unique`, `sales_first`, `sales_repeat`, `completed_first`, `completed_repeat`, `profit` FROM (' . $sql_dates . ') t LEFT OUTER JOIN (' . $sql_unigue . ') t0 ON date=date0 LEFT OUTER JOIN (' . $sql_sales_first . ') t1 ON date=date1 LEFT OUTER JOIN (' . $sql_sales_repeat . ') t2 ON date=date2 LEFT OUTER JOIN (' . $sql_completed_first . ') t3 ON date=date3 LEFT OUTER JOIN (' . $sql_completed_repeat . ') t4 ON date=date4 LEFT OUTER JOIN (' . $sql_profit . ') t5 ON date=date5'; $command = Yii::app()->db->createCommand($sql); $command->bindParam(':pid', $pid, PDO::PARAM_INT); $command->bindParam(":start_date", $start_date, PDO::PARAM_STR); $command->bindParam(":finish_date", $finish_date, PDO::PARAM_STR); return $command->queryAll(); }
public function actionCancelTransaction() { // Ajax approve in actionView $this->_prepairJson(); $id = $this->_request->getParam('id'); $method = $this->_request->getParam('method'); if (!$method) { $method = 'Cash'; } $payment = Payment::model()->findByPk($id); if (!$payment) { $this->_response->setData(array('result' => false, 'message' => 'Not found')); Yii::app()->end(); } $this->_response->setData(array('result' => $payment->cancelPayment($method))); $this->_response->send(); }
<td><?php echo $v->challan->date_time_offence; ?> </td> <td><?php echo $v->challan->name_person; ?> </td> <td><?php echo CHtml::link('<i class="icon-eye-open"></i>', array('challanAssignments/viewchallan&id=' . $v->challan->id), array('class' => '', 'data-original-title' => 'View Challan', 'rel' => 'tooltip', 'target' => '_blank')); ?> </td> <td> <?php if ($v->status == "Paid") { $payment = Payment::model()->findByAttributes(array("dispatch_id" => $v->id)); echo $payment->rupee . " Paid"; } else { ?> <input type="text" id="rupee-<?php echo $v->id; ?> " style="width:100px;" /> <?php } ?> </td> <td> <?php if ($v->status != "Paid") {
function cardtypeAction() { $clearArray = array('campaign_id', 'detail_dates', 'currency_id', 'country_id'); $this->filter($clearArray); if (!isset($this->params['r_dates'])) { $today = date("d.m.Y"); $this->params['r_dates'] = $today . '-' . $today; } $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true)); $models = isset($this->params['download_csv']) ? AFActiveDataProvider::models('Payment', $this->params) : AFActiveDataProvider::models('Payment', $this->params, $pagination); $filterFields = $models->getoutFilterFields($clearArray, array('r_dates')); $campaigns = isset($filterFields['campaign_id']) ? $filterFields['campaign_id'] : null; $country_id = isset($filterFields['country_id']) ? $filterFields['country_id'] : null; $currency_id = isset($filterFields['currency_id']) ? $filterFields['currency_id'] : null; $msql = SafeMySQL::getInstance(); if ($campaigns) { $models->setWhere($msql->parse(" AND `c`.`campaign_id` IN (?a)", $campaigns), 'campaign_id'); } if ($currency_id) { $models->setWhere($msql->parse(" AND `c`.`campaign_id` IN ( select campaign_id from campaigns where currency_id in (?a))", $currency_id), 'currency_id'); } if ($country_id) { $models->setWhere($msql->parse(" AND `c`.`campaign_id` IN ( select campaign_id from campaigns where country_id in (?a))", $country_id), 'country_id'); } $groupDate = !isset($this->params['detail_dates']) ? false : true; $dataProvider = $models->getCardTypeReport($groupDate); $total = $models->getTotalCardTypeReport(); $subTotal = $models->getSubTotalCardTypeReport(); $fields = array('gateway_alias', 'campaign_name', 'ccard_type', 'count'); // build filter select datasources $currencies = Currency::model()->cache()->findAllInArray(); $countries = Country::model()->cache()->findAllInArray(); $campaigns = $models->getCardTypeReportCampaigns(); if (isset($this->params['detail_dates'])) { array_unshift($fields, 'created'); } // set ajax table if (AF::isAjaxRequestModels()) { $this->view->includeFile('_cardtype_table', array('application', 'views', 'reports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'total' => $total, 'subTotal' => $subTotal, 'fields' => $fields, 'campaigns' => $campaigns, 'currencies' => $currencies, 'countries' => $countries)); die; } // CSV if (isset($this->params['download_csv'])) { $csv = array(); $headers = array(); // build header $labels = Payment::model()->attributeLabels(); foreach ($fields as $f) { $headers[] = $labels[$f]; } $csv[] = $headers; // build report rows foreach ($dataProvider as $dp) { $row = array(); foreach ($fields as $f) { $row[] = $dp->{$f}; } $csv[] = $row; } // if subtotal, build row if ($subTotal) { foreach ($subTotal as $st) { $row = array(); foreach ($fields as $f) { if ($f == 'ccard_type') { $row[] = $st[$f]; } else { $row[] = $f != 'count' ? '' : $st[$f]; } } $csv[] = $row; } } // if total, build row if ($total) { $row = array(); foreach ($fields as $f) { if ($f == 'ccard_type') { $row[] = 'Total'; } else { $row[] = $f != 'count' ? '' : $total[$f]; } } $csv[] = $row; } self::csvReport($csv, 'CardType'); die; } $this->addToPageTitle(__('sales_by_cardtype')); Assets::css('jquery-ui'); Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js'); Assets::js('dateRange/jquery.daterange'); Assets::js('ajax_table'); $this->render('cardtype', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'models' => $models, 'filterFields' => $filterFields, 'campaigns' => $campaigns, 'total' => $total, 'subTotal' => $subTotal, 'currencies' => $currencies, 'countries' => $countries, 'fields' => $fields)); }
<?php echo $form->labelEx($model, 'last_update'); ?> <?php echo $form->textField($model, 'last_update'); ?> <?php echo $form->error($model, 'last_update'); ?> </div><!-- row --> <label><?php echo GxHtml::encode($model->getRelationLabel('payments')); ?> </label> <?php echo $form->checkBoxList($model, 'payments', GxHtml::encodeEx(GxHtml::listDataEx(Payment::model()->findAllAttributes(null, true)), false, true)); ?> <label><?php echo GxHtml::encode($model->getRelationLabel('rentals')); ?> </label> <?php echo $form->checkBoxList($model, 'rentals', GxHtml::encodeEx(GxHtml::listDataEx(Rental::model()->findAllAttributes(null, true)), false, true)); ?> <?php echo GxHtml::submitButton('Save'); $this->endWidget(); ?> </div><!-- form -->
public function handleReturn() { $transactionId = @$_GET['ti']; $errorCode = @$_GET['ec']; $errorMessage = @$_GET['em']; $cardNumber = @$_GET['cardno']; $merchantSession = @$_GET["ms"]; $payment = Payment::model()->findByAttributes(array("session_id" => $merchantSession)); return $payment; }
/** *【用户中心】获取订单详情【用户中心订单展示】. * @param $userId * @param $order_sn */ public function getUserOrderInfoBySn($userId, $order_sn) { if (empty($order_sn)) { throw new exception('订单号不能为空', 302); } $oInfo = Order::model()->findByAttributes(array('order_sn' => $order_sn)); if (empty($oInfo)) { throw new exception('订单不存在', 302); } if ($userId != $oInfo->user_id) { throw new exception('订单和数据部匹配', 302); } $oInfo = $oInfo->getAttributes(); $oInfo['order_status_txt'] = $this->getOrderStatus($oInfo['order_status']); $addressData = array($oInfo['province'], $oInfo['city'], $oInfo['district']); $addData = Region::model()->getRegionInfoByIds($addressData); if (!empty($addData)) { $oInfo['province_name'] = isset($addData[$oInfo['province']]) ? $addData[$oInfo['province']]['region_name'] : ''; $oInfo['city_name'] = isset($addData[$oInfo['city']]) ? $addData[$oInfo['city']]['region_name'] : ''; $oInfo['district_name'] = isset($addData[$oInfo['district']]) ? $addData[$oInfo['district']]['region_name'] : ''; } else { $oInfo['province_name'] = ''; $oInfo['city_name'] = ''; $oInfo['district_name'] = ''; } if ($oInfo['shipping_id']) { $shippingInfo = Shipping::model()->findByPk($oInfo['shipping_id']); $oInfo['shipping_name'] = empty($shippingInfo) ? '暂无快递信息' : $shippingInfo->shipping_name; } if ($oInfo['pay_id']) { $payInfo = Payment::model()->findByPk($oInfo['pay_id']); $oInfo['payment_name'] = empty($payInfo) ? '暂无快递信息' : $payInfo->pay_name; } $oInfo['need_pay_amount'] = $oInfo['product_amount'] + $oInfo['shipping_fee'] - $oInfo['coupon_amount'] - $oInfo['discount'] - $oInfo['pay_amount']; return $oInfo; }
public function paymentTypewiseSummary(&$rsltObject, $personid, $loginid, $roleid, $date = null) { $ttlCashSales = 0; $rsltObject->cashsummary = array(); foreach(Yii::app()->controller->paymenttypes as $paymenttype) { $criteria=new CDbCriteria; $criteria->select = array( new CDbExpression("IFNULL(SUM(t.amount),0) as tmptotal"), ); $condition = " LCASE(type) = '" . strtolower($paymenttype) . "'"; $criteria->addCondition($condition); if(!empty($date)) { $condition = " DATE(created_at) = DATE('". $date . "')"; } else { $condition = "DATE(created_at) = DATE(NOW())"; } $criteria->addCondition($condition); $condition = "person_id = " . $personid; $criteria->addCondition($condition); $result = Payment::model()->findAll($criteria); foreach($result as $row) { $rsltObject->cashsummary[] = array($paymenttype, $row->tmptotal); if($paymenttype == Helper::CONST_Cash) { $ttlCashSales = $row->tmptotal; } break; } } $rsltObject->ttlcashSales = $ttlCashSales; $this->getRegisterOPBalance($rsltObject, $loginid, $roleid); $this->getRegisterCLBalance($rsltObject, $loginid, $roleid); $rsltObject->expectedCB = $rsltObject->ttlcashSales + $rsltObject->op_balance; }
public function actionPaymentSystemSettings() { $payment = Payment::model()->findByPk(Yii::app()->request->getParam('payment_id')); $this->renderPartial('_payment_system_settings', ['paymentSystem' => Yii::app()->request->getParam('payment_system'), 'paymentSettings' => $payment ? $payment->getPaymentSystemSettings() : []]); }
<?php echo Yii::t('OrderModule.order', 'Orders'); ?> <small><?php echo Yii::t('OrderModule.order', 'manage'); ?> </small> </h1> </div> <?php $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'order-grid', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'datePickers' => ['Order_date'], 'afterAjaxUpdate' => 'reinstallDatePicker', 'columns' => [['name' => 'id', 'htmlOptions' => ['width' => '90px'], 'type' => 'raw', 'value' => function ($data) { return CHtml::link($data->id, ["/order/orderBackend/update", "id" => $data->id]); }], ['name' => 'date', 'type' => 'html', 'filter' => $this->widget('booster.widgets.TbDatePicker', ['model' => $model, 'attribute' => 'date', 'options' => ['format' => 'yyyy-mm-dd'], 'htmlOptions' => ['class' => 'form-control']], true), 'value' => function ($data) { return CHtml::link(Yii::app()->getDateFormatter()->formatDateTime($data->date, 'medium'), ["/order/orderBackend/update", "id" => $data->id]); }], ['name' => 'name', 'type' => 'raw', 'value' => function ($data) { return isset($data->client) ? CHtml::link($data->client->getFullName(), ['/order/clientBackend/view', 'id' => $data->user_id]) : $data->name; }, 'htmlOptions' => ['width' => '400px']], ['name' => 'total_price', 'value' => function ($data) { return Yii::app()->getNumberFormatter()->formatCurrency($data->total_price, Yii::app()->getModule('store')->currency); }], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'status_id', 'url' => $this->createUrl('/order/orderBackend/inline'), 'source' => OrderHelper::statusList(), 'options' => OrderHelper::labelList()], ['name' => 'payment_method_id', 'value' => function ($data) { return $data->payment ? $data->payment->name : '---'; }, 'filter' => CHtml::listData(Payment::model()->findAll(), 'id', 'name')], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'paid', 'url' => $this->createUrl('/order/orderBackend/inline'), 'source' => $model->getPaidStatusList(), 'options' => [Order::PAID_STATUS_NOT_PAID => ['class' => 'label-danger'], Order::PAID_STATUS_PAID => ['class' => 'label-success']]], ['name' => 'delivery_id', 'header' => Yii::t('OrderModule.order', 'Delivery'), 'filter' => CHtml::listData(Delivery::model()->findAll(), 'id', 'name'), 'value' => function (Order $data) { return $data->delivery->name; }], ['name' => 'manager_id', 'type' => 'raw', 'filter' => CHtml::listData(User::model()->findAll('access_level = :level', [':level' => User::ACCESS_LEVEL_ADMIN]), 'id', 'fullName'), 'value' => function ($data) { return isset($data->manager) ? \yupe\helpers\YText::shortName($data->manager->getFullName()) : null; }], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'buttons' => ['update' => ['visible' => function ($row, Order $order) { return $order->checkManager(Yii::app()->getUser()); }], 'delete' => ['visible' => function ($row, Order $order) { return $order->checkManager(Yii::app()->getUser()); }]]]]]);
public function actionApproveFromBookkeeper() { $this->_prepairJson(); $id = $this->_request->getParam('id'); $method = $this->_request->getParam('method'); if (!$method) { $method = 'Cash'; } $payment = Payment::model()->findByPk($id); if (!$payment) { $this->_response->setData(array('result' => false, 'message' => 'Not found')); Yii::app()->end(); } $this->_response->setData(array('result' => $payment->approveFromBookkeeper($method))); $this->_response->send(); }