示例#1
0
 /**
  * @see		ApplicationView::createUserInterface()
  */
 protected function createUserInterface()
 {
     parent::createUserInterface();
     $this->addStyle('/css/home.css');
     $resourceBundle = Application::getInstance()->getBundle();
     $products = $this->products->getProducts();
     if (count($products) == 0) {
         $this->contentPanel->addChild(new Heading(2))->addChild(new Text($resourceBundle->getString('NO_PRODUCT')));
     } else {
         $this->contentPanel->addChild(new ProductList())->setProductList($products);
     }
 }
 public function actionIndex()
 {
     $platforms = array();
     $platforms = Platform::getPlatformList();
     $genres = array();
     $genres = Genre::getGenreList();
     $productList = array();
     $productList = Products::getProducts(6);
     require_once ROOT . '/views/site/index.php';
     return true;
 }
 public function actionIndex($page = 1)
 {
     self::validateAdmin();
     $count = 6;
     $productList = array();
     $productList = Products::getProducts($count, $page);
     $total = Products::getTotalProductInCatalog();
     $pagination = new Pagination($total, $page, $count, 'page-');
     require_once ROOT . '/views/admin_product/index.php';
     return true;
 }
 public function runMiddle()
 {
     $count = Products::getProductsCount();
     if (isset($this->params[0]) && $this->params[0] != "") {
         $page = $this->params[0];
     } else {
         $page = 1;
     }
     $products = Products::getProducts($page - 1, 50);
     $max = ceil($count / 50);
     include dirname(__FILE__) . "/../views/product_list.php";
 }
 public function actionIndex($page = 1)
 {
     $count = 6;
     $platforms = array();
     $platforms = Platform::getPlatformList();
     $genres = array();
     $genres = Genre::getGenreList();
     $productList = array();
     $productList = Products::getProducts($count, $page);
     $total = Products::getTotalProductInCatalog();
     $pagination = new Pagination($total, $page, $count, 'page-');
     require_once ROOT . '/views/catalog/index.php';
     return true;
 }
示例#6
0
 public function getBundlingWithDetail($id)
 {
     if ($id != '') {
         //$bundling = $this->model->fields("*")->join("left join goods as go on pr.goods_id = go.id ")->where("pr.id in($id)")->find();
         $bundling = $this->model->fields("*")->where("bd.id in({$id})")->find();
         //!empty($bundling)
         if ($bundling != NULL) {
             if (isset($bundling['products_ids']) && $bundling['products_ids'] != "") {
                 $product_inst = new Products();
                 $ret = $product_inst->getProducts($bundling['products_ids']);
                 if (isset($ret['status']) && $ret['status'] == 1) {
                     $bundling['Products'] = $ret['data'];
                 }
             }
         }
         return $bundling;
     } else {
         return NULL;
     }
 }
示例#7
0
<?php

require_once "../helper.php";
require_once "../classes/Products.class.php";
require_once "../classes/Company.class.php";
$helper = new Helper();
$productObj = new Products();
$companyObj = new Company();
if (($result = $companyObj->checkLoggedIn()) && !isset($result['error'])) {
    $result = $productObj->getProducts($result['company_id'], $_POST['id']);
}
echo json_encode($result);
?>
	
示例#8
0
                    <h2>Our Products</h2>
                    <a class="pages" href="products.php?page=<?php 
print $prev;
?>
">&lt;prev</a>
                    &nbsp;|&nbsp;
                    <a class="pages" href="products.php?page=<?php 
print $next;
?>
">next&gt;</a>
                    <?php 
print $message ? "&nbsp;&nbsp;<b>{$message}<br/>" : '';
?>
                    <ul>
                        <?php 
print $view->displayProducts($page, $linesPerPage, $maxProducts, $products->getProducts());
?>
                    </ul>
                </div><!-- product-list -->


            </div><!-- rightnav -->

            <br class="clear-all"/>
        </div><!-- content -->

    </div><!-- maincontent -->

    <div id="footer">
        <div class="footer">
            Copyright &copy; 2012 sweetscomplete.com. All rights reserved. <br/>
