function getProducts($products) { foreach ($products as $k => $product) { $skus = ProductsSku::getItemSkus($product['item']); $min = 100000.0; $max = 0.0; $price = ''; foreach ($skus as $sku) { if ($min > $sku['current_price']) { $min = $sku['current_price']; } if ($max < $sku['current_price']) { $max = $sku['current_price']; } } if ($min == $max) { $price = $min; } else { $price = "{$min} ~ {$max}"; } $products[$k]['price'] = $price; if (!isset($products[$k]['pics']) || !$products[$k]['pics']) { $path = ''; foreach ($skus as $sku) { $pic = ProductsPic::getOne(array('sku' => $sku['sku']), 'path', 'sort DESC'); $path = isset($pic['path']) ? $pic['path'] : ''; if ($path) { break; } } $products[$k]['pics'] = $path; } } return $products; }
public static function getProductsPic(&$products) { foreach ($products as $k => $sk) { $pic = ProductsPic::getOne(array('sku' => $sk['sku']), 'path', 'sort DESC'); $path = isset($pic['path']) ? $pic['path'] : ''; $products[$k]['pic'] = $path; } return $products; }
public static function getOrderSku($order_code) { if (!$order_code) { return array(); } $table = self::table(); $sku_table = ProductsSku::table(); $item_table = ProductsItem::table(); $pic_table = ProductsPic::table(); $sql = "SELECT c.title, b.sku, b.sku_name, b.item, b.current_price, SUM(a.product_num) AS product_num\n\t\tFROM {$table} AS a, {$sku_table} AS b, {$item_table} AS c\n\t\tWHERE c.item=b.item AND a.product_sku=b.sku AND a.order_code='{$order_code}' GROUP BY a.product_sku"; $rs = DB::GetQueryResult($sql, false); return $rs; }
public static function getProducts($user_id) { $user_id = (int) $user_id; if (!$user_id) { return array(); } $rs = self::getList("user_id='{$user_id}' AND status=0", 'sku_id, qt', 'update_time DESC'); foreach ($rs as $k => $v) { $rs[$k]['sku'] = $skus = ProductsSku::getData($v['sku_id']); $pic = ProductsPic::getOne(array('sku' => $skus['sku']), 'path', 'sort DESC'); $rs[$k]['sku']['pic'] = $pic['path']; $item = ProductsSku::getSkuItem($skus['item'], 'title'); $rs[$k]['sku']['title'] = $item['title']; } return $rs; }
exit; } $sku = ProductsSku::getData($id); if (!$sku) { header("Location: /html/404.html?004"); exit; } $item_code = $sku['item']; $item = ProductsItem::getOne(array('item' => $item_code, 'status' => 1)); if (!$item) { header("Location: /html/404.html?005"); exit; } $sku['iteminfo'] = $item; $sku_code = $sku['sku']; $pics = ProductsPic::getSkuPics($sku_code, 'path', 'sort DESC LIMIT 0,3'); $sku['pics'] = $pics; $sku['order_num'] = OrdersProducts::getSkuAllNum($sku_code); $sku['stock'] = ProductsStock::getSkuStock($sku_code); $skus = ProductsSku::getItemSkus($item_code, "id,sku,sku_name"); $skus = ProductsSku::getProductsPic($skus); $sku['skus'] = $skus; $userid = isset($_SESSION['userid']) ? (int) $_SESSION['userid'] : 0; $history = array(); if ($userid) { $history = UsersHistory::getProductViewLog($userid, $id); } if (!$history) { $history = ProductsSku::getRand($item_code); } $history = ProductsSku::getProductsPic($history);
exit; } $userid = isset($_SESSION['userid']) ? (int) $_SESSION['userid'] : 0; $product_ids = isset($_POST['product_ids']) ? $_POST['product_ids'] : array(); $qts = isset($_POST['qts']) ? $_POST['qts'] : array(); $skus = array(); $total = 0.0; foreach ($product_ids as $sku_id => $product_id) { $qt = isset($qts[$sku_id]) ? (int) $qts[$sku_id] : 0; if ($qt < 1) { continue; } $skus[$sku_id]['qt'] = $qt; $skus[$sku_id]['info'] = $info = ProductsSku::getData($sku_id); $current_price = isset($info['current_price']) ? $info['current_price'] : 0.0; $pic = ProductsPic::getOne(array('sku' => $info['sku']), 'path', 'sort DESC'); $skus[$sku_id]['info']['pic'] = $pic['path']; $item = ProductsSku::getSkuItem($info['item'], 'title'); $skus[$sku_id]['info']['title'] = $item['title']; $total = $total + $qt * $current_price; } //var_dump($product_ids,$skus);exit; $userlevel = Users::getLevel($userid); $discount = $userlevel['discount']; $newtotal = $total * $discount; $address = ReceiverAddress::getInfoByUser($userid); //var_dump($address); $yunfei = 0.0; $token = ABase::token(); Templates::Assign('yunfei', $yunfei); Templates::Assign('token', $token);