当前位置: 首页>>代码示例>>PHP>>正文


PHP Payment::save方法代码示例

本文整理汇总了PHP中Payment::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::save方法的具体用法?PHP Payment::save怎么用?PHP Payment::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Payment的用法示例。


在下文中一共展示了Payment::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logToReceiptRecords

 public static function logToReceiptRecords($f)
 {
     $file_db = new PDO('sqlite:' . $f);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $result = $file_db->query('SELECT * FROM transactions;');
     $receiptNO = "";
     foreach ($result as $m) {
         $receiptNo = $m["receiptNo"];
     }
     $receiptlines = ReceiptLine::where('receiptNo', $receiptNo)->get();
     foreach ($receiptlines as $receiptline) {
         ReceiptLine::destroy($receiptline->id);
     }
     $receiptRecords = Receiptrecord::where(['receiptNo' => $receiptNo, 'progress' => '提供済み'])->get();
     foreach ($receiptRecords as $receiptRecord) {
         $receiptRecord->payment_id = $m['payment_id'];
         $receiptRecord->progress = "支払い済み";
         $receiptRecord->save();
     }
     $file_db = new PDO('sqlite:' . $f);
     $file_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $result = $file_db->query('SELECT * FROM payments;');
     foreach ($result as $m) {
         $payment = new Payment();
         $payment->price = $m["price"];
         $payment->payment = $m["payment"];
         $payment->changes = $m["changes"];
         $payment->time = $m["time"];
         $payment->uuid = $m["uuid"];
         $payment->shopName = $m["shopName"];
         $payment->employeeName = $m["employeeName"];
         $payment->save();
     }
     //        unlink($f);
 }
开发者ID:noikiy,项目名称:posco-laravel-server,代码行数:35,代码来源:CashierReceiver.php

示例2: postPayment

 public function postPayment()
 {
     // Step 1: Check if the request contains required fields
     if (!$this->validatePaymentRequest()) {
         $this->response->addMessage('Invalid Payment Request.');
         return $this->output();
     }
     // Step 2: Validation passed -> Create new payment
     $payment = new \Payment();
     $payment->payment_amount_ex_vat = $this->data['payment_amount_ex_vat'];
     $payment->vat_amount = $this->data['vat_amount'];
     $payment->gratuity_amount = isset($this->data['gratuity_amount']) ? $this->data['gratuity_amount'] : 0;
     $payment->branch_id = $this->data['branch_id'];
     $payment->payment_vendor_id = $this->data['payment_vendor_id'];
     $payment->employee_id = $this->data['employee_id'];
     $payment->order_id = $this->data['order_id'];
     $payment->payment_taken_at = $this->data['payment_taken_at'];
     $payment->terminal_id = $this->data['terminal_id'];
     $payment->created_at = \Carbon\Carbon::now();
     // Step 3: Save the payment into the database
     if ($payment->save()) {
         $this->response->setSuccess(1);
         $this->response->setPaymentId($payment->id);
         return $this->output();
     }
 }
开发者ID:salmander,项目名称:flypay_restaurant_api,代码行数:26,代码来源:FlyPay.php

示例3: bankReturn

 /**
  * @param Response $response
  * @return OrderInterface
  */
 public function bankReturn(Response $response)
 {
     $this->status = $response->isSuccessful() ? 'paid' : 'error';
     $this->save();
     // log bank return
     $log = new Payment(['user_id' => $this->user_id, 'order_id' => $this->id, 'bank_code' => $response->getAdapter()->adapterTag, 'amount' => $this->due_amount, 'status' => $this->status, 'data_dump' => $response->__toString(), 'created' => new Expression('NOW()')]);
     $log->save();
     return $this;
 }
开发者ID:Hrachkhachatryan,项目名称:yii2,代码行数:13,代码来源:Order.php