示例#9
0
 public function order_act()
 {
     if ($this->checkOnline()) {
         $ship_id = Filter::int(Req::args('ship_id'));
         // 发货库房位置 ID
         $address_id = Filter::int(Req::args('address_id'));
         // 地址
         $payment_id = Filter::int(Req::args('payment_id'));
         // 支付ID
         $prom_id = Filter::int(Req::args('prom_id'));
         // 去掉
         $is_invoice = Filter::int(Req::args('is_invoice'));
         //
         $invoice_type = Filter::int(Req::args('invoice_type'));
         //
         $invoice_title = Filter::text(Req::args('invoice_title'));
         //
         $user_remark = Filter::txt(Req::args('user_remark'));
         $voucher_id = Filter::int(Req::args('voucher'));
         //非普通促销信息
         // $type = Req::args("type");  // 去掉
         $id = Filter::int(Req::args('id'));
         $product_id = Req::args('product_id');
         $buy_num = Req::args('buy_num');
         if (!$address_id || !$payment_id || $is_invoice == 1 && $invoice_title == '') {
             // product_id  产品ID列表 处理
             if (is_array($product_id)) {
                 foreach ($product_id as $key => $val) {
                     $product_id[$key] = Filter::int($val);
                 }
                 $product_id = implode('-', $product_id);
             } else {
                 $product_id = Filter::int($product_id);
             }
             $data = Req::args();
             $data['is_invoice'] = $is_invoice;
             if (!$address_id) {
                 $data['msg'] = array('fail', "必需选择收货地址,才能确认订单。");
             } else {
                 if (!$payment_id) {
                     $data['msg'] = array('fail', "必需选择支付方式,才能确认订单。");
                 } else {
                     $data['msg'] = array('fail', "索要发票,必需写明发票抬头。");
                 }
             }
             // type 类型
             // 下面代码没有使用
             //if ($type == null)
             //    $this->redirect("order", false, $data);
             //else {
             unset($data['act']);
             Req::args('pid', $product_id);
             Req::args('id', $id);
             unset($_GET['act']);
             //     Req::args('type', $type);
             Req::args('msg', $data['msg']);
             $this->redirect("/simple/order", true, Req::args());
             //$this->redirect("/simple/order_info", true, Req::args());
             //}
             exit;
         }
         //地址信息
         $address_model = new Model('address');
         $address = $address_model->where("id={$address_id} and user_id=" . $this->user['id'])->find();
         if (!$address) {
             $data = Req::args();
             $data['msg'] = array('fail', "选择的地址信息不正确!");
             $this->redirect("order", false, $data);
             exit;
         }
         //if(!$payment_id)$this->redirect("order",false,Req::args());
         if ($this->getModule()->checkToken('order')) {
             //订单类型: 0普通订单 1团购订单 2限时抢购 3捆绑促销
             $order_type = 0;
             $model = new Model('');
             //团购处理
             // 这部分去掉
             /*
             if($type=="groupbuy"){
                 $product_id = Filter::int($product_id[0]);
                 $num = $buy_num[0];
                 $item = $model->table("groupbuy as gb")->join("left join goods as go on gb.goods_id=go.id left join products as pr on pr.id=$product_id")->fields("*,pr.id as product_id,pr.spec")->where("gb.id=$id")->find();
                 $order_products = $this->packGroupbuyProducts($item,$num);
             
                 $groupbuy = $model->table("groupbuy")->where("id=$id")->find();
                 unset($groupbuy['description']);
                 $data['prom'] = serialize($groupbuy);
                 $data['prom_id'] = $id;
                 $order_type = 1;
             
             }
               if($order_type==0){
                 $order_products = $this->cart[$ship_id]['products'];
                 $data['prom_id'] = $prom_id;
             }
             */
             // 购物车
             //$cart = Cart::getCart();
             $cart_info = $this->cart_inst->all();
             //商品总金额,重量,积分计算
             $payable_amount = 0.0;
             $real_amount = 0.0;
             $weight = 0;
             $point = 0;
             $order_products = array();
             $error = 0;
             // 是否促销
             $error_list = array();
             if (isset($cart_info[$ship_id]['products'])) {
                 $order_products =& $cart_info[$ship_id]['products'];
                 // 循环购物车cart中每个产品
                 // 在这判断每个商品的购买方式
                 //
                 $prom_inst = new Prom();
                 foreach ($order_products as $goods_id => $products) {
                     foreach ($products as $product_id => $item) {
                         $item_ref =& $order_products[$goods_id][$product_id];
                         // Tiny::log(__FILE__ . __LINE__ . "-------products item----$key----" . var_export($item, true));
                         // 校验 所有商品的库存和活动是否结束
                         if (isset($item["order_type"])) {
                             if (is_array($item["order_type"])) {
                                 if ($item["order_type"]["flash_sale"] == true) {
                                     // test OK
                                     $goods_info = array("product_id" => $item["product_id"], 'goods_id' => $item['goods_id']);
                                     $flash_sale = array();
                                     $ret = $prom_inst->get_flash_sale($goods_info);
                                     if ($ret["status"] == 1 && isset($ret["data"])) {
                                         $flash_sale = $ret["data"];
                                         // 抢购促销校验
                                         // 是否有库存
                                         if ($flash_sale['max_num'] <= 0) {
                                             // test OK
                                             $error = 1;
                                             $error_item = array("msg" => '商品:' . $item['name'] . '--库存已经没有!', "product_id" => $item['product_id']);
                                             $error_list[] = $error_item;
                                         } else {
                                             if ($flash_sale['max_num'] < $item["num"]) {
                                                 // test OK
                                                 $error = 1;
                                                 $error_item = array("msg" => '商品:' . $item['name'] . '--库存只有' . $flash_sale['max_num'] . '个!', "product_id" => $item['product_id']);
                                                 $error_list[] = $error_item;
                                             }
                                         }
                                     } else {
                                         $error = 1;
                                         $error_item = array("msg" => '商品:' . $item['name'] . '--抢购已经结束!', "product_id" => $item['product_id']);
                                         $error_list[] = $error_item;
                                     }
                                 } elseif ($item["order_type"]["prom_series"] == true && $item["order_type"]["prom_goods"] == true) {
                                     //2 判断商品促销(单品)
                                     $products_inst = new Products();
                                     $products_item = array();
                                     $ret = $products_inst->getProduct($item['product_id']);
                                     // 获取商品信息 item = product
                                     if (isset($ret['status']) && $ret['status'] == 1) {
                                         $item_new = $ret['data'];
                                     }
                                     $item_new['goods_nums'] = $item['num'];
                                     // get prom goods 需要传参数goods_nums
                                     $prom_goods = $prom_inst->get_prom_goods($item_new);
                                     if (!empty($prom_goods)) {
                                         $prom_goods['parse'] = $prom_inst->do_prom_goods($item_new, $prom_goods);
                                         if (isset($prom_goods['parse']['note']) && $prom_goods['parse']['note'] != '') {
                                             $prom_goods['parse']['note'] = '商品优惠:' . $prom_goods['parse']['note'];
                                         }
                                         $amount = sprintf("%01.2f", $prom_goods['parse']['real_price'] * $item["num"]);
                                         $sell_total = $item['sell_price'] * $item["num"];
                                         // 是否有库存
                                         if ($item_new['store_nums'] <= 0) {
                                             // test OK
                                             $error = 1;
                                             $error_item = array("msg" => '商品:' . $item['name'] . '--库存已经没有!', "product_id" => $item['product_id']);
                                             $error_list[] = $error_item;
                                         } else {
                                             if ($item_new['store_nums'] < $item["num"]) {
                                                 // test OK
                                                 $error = 1;
                                                 $error_item = array("msg" => '商品:' . $item['name'] . '--库存只有' . $item_new['store_nums'] . '个!', "product_id" => $item['product_id']);
                                                 $error_list[] = $error_item;
                                             }
                                         }
                                         //修改ITEM内容 价格
                                         $item_ref['real_price'] = $prom_goods['parse']['real_price'];
                                     } else {
                                         // 单品--商品促销结束
                                         $item_ref['order_type']['prom_goods'] = false;
                                         $item_ref['real_price'] = $item_ref['sell_price'];
                                         // 真正价格 为 原来的 销售价格
                                         $item_ref['prom'] = "";
                                         $error = 1;
                                         $error_item = array("msg" => '商品:' . $item['name'] . '--商品促销已经结束!', "product_id" => $item['product_id']);
                                         $error_list[] = $error_item;
                                     }
                                     //3 系列促销
                                     //商品促销与系列促销叠加运算
                                     //$prom_series = $prom_inst->prom_series($item, $prom_goods);
                                     $prom_series = $prom_inst->get_prom_series($item_new);
                                     if (!empty($prom_series)) {
                                         $prom_series['parse'] = $prom_inst->do_prom_series($item_new, $prom_goods, $prom_series);
                                         $note = isset($prom_goods['parse']['note']) ? $prom_goods['parse']['note'] : "";
                                         if (isset($prom_series['parse']['note']) && $prom_series['parse']['note'] != '') {
                                             $note .= '; 系列优惠:' . $prom_series['parse']['note'];
                                         }
                                         $amount = sprintf("%01.2f", $prom_series['parse']['real_price'] * $item["num"]);
                                         $sell_total = $item['sell_price'] * $item["num"];
                                         //合并商品与系统促销
                                         // 送积分
                                         $multiple = 0;
                                         if (isset($prom_series['multiple']) && $prom_series['multiple'] >= 0) {
                                             $multiple = $prom_series['multiple'];
                                         }
                                         $prom_goods['series'] = $prom_series;
                                         // 是否有库存 --- 上面检查过库存  下面部分代码不需要检查库存
                                         /*
                                                                                    *   if ($item_new['store_nums'] <= 0) {    // test OK
                                                                                         $error = 1;
                                                                                         $error_item = array("msg" => '商品:' . $item['name'] . '--库存已经没有!',
                                                                                             "product_id" => $item['product_id'],
                                                                                         );
                                                                                         $error_list[] = $error_item;
                                                                                     } else if ($item_new['store_nums'] < $item["num"]) {          // test OK
                                                                                         $error = 1;
                                                                                         $error_item = array("msg" => '商品:' . $item['name'] . '--库存只有' . $item_new['store_nums'] . '个!',
                                                                                             "product_id" => $item['product_id'],
                                                                                         );
                                                                                         $error_list[] = $error_item;
                                                                                     }  */
                                         //修改ITEM内容
                                         $item_ref['real_price'] = $prom_series['parse']['real_price'];
                                         $item_ref['prom'] = $note;
                                         //$item_ref['store_nums']  = $prom_goods['store_nums'];
                                     } else {
                                         // 单品--商品促销结束
                                         $item_ref['order_type']['prom_series'] = false;
                                         // $item_ref['real_price'] = $item_ref['sell_price'];   // 真正价格 为 原来的 销售价格  上一步执行
                                         // $item_ref['prom'] = "";
                                         $error = 1;
                                         $error_item = array("msg" => '商品:' . $item['name'] . '--系列促销已经结束!', "product_id" => $item['product_id']);
                                         $error_list[] = $error_item;
                                     }
                                 } elseif ($item["order_type"]["prom_goods"] == true) {
                                     //2 判断商品促销(单品)
                                     $products_inst = new Products();
                                     $ret = $products_inst->getProduct($item['product_id']);
                                     // 获取商品信息 item = product
                                     if (isset($ret['status']) && $ret['status'] == 1) {
                                         $item_new = $ret['data'];
                                     }
                                     $item_new['goods_nums'] = $item['num'];
                                     // get prom goods 需要传参数goods_nums
                                     $prom_goods = $prom_inst->get_prom_goods($item_new);
                                     if (!empty($prom_goods)) {
                                         $prom_goods['parse'] = $prom_inst->do_prom_goods($item_new, $prom_goods);
                                         if (isset($prom_goods['parse']['note']) && $prom_goods['parse']['note'] != '') {
                                             $prom_goods['parse']['note'] = '商品优惠:' . $prom_goods['parse']['note'];
                                         }
                                         $amount = sprintf("%01.2f", $prom_goods['parse']['real_price'] * $item["num"]);
                                         $sell_total = $item['sell_price'] * $item["num"];
                                         // 是否有库存
                                         if ($item_new['store_nums'] <= 0) {
                                             // test OK
                                             $error = 1;
                                             $error_item = array("msg" => '商品:' . $item['name'] . '--库存已经没有!', "product_id" => $item['product_id']);
                                             $error_list[] = $error_item;
                                         } else {
                                             if ($item_new['store_nums'] < $item["num"]) {
                                                 // test OK
                                                 $error = 1;
                                                 $error_item = array("msg" => '商品:' . $item['name'] . '--库存只有' . $item_new['store_nums'] . '个!', "product_id" => $item['product_id']);
                                                 $error_list[] = $error_item;
                                             }
                                         }
                                         //修改ITEM内容 价格
                                         $item_ref['real_price'] = $prom_goods['parse']['real_price'];
                                     } else {
                                         // 单品--商品促销结束
                                         $item_ref['order_type']['prom_goods'] = false;
                                         $item_ref['real_price'] = $item_ref['sell_price'];
                                         // 真正价格 为 原来的 销售价格
                                         $item_ref['prom'] = "";
                                         $error = 1;
                                         $error_item = array("msg" => '商品:' . $item['name'] . '--商品促销已经结束!', "product_id" => $item['product_id']);
                                         $error_list[] = $error_item;
                                     }
                                 } elseif ($item["order_type"]["prom_series"] == true) {
                                     //3 系列促销
                                     //商品促销与系列促销叠加运算
                                     $products_inst = new Products();
                                     $products_item = array();
                                     $note = "";
                                     $ret = $products_inst->getProduct($item['product_id']);
                                     // 获取商品信息 item = product
                                     if (isset($ret['status']) && $ret['status'] == 1) {
                                         $item_new = $ret['data'];
                                     }
                                     $prom_series = $prom_inst->get_prom_series($item_new);
                                     if (!empty($prom_series)) {
                                         $prom_series['parse'] = $prom_inst->do_prom_series($item_new, NULL, $prom_series);
                                         if (isset($prom_series['parse']['note']) && $prom_series['parse']['note'] != '') {
                                             $note .= '; 系列优惠:' . $prom_series['parse']['note'];
                                         }
                                         $amount = sprintf("%01.2f", $prom_series['parse']['real_price'] * $item["num"]);
                                         $sell_total = $item['sell_price'] * $item["num"];
                                         //合并商品与系统促销
                                         $multiple = 0;
                                         if (isset($prom_series['multiple']) && $prom_series['multiple'] >= 0) {
                                             $multiple = $prom_series['multiple'];
                                         }
                                         $prom_goods['series'] = $prom_series;
                                         // 是否有库存
                                         if ($item_new['store_nums'] <= 0) {
                                             // test OK
                                             $error = 1;
                                             $error_item = array("msg" => '商品:' . $item['name'] . '--库存已经没有!', "product_id" => $item['product_id']);
                                             $error_list[] = $error_item;
                                         } else {
                                             if ($item_new['store_nums'] < $item["num"]) {
                                                 // test OK
                                                 $error = 1;
                                                 $error_item = array("msg" => '商品:' . $item['name'] . '--库存只有' . $item_new['store_nums'] . '个!', "product_id" => $item['product_id']);
                                                 $error_list[] = $error_item;
                                             }
                                         }
                                         //修改ITEM内容
                                         $item_ref['real_price'] = $prom_series['parse']['real_price'];
                                         $item_ref['prom'] = $note;
                                         // $item_ref['store_nums']  = $prom_goods['store_nums'];
                                     } else {
                                         // 单品--商品促销结束
                                         $item_ref['order_type']['prom_series'] = false;
                                         // $item_ref['real_price'] = $item_ref['sell_price'];   // 真正价格 为 原来的 销售价格  上一步执行
                                         // $item_ref['prom'] = "";
                                         $error = 1;
                                         $error_item = array("msg" => '商品:' . $item['name'] . '--系列促销已经结束!', "product_id" => $item['product_id']);
                                         $error_list[] = $error_item;
                                     }
                                 } else {
                                     // 正常的销售
                                     $products_inst = new Products();
                                     $products_item = array();
                                     $ret = $products_inst->getProduct($item['product_id']);
                                     // 获取商品信息 item = product
                                     if (isset($ret['status']) && $ret['status'] == 1) {
                                         $item_new = $ret['data'];
                                     }
                                     // 是否有库存
                                     if (isset($item_new)) {
                                         if ($item_new['store_nums'] <= 0) {
                                             $error = 1;
                                             $error_item = array("msg" => '商品:' . $item['name'] . '--库存已经没有!', "product_id" => $item['product_id']);
                                             $error_list[] = $error_item;
                                         } else {
                                             if ($item_new['store_nums'] < $item["num"]) {
                                                 $error = 1;
                                                 $error_item = array("msg" => '商品:' . $item['name'] . '--库存只有' . $item_new['store_nums'] . '个!', "product_id" => $item['product_id']);
                                                 $error_list[] = $error_item;
                                             }
                                         }
                                     } else {
                                         $error = 1;
                                         $error_item = array("msg" => '商品:' . $item['name'] . '--已经下线!', "product_id" => $item['product_id']);
                                         $error_list[] = $error_item;
                                     }
                                 }
                             }
                         }
                         $payable_amount += $item['sell_price'] * $item['num'];
                         // 成交价格
                         $real_amount += $item['real_price'] * $item['num'];
                         // 真实成交价格
                         // $payable_amount += $item['sell_total'];
                         //$real_amount += $item['amount'];
                         $weight += $item['weight'] * $item['num'];
                         $point += $item['point'] * $item['num'];
                     }
                 }
             }
             $order_bundling = null;
             $error_bd_list = array();
             if (!empty($cart_info[$ship_id]['bundling_list'])) {
                 //Tiny::log(__FILE__ . __LINE__ . "------cart info---" . var_export($cart_info, true));
                 $order_bundling =& $cart_info[$ship_id]['bundling_list'];
                 foreach ($order_bundling as $b_key => $b_val) {
                     // Tiny::log(__FILE__ . __LINE__ . "-------products item----$key----" . var_export($item, true));
                     // 判断是否存在
                     $bundling_total = 0;
                     foreach ($b_val as $v_key => $v_val) {
                         $num = $v_val['num'];
                         // 计算
                         $payable_amount += $v_val["val"]['price'] * $v_val["num"];
                         //$real_amount += $v_val["val"]['price'];  // 在item里面增加amount 项目
                         $real_amount += $v_val["val"]['price'] * $v_val["num"];
                         $bundling_total += $v_val["num"];
                         $arr_id = explode('-', $v_key);
                         //$str_ids = join(',', $arr_id);
                         $product_list = array();
                         if (!empty($arr_id)) {
                             $product_inst = new Products();
                             $ret = $product_inst->getProducts($arr_id);
                             if (isset($ret['status']) && $ret['status'] == 1) {
                                 $product_list = $ret['data'];
                             }
                         }
                         //SKM-ORDER-STORE  todo 判断库存是否足够
                         foreach ($product_list as $p_k => $p_v) {
                             if ($p_v['store_nums'] < $num) {
                                 // test OK
                                 $error = 1;
                                 $error_item = array("msg" => '套餐中商品:' . $p_v['name'] . '--库存只有' . $p_v['store_nums'] . '个!');
                                 $error_bd_list[] = $error_item;
                             }
                         }
                     }
                 }
             }
             if ($error == 1) {
                 $this->assign('error_list', $error_list);
                 $this->assign('error_bd_list', $error_bd_list);
                 // Req::args('msg', "提交订单失败");
                 //$this->redirect("/simple/cart", true, Req::args());
                 $this->redirect("/simple/cart", false);
                 exit;
             }
             // 处理整个订单
             //计算运费
             $fare = new Fare($weight);
             $payable_freight = $fare->calculate($address_id);
             $real_freight = $payable_freight;
             //计算订单优惠
             $prom_order = array();
             $discount_amount = 0;
             // order_type 购买的方式
             //if ($order_type == 0) {
             if ($prom_id) {
                 // 往Prom_Order 表中查询
                 // 这部分属于整个订单促销活动
                 $prom = new Prom($real_amount);
                 $prom_order = $model->table("prom_order")->where("id={$prom_id}")->find();
                 //防止非法会员使用订单优惠
                 $user = $this->user;
                 $group_id = ',0,';
                 if (isset($user['group_id'])) {
                     $group_id = ',' . $user['group_id'] . ',';
                 }
                 if (stripos(',' . $prom_order['group'] . ',', $group_id) !== false) {
                     $prom_parse = $prom->parsePorm($prom_order);
                     $discount_amount = $prom_parse['value'];
                     if ($prom_order['type'] == 4) {
                         $discount_amount = $payable_freight;
                     } else {
                         if ($prom_order['type'] == 2) {
                             $multiple = intval($prom_order['expression']);
                             $multiple = $multiple == 0 ? 1 : $multiple;
                             $point = $point * $multiple;
                         }
                     }
                     $data['prom'] = serialize($prom_order);
                 } else {
                     $data['prom'] = serialize(array());
                 }
             }
             // }
             //税计算
             $tax_fee = 0;
             /*
             $config = Config::getInstance();
             $config_other = $config->get('other');
             $open_invoice = isset($config_other['other_is_invoice']) ? !!$config_other['other_is_invoice'] : false;
             $tax = isset($config_other['other_tax']) ? intval($config_other['other_tax']) : 0;
             if ($open_invoice && $is_invoice) {
                 $tax_fee = $real_amount * $tax / 100;
             }
             */
             $ret = $this->cart_inst->getTaxAmountByShip($ship_id);
             if (isset($ret['status']) && $ret['status'] == 1 && $ret['data'] > 0) {
                 $tax_fee = $ret['data'];
             }
             //代金券处理
             $voucher_value = 0;
             $voucher = array();
             if ($voucher_id) {
                 $voucher = $model->table("voucher")->where("id={$voucher_id} and is_send=1 and user_id=" . $this->user['id'] . " and status = 0 and '" . date("Y-m-d H:i:s") . "' <=end_time and '" . date("Y-m-d H:i:s") . "' >=start_time and money<=" . $real_amount)->find();
                 if ($voucher) {
                     $voucher_value = $voucher['value'];
                     if ($voucher_value > $real_amount) {
                         $voucher_value = $real_amount;
                     }
                 }
             }
             if ($tax_fee <= 50) {
                 $tax_fee = 0;
             }
             //计算订单总金额
             $order_amount = $real_amount + $payable_freight + $tax_fee - $discount_amount - $voucher_value;
             $payable_amount += $payable_freight + $tax_fee;
             //填写订单
             $data['order_no'] = Common::createOrderNo();
             $data['user_id'] = $this->user['id'];
             $data['sender_name'] = $this->user['name'];
             $data['payment'] = $payment_id;
             $data['status'] = 2;
             $data['pay_status'] = 0;
             $data['accept_name'] = $address['accept_name'];
             $data['phone'] = $address['phone'];
             $data['mobile'] = $address['mobile'];
             $data['province'] = $address['province'];
             $data['city'] = $address['city'];
             $data['county'] = $address['county'];
             $data['addr'] = $address['addr'];
             $data['zip'] = $address['zip'];
             $data['payable_amount'] = $payable_amount;
             $data['payable_freight'] = $payable_freight;
             $data['real_freight'] = $real_freight;
             $data['create_time'] = date('Y-m-d H:i:s');
             $data['user_remark'] = $user_remark;
             $data['is_invoice'] = $is_invoice;
             if ($is_invoice == 1) {
                 $data['invoice_title'] = $invoice_type . ':' . $invoice_title;
             } else {
                 $data['invoice_title'] = '';
             }
             $data['taxes'] = $tax_fee;
             $data['discount_amount'] = $discount_amount;
             $data['order_amount'] = $order_amount;
             $data['real_amount'] = $real_amount;
             $data['point'] = $point;
             $data['type'] = $order_type;
             // type -> order_type
             $data['voucher_id'] = $voucher_id;
             $data['voucher'] = serialize($voucher);
             //var_dump($order_products);exit();
             // TODO SKM 写入订单数据
             $order_id = $model->table("order")->data($data)->insert();
             //写入订单商品
             // 单品 加入订单详情表
             foreach ($order_products as $goods_id => $products) {
                 foreach ($products as $product_id => $item) {
                     $tem_data = array('order_id' => '', 'goods_id' => '', 'product_id' => '', 'goods_name' => '', 'goods_price' => '', 'real_price' => '', 'goods_nums' => '', 'tax_code' => '', 'spec' => '');
                     if (isset($item["order_type"])) {
                         if (is_array($item["order_type"])) {
                             if ($item["order_type"]["flash_sale"] == true) {
                             } elseif ($item["order_type"]["prom_series"] == true) {
                                 $tem_data['prom_goods'] = serialize($item['prom_goods']);
                             } elseif ($item["order_type"]["prom_series"] == false && $item["order_type"]["prom_goods"] == true) {
                                 $tem_data['prom_goods'] = serialize($item['prom_goods']);
                             } elseif ($item["order_type"]["bundling"] == true) {
                             }
                         }
                     }
                     $tem_data['order_id'] = $order_id;
                     $tem_data['goods_id'] = $item['goods_id'];
                     $tem_data['goods_no'] = $item['goods_no'];
                     $tem_data['product_id'] = $product_id;
                     $tem_data['goods_name'] = $item['name'];
                     $tem_data['goods_price'] = $item['sell_price'];
                     $tem_data['real_price'] = $item['real_price'];
                     $tem_data['goods_nums'] = $item['num'];
                     //$tem_data['goods_weight'] = $item['weight'];
                     $tem_data['tax_code'] = $item['tax_code'];
                     // todo SKM 跟税种相关
                     $tem_data['origin_country'] = $item['origin_country'];
                     $tem_data['spec'] = serialize($item['spec']);
                     $model->table("order_goods")->data($tem_data)->insert();
                 }
             }
             // 捆绑销售 加入订单详情表
             if (!empty($cart_info[$ship_id]['bundling_list'])) {
                 $order_bundling = $cart_info[$ship_id]['bundling_list'];
                 foreach ($order_bundling as $item) {
                     $tem_data = array();
                     //$tem_data['prom_goods'] = serialize($item['prom_goods']);
                     foreach ($item as $key_bundling => $val_bundling) {
                         $bundling = $val_bundling;
                         $arr_products_id = explode('-', $key_bundling);
                         $str_products_ids = join(',', $arr_products_id);
                         $tem_data['order_id'] = $order_id;
                         $tem_data['goods_ids'] = $bundling["val"]['goods_id'];
                         $tem_data['products_ids'] = $str_products_ids;
                         //  $tem_data['goods_price'] = $item['sell_price'];
                         $tem_data['title'] = $bundling["val"]['title'];
                         $tem_data['prom_type'] = "bundling";
                         $tem_data['bundling_id'] = $bundling["val"]['id'];
                         $tem_data['real_price'] = $bundling['val']['price'];
                         $tem_data['goods_nums'] = $bundling['num'];
                         // $tem_data['goods_weight'] = $item['weight'];
                         //  $tem_data['spec'] = serialize($item['spec']);
                         $model->table("order_goods")->data($tem_data)->insert();
                     }
                 }
             }
             //优惠券锁死
             if (!empty($voucher)) {
                 $model->table("voucher")->where("id={$voucher_id} and user_id=" . $this->user['id'])->data(array('status' => 2))->update();
             }
             //清空购物车与表单缓存
             if ($order_type == 0) {
                 $this->cart_inst = Cart::getCart();
                 $this->cart_inst->clearShip($ship_id);
                 // 清空 ship_id 购物车   分库位置
                 //$cart->clear();
                 Session::clear("order_status");
             }
             $this->redirect("/simple/order_status/order_id/{$order_id}");
         } else {
             $msg = array('type' => 'fail', 'msg' => '非法提交订单!');
             $this->redirect('/index/msg', false, $msg);
         }
     } else {
         $this->redirect("login");
     }
 }
