public function init() { header("Content-type: text/html; charset=" . $this->encoding); $this->model = new Model(); $this->safebox = Safebox::getInstance(); $this->user = $this->safebox->get('user'); if ($this->user == null) { $this->user = Common::autoLoginUserInfo(); $this->safebox->set('user', $this->user); } $category = Category::getInstance(); $this->category = $category->getCategory(); $cart = Cart::getCart(); $action = Req::args("act"); switch ($action) { case 'order_detail': $action = 'order'; break; case 'refund_detail': $action = 'refund'; break; } $this->assign("actionId", $action); $this->assign("cart", $cart->all()); $this->assign("cart_num", $cart->getNum()); $this->assign("sidebar", $this->sidebar); $this->assign("category", $this->category); $this->assign("seo_title", "用户中心"); }
public function init() { header("Content-type: text/html; charset=" . $this->encoding); $this->model = new Model(); $this->safebox = Safebox::getInstance(); $this->user = $this->safebox->get('user'); $category = Category::getInstance(); $this->category = $category->getCategory(); $cart = Cart::getCart(); $this->assign("cart_num", $cart->getNum()); $this->assign("cart", $cart->all()); $this->assign("category", $this->category); }
function addToCart() { $result = $this->Cart->Product->findById($this->p); if (empty($result)) { $this->Session->setFlash('This product was not found!'); $this->redirect(array('action' => 'index')); } else { if ($result['Product']['pd_qty'] <= 0) { $this->Session->setFlash('The product you requested is out of stock!'); $this->redirect(array('action' => 'index')); } } //ce je user loginan se uporablja userov ID if ($this->Auth->user()) { $sessionData = $this->Cart->getCart($this->p, $this->sid, $this->Session->read('Auth.User.id')); if (empty($sessionData)) { $this->Cart->addToCart($this->p, $this->sid, $this->Session->read('Auth.User.id')); $this->Session->setFlash('Product added to cart! -> through user ID / inserted'); } else { $this->Cart->updateCart($this->p, $this->sid, $this->Session->read('Auth.User.id')); $this->Session->setFlash('Product added to cart! -> through session ID / updated'); } //ce user ni prijavljen se uporablja sejni ID } else { $sessionData = $this->Cart->getCart($this->p, $this->sid); if (empty($sessionData)) { $this->Cart->addToCart($this->p, $this->sid); $this->Session->setFlash('Product added to cart! -> through session ID / inserted'); } else { $this->Cart->updateCart($this->p, $this->sid); $this->Session->setFlash('Product added to cart! -> through session ID / updated'); } } $this->Cart->cleanUp(); $this->redirect(array('controller' => 'carts', 'action' => "index/c:{$this->c}/p:{$this->p}")); }
if (page('shop')->mailing_address()->bool() and get('payer_address')) { // Address provided, we're good. $valid = true; } else { // No address provided. $valid = false; } } } else { // No name or email provided. $valid = false; } if ($valid) { // Save customer details to the transaction try { $txn->update(['payer-name' => get('payer_name'), 'payer-email' => get('payer_email'), 'payer-address' => get('payer_address')], $site->defaultLanguage()->code()); } catch (Exception $e) { // Update failed snippet('mail.order.update.error', ['txn' => $txn, 'payment_status' => $txn->status(), 'payer_name' => get('payer_name'), 'payer_email' => get('payer_email'), 'payer_address' => get('payer_address')]); return false; } // Empty the cart $cart = Cart::getCart(); $cart->emptyItems(); // Redirect to orders page go('shop/orders?txn_id=' . $txn->txn_id()); } } // Form is invalid or hasn't been submitted yet return ['txn' => $txn, 'payer_name' => $payer_name, 'payer_email' => $payer_email, 'payer_address' => $payer_address]; };
page('shop/orders/' . get('update_id'))->update(['status' => 'paid']); } catch (Exception $e) { echo $e->getMessage(); } } // Role-based filters if (get('txn_id') != '') { // If single transaction ID passed, show just that one order $orders = $page->children()->sortBy('txn_date', 'desc')->filterBy('txn_id', get('txn_id')); } else { if ($user and $user->role() == 'admin') { // If admin, show all orders $orders = $page->children()->sortBy('txn_date', 'desc'); } else { if ($user) { // If logged in, show this user's orders $orders = $page->children()->sortBy('txn_date', 'desc')->filterBy('payer_email', $user->email()); } else { // If not logged in, don't show orders $orders = false; } } } // Status filters if (get('status')) { $orders = $orders->filter(function ($order) { return in_array($order->status(), get('status')); }); } return ['user' => $site->user(), 'cart' => Cart::getCart(), 'orders' => $orders]; };
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"); } }
/** * The function posts order. * * @access public * @return string The JSON response. */ public function order() { $Cart = Cart::getCart(); $Order = $Cart->getOrder(); $Order->Type = Order::STANDARD; return $this->postOrder($Order, $Cart); }
<?php // Ensure source code is readable: if (isset($_GET['source'])) { highlight_file($_SERVER['SCRIPT_FILENAME']); exit; } // Call on required codes: require 'model.php'; require 'view.php'; // Begin calling classes: $user = new User(); if ($user->validate()) { $user->getRight(); $cart = new Cart($_SESSION['data'], $user->session); if ($cart->getCart()) { $cartPanel = new cartView($cart); $cartPanel->output(); } if (in_array("admin", $user->rights)) { $inventory = new Inventory($user->session); $inventoryPanel = new InventoryView($inventory->getInventory()); $inventoryPanel->output(); } } ?> <!DOCTYPE html> <html> <head> <title>Log-In Page</title> <meta charset="utf-8">
/** * The function returns address (contact) block for order. * * @access public * @return string The HTML code. */ public function htmlCartAddress() { return $this->includeLayout('view/cart/contact.html', array('Cart' => Cart::getCart())); }
private function checkProductTax_p2($ship_id, $tax_amount) { $cart = Cart::getCart(); $ret = $cart->getTaxAmountByShip($ship_id); if ($ret['status'] == 1) { $tax_amount = $ret['data'] + $tax_amount; } return $tax_amount; }