示例4: add

 public static function add($input)
 {
     // init
     $total_donation = 0;
     $currency = 'IDR';
     // get payment ids
     $donation_ids = explode(',', $input['donation_ids']);
     unset($input['donation_ids']);
     // compare total of donation with total of payment
     $donations = Donation::whereIn('id', $donation_ids)->get();
     foreach ($donations as $donation) {
         $total_donation += $donation->total;
         $currency = $donation->currency;
     }
     if ($total_donation > $input['total']) {
         return array('success' => false, 'errors' => array('Total yang Anda inputkan tidak sama dengan total donasi Anda. Jika Anda ingin melakukan perubahan donasi silahkan batalkan donasi sebelumnya dan lakukan donasi kembali.'));
     } else {
         if ($currency != $input['currency']) {
             return array('success' => false, 'errors' => array('Mata uang yang Anda inputkan tidak sama dengan mata uang donasi Anda. Jika Anda ingin melakukan perubahan donasi silahkan batalkan donasi sebelumnya dan lakukan donasi kembali.'));
         }
     }
     // set rules
     $rules = array('user_id' => 'required|exists:users,id', 'currency' => 'required', 'transferred_at' => 'required|numeric', 'total' => 'required|numeric', 'to_bank' => 'required|max:100', 'bank_name' => 'required|max:40', 'bank_account' => 'required|max:25', 'bank_account_name' => 'required|max:40', 'message' => '');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         // if fails
         return array('success' => false, 'errors' => $validator->errors()->all());
     } else {
         // save to database
         $payment = new Payment();
         // set input
         foreach ($input as $field => $value) {
             $payment->{$field} = $value;
         }
         $payment->status = 0;
         // new (waiting approval)
         $payment->save();
         // update donation
         foreach ($donation_ids as $donation_id) {
             $donation = Donation::find($donation_id);
             $donation->payment_id = $payment->id;
             $donation->save();
         }
         // send email
         $payment = Payment::with(array('user', 'donations'))->find($payment->id);
         // set type for each donation
         foreach ($payment->donations as $donation) {
             $donation->setAppends(array('type'));
         }
         // send email to donor
         Newsletter::addPaymentNewsletter($payment);
         return array('success' => true, 'data' => $payment);
     }
 }
开发者ID:whiterun,项目名称:bagikasih-v2,代码行数:54,代码来源:Payment.php