示例#10
0
 public function print_picking()
 {
     $this->layout = 'blank';
     $this->title = '配货单打印';
     $this->assign("id", Req::args("id"));
     $order_init = new Order();
     $order_id = Filter::int(Req::args("id"));
     $ret = $order_init->getOrderWithDetail($order_id);
     if ($ret['status'] == 1) {
         $order_list = $ret['data'];
     }
     $order_goods_list = $order_list['OrderGoods'];
     if ($order_goods_list) {
         foreach ($order_goods_list as $key => $item) {
             if ($item['prom_type'] == 'bundling') {
                 $goods_attrs[] = $item['products_ids'];
                 $products_init = new Products();
                 $ret = $products_init->getProducts($goods_attrs);
                 if ($ret['status'] == 1) {
                     $products_list = $ret['data'];
                 }
                 $order_goods_list[$key]["products_list"] = $products_list;
             }
         }
         $this->assign('order_goods_list', $order_goods_list);
     }
     $this->redirect();
 }
示例#11
0
 public function order_detail()
 {
     $id = Filter::int(Req::args("id"));
     $order = $this->model->table("order as od")->fields("od.*,pa.pay_name")->join("left join payment as pa on od.payment = pa.id")->where("od.id = {$id} and od.user_id=" . $this->user['id'])->find();
     if ($order) {
         $invoice = $this->model->table("doc_invoice as di")->fields("di.*,ec.code as ec_code,ec.name as ec_name,ec.alias as ec_alias")->join("left join express_company as ec on di.express_company_id = ec.id")->where("di.order_id=" . $id)->find();
         $order_goods = $this->model->table("order_goods as og ")->join("left join goods as go on og.goods_id = go.id left join products as pr on og.product_id = pr.id")->where("og.order_id=" . $id)->findAll();
         $this->assign("order_goods", $order_goods);
         $this->assign("invoice", $invoice);
         $this->assign("order", $order);
         $order_init = new Order();
         $order_id = Filter::int(Req::args("id"));
         $ret = $order_init->getOrderWithDetail($order_id);
         if ($ret['status'] == 1) {
             $order_list = $ret['data'];
         }
         $order_goods_list = $order_list['OrderGoods'];
         if ($order_goods_list) {
             foreach ($order_goods_list as $key => $item) {
                 if ($item['prom_type'] == 'bundling') {
                     $goods_attrs[] = $item['products_ids'];
                     $products_init = new Products();
                     $ret = $products_init->getProducts($goods_attrs);
                     if ($ret['status'] == 1) {
                         $products_list = $ret['data'];
                     }
                     $order_goods_list[$key]["products_list"] = $products_list;
                 }
             }
             $this->assign('order_goods_list', $order_goods_list);
         }
         $this->redirect();
     } else {
         Tiny::Msg($this, 404);
     }
 }
