예제 #1
0
 public function actionDeleteProduct()
 {
     $id = Yii::app()->request->getParam('id');
     $orderProduct = OrderProduct::model()->findByPk($id);
     if ($orderProduct) {
         if ($orderProduct->amount > 1) {
             $restNum = $orderProduct->amount - 1;
             $orderProduct->saveAttributes(array('amount' => $restNum));
             $data = array('status' => true, 'amount' => $restNum, 'price' => $orderProduct->price);
         } else {
             $orderProduct->delete();
             $data = array('status' => true, 'amount' => 0, 'price' => 0);
         }
         $data['total'] = OrderProduct::getTotal($orderProduct->order_id);
         echo json_encode($data);
         exit;
     }
     echo json_encode(array('status' => false));
     exit;
 }
예제 #2
0
 public function actionOrderPrintlist()
 {
     $companyId = Yii::app()->request->getParam('companyId', 0);
     $orderId = Yii::app()->request->getParam('orderId', "0");
     $padId = Yii::app()->request->getParam('padId', "0");
     $payShouldAccount = Yii::app()->request->getParam('payShouldAccount', "0");
     $order = new Order();
     //Yii::app()->end(json_encode(array('status'=>false,'msg'=>"111")));
     if ($orderId != '0') {
         $order = Order::model()->with('company')->find(' t.lid=:lid and t.dpid=:dpid and t.order_status in(1,2,3)', array(':lid' => $orderId, ':dpid' => $companyId));
         //Yii::app()->end(json_encode(array('status'=>false,'msg'=>"234")));
         if (empty($order)) {
             Yii::app()->end(json_encode(array('status' => false, 'msg' => "该订单不存在")));
         }
         $productTotal = OrderProduct::getTotal($order->lid, $order->dpid);
         $criteria = new CDbCriteria();
         $criteria->condition = 't.dpid=' . $companyId . ' and t.site_id=' . $order->site_id . ' and t.is_temp=' . $order->is_temp;
         $criteria->order = ' t.lid desc ';
         $siteNo = SiteNo::model()->find($criteria);
         if ($order->is_temp == '1') {
             $total = array('total' => $productTotal, 'remark' => yii::t('app', '临时座:') . $siteNo->site_id % 1000);
         } else {
             $total = Helper::calOrderConsume($order, $siteNo, $productTotal);
         }
         $order->should_total = $total['total'];
         $order->reality_total = $payShouldAccount;
     }
     //Yii::app()->end(json_encode(array('status'=>false,'msg'=>"111")));
     $pad = Pad::model()->with('printer')->find(' t.dpid=:dpid and t.lid=:lid', array(':dpid' => $order->dpid, 'lid' => $padId));
     //前面加 barcode
     $precode = "";
     //"1D6B450B".strtoupper(implode('',unpack('H*', 'A'.$order->lid)))."0A".strtoupper(implode('',unpack('H*', 'A'.$order->lid)))."0A";
     $orderProducts = OrderProduct::getHasOrderProducts($order->lid, $order->dpid);
     $memo = "清单";
     $printList = Helper::printList($order, $orderProducts, $pad, $precode, "0", $memo);
     Yii::app()->end(json_encode($printList));
 }
예제 #3
0
 public function actionOrderList()
 {
     $isCode = 0;
     $orderId = 0;
     $seatnum = Yii::app()->request->getParam('code');
     if ($seatnum != $this->seatNum) {
         $isCodeModel = SiteNo::model()->find('code=:code and delete_flag=0', array(':code' => $seatnum));
         //判断是否是正式开台号
         if ($isCodeModel) {
             $isCode = 1;
             $this->seatNum = $seatnum;
         }
     } else {
         //输入的和开台号相等  判断是否是真的座次号(可能输入临时的座次号)
         $isCodeModel = SiteNo::model()->find('code=:code and delete_flag=0', array(':code' => $seatnum));
         //判断是否是正式开台号
         if ($isCodeModel) {
             $isCode = 1;
             $this->seatNum = $seatnum;
         }
     }
     $model = Order::model()->with('siteNo')->find('t.order_status=0 and t.company_id=:companyId and code=:code and delete_flag=0', array(':code' => $this->seatNum, ':companyId' => $this->companyId));
     if ($model) {
         $orderId = $model->order_id;
     }
     $time = $model ? $model->create_time : 0;
     $orderProducts = OrderProduct::getOrderProducts($orderId);
     $totalPrice = OrderProduct::getTotal($orderId);
     if ($model) {
         $priceInfo = Helper::calOrderConsume($model, $totalPrice);
     } else {
         if ($isCodeModel) {
             $priceInfo = Helper::lowConsumeInfo($isCodeModel->site_id);
         }
     }
     $this->render('orderlist', array('id' => $orderId, 'orderProducts' => $orderProducts, 'totalPrice' => $priceInfo, 'time' => $time, 'seatNum' => $this->seatNum, 'cid' => $this->companyId));
 }