示例5: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Payment();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Payment'])) {
         $model->attributes = $_POST['Payment'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->payment_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:lhfcainiao,项目名称:basic,代码行数:17,代码来源:PaymentController.php

示例6: getPaymentUrl

 public function getPaymentUrl($invoice_id, $options = array())
 {
     $invoice = Invoice::model()->findByPk($invoice_id);
     if ($invoice == null) {
         return false;
     }
     if ($invoice->customer_id != Yii::app()->user->getId()) {
         return false;
     }
     $amount = $invoice->amount;
     $amount = $amount * 100;
     $merchantSession = urlencode(time() . '-' . $this->makePaystationSessionID(8, 8));
     $this->setSessionId($merchantSession);
     $this->merchantRef = Yii::app()->user->getId();
     $paystationUrl = "https://www.paystation.co.nz/direct/paystation.dll";
     $paystationParameters = "paystation=_empty&pstn_pi=" . $this->paystationId . "&pstn_gi=" . $this->gatewayId . "&pstn_ms=" . $merchantSession . "&pstn_mr=" . $this->merchantRef . "&pstn_am=" . $amount . "&pstn_nr=t";
     if ($this->testMode == 'true') {
         $paystationParameters = $paystationParameters . "&pstn_tm=t";
     }
     foreach ($options as $key => $value) {
         $paystationParameters .= "&" . $key . "=" . $value;
     }
     $result = $this->doPostRequest($paystationUrl, $paystationParameters);
     // handle result
     $xmlData = new SimpleXMLElement($result);
     $digitalOrder = $xmlData->DigitalOrder;
     // The URL that we re-direct the customer too.
     $transactionID = $xmlData->PaystationTransactionID;
     //The transaction ID Paystation has just created.
     $PaymentRequestTime = $xmlData->PaymentRequestTime;
     // The time that the transaction was initiated
     $DigitalOrderTime = $xmlData->DigitalOrderTime;
     //The time Paystation responds
     // redirect
     if ($digitalOrder) {
         $payment = new Payment();
         $payment->transaction_id = $transactionID;
         $payment->session_id = $merchantSession;
         $payment->order_time = $DigitalOrderTime;
         $payment->merchant_ref = $this->merchantRef;
         $payment->customer_id = Yii::app()->user->getId();
         $payment->invoice_id = $invoice_id;
         $payment->save(false);
         return $digitalOrder;
     } else {
         //echo "<pre>".htmlentities($result)."</pre>"; //no digitalorder variable, so initiation must have failed.  Print out xml packet for debugging purposes
         return false;
     }
     return false;
 }
开发者ID:huynt57,项目名称:vs,代码行数:50,代码来源:PayStation.php

示例7: actionCreate

 public function actionCreate()
 {
     $model = new Payment();
     if (isset($_POST['Payment'])) {
         $model->setAttributes($_POST['Payment']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('view', 'id' => $model->payment_id));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:schmunk42,项目名称:yii-sakila-crud,代码行数:15,代码来源:PaymentController.php

示例8: store

 /**
  * Store a newly created payment in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Payment::$rules, Payment::$messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $payment = new Payment();
     $payment->erporder_id = Input::get('order');
     $payment->amount_paid = Input::get('amount');
     $payment->receipt_no = Input::get('receipt');
     $payment->received_by = Input::get('received_by');
     $payment->date = date("Y-m-d", strtotime(Input::get('pay_date')));
     $payment->save();
     return Redirect::route('payments.index')->withFlashMessage('Payment successfully created!');
 }
开发者ID:kenkode,项目名称:xaraerp,代码行数:20,代码来源:PaymentsController.php

示例9: actionAdd

 public function actionAdd()
 {
     if (empty($_POST)) {
         $viewData = array();
         $this->render('add', $viewData);
         exit;
     }
     $res = array('statusCode' => 200, 'message' => '添加成功!');
     try {
         $imageConfig = Yii::app()->params['image']['bank'];
         if (empty($imageConfig)) {
             throw new exception('缺少商品图片配置');
         }
         $image = CUploadedFile::getInstanceByName('payment_logo');
         $imageNamePath = '';
         if ($image) {
             $imageName = date('YmdHis') . rand(1, 1000);
             $imageNamePath = $imageConfig['path'] . $imageName . '.' . $image->getExtensionName();
             $image->saveAs($imageNamePath, true);
         }
         $payment = new Payment();
         $payment->pay_code = $_POST['pay_code'];
         $payment->pay_name = $_POST['pay_name'];
         if ($imageNamePath) {
             $payment->payment_logo = str_replace(ROOT_PATH . '/images/bank/', '', $imageNamePath);
         }
         $payment->keya = $_POST['keya'];
         $payment->keyb = $_POST['keyb'];
         $payment->is_valid = $_POST['is_valid'];
         $payment->is_plat = $_POST['is_plat'];
         $payment->sort = $_POST['sort'];
         $flag = $payment->save();
         if (!$flag) {
             throw new exception('添加失败');
         }
     } catch (Exception $e) {
         $res['statusCode'] = 300;
         $res['message'] = '失败【' . $e->getMessage() . '】';
     }
     $res['navTabId'] = 'paymentList';
     $res['callbackType'] = 'closeCurrent';
     $res['forwardUrl'] = '/manage/payment/index';
     $this->ajaxDwzReturn($res);
 }
开发者ID:conghua1013,项目名称:yii,代码行数:44,代码来源:PaymentController.php

示例10: testDestroyAssociatedRecords

 function testDestroyAssociatedRecords()
 {
     $c = new Company();
     $c->set(array('name' => 'destroy_test'));
     $c->save();
     $p = new Project();
     $p->set(array('company_id' => $c->id, 'name' => 'destroy_project_test'));
     $p->save();
     $e = new Estimate();
     $e->set(array('project_id' => $p->id, 'name' => 'destroy_estimate_test'));
     $e->save();
     $h = new Hour();
     $h->set(array('estimate_id' => $e->id, 'name' => 'destroy_hour_test'));
     $h->save();
     $ch = new Charge();
     $ch->set(array('company_id' => $c->id, 'name' => 'destroy_charge_test'));
     $ch->save();
     $con = new SupportContract();
     $con->set(array('company_id' => $c->id, 'name' => 'destroy_contract_test'));
     $con->save();
     $sup_hr = new Hour();
     $sup_hr->set(array('support_contract_id' => $con->id, 'description' => 'destroy_support_hour_test'));
     $sup_hr->save();
     $pay = new Payment();
     $pay->set(array('company_id' => $c->id, 'name' => 'destroy_payment_test'));
     $pay->save();
     $deleted_items = array('company' => $c->id, 'project' => $p->id, 'estimate' => $e->id, 'hour' => $h->id, 'support_hour' => $sup_hr->id, 'charge' => $ch->id, 'support_contract' => $con->id, 'payment' => $pay->id);
     $c->destroyAssociatedRecords();
     $c->delete();
     $dbcon = AMP::getDb();
     foreach ($deleted_items as $table => $id) {
         if ($table == 'support_hour') {
             $table = 'hour';
         }
         $sql = 'SELECT * FROM ' . $table . ' WHERE id = ' . $id;
         if ($records = $dbcon->Execute($sql)) {
             $this->assertEqual($records->RecordCount(), 0, "{$table} not deleted correctly: %s");
         } else {
             trigger_error($dbcon->ErrorMsg());
         }
     }
 }
开发者ID:radicaldesigns,项目名称:gtd,代码行数:42,代码来源:model_tests.php

示例11: actionCreate

 public function actionCreate()
 {
     $model = new Payment();
     if (Yii::app()->getRequest()->getIsPostRequest() && isset($_POST['Payment'])) {
         $model->setAttributes(Yii::app()->getRequest()->getPost('Payment'));
         $model->setPaymentSystemSettings(Yii::app()->getRequest()->getPost('PaymentSettings', []));
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('PaymentModule.payment', 'Record was created!'));
             if (!isset($_POST['submit-type'])) {
                 $this->redirect(['update', 'id' => $model->id]);
             } else {
                 $this->redirect([$_POST['submit-type']]);
             }
         }
     }
     //@TODO вынести в метод модели
     $criteria = new CDbCriteria();
     $criteria->select = new CDbExpression('MAX(position) as position');
     $max = $model->find($criteria);
     $model->position = $max->position + 1;
     $this->render('create', ['model' => $model]);
 }
开发者ID:alextravin,项目名称:yupe,代码行数:22,代码来源:PaymentBackendController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  * POST /accountreceivables
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('invoiceID' => 'required|max:50|', 'houseID' => 'required', 'amount' => 'required|min:2', 'paymenttype' => 'required', 'amountpayed' => 'required', 'paymenttyperef' => 'required'));
     if ($v->passes()) {
         $gamount = Input::get('amount');
         $gpayed = Input::get('amountpayed');
         $initpaid = Input::get('initpaid');
         $id = Input::get('invoiceID');
         $balance = $gamount - $gpayed;
         $invoice = Invoice::find($id);
         $invoice->balance = $gamount - $gpayed;
         $invoice->amountpaid = $gpayed + $initpaid;
         $invoice->save();
         $payment = new Payment();
         $payment->invoiceID = Input::get('invoiceID');
         $payment->amount = Input::get('amount');
         $payment->amountpayed = Input::get('amountpayed');
         $payment->houseID = Input::get('houseID');
         $payment->balance = $gamount - $gpayed;
         $payment->paymenttype = Input::get('paymenttype');
         $payment->paymenttyperef = Input::get('paymenttyperef');
         $payment->save();
         #send an sms to the tenant
         $findTenant = $invoice->recipient;
         $tenants = Tenant::where('name', $findTenant)->get();
         foreach ($tenants as $tenant) {
             $t_name = $tenant->name;
             $to = $tenant->phone;
         }
         $message = ' Hi ' . $t_name . ', Your invoivce Payment  of amount: Ksh. ' . number_format($gpayed, 2) . ' has been received  due balance ' . number_format($balance, 2) . ', Thank you for Choosing us';
         LaravelAtApi::sendMessage($to, $message);
         return Redirect::route('admin.invoice.show', $id);
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
开发者ID:jeremiteki,项目名称:mteja,代码行数:42,代码来源:PaymentController.php

示例13: actionUpdate

 /**
  * 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;
//.........这里部分代码省略.........
开发者ID:akoch-ov,项目名称:dipstart-development,代码行数:101,代码来源:ZakazController.php

示例14: charges_store

 public function charges_store()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $collector = Collector::where('user_id', '=', $user_id)->where('urbanism_id', '=', $urbanism->id)->first();
     $ano = date("Y");
     $neighbor = Input::get('valorid');
     $amount = Input::get('amount');
     $income_charge = new Payment();
     $income_charge->neighbor_property_id = $neighbor;
     $income_charge->collector_id = $collector->id;
     $income_charge->amount = $amount;
     $income_charge->sub_account_id = Input::get('sub_account_id');
     $income_charge->coments = Input::get('coments');
     $income_charge->deposit = null;
     $income_charge->debt = null;
     $income_charge->status_id = 1;
     $income_charge->updated_at = date('Y') . '-01-01 ' . date('H:i:s');
     if ($income_charge->save()) {
         $neighbor_payments = $income_charge;
         $payment_state = PaymentStates::where('neighbor_property_id', '=', $neighbor)->where('year', '=', $ano)->orderBy('created_at', 'desc')->first();
         $months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
         $monthly_all = MonthlyFee::where('monthly_fee.urbanism_id', '=', $collector->urbanism_id)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->get();
         $monthly_ini = MonthlyFee::where('monthly_fee.urbanism_id', '=', $collector->urbanism_id)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->orderBy('monthly_fee.created_at', 'ASC')->pluck('since');
         $mes_ini = (int) date("m", strtotime($monthly_ini));
         $cuotas = array();
         foreach ($monthly_all as $cuota_mensual) {
             $ini = (int) date("m", strtotime($cuota_mensual->since));
             $fin = (int) date("m", strtotime($cuota_mensual->until));
             if ($cuota_mensual->until == NULL) {
                 $fin = (int) date("m");
             }
             for ($i = $ini; $i <= $fin; $i++) {
                 $cuotas[$months[$i - 1]] = $cuota_mensual->amount;
             }
         }
         $acumulado = $amount;
         //para guardar el monto
         $ValorInicial = $amount;
         //para guardar el valor inicial del monto ingresado
         $ValorResto = 0;
         //para comparar con el valor inicial
         $balance = Balance::where('neighbor_property_id', '=', $neighbor)->pluck('amount');
         $balance_saldo = Balance::where('neighbor_property_id', '=', $neighbor)->first();
         if ($balance) {
             $saldo = $balance;
             if ($saldo > $amount) {
                 $saldo = $saldo - $amount;
                 $amount = 0;
                 $balance_saldo->amount = $saldo;
                 $balance_saldo->update(['id']);
             } else {
                 if ($saldo < $amount) {
                     $saldo = $amount - $saldo;
                     $amount = $saldo;
                     $balance_saldo->delete(['id']);
                 } else {
                     $saldo = 0;
                     $amount = 0;
                     $balance_saldo->delete(['id']);
                 }
             }
         } else {
             $saldo = 0;
         }
         //Si el usuario no ha realizado ningún pago, se llena la tabla Payment_States por primera vez
         if (!$payment_state) {
             $TotalCuotas = 0;
             $payment_state_detail = new PaymentStates();
             $payment_state_detail->neighbor_property_id = $neighbor_payments->neighbor_property_id;
             $payment_state_detail->year = date('Y', strtotime($neighbor_payments->created_at));
             //Ciclo hasta el mes actual
             for ($i = $mes_ini - 1; $i < date('m'); $i++) {
                 if (date('m') != $i + 1) {
                     if ($amount > $cuotas[$months[$i]]) {
                         $payment_state_detail->{$months}[$i] = $cuotas[$months[$i]];
                         $amount = $amount - $cuotas[$months[$i]];
                     } else {
                         if ($amount < $cuotas[$months[$i]] && $amount != 0) {
                             $payment_state_detail->{$months}[$i] = $amount;
                             $amount = 0;
                         } else {
                             $payment_state_detail->{$months}[$i] = $cuotas[$months[$i]];
                             $amount = 0;
                         }
                     }
                 } else {
                     //si es el mes actual
                     // for: suma todas las cuotas de cada mes, las q se deben
                     for ($j = $mes_ini - 1; $j < date('m'); $j++) {
                         if ($payment_state_detail->{$months}[$j] == null) {
                             $TotalCuotas = $TotalCuotas + $cuotas[$months[$j]];
                         } elseif ($payment_state_detail->{$months}[$j] < $cuotas[$months[$j]] && $payment_state_detail->{$months}[$j] > 0) {
                             $resto_mes = $cuotas[$months[$j]] - $payment_state_detail->{$months}[$j];
                             $TotalCuotas = $TotalCuotas + $resto_mes;
                         }
                     }
                     if ($TotalCuotas > $amount) {
                         $TotalCuotas = $TotalCuotas - $amount;
//.........这里部分代码省略.........
开发者ID:prianticonsulting,项目名称:Habitaria,代码行数:101,代码来源:IncomesController.php

示例15: postSave

 public function postSave()
 {
     $in = Input::get();
     //print_r($in);
     /*
     current_trx:3IseB
     cc_amount:
     cc_number:
     cc_expiry:
     dc_amount:
     dc_number:
     payable_amount:632500
     cash_amount:
     cash_change:
     */
     $trx = Payment::where('sessionId', $in['current_trx'])->first();
     //print_r($trx);
     if ($trx) {
     } else {
         $trx = new Payment();
         $trx->sessionId = $in['current_trx'];
         $trx->createdDate = new MongoDate();
         $trx->sessionStatus = 'open';
     }
     $trx->by_name = $in['by_name'];
     $trx->by_gender = $in['by_gender'];
     $trx->by_address = $in['by_address'];
     $trx->cc_amount = $in['cc_amount'];
     $trx->cc_number = $in['cc_number'];
     $trx->cc_expiry = $in['cc_expiry'];
     $trx->dc_amount = $in['dc_amount'];
     $trx->dc_number = $in['dc_number'];
     $trx->payable_amount = $in['payable_amount'];
     $trx->cash_amount = $in['cash_amount'];
     $trx->cash_change = $in['cash_change'];
     $trx->lastUpdate = new MongoDate();
     $trx->save();
     return Response::json(array('result' => 'OK'));
 }
开发者ID:awidarto,项目名称:tmadminflat,代码行数:39,代码来源:PosController.php


注:本文中的Payment::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。