示例#12
0
 public function modifyBundlingNum($bundling, $num = 1)
 {
     $bundling_id = NULL;
     $ship_id = NULL;
     $products_ids = NULL;
     if (isset($bundling["bundling_id"]) && $bundling["bundling_id"] > 0) {
         $bundling_id = $bundling["bundling_id"];
     } else {
         $ret["msg"] = "修改商品数量失败";
         $ret["status"] = false;
         return $ret;
     }
     if (isset($bundling["ship_id"]) && $bundling["ship_id"] > 0) {
         $ship_id = $bundling["ship_id"];
     } else {
         $ret["msg"] = "修改商品数量失败";
         $ret["status"] = false;
         //Tiny::log(__FILE__.__LINE__."------------carts----------".$ret["msg"]);
         return $ret;
     }
     if (isset($bundling["products_ids"]) && $bundling["products_ids"] > 0) {
         $products_ids = $bundling["products_ids"];
     } else {
         $ret["msg"] = "没有组合商品内容";
         $ret["status"] = false;
         //Tiny::log(__FILE__.__LINE__."------------carts----------".$ret["msg"]);
         return $ret;
     }
     /*
      * $bundling_inst = new Bundling();
     if( (isset($bundling["products_ids"]) && $bundling["products_ids"]!= "") && isset($bundling["ship_id"]) && $bundling["ship_id"]>0  ){
         $products_ids = $bundling["products_ids"];
         $ship_id = $bundling["ship_id"];
     }else{
     
         $item = array();
         $item = $bundling_inst->getBundling($bundling_id);  // 获取购物车 所有的商品
     
         if (!empty($item) && isset($item["goods_id"])){
            // $products_ids = $item["goods_id"];
            // $goods_id = $item["goods_id"];
             //$ship_id = $item["ship_id"]; // 为非空  取 goods_id 的第一个
         }else{
             $ret["msg"] =  "删除商品失败,没有商品ID或ship_id";
             $ret["status"] = false;
             return $ret;
         }
     }
     */
     $bundling_info = array("ship_id" => $ship_id, "bundling_id" => $bundling_id, "products_ids" => $products_ids);
     //Tiny::log(__FILE__.__LINE__."------------carts----------".var_export($bundling_info, true) );
     if (!$this->hasBundling($bundling_info)) {
         $ret["msg"] = "修改商品数量失败,没有商品";
         $ret["status"] = false;
         return $ret;
     }
     //SKM 判断商品是否超过库存量
     // todo products.num + bundling.num > store_nums
     // 当前 bundling.num > store_nums
     //$bundling_inst = new Bundling();
     //$bund = $bundling_inst->getBundlingWithDetail($bundling_id);
     $max_nums = $num;
     $arr_ids = explode('-', $products_ids);
     $products_inst = new Products();
     $max_store_nums = 100;
     // 初始化为100
     $ret = $products_inst->getProducts($arr_ids);
     if (isset($ret['status']) && $ret['status'] == 1) {
         $bundProducts = $ret['data'];
         if (isset($bundProducts)) {
             foreach ($bundProducts as $p_v) {
                 $product_num = $this->bundlingInProducts($ship_id, $p_v['id']);
                 if ($max_store_nums > $p_v['store_nums']) {
                     $max_store_nums = $p_v['store_nums'];
                 }
                 if ($max_nums > $p_v['store_nums'] - $product_num) {
                     $max_nums = $p_v['store_nums'] - $product_num;
                 }
             }
         }
     }
     if ($num >= $max_nums) {
         $this->items[$ship_id]["bundling_list"][$bundling_id][$products_ids]['num'] = $max_nums;
         $this->items[$ship_id]["bundling_list"][$bundling_id][$products_ids]['max_nums'] = $max_nums;
     } else {
         $this->items[$ship_id]["bundling_list"][$bundling_id][$products_ids]['num'] = $num;
         $this->items[$ship_id]["bundling_list"][$bundling_id][$products_ids]['max_nums'] = $max_nums;
     }
     $ret["msg"] = "修改商品数量成功";
     $ret["status"] = true;
     return $ret;
 }
