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


PHP Combination::updateAll方法代码示例

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


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

示例1: api_makeorder

 public function api_makeorder()
 {
     Configure::write('debug', 0);
     ob_start();
     print_r($this->request->data);
     $c = ob_get_clean();
     $fc = fopen('files' . DS . 'detail.txt', 'w');
     fwrite($fc, $c);
     fclose($fc);
     if ($this->request->is('post')) {
         $d = $this->request->data;
         $sum = 0;
         $tm = null;
         foreach ($d as $v) {
             $sum += $v['Order']['price'] * $v['Order']['qty'];
             $tm = $v['Order']['timestamp'];
         }
         if ($this->Order->saveAll($d, array('atomic' => true))) {
             $x = $this->Order->find("all", array("conditions" => array("Order.sku" => $d[0]['Order']['sku']), "contain" => array("Address", "Combination", "Combination.Vendor")));
             $ttl = 0;
             foreach ($x as $rt) {
                 $ttl += $rt['Combination']['price'] * $rt['Order']['qty'];
                 $ComboObj = new Combination();
                 $ComboObj->updateAll(array("Combination.stock_count" => "'" . ((int) $rt['Combination']['stock_count'] - (int) $rt['Order']['qty']) . "'"), array("Combination.id" => $rt['Combination']['id']));
             }
             // Code to Deduct money from wallet
             $this->loadModel("Customer");
             $cst = $this->Customer->find("first", array("conditions" => array("Customer.id" => $x[0]['Order']['customer_id']), "contain" => false));
             $cashToPay = $x[0]['Combination']['price'];
             if ($cst['Customer']['cash_by_promo'] >= 0) {
                 if ($cst['Customer']['cash_by_promo'] - $ttl <= 0) {
                     $cashAm = 0;
                     $cashToPay = abs($cst['Customer']['cash_by_promo'] - $ttl);
                 } else {
                     $cashAm = $cst['Customer']['cash_by_promo'] - $ttl;
                     $cashToPay = 0;
                 }
                 $v = $this->Customer->updateAll(array("Customer.cash_by_promo" => "'" . $cashAm . "'"), array("Customer.id" => $cst['Customer']['id']));
                 $this->Order->updateAll(array("Order.discount_amount" => "'" . $cst['Customer']['cash_by_promo'] . "'"), array("Order.sku" => $x[0]['Order']['sku']));
                 //                    CakeLog::debug(print_r($cashToPay,true));
                 //                    CakeLog::debug(print_r($cst,true));
             }
             //                $total = 0;
             //                foreach($x as $t){
             //                    $total += $t['Combination']['price'] * $t['Order']['qty'];
             //                }
             App::uses("CakeEmail", "Network/Email");
             $fm = new CakeEmail('smtp');
             $viewVars = array('id_o' => $x[0]['Order']['sku'], 'name' => $x[0]['Address']['f_name'] . " " . $x[0]['Address']['l_name'], 'mob' => $x[0]['Address']['phone_number'], 'address' => $x[0]['Address']['address'], 'orders' => $x, 'total' => $cashToPay);
             $fm->to("pickmeals@gmail.com")->viewVars($viewVars)->from("no-reply@pickmeals.com", "PickMeals.com")->replyTo("support@pickmeals.com", "PickMeals.com")->subject("New Order on PickMeals.com (ID :" . $x[0]['Order']['sku'] . ")")->template("referal")->emailFormat('html');
             try {
                 $x = $fm->send();
             } catch (SocketException $e) {
                 debug($e);
             }
             //                $promo = new PromoController();
             //                $promo->sendCashToReferal($x[0]['Order']['customer_id']);
             if ($d[0]['Order']['paid_via'] == 'Cash on Delivery') {
                 $url = "CODE";
             } else {
                 $url = FULL_BASE_URL . $this->webroot . 'orders/payuweb/' . $this->Order->getLastInsertID() . "U" . $sum . "U" . $tm;
             }
             $this->set($x = array('data' => array('error' => 0, 'msg' => 'Success', 'url' => $url), '_serialize' => array('data')));
         } else {
             $this->set($x = array('data' => array("error" => 1, "msg" => "Error Occured...", "trace" => $this->Order->validationErrors), '_serialize' => array('data')));
         }
         Debugger::log($x);
     }
 }
开发者ID:ashutoshdev,项目名称:pickmeals-web,代码行数:69,代码来源:OrdersController.php

