public function order_completed() { if ($this->checkOnline()) { $order_id = Filter::int(Req::args("order_id")); if ($order_id) { //TEST-LOG //Tiny::log(__FILE__.__LINE__."--ORDER-COMPLETED--".$this->user['id']); //Tiny::log(__FILE__.__LINE__."--ORDER-COMPLETED--".$order_id); $order = $this->model->table("order as od")->join("left join payment as pa on od.payment= pa.id")->fields("od.id,od.order_no,od.payment,od.pay_status,od.order_amount,pa.pay_name as payname,od.type,od.status")->where("od.id={$order_id} and od.status<4 and od.user_id = " . $this->user['id'])->find(); //TEST-LOG //echo $this->user['id']."\n ------ORDER COMPLETED"; //echo var_export($order, true); //exit(); //TEST-LOG //Tiny::log(__FILE__.__LINE__."--ORDER-COMPLETED--".var_export($order,true)); if ($order) { if ($order['pay_status'] == 1) { $this->assign("order", $order); $this->redirect("order_finish", false); // BUG 支付完成出现的BUG } else { if ($order['pay_status'] == 0) { $payment_plugin = Common::getPaymentInfo($order['payment']); if ($payment_plugin != null && $payment_plugin['class_name'] == 'received') { $this->assign("payment_type", "received"); $this->assign("order", $order); $this->redirect(); } else { $this->redirect("/simple/order_status/order_id/{$order_id}"); } } } } else { Tiny::Msg($this, 404); } } else { Tiny::Msg($this, 404); } } else { $this->redirect("login"); } }
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); } }
/** * 渲染文件视图 * * @access public * @param mixed $view * @param mixed $data * @param bool $return * @return mixed */ public function render($view, $data = null, $return = false) { $viewfile = $this->getViewFile($view) . $this->templateExt; $runfile = Tiny::app()->getRuntimePath() . DIRECTORY_SEPARATOR . $this->getId() . DIRECTORY_SEPARATOR . $view . $this->scriptExt; //if(file_exists($viewfile)) if (is_file($viewfile)) { $layoutfile = $this->getLayoutFile() . $this->templateExt; if (file_exists($layoutfile)) { $layoutexists = true; } else { $layoutexists = false; } if (!file_exists($runfile) || filemtime($runfile) < filemtime($viewfile) || $layoutexists && filemtime($runfile) < filemtime($layoutfile)) { $file = new File($runfile, 'w+'); $template = $file->getContents($viewfile); $t = new Tag(); $tem = $t->resolve($template, dirname($view)); if ($layoutexists) { $theme_str = $t->resolve(file_get_contents($layoutfile)); $tem = str_replace("{__viewcontents}", $tem, $theme_str); } $file->write($tem); unset($file); } echo $this->renderExecute($runfile, $data); } else { Tiny::Msg($this, '请求的页面不存在!', 404); } }
public function product() { //todo 测试代码 加入购物车 /* $addid = Filter::int(Req::args('addid')); if(isset($addid)){ $goods_info = array("product_id" => $addid); $cart = Cart::getCart(); //Tiny::log(__FILE__.__LINE__."---------------------add cart--------------------".var_export($cart, true)); $cart->addProduct($goods_info, 1); } */ $parse = array('直接打折', '减价优惠', '固定金额', '买就赠优惠券', '买M件送N件'); $id = Filter::int(Req::args('id')); $this->assign('id', $id); $id = is_numeric($id) ? $id : 0; // EC 变更 2015-06-16 14:58 关税大于50元,提示信息表示 START //$goods = $this->model->table("goods as go")->join("left join tiny_goods_category as gc on go.category_id = gc.id")->fields("go.*,gc.path")->where("go.id=$id and go.is_online=0")->find(); $goods = $this->model->table("goods as go")->join("left join tiny_goods_category as gc on go.category_id = gc.id left join tiny_tax_type as ttt on go.tax_type_id = ttt.tax_type_id")->fields("go.*,gc.path,ttt.tax_type_percent")->where("go.id={$id} and go.is_online=0")->find(); // EC 变更 2015-06-16 14:58 关税大于50元,提示信息表示 END $order_type = array("flash_sale" => false, "prom_goods" => false, "prom_series" => false, "bundling" => false); //Tiny::log(__FILE__.__LINE__.var_export($goods, true)); if ($goods) { // EC 变更 2015-06-16 14:58 关税大于50元,提示信息表示 START if (!isset($goods["tax_type_percent"])) { $goods["tax_type_percent"] = 0; } // EC 变更 2015-06-16 14:58 关税大于50元,提示信息表示 END $skumap = array(); $products = $this->model->table("products")->fields("sell_price,market_price,store_nums,specs_key,pro_no,id")->where("goods_id = {$id}")->findAll(); //Tiny::log( __FILE__.__LINE__.var_export($products, true)); if ($products) { foreach ($products as $product) { $skumap[$product['specs_key']] = $product; } } $path = trim($goods['path'], ','); $category = Category::getInstance(); $childCategory = $category->getCategoryChild($path); $category = $this->model->table("goods_category")->where("id in ({$path})")->order("field(`id`,{$path})")->findAll(); $time = "'" . date('Y-m-d H:i:s') . "'"; $attr_array = unserialize($goods['attrs']); $goods_attrs = array(); if ($attr_array) { $rows = $this->model->fields("ga.*,av.name as vname,av.id as vid")->table("goods_attr as ga")->join("left join attr_value as av on ga.id=av.attr_id")->where("ga.type_id = {$goods['type_id']}")->findAll(); $attrs = $_attrs = array(); foreach ($rows as $row) { $attrs[$row['id'] . '-' . $row['vid']] = $row; $_attrs[$row['id']] = $row; } foreach ($attr_array as $key => $value) { if (isset($attrs[$key . '-' . $value])) { $goods_attrs[] = $attrs[$key . '-' . $value]; } else { $_attrs[$key]['vname'] = $value; $goods_attrs[] = $_attrs[$key]; } } unset($attrs, $_attrs); } //评论 $comment = array(); $review = array('1' => 0, '2' => 0, '3' => 0, '4' => 0, '5' => 0); $rows = $this->model->table("review")->fields("count(id) as num,point")->where("status=1 and goods_id = {$id}")->group("point")->findAll(); foreach ($rows as $row) { $review[$row['point']] = intval($row['num']); } $a = $review[4] + $review[5]; $b = $review[3]; $c = $review[1] + $review[1]; $total = $a + $b + $c; $comment['total'] = $total; if ($total == 0) { $total = 1; } $comment['a'] = array('num' => $a, 'percent' => round(100 * $a / $total)); $comment['b'] = array('num' => $b, 'percent' => round(100 * $b / $total)); $comment['c'] = array('num' => $c, 'percent' => round(100 * $c / $total)); if ($goods['seo_title'] != '') { $seo_title = $goods['seo_title']; } else { if ($goods['name'] != '') { $seo_title = $goods['name']; } } if ($seo_title != '') { $this->assign('seo_title', $seo_title); } if ($goods['seo_keywords'] != '') { $this->assign('seo_keywords', $goods['seo_keywords']); } if ($goods['seo_description'] != '') { $this->assign('seo_description', $goods['seo_description']); } // 2 商品促销 $goods['goods_nums'] = PHP_INT_MAX; $prom_inst = new Prom(); // 1 限时抢购 与下面的冲突 优先级最高 // 2 捆绑销售 单独分支 // 3 商品促销 与 4 系列促销 叠加处理 //4 系列促销 $prom_goods = NULL; $prom_series = NULL; $goods_info = array("goods_id" => $goods["id"], "prom_id" => $goods["prom_id"], "ship_id" => $goods["ship_id"], "series_id" => $goods["series_id"], "sell_price" => $goods["sell_price"], "goods_nums" => $goods['goods_nums']); $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) { $this->assign("flash_sale", $flash_sale); $order_type["flash_sale"] = true; } else { // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 START $goods["real_price"] = $goods["sell_price"]; // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 END $prom_goods = $prom_inst->get_prom_goods($goods_info); //Tiny::log(__FILE__.__LINE__.var_export($prom_goods, true)); if (!empty($prom_goods)) { $prom_goods['parse'] = $prom_inst->do_prom_goods($goods_info, $prom_goods); // 商品促销 $order_type["prom_goods"] = true; // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 START $goods["real_price"] = $prom_goods['parse']["real_price"]; if ($goods["sell_price"] == $goods["real_price"]) { $order_type["prom_goods"] = false; } // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 END } // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 START //$prom_series_item = $prom_inst->get_prom_series($goods_info, $prom_goods); //if (!empty($prom_series_item)) { //$prom_goods['parse'] = $prom_inst->do_prom_goods($goods, $prom_goods); // 商品促销 $prom_series = $prom_inst->get_prom_series($goods_info, $prom_goods); // 系列促销 if (!empty($prom_series)) { //$prom_series = $prom_inst->do_prom_series($goods_info, $prom_goods, $prom_series_item); $prom_series["parse"] = $prom_inst->do_prom_series($goods_info, $prom_goods, $prom_series); // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 END $order_type["prom_series"] = true; // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 START $goods["real_price"] = $prom_series['parse']["real_price"]; if ($goods["sell_price"] == $goods["real_price"]) { $order_type["prom_series"] = false; } // EC 变更 2015-06-04 10:16 抢购以外的场合,促销价,销售价,优惠信息的修正 END } } //Tiny::log( __FILE__.__LINE__."--flash_sale--".var_export($flash_sale, true)); //Tiny::log( __FILE__.__LINE__."--goods--".var_export($prom_goods, true)); //Tiny::log( __FILE__.__LINE__."--series--".var_export($prom_series, true)); //售后保障 $sale_protection = $this->model->table('help')->where("title='售后保障'")->find(); if ($sale_protection) { $this->assign("sale_protection", $sale_protection['content']); } $this->assign("child_category", $childCategory); $this->assign("prom_g", $prom_goods); $this->assign("prom", $prom_series); $this->assign("order_type", $order_type); $this->assign("flash_sale", $flash_sale); $this->assign("goods", $goods); $this->assign("ship_id", $goods["ship_id"]); $this->assign("goods_attrs", $goods_attrs); $this->assign("category_nav", $category); $this->assign("skumap", $skumap); $this->assign("comment", $comment); // EC 变更 2015-06-16 14:58 关税大于50元,提示信息表示 START // $tax_amount = 0; // if ($order_type["flash_sale"]) { // $tax_amount = $this->checkProductTax_p($goods["ship_id"], $flash_sale['price'], $goods["tax_type_percent"], 1); // } else { // $tax_amount = $this->checkProductTax_p($goods["ship_id"], $goods["real_price"], $goods["tax_type_percent"], 1); // } $tax_amount = $this->checkProductTax_p($goods["ship_id"], $goods["sell_price"], $goods["tax_type_percent"], 1); $this->assign("taxAmount", $tax_amount); // EC 变更 2015-06-16 14:58 关税大于50元,提示信息表示 END // 是否过了促销期 $instFlashSale = new FlashSale(); Tiny::log(" id " . var_export($id, true)); $goodSel = $instFlashSale->getFlashSale($id); if ($goodSel != null) { $sTimeEnd = $goodSel['end_time']; $sTimeNow = date("Y-m-d H:i:s"); Tiny::log("id " . var_export($id, true)); Tiny::log("now " . var_export(strtotime($sTimeNow), true)); Tiny::log("end " . var_export(strtotime($sTimeEnd), true)); if (strtotime($sTimeNow) > strtotime($sTimeEnd)) { $this->assign("OnFlashTime", false); } else { $this->assign("OnFlashTime", true); } } else { $this->assign("OnFlashTime", false); } $this->redirect(); } else { Tiny::Msg($this, "404"); } }