示例#13
0
 public function order_get()
 {
     $my_order = array();
     $order_no = Filter::str(Req::args('order_no'));
     $ret = Order::getOrderWithDetailByNo($order_no);
     if (isset($ret['status']) && $ret['status'] == 1) {
         $order = $ret['data'];
         if ($order != NULL) {
             $my_order = $order;
             $my_order_detail = array();
             if (isset($order['OrderGoods'])) {
                 foreach ($order['OrderGoods'] as $key => $val) {
                     if ($val['prom_type'] == 'bundling') {
                         $arr_ids = explode(',', $val['products_ids']);
                         $product_inst = new Products();
                         $ret_p = $product_inst->getProducts($arr_ids);
                         if (isset($ret_p['status']) && $ret_p['status'] == 1) {
                             $products_list = $ret_p['data'];
                             foreach ($products_list as $sub_key => $sub_val) {
                                 $product_item = array('goods_id' => $sub_val['goods_id'], 'goods_no' => $sub_val['goods_no'], 'weight' => $sub_val['weight'], 'num' => $val['goods_nums']);
                                 $my_order_detail[] = $product_item;
                             }
                         }
                     } else {
                         $product_item = array('goods_id' => $sub_val['goods_id'], 'goods_no' => $val['goods_no'], 'weight' => $val['weight'], 'num' => $val['num']);
                         $my_order_detail[] = $product_item;
                     }
                 }
             }
             $my_order['OrderGoods'] = $my_order_detail;
         }
     }
     echo json_encode($my_order, JSON_UNESCAPED_SLASHES);
 }
示例#14
0
            return $product->getId();
            //endif;
        } catch (Exception $e) {
            echo $e->getMessage();
            Mage::log('product import error' . $e->getMessage());
        }
    }
    /**************** Create Configurable Product ********************************/
    function updateProductIdinInterspire($intespireid, $magenotproductid)
    {
        $prepare = $this->conInterspire->prepare("\n            update `isc_products` set `magentoproductid`='" . $magenotproductid . "' where \n           `productid`='" . $intespireid . "'\n        ");
        $prepare->execute();
    }
}
$obj = new Products();
$products = $obj->getProducts();
foreach ($products as $product) {
    $configurableoptions = $obj->getConfigurableOptions($product['productid']);
    if (count($configurableoptions)) {
        $productimages = $obj->getProductImages($product['productid']);
        try {
            $simpleProduct = $this->_createProduct(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
            // create simple product
            $confProduct = $this->_createProduct(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, false);
            // create conf product but do not save
            //   $productid=$obj->addConfigurableProduct($product,$productimages);
        } catch (exception $e) {
            echo $e->getMessage();
        }
        foreach ($configurableoptions as $option) {
            echo '<pre>';