示例#1
0
						<tbody>
						<?php 
if ($models) {
    ?>
						<?php 
    foreach ($models as $model) {
        ?>
							<tr class="odd gradeX">
								<td ><?php 
        echo $model->product_name;
        ?>
</td>
								<td>
									<?php 
        foreach ($model->productAddition as $val) {
            echo ProductClass::getProductName($val->sproduct_id, $model->dpid) . ' ';
        }
        ?>
								</td>
								<td class="center">
								<a href="<?php 
        echo $this->createUrl('productAddition/detail', array('lid' => $model->lid, 'companyId' => $model->dpid));
        ?>
"><?php 
        echo yii::t('app', '编辑');
        ?>
</a>
								</td>
							</tr>
						<?php 
    }
 public function actionAddAddition()
 {
     $companyId = Yii::app()->request->getParam('companyId', '0');
     $typeId = Yii::app()->request->getParam('typeId', '0');
     $orderId = Yii::app()->request->getParam('orderId', '0');
     $productId = Yii::app()->request->getParam('productId', '0');
     $products = ProductClass::getAdditionProducts($productId, $companyId);
     if (Yii::app()->request->isPostRequest) {
         Until::validOperate($companyId, $this);
         $additionnames = Yii::app()->request->getPost('additionnames', '');
         $db = Yii::app()->db;
         $transaction = $db->beginTransaction();
         try {
             if (strlen($additionnames) > 10) {
                 $productIdlist = explode(',', $additionnames);
                 //update parent product
                 $db->createCommand('update nb_order_product set main_id=product_id where product_id=:productid and dpid=:dpid')->execute(array(':productid' => $productId, ':dpid' => $companyId));
                 foreach ($productIdlist as $product) {
                     //var_dump($productId);
                     $sorderProduct = new OrderProduct();
                     $sorderProduct->dpid = $companyId;
                     $sorderProduct->delete_flag = '0';
                     $sorderProduct->product_order_status = '0';
                     $sorderProduct->order_id = $orderId;
                     $sorderProduct->main_id = $productId;
                     $sorderProduct->set_id = '0000000000';
                     //$orderProduct->attributes = Yii::app()->request->getPost('OrderProduct');
                     $sorderProduct->create_at = date('Y-m-d H:i:s', time());
                     $productUnit = explode('|', $product);
                     $sorderProduct->product_id = $productUnit[0];
                     $sorderProduct->price = $productUnit[1];
                     $sorderProduct->amount = $productUnit[2];
                     $sorderProduct->is_giving = '0';
                     $sorderProduct->zhiamount = 0;
                     $se = new Sequence("order_product");
                     $sorderProduct->lid = $se->nextval();
                     //var_dump($orderProduct);exit;
                     $sorderProduct->save();
                 }
             }
             $transaction->commit();
             Yii::app()->user->setFlash('success', yii::t('app', '添加成功'));
             $this->redirect(array('defaultOrder/order', 'companyId' => $this->companyId, 'orderId' => $orderId, 'typeId' => $typeId));
         } catch (Exception $e) {
             $transaction->rollback();
             //如果操作失败, 数据回滚
             //echo json_encode(array('status'=>0,'message'=>'换台失败'));
             Yii::app()->user->setFlash('success', yii::t('app', '添加失败'));
             return false;
         }
         //var_dump($orderProduct);exit;
         //第一个菜需要更新订单状态。。。。
         //添加产品时,还可以添加套餐。。。
     }
     $paymentMethods = PaymentClass::getPaymentMethodList($companyId);
     //var_dump($paymentMethods);exit;
     $this->renderPartial('additiondetail', array('orderId' => $orderId, 'models' => $products, 'productId' => $productId, 'typeId' => $typeId));
 }
示例#3
0
 public static function getCategoryProducts($dpid = 0, $categoryId, $siteNoId = 0, $pad)
 {
     $siteId = 0;
     $siteNo = SiteNo::model()->find('lid=:lid', array(':lid' => $siteNoId));
     if ($siteNo) {
         $siteId = $siteNo['site_id'];
     }
     //pad 0 非pad 1 pad
     if ($pad) {
         //producttype 0 普通商品 1 套餐
         $sql = 'select tao.* from (' . ' select t.*,tc.order_num as order_num,category_name,tc.pid from' . ' (select lid,dpid,category_id,product_name, original_price, main_picture, rank, store_number, order_number, favourite_number,0 as producttype from nb_product where dpid=:companyId and status=0 and delete_flag=0 and is_show = 1)t' . ' LEFT JOIN nb_product_category tc on tc.lid=t.category_id and tc.dpid=t.dpid ' . ' union select r.*,10000 as order_num,"套餐" as category_name,"套餐" as pid from(' . 'select lid , dpid as dpid, category_id, product_name, sum(price) as original_price, main_picture, rank, store_number, order_number, favourite_number, producttype ' . ' from(select n.lid,n.dpid as dpid,0 as category_id,n.set_name as product_name, n.main_picture, n.rank, n.store_number, n.order_number, n.favourite_number, n1.price*n1.number as price,1 as producttype from nb_product_set n' . ' LEFT JOIN nb_product_set_detail n1 on n.lid=n1.set_id  where n.dpid=n1.dpid and n.dpid=:companyId  and n.delete_flag=0 and n1.delete_flag=0 and n1.is_select=1)r1 group by lid )r' . ') tao order by tao.pid ASC, tao.order_num DESC';
         $connect = Yii::app()->db->createCommand($sql);
         $connect->bindValue(':companyId', $dpid);
         //			$connect->bindValue(':siteId',$siteId);
         $product = $connect->queryAll();
     } else {
         //type 0 普通商品 1 套餐
         $sql = 'select t.*,t1.order_id from(select lid,product_name, original_price, main_picture, rank, store_number, order_number, favourite_number,0 as type from nb_product where dpid=:companyId and category_id=:categoryId and status=0 and delete_flag=0 and is_show = 1)t LEFT JOIN (select order_id,product_id from nb_order_product t2 LEFT JOIN nb_order t3 on t2.order_id=t3.lid where t2.dpid = :companyId and t3.site_id=:siteId and t2.delete_flag=0 and t2.product_order_status=0 and t2.set_id=0 )t1 on t.lid=t1.product_id ' . 'union select r.*,s.order_id from(' . 'select lid , product_name, sum(price) as original_price, main_picture, rank, store_number, order_number, favourite_number, type from(' . 'select n.lid,n.set_name as product_name, n.main_picture, n.rank, n.store_number, n.order_number, n.favourite_number, n1.price,1 as type from nb_product_set n LEFT JOIN nb_product_set_detail n1 on n.lid=n1.set_id  where n.dpid=n1.dpid and n.dpid=:companyId  and n.delete_flag=0 and n1.delete_flag=0 and n1.is_select=1)r1 group by lid )r LEFT JOIN (select order_id,set_id from nb_order_product t4 LEFT JOIN nb_order t5 on t4.order_id=t5.lid where t4.dpid = :companyId and t5.site_id=:siteId and t4.delete_flag=0 and t4.product_order_status=0  and t4.set_id > 0)s on r.lid=s.set_id';
         $connect = Yii::app()->db->createCommand($sql);
         $connect->bindValue(':companyId', $dpid);
         $connect->bindValue(':categoryId', $categoryId);
         $connect->bindValue(':siteId', $siteId);
         $product = $connect->queryAll();
     }
     if ($product) {
         foreach ($product as $k => $v) {
             $sql = 'select t.taste_group_id,t1.name from nb_product_taste t,nb_taste_group t1 where t.taste_group_id=t1.lid and t.dpid=t1.dpid and t1.dpid=:dpid and t.product_id=:productId and t1.delete_flag=0 and t1.allflae=0';
             $connect = Yii::app()->db->createCommand($sql);
             $connect->bindValue(':dpid', $dpid);
             $connect->bindValue(':productId', $v['lid']);
             $tasteGroup = $connect->queryAll();
             if ($tasteGroup) {
                 foreach ($tasteGroup as $key => $group) {
                     $sql = 'select lid,name from nb_taste where dpid=:dpid and taste_group_id=:tasteGroupId and delete_flag=0 and allflae=0';
                     $connect = Yii::app()->db->createCommand($sql);
                     $connect->bindValue(':dpid', $dpid);
                     $connect->bindValue(':tasteGroupId', $group['taste_group_id']);
                     $taste = $connect->queryAll();
                     $product[$k]['taste'][$key] = $taste;
                 }
             } else {
                 $product[$k]['taste'] = array();
             }
             if ($v['producttype']) {
                 $sql = 'select t.*,t1.product_name from nb_product_set_detail t,nb_product t1 where t.product_id=t1.lid and t.dpid=t1.dpid and t.set_id=:setId and t.dpid=:dpid and t.delete_flag=0 and t1.delete_flag=0';
                 $connect = Yii::app()->db->createCommand($sql);
                 $connect->bindValue(':dpid', $dpid);
                 $connect->bindValue(':setId', $v['lid']);
                 $productSets = $connect->queryAll();
                 if ($productSets) {
                     foreach ($productSets as $productSet) {
                         $product[$k]['productset'][$productSet['group_no']][] = $productSet;
                     }
                 } else {
                     $product[$k]['productset'] = array();
                 }
             }
             $product[$k]['is_top10'] = 0;
         }
     }
     $productTop10 = ProductClass::getProductTop10($dpid);
     $totalProduct = array_merge($productTop10, $product);
     return $totalProduct;
     //		return $product;
 }
示例#4
0
<?php

/* @var $this ProductController */
$parentCategorys = ProductCategory::getCategorys($this->companyId);
$result = ProductClass::getCartInfo($this->companyId, $siteNoId);
$resArr = explode(':', $result);
$price = $resArr[0];
$nums = $resArr[1];
//	var_dump($parentCategorys);exit;
$baseUrl = Yii::app()->baseUrl;
?>
<link rel="stylesheet" type="text/css"  href="<?php 
echo $baseUrl . '/css/product/categorypad_h.css';
?>
" />

<div id="page_0_left">
	<?php 
if ($parentCategorys) {
    ?>
		<?php 
    foreach ($parentCategorys as $categorys) {
        ?>
                  <div class="category-partents level1" lid="<?php 
        echo $categorys['lid'];
        ?>
"><?php 
        echo Helper::truncate_utf8_string($categorys['category_name'], 6);
        ?>
</div>
			<?php 
示例#5
0
function cart()
{
    require_once '../../Model/ProductClass.php';
    global $navegador;
    global $connection;
    global $user;
    $titulo = 'David\'s SHOP -Cart';
    $description = 'description';
    $palabrasClaves = 'palabrasClaves';
    $totalPrice = 0;
    if (isset($_COOKIE['Products'])) {
        if ($_COOKIE['Products'] != '[]' || $_COOKIE['Products'] != NULL) {
            $productsCart = $_COOKIE['Products'];
            $productsCart = str_replace("[", "", $productsCart);
            $productsCart = str_replace("]", "", $productsCart);
            if ($productsCart != '') {
                $productsCart = explode(",", $productsCart);
                foreach ($productsCart as $key => $value) {
                    $product = new ProductClass($connection);
                    $product->fetch($value);
                    if (!isset($product->imgs[0]['name'])) {
                        $img = 'not-found.png';
                    } else {
                        $img = $product->imgs[0]['name'];
                    }
                    $listProductsCart[] = array('name' => $product->name, 'description' => $product->description, 'price' => $product->price, 'img' => $img, 'id' => $product->id);
                    $totalPrice = floatval($product->price) + $totalPrice;
                }
            }
        }
    }
    require_once '../../View/Front/cart.php';
}
示例#6
0
?>

	<?php 
$this->renderPartial('parentcategory', array('categoryId' => $categoryId, 'type' => $type));
?>
	<link href='../css/product/reset.css' rel='stylesheet' type='text/css'>
	<link href='../css/product/slick.css' rel='stylesheet' type='text/css'>
	<script type="text/javascript" src="../js/product/slick.min.js"></script>
	<script type="text/javascript" src="../js/product/classie.js"></script>
	<script type="text/javascript" src="../js/product/product.js"></script>
	<div id="page_0" class="up ub ub-ver" tabindex="0">
	<!--content开始-->
    <div id="content" class="ub-f1 tx-l t-bla ub-img6 res10">
        <div class="product-category"><?php 
if (!$type && $pid) {
    echo ProductClass::getCategoryName($pid) . ' >>> ' . ProductClass::getCategoryName($categoryId);
} else {
    if ($type == 1) {
        echo yii::t('app', '推荐品');
    } elseif ($type == 2) {
        echo yii::t('app', '套餐');
    } elseif ($type == 3) {
        echo yii::t('app', '点赞TOP10');
    } else {
        echo yii::t('app', '点单TOP10');
    }
}
?>
</div>
		<div id="forum_list">
			<div class="outDiv" id="leftPic">
示例#7
0
 /**
  * 
  * 大pad下单并打印
  * 
  */
 public static function createPadOrder($dpid, $goodsIds, $padId)
 {
     $isTemp = $goodsIds['client_is_temp'];
     $site_id = $goodsIds['client_site_id'];
     $siteName = $goodsIds['client_site_name'];
     $reprint = $goodsIds['client_reprint'];
     $waitorname = $goodsIds['client_waitor_name'];
     //订单的状态,临时做下单时挂单状态,非临时做下单直接厨打
     $orderStatus = "2";
     $orderPorductStatus = "1";
     if ($isTemp == "1") {
         $orderStatus = "1";
         $orderPorductStatus = "0";
     }
     unset($goodsIds['client_is_temp']);
     unset($goodsIds['client_site_id']);
     unset($goodsIds['client_site_name']);
     unset($goodsIds['client_reprint']);
     unset($goodsIds['client_waitor_name']);
     $siteStatus = self::getSiteStatus($site_id, $dpid, $isTemp);
     if (empty($siteStatus)) {
         throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', '请先开台后下单!'))));
     }
     $sellOff = array();
     $printOrderProducts = array();
     $time = date('Y-m-d H:i:s', time());
     $db = Yii::app()->db;
     //return json_encode(array('status'=>false,'msg'=>$waitorname));
     $transaction = $db->beginTransaction();
     try {
         if ($site_id == 0) {
             //未开台的临时台
             $se = new Sequence("site_no");
             $lid = $se->nextval();
             $code = rand(1000, 9999);
             $se = new Sequence("temp_site");
             $site_id = $se->nextval();
             $data = array('lid' => $lid, 'dpid' => $dpid, 'create_at' => date('Y-m-d H:i:s', time()), 'update_at' => date('Y-m-d H:i:s', time()), 'is_temp' => $isTemp, 'site_id' => $site_id, 'status' => $orderStatus, 'code' => $code, 'number' => 1, 'delete_flag' => '0');
             $db->createCommand()->insert('nb_site_no', $data);
             $feedback_memo = '开台';
             $se = new Sequence("order");
             $orderId = $se->nextval();
             $data = array('lid' => $orderId, 'dpid' => $dpid, 'site_id' => $site_id, 'create_at' => $time, 'username' => $waitorname, 'is_temp' => $isTemp, 'order_status' => $orderStatus, 'number' => 1, 'update_at' => $time, 'remark' => yii::t('app', '无'), 'taste_memo' => "");
             $db->createCommand()->insert('nb_order', $data);
             $sef = new Sequence("order_feedback");
             $lidf = $sef->nextval();
             $dataf = array('lid' => $lidf, 'dpid' => $dpid, 'create_at' => date('Y-m-d H:i:s', time()), 'update_at' => date('Y-m-d H:i:s', time()), 'is_temp' => $isTemp, 'site_id' => $site_id, 'is_deal' => '0', 'feedback_id' => 0, 'order_id' => 0, 'is_order' => '1', 'feedback_memo' => $feedback_memo, 'delete_flag' => '0');
             $db->createCommand()->insert('nb_order_feedback', $dataf);
         } else {
             //已经开台的固定台或临时台,
             //$feedback_memo = yii::t('app','点单');
             // 				//查找site表
             // 				$sql = 'select * from nb_site_no where site_id='.$site_id.' and dpid='.$dpid.' order by lid desc';
             // 				$siteModel = $db->createCommand($sql)->queryRow();
             // 				if(!$siteModel){
             // 					throw new Exception(json_encode( array('status'=>false,'dpid'=>$dpid,'msg'=>yii::t('app','存在该座次号,请重新选座次下单!')),JSON_UNESCAPED_UNICODE));
             // 				}
             // 				 //如果该座位 状态开台未下单
             //	            if(0 < $siteModel['status'] && $siteModel['status'] < 4){
             //	            	//先查找是否已经存在订单
             //	            	$sql = 'select * from nb_order where site_id='.$site_id.' and dpid='.$dpid.' and is_temp='.$isTemp.' order by lid desc';
             $criteria = new CDbCriteria();
             $criteria->condition = ' t.order_status in ("1","2","3") and  t.dpid=' . $dpid . ' and t.site_id=' . $site_id . ' and t.is_temp=' . $isTemp;
             $criteria->order = ' t.lid desc ';
             $orderModel = Order::model()->find($criteria);
             $criteria->condition = ' t.status in ("1","2","3") and  t.dpid=' . $dpid . ' and t.site_id=' . $site_id . ' and t.is_temp=' . $isTemp;
             $criteria->order = ' t.lid desc ';
             $siteNo = SiteNo::model()->find($criteria);
             $siteNo->status = $orderStatus;
             $siteNo->update_at = date('Y-m-d H:i:s', time());
             $siteNo->save();
             if ($isTemp == "0") {
                 $site = Site::model()->find(" t.dpid=:dpid and t.lid=:siteid", array(':dpid' => $siteNo->dpid, ':siteid' => $siteNo->site_id));
                 $site->status = $orderStatus;
                 $site->update_at = date('Y-m-d H:i:s', time());
                 $site->save();
             }
             if ($orderModel) {
                 $orderId = $orderModel['lid'];
             } else {
                 //生成订单
                 $se = new Sequence("order");
                 $orderId = $se->nextval();
                 $data = array('lid' => $orderId, 'dpid' => $dpid, 'site_id' => $site_id, 'create_at' => $time, 'username' => $waitorname, 'is_temp' => $isTemp, 'order_status' => $orderStatus, 'number' => $siteNo->number, 'update_at' => $time, 'remark' => yii::t('app', '无'), 'taste_memo' => "");
                 $db->createCommand()->insert('nb_order', $data);
                 //更新site表状态
                 //						$sql = 'update nb_site set status=1 where lid='.$site_id.' and dpid='.$dpid.' order by lid desc';
                 //					    $db->createCommand($sql)->execute();
                 //					    //更新site_no表状态
                 //					    $sql = 'update nb_site_no set status=1 where site_id='.$site_id.' and dpid='.$dpid.' and is_temp='.$isTemp.' order by lid desc';
                 //					    $db->createCommand($sql)->execute();
             }
         }
         //            return json_encode(array('status'=>false,'msg'=>"test"));
         //订单产品 $goodsIds = array('goods_id'=>goods_num,'set_id,1'=>set_num);
         $orderPrice = 0;
         foreach ($goodsIds as $key => $num) {
             $se = new Sequence("order_product");
             $orderProductId = $se->nextval();
             $goodsArr = explode(',', $key);
             if (count($goodsArr) > 1) {
                 // 套餐
                 $sql = 'select * from nb_product_set where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                 $result = $db->createCommand($sql)->queryRow();
                 if ($result) {
                     if ($result['store_number'] == 0 || $result['store_number'] > 0 && $result['store_number'] < 1) {
                         throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', $result['set_name'] . '库存不足!'))));
                     }
                 } else {
                     throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', '没有找到该产品请清空后重新下单!'))));
                 }
                 //添加选择的套餐明细
                 foreach ($num as $setDetail) {
                     $detailId = key($setDetail);
                     $productSet = self::getSetProductId($dpid, $detailId);
                     $orderProductData = array('lid' => $orderProductId, 'dpid' => $dpid, 'create_at' => $time, 'order_id' => $orderId, 'set_id' => $goodsArr[0], 'product_id' => $productSet['product_id'], 'price' => $productSet['price'], 'update_at' => $time, 'amount' => $productSet['number'], 'taste_memo' => "", 'product_order_status' => $orderPorductStatus);
                     $db->createCommand()->insert('nb_order_product', $orderProductData);
                     $se = new Sequence("order_product");
                     $orderProductId = $se->nextval();
                     $orderPrice += $productSet['price'] * $productSet['number'];
                     array_push($printOrderProducts, array('amount' => $productSet['number'], 'price' => $productSet['price'], 'product_name' => ProductClass::getProductName($productSet['product_id'], $dpid)));
                 }
                 if ($result['store_number'] > 0) {
                     $sql = 'update nb_product_set set store_number=store_number-1 where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                     $db->createCommand($sql)->execute();
                     array_push($sellOff, array("product_id" => sprintf("%010d", $goodsArr[0]), "type" => "set", "num" => $result['store_number'] - 1));
                 }
             } else {
                 //单品 如果有口味  num-eq =>array('taste_id1','taste_id2') num 是数量 eq是序号 $goodsArr[0] 产品id
                 if ($goodsArr[0] == 'quandan') {
                     //全单口味
                     foreach ($num as $tasteId => $taste) {
                         $se = new Sequence("order_taste");
                         $orderTasteId = $se->nextval();
                         $orderTasteData = array('lid' => $orderTasteId, 'dpid' => $dpid, 'create_at' => $time, 'order_id' => $orderId, 'taste_id' => $tasteId, 'is_order' => 1, 'update_at' => $time);
                         $db->createCommand()->insert('nb_order_taste', $orderTasteData);
                     }
                 } else {
                     $sql = 'select * from nb_product where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                     $result = $db->createCommand($sql)->queryRow();
                     $productPrice = self::getProductPrice($dpid, $key, 0);
                     if (is_array($num)) {
                         //有口味$num = num-eq 格式
                         foreach ($num as $k => $v) {
                             $numEq = explode('-', $k);
                             $amount = $numEq[0];
                             if ($result) {
                                 if ($result['store_number'] == 0 || $result['store_number'] > 0 && $result['store_number'] < $amount) {
                                     throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', $result['product_name'] . '库存不足!'))));
                                 }
                             } else {
                                 throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', '没有找到该产品请清空后重新下单!'))));
                             }
                             //每一个eq 生成一个订单
                             $orderProductData = array('lid' => $orderProductId, 'dpid' => $dpid, 'create_at' => $time, 'order_id' => $orderId, 'set_id' => 0, 'product_id' => $goodsArr[0], 'price' => $productPrice, 'update_at' => $time, 'amount' => $amount, 'taste_memo' => "", 'product_order_status' => $orderPorductStatus);
                             $db->createCommand()->insert('nb_order_product', $orderProductData);
                             $orderPrice += $productPrice * $amount;
                             array_push($printOrderProducts, array('amount' => $amount, 'price' => $productPrice, 'product_name' => ProductClass::getProductName($goodsArr[0], $dpid)));
                             //该订单对应的多个口味
                             foreach ($v as $tasteId => $val) {
                                 if ($tasteId) {
                                     $orderTastSe = new Sequence("order_taste");
                                     $orderTasteId = $orderTastSe->nextval();
                                     $orderTasteData = array('lid' => $orderTasteId, 'dpid' => $dpid, 'create_at' => $time, 'update_at' => $time, 'taste_id' => $tasteId, 'order_id' => $orderProductId, 'is_order' => 0);
                                     $db->createCommand()->insert('nb_order_taste', $orderTasteData);
                                 }
                             }
                             $se = new Sequence("order_product");
                             $orderProductId = $se->nextval();
                             if ($result['store_number'] > 0) {
                                 $sql = 'update nb_product set store_number=store_number-' . $amount . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                                 $db->createCommand($sql)->execute();
                                 array_push($sellOff, array("product_id" => sprintf("%010d", $goodsArr[0]), "type" => "product", "num" => $result['store_number'] - $amount));
                             }
                             $sqladd = 'update nb_product set order_number=order_number+' . $amount . ',favourite_number=favourite_number+' . $amount . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                             $db->createCommand($sqladd)->execute();
                         }
                     } else {
                         if ($result) {
                             if ($result['store_number'] == 0 || $result['store_number'] > 0 && $result['store_number'] < $num) {
                                 throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', $result['product_name'] . '库存不足!'))));
                             }
                         } else {
                             throw new Exception(json_encode(array('status' => false, 'dpid' => $dpid, 'jobid' => "0", 'type' => 'local', 'msg' => yii::t('app', '没有找到该产品请清空后重新下单!'))));
                         }
                         $orderProductData = array('lid' => $orderProductId, 'dpid' => $dpid, 'create_at' => $time, 'order_id' => $orderId, 'set_id' => 0, 'product_id' => $goodsArr[0], 'price' => $productPrice, 'update_at' => $time, 'amount' => $num, 'taste_memo' => "", 'product_order_status' => $orderPorductStatus);
                         $db->createCommand()->insert('nb_order_product', $orderProductData);
                         $orderPrice += $productPrice * $num;
                         array_push($printOrderProducts, array('amount' => $num, 'price' => $productPrice, 'product_name' => ProductClass::getProductName($goodsArr[0], $dpid)));
                         if ($result['store_number'] > 0) {
                             $sql = 'update nb_product set store_number=store_number-' . $num . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                             $db->createCommand($sql)->execute();
                             array_push($sellOff, array("product_id" => sprintf("%010d", $goodsArr[0]), "type" => "product", "num" => $result['store_number'] - $num));
                         }
                         $sqladd = 'update nb_product set order_number=order_number+' . $num . ',favourite_number=favourite_number+' . $num . ' where dpid=' . $dpid . ' and lid=' . $goodsArr[0];
                         $db->createCommand($sqladd)->execute();
                     }
                 }
             }
         }
         $sql = 'update nb_order set should_total=' . $orderPrice . ' where lid=' . $orderId . ' and dpid=' . $dpid;
         $db->createCommand($sql)->execute();
         //                        $sql = 'update nb_site_no set status='.$orderPrice.' where lid='.$orderId.' and dpid='.$dpid;
         //			$db->createCommand($sql)->execute();
         //			return json_encode(array('status'=>false,'msg'=>"test22"));
         //厨打
         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' => $dpid));
             //Yii::app()->end(json_encode(array('status'=>false,'msg'=>"234")));
             if (empty($order)) {
                 return json_encode(array('status' => false, 'msg' => "该订单不存在"));
             }
         }
         //           return json_encode(array('status'=>false,'msg'=>"test2236"));
         if ($order->is_temp == "0") {
             //               return json_encode(array('status'=>false,'msg'=>"test2235"));
             $criteria = new CDbCriteria();
             $criteria->condition = 't.dpid=' . $dpid . ' and t.site_id=' . $order->site_id . ' and t.is_temp=' . $order->is_temp;
             $criteria->order = ' t.lid desc ';
             $siteNo = SiteNo::model()->find($criteria);
             //order site 和 siteno都需要更新状态 所以要取出来
             $criteria2 = new CDbCriteria();
             $criteria2->condition = 't.dpid=' . $dpid . ' and t.lid=' . $order->site_id;
             $criteria2->order = ' t.lid desc ';
             $site = Site::model()->with("siteType")->find($criteria2);
             //            return json_encode(array('status'=>false,'msg'=>"test8"));
             $printList = Helper::printKitchenAll3($order, $site, $siteNo, false);
         } else {
             //                return json_encode(array('status'=>false,'msg'=>"test223"));
             $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::getOrderProducts($order->lid, $order->dpid);
             //var_dump($orderProducts);exit;
             //return json_encode(array('status'=>false,'msg'=>"test2234"));
             $memo = "清单";
             $printList = Helper::printList($order, $orderProducts, $pad, $precode, "0", $memo);
         }
         if (!$printList['status']) {
             throw new Exception(json_encode($printList));
         }
         //$printList2=array_merge($printList,array('sitenoid'=> $lid));
         //            }
         $transaction->commit();
         //估清产品通知
         if (!empty($sellOff)) {
             Gateway::getOnlineStatus();
             $store = Store::instance('wymenu');
             $pads = Pad::model()->findAll(" dpid = :dpid and delete_flag='0' and pad_type in ('0','1','2')", array(":dpid" => $dpid));
             //var_dump($pads);exit;
             $sendjsondata = json_encode(array("company_id" => $dpid, "do_id" => "sell_off", "do_data" => $sellOff));
             //var_dump($sendjsondata);exit;
             foreach ($pads as $pad) {
                 $clientId = $store->get("padclient_" . $dpid . $pad->lid);
                 //var_dump($clientId,$print_data);exit;
                 if (!empty($clientId)) {
                     Gateway::sendToClient($clientId, $sendjsondata);
                 }
             }
         }
         return json_encode($printList);
     } catch (Exception $e) {
         $transaction->rollback();
         //如果操作失败, 数据回滚
         throw new Exception($e->getMessage());
         //return $e->getMessage();
     }
 }
示例#8
0
function product($idProduct = "")
{
    require_once '../../Model/ProductClass.php';
    global $viewLogin;
    if (!$viewLogin) {
        header('Location: ../Front/controller.php?f=index');
    }
    global $navegador;
    global $navegadorAdmin;
    $navegador = $navegadorAdmin;
    global $connection;
    $product = new ProductClass($connection);
    //    var_dump($_POST);
    if ($idProduct != '') {
        $product->fetch($idProduct);
        if ($product->imgs == '') {
            $product->imgs = array('not-found.png');
        }
        if (isset($_POST['button']) && $_POST['button'] == 'Save') {
            if (!is_numeric($_POST['price'])) {
                echo '<script>alert("Error : price It is not a numeric value")</script>';
            } else {
                $product->name = $_POST['name'];
                $product->description = $_POST['description'];
                $product->longDescription = $_POST['longDescription'];
                $product->price = $_POST['price'];
                $product->category = $_POST['category'];
                $product->insertProduct();
            }
        }
        if (isset($_POST['button']) && $_POST['button'] == 'Delete') {
            $product->deleteProduct();
            header('Location: ../Back/controller.php?f=productList');
        }
    } else {
        if (isset($_POST['button']) && $_POST['button'] == 'Save') {
            $product = new ProductClass($connection, $_POST['name'], $_POST['description'], $_POST['longDescription'], $_POST['price'], '', $_POST['category']);
            // cargarlo de categorias
            $idLastInsert = $product->insertProduct();
            //            var_dump($idLastInsert);
            if ($idLastInsert != 0) {
                product($idLastInsert);
            }
            //            $product->insertProduct();
        }
    }
    // cargarlo de categorias
    $options = array(array('value' => '1', 'string' => 'Book'), array('value' => '2', 'string' => 'Music'));
    $titulo = $product->name;
    $description = $product->description;
    $palabrasClaves = 'palabrasClaves';
    require_once '../../View/Back/product.php';
}
示例#9
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once '../app/config.php';
require_once 'ProductClass.php';
require_once '../app/connection/Connexion.php';
$connection = new Connexion($dbName, $host, $user, $pass);
//var_dump($_POST);
$product = new ProductClass($connection);
$product->fetch($_POST['id']);
echo json_encode($product->imgs);
示例#10
0
 public function actionGetProductPicJson()
 {
     $id = Yii::app()->request->getParam('id');
     $pic = ProductClass::getProductPic($this->companyId, $id);
     //var_dump($pic);exit;
     if (empty($pic)) {
         echo 'nopic';
     } else {
         $this->renderPartial('_productImg', array('pics' => $pic));
     }
 }