示例#1
0
 public function addAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $data = $this->params()->fromPost();
         echo json_encode($data);
         die;
         //check api
         $userApi = Utility::userApi($data['userName'], $data['apiKey']);
         if ($userApi->getId() == '') {
             die(-1);
         }
         $this->userId = $userApi->getId();
         //end check api
         // insert new customer before insert new  order
         $customerId = Utility::createCustomer($data);
         //insert new order
         $order = new Orders();
         $order->setUserId($this->userId);
         $order->setStatus($data['status']);
         $order->setTotalCost($data['total_cost']);
         $order->setTotalRealCost($data['total_real_cost']);
         $order->setCreateDate(time());
         $order->setIsdelete(0);
         $order->setTableId(0);
         $order->setSurtaxId(0);
         $order->setCustomerId($customerId);
         //end insert new order
         $order = $this->orderModel->insert($order);
         $orderId = $order->getId();
         //insert orderDetail
         $orderDetails = $data['detai'];
         foreach ($orderDetails as $details) {
             $orderDetail = new OrderDetail();
             $orderDetail->setOrderId($orderId);
             $orderDetail->setMenuId($details['menu_id']);
             $orderDetail->setCostType($details['cost_type']);
             $orderDetail->setQuantity($details['quantity']);
             $orderDetail->setMenuCost($details['menu_cost']);
             $orderDetail->setRealCost($details['real_cost']);
             $orderDetail->setCustomerId($customerId);
             $orderDetail->setIsdelete(0);
             $this->orderDetailModel->insert($orderDetail);
         }
         //insert order detail
         die;
     }
     die;
 }
示例#2
0
 public function init()
 {
     //check api
     $userApi = Utility::userApi($this->params()->fromQuery('userName'), $this->params()->fromQuery('apiKey'));
     if ($userApi->getId() == '') {
         die(-1);
     }
     $this->userId = $userApi->getId();
     //end check api
     $this->modelMenu = new menuModel($this->doctrineService);
     $this->modelCombo = new comboModel($this->doctrineService);
     $this->catModel = new categoryModel($this->doctrineService);
     $this->translator = Utility::translate();
     parent::init();
 }
示例#3
0
 /**
  *
  */
 public function loginAction()
 {
     $request = $this->getRequest();
     $result = array();
     if ($request->isPost()) {
         $userApi = Utility::userApi($this->params()->fromQuery('userName'), $this->params()->fromQuery('apiKey'));
         $this->userId = $userApi->getId();
         $customerLogin = $this->params()->fromPost();
         $result = Utility::checkCustomer($customerLogin);
         if ($result) {
             echo $result->getId();
         } else {
             echo 0;
         }
         die;
     }
     die('Die Hacked');
 }