コード例 #1
0
ファイル: OrderList.php プロジェクト: song-yuan/wymenujp
 public static function UpdatePadOrder($dpid, $orderId, $goodsIds)
 {
     if ($goodsIds) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             foreach ($goodsIds as $key => $val) {
                 if (!strpos($key, 'group')) {
                     //去除套餐中的 checkbox
                     $goodsArr = explode(',', $key);
                     //如果数组元素个数是2 证明书套餐
                     if (count($goodsArr) == 2) {
                         $setId = $goodsArr[0];
                         $sql = 'delete from nb_order_product where order_id=:orderId and set_id=:setId and dpid=:dpid';
                         $connect = Yii::app()->db->createCommand($sql);
                         $connect->bindValue(':setId', $setId);
                         $connect->bindValue(':orderId', $orderId);
                         $conn->bindValue(':dpid', $dpid);
                         $connect->execute();
                         $goodsData = explode('-', $goodsArr[1]);
                         foreach ($goodsData as $goods) {
                             $se = new Sequence("order_product");
                             $lid = $se->nextval();
                             $insertData = array('lid' => $lid, 'dpid' => $dpid, 'create_at' => date('Y-m-d H:i:s', time()), 'order_id' => $orderId, 'set_id' => $setId, 'product_id' => $goods, 'price' => ProductSetClass::GetProductSetPrice($dpid, $setId, $goods), 'update_at' => date('Y-m-d H:i:s', time()), 'amount' => $val, 'taste_memo' => yii::t('app', '无'));
                             Yii::app()->db->createCommand()->insert('nb_order_product', $insertData);
                         }
                     } else {
                         $sql = 'update nb_order_product set amount = :amount where order_id = :orderId and product_id = :productId and dpid=:dpid';
                         $conn = Yii::app()->db->createCommand($sql);
                         $conn->bindValue(':amount', $val);
                         $conn->bindValue(':orderId', $orderId);
                         $conn->bindValue(':productId', $key);
                         $conn->bindValue(':dpid', $dpid);
                         $conn->execute();
                     }
                 }
             }
             $transaction->commit();
             return true;
         } catch (Exception $e) {
             $transaction->rollback();
             //如果操作失败, 数据回滚
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: orderlist.php プロジェクト: song-yuan/wymenujp
		<?php 
        } else {
            ?>
		<!--套餐-->
		<?php 
            // key是set_id $order 是该套餐对应产品的数组
            $productSets = array();
            foreach ($orderProduct as $k => $order) {
                $productSets[$order['set_id']][] = $order;
            }
            ?>
		<?php 
            foreach ($productSets as $key => $productSet) {
                ?>
			<div class="order-category"><?php 
                echo ProductSetClass::GetProductSetName($this->companyId, $key);
                ?>
</div>
			<?php 
                foreach ($productSet as $order) {
                    ?>
				<div class="order-product">
				<div class="order-product-left"><img src="<?php 
                    echo $order['main_picture'];
                    ?>
" /></div>
				<div class="order-product-right">
				<div class="right-up"><?php 
                    echo $order['original_price'];
                    ?>
</div>
コード例 #3
0
ファイル: order.php プロジェクト: song-yuan/wymenujp
	<?php 
    } else {
        ?>
	<!--套餐-->
	<?php 
        // key是set_id $order 是该套餐对应产品的数组
        $productSets = array();
        foreach ($orderProduct as $k => $order) {
            $productSets[$order['set_id']][] = $order;
        }
        ?>
	<?php 
        foreach ($productSets as $key => $productSet) {
            ?>
		<div class="order-category"><?php 
            echo ProductSetClass::GetProductSetName($key);
            ?>
</div>
		<?php 
            foreach ($productSet as $order) {
                ?>
		<div class="product">
		<div class="product-up">
			<!--original_price 表示套餐产品的名称-->
			<div class="product-up-left"><?php 
                echo $order['original_price'];
                ?>
</div>
		</div>
		<div class="product-middle select-taste"  data-id="<?php 
                echo $order['lid'];
コード例 #4
0
 public function actionAddProduct()
 {
     $companyId = Yii::app()->request->getParam('companyId', '0');
     $typeId = Yii::app()->request->getParam('typeId', '0');
     $orderId = Yii::app()->request->getParam('orderId', '0');
     $orderProduct = new OrderProduct();
     $orderProduct->order_id = $orderId;
     $categories = ProductClass::getCategories($companyId);
     $isset = Yii::app()->request->getParam('isset', '0');
     //var_dump($categories);exit;
     $setlist = ProductSetClass::getSetlist($companyId);
     $categoryId = 0;
     $products = ProductClass::getProducts($categoryId, $companyId);
     $productslist = CHtml::listData($products, 'lid', 'product_name');
     if (Yii::app()->request->isPostRequest) {
         Until::validOperate($companyId, $this);
         //$isset = Yii::app()->request->getPost('isset',0);
         //$setid = Yii::app()->request->getParam('setid',0);
         $selsetlist = Yii::app()->request->getPost('selsetlist', 0);
         $db = Yii::app()->db;
         $transaction = $db->beginTransaction();
         try {
             //var_dump($isset);exit;
             if ($isset == 0) {
                 $orderProduct = new OrderProduct();
                 $orderProduct->dpid = $companyId;
                 $orderProduct->delete_flag = '0';
                 $orderProduct->taste_memo = "";
                 $orderProduct->product_order_status = '0';
                 $orderProduct->attributes = Yii::app()->request->getPost('OrderProduct');
                 $orderProduct->create_at = date('Y-m-d H:i:s', time());
                 $orderProduct->set_id = '0000000000';
                 $se = new Sequence("order_product");
                 $orderProduct->lid = $se->nextval();
                 //var_dump($orderProduct);exit;
                 $orderProduct->save();
             } else {
                 //var_dump($selsetlist);exit;
                 if (strlen($selsetlist) > 10) {
                     $productIdlist = explode(',', $selsetlist);
                     $setid = Yii::app()->request->getPost('OrderProduct');
                     //var_dump($setid['set_id']);exit;
                     foreach ($productIdlist as $productId) {
                         //var_dump($productId);
                         $sorderProduct = new OrderProduct();
                         $sorderProduct->dpid = $companyId;
                         $sorderProduct->delete_flag = '0';
                         $sorderProduct->product_order_status = '0';
                         $sorderProduct->set_id = $setid['set_id'];
                         $sorderProduct->main_id = '0000000000';
                         $sorderProduct->order_id = $setid['order_id'];
                         //$orderProduct->attributes = Yii::app()->request->getPost('OrderProduct');
                         $sorderProduct->create_at = date('Y-m-d H:i:s', time());
                         $productUnit = explode('|', $productId);
                         $sorderProduct->product_id = $productUnit[0];
                         $sorderProduct->amount = $productUnit[1];
                         $sorderProduct->price = $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('addproduct', array('orderId' => $orderId, 'orderProduct' => $orderProduct, 'paymentMethods' => $paymentMethods, 'categories' => $categories, 'products' => $productslist, 'typeId' => $typeId, 'setlist' => $setlist, 'isset' => $isset));
 }
コード例 #5
0
 public function actionGetOrderListJson()
 {
     $orderProductList = array();
     $orderList = new OrderList($this->companyId, $this->siteNoId);
     if ($orderList->order) {
         $orderProductList = $orderList->OrderProductList($orderList->order['lid'], 0, 1);
         foreach ($orderProductList as $key => $val) {
             $orderProductList[$key]['category_name'] = OrderList::GetCatoryName($key, $this->companyId);
             if (!$key) {
                 foreach ($val as $k => $v) {
                     $orderProductList[$key][$k]['product_id'] = ProductSetClass::GetProductSetProductIds($this->companyId, $v['set_id']);
                 }
             }
         }
     }
     Yii::app()->end(json_encode($orderProductList));
 }