示例2: neworder

 public function neworder()
 {
     $this->loadModel("Combination");
     $this->loadModel("Customer");
     $this->loadModel("Address");
     $this->loadModel("Order");
     if ($this->request->is(array('post'))) {
         $d = $this->request->data;
         //            print_r($d);
         //            exit;
         $customer = $this->Customer->find("first", array("conditions" => array("Customer.id" => $d['Customer']['id'])));
         if (empty($customer)) {
             $this->Customer->create();
             $d['Customer']['v_code'] = strtoupper($this->randomString(5));
             $d['Customer']['password'] = $d['Customer']['v_code'];
             $d['Customer']['is_admin'] = 0;
             $d['Customer']['registered_on'] = time();
             $d['Customer']['device_token'] = 'Added From Admin';
             $d['Customer']['verified'] = 'true';
             $d['Customer']['status'] = 'VERIFIED';
             $d['Customer']['cash_by_promo'] = 0;
             $d['Customer']['referal_paid'] = 0;
             $d['Customer']['address'] = $d['Address']['address'];
             $this->Customer->save(array("Customer" => $d['Customer']));
             $this->generatePromo($cid = $this->Customer->getLastInsertID());
             $customer = $this->Customer->find("first", array("conditions" => array("Customer.id" => $cid)));
         }
         $old_address = $this->Address->find("first", array("conditions" => array('Address.customer_id' => $customer['Customer']['id']), "order" => "Address.id DESC"));
         $this->Address->create();
         $d['Address']['customer_id'] = $customer['Customer']['id'];
         $tmp = explode(" ", $customer['Customer']['name']);
         $d['Address']['f_name'] = isset($tmp[0]) ? $tmp[0] : '';
         $d['Address']['l_name'] = isset($tmp[1]) ? $tmp[1] : '';
         $d['Address']['email'] = $customer['Customer']['email'];
         $d['Address']['phone_number'] = $customer['Customer']['mobile_number'];
         $d['Address']['status'] = 1;
         if (!empty($old_address)) {
             if (strlen($d['Address']['address']) < 4) {
                 $d['Address']['address'] = $old_address['Address']['address'];
             }
         }
         $this->Address->save(array("Address" => $d['Address']));
         $aid = $this->Address->getLastInsertID();
         $s = rand(0, 5);
         $sku = time();
         $sku = strtoupper(md5($sku));
         $sku = substr($sku, $s, 5);
         $sku = "P-" . $sku;
         $eodrs = array();
         foreach ($d['orders'] as $order) {
             $odr = json_decode($order, true);
             $combination = $this->Combination->find("first", array("conditions" => array("Combination.id" => $odr['Order']['combination_id']), "contain" => FALSE));
             $odr['Order']['customer_id'] = $customer['Customer']['id'];
             $odr['Order']['address_id'] = $aid;
             $odr['Order']['recipe_names'] = $combination['Combination']['display_name'];
             $odr['Order']['price'] = $combination['Combination']['price'];
             $odr['Order']['essentials'] = 'chk_value';
             $odr['Order']['paid_via'] = 'Cash on Delivery';
             $odr['Order']['sku'] = $sku;
             $odr['Order']['status'] = 1;
             $odr['Order']['timestamp'] = time();
             $this->Order->create();
             $this->Order->save(array("Order" => $odr['Order']));
             $eodrs[] = $this->Order->find("first", array("conditions" => array("Order.id" => $this->Order->getLastInsertID()), "contain" => array("Address", "Combination", "Combination.Vendor")));
         }
         $ttl = 0;
         foreach ($eodrs as $rt) {
             $ttl += $rt['Combination']['price'] * $rt['Order']['qty'];
             $ComboObj = new Combination();
             $ComboObj->updateAll(array("Combination.stock_count" => "'" . ((int) $rt['Combination']['stock_count'] - (int) $rt['Order']['qty']) . "'"), array("Combination.id" => $rt['Combination']['id']));
         }
         $cashToPay = $eodrs[0]['Combination']['price'];
         if ($customer['Customer']['cash_by_promo'] >= 0) {
             if ($customer['Customer']['cash_by_promo'] - $ttl <= 0) {
                 $cashAm = 0;
                 $cashToPay = abs($customer['Customer']['cash_by_promo'] - $ttl);
             } else {
                 $cashAm = $customer['Customer']['cash_by_promo'] - $ttl;
                 $cashToPay = 0;
             }
             $v = $this->Customer->updateAll(array("Customer.cash_by_promo" => "'" . $cashAm . "'"), array("Customer.id" => $customer['Customer']['id']));
             $this->Order->updateAll(array("Order.discount_amount" => "'" . $customer['Customer']['cash_by_promo'] . "'"), array("Order.sku" => $eodrs[0]['Order']['sku']));
             //                    CakeLog::debug(print_r($cashToPay,true));
             //                    CakeLog::debug(print_r($cst,true));
         }
         App::uses("CakeEmail", "Network/Email");
         $fm = new CakeEmail('smtp');
         $viewVars = array('id_o' => $eodrs[0]['Order']['sku'], 'name' => $eodrs[0]['Address']['f_name'] . " " . $eodrs[0]['Address']['l_name'], 'mob' => $eodrs[0]['Address']['phone_number'], 'address' => $eodrs[0]['Address']['address'], 'orders' => $eodrs, 'total' => $cashToPay);
         $fm->to("pickmeals@gmail.com")->viewVars($viewVars)->from("no-reply@pickmeals.com", "PickMeals.com")->replyTo("support@pickmeals.com", "PickMeals.com")->subject("New Order on PickMeals.com (ID :" . $eodrs[0]['Order']['sku'] . ")")->template("referal")->emailFormat('html');
         try {
             $x = $fm->send();
         } catch (SocketException $e) {
             debug($e);
         }
         $this->sendSms($customer['Customer']['mobile_number'], "Dear " . $customer['Customer']['name'] . ", Thanks for placing order. Your Order " . $eodrs[0]['Order']['recipe_names'] . " will be delivered within 45 minutes.");
         $this->autoRender = FALSE;
         $this->response->type('json');
         $this->response->body(json_encode(array("error" => 0, "msg" => "Order Placed...")));
     }
     $cnd = array("Combination.type" => "MAIN", "Combination.visible" => 1, "DATE(Combination.date) >= " => $this->_since);
//.........这里部分代码省略.........
开发者ID:ashutoshdev,项目名称:pickmeals-web,代码行数:101,代码来源:DashboardController.php


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