Example #1
0
 public static function getSkuItem($item, $select = '*')
 {
     if (!$item) {
         return array();
     }
     return ProductsItem::getOne(array('item' => $item, 'status' => 1), $select);
 }
Example #2
0
 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;
 }
Example #3
0
 public static function getLists($user_id, $page, $page_size)
 {
     $user_id = (int) $user_id;
     if (!$user_id) {
         return array();
     }
     $table = self::table();
     $sku_table = ProductsSku::table();
     $item_table = ProductsItem::table();
     $sql = " SELECT a.id, b.id AS skuid, c.title, b.sku, b.sku_name, b.current_price FROM {$table} AS a, {$sku_table} AS b, {$item_table} AS c WHERE b.item=c.item AND a.sku_id=b.id AND a.user_id='{$user_id}' ORDER BY a.id DESC";
     $lists = Paging::bySQL($sql, $page, $page_size, 'a');
     ProductsSku::getProductsPic($lists['data']);
     return $lists;
 }
Example #4
0
    }
    header("Location: /product/?id={$skuid}");
    exit;
} else {
    $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
    if (!$id) {
        header("Location: /html/404.html?003");
        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();
Example #5
0
function getOrder()
{
    $orders = Orders::publicPayOrderSignVerify();
    $order_code = isset($orders['order_code']) ? $orders['order_code'] : '';
    $order_id = isset($orders['id']) ? (int) $orders['id'] : 0;
    $paid = isset($orders['paid']) ? (double) $orders['paid'] : 0.0;
    $order_amount = isset($orders['amount']) ? (double) $orders['amount'] : 0.0;
    $payRate = isset($orders['payRate']) ? floatval($orders['payRate']) : 1;
    $order_type = substr($order_code, -2, 2);
    if ('SK' == $order_type) {
        $orders['amount'] = round($order_amount * $payRate, 2);
    }
    $order_status = isset($orders['order_status']) ? (int) $orders['order_status'] : 0;
    if ('YK' == $order_type) {
        if ($order_status > 5) {
            ABase::toJson(1007, "订单状态已改变 order_status: {$order_status}");
        }
        $sk_order_code = str_replace('YK', 'SK', $order_code);
        $products = OrdersProducts::getList("order_code='{$sk_order_code}'", 'product_sku,product_num', 'product_sku');
    } else {
        if ($order_status > 1) {
            ABase::toJson(1009, "订单状态已改变");
        }
        $products = OrdersProducts::getList("order_code='{$order_code}'", 'product_sku,product_num', 'product_sku');
    }
    if (!$products) {
        ABase::toJson(1008, "订单产品获取失败");
    }
    $len = count($products);
    if ($len > 1) {
        $title = "合并 | {$len} 笔订单";
    } else {
        $product_sku = isset($products[0]['product_sku']) ? $products[0]['product_sku'] : '';
        $product_num = isset($products[0]['product_num']) ? (int) $products[0]['product_num'] : '';
        if (!$product_sku) {
            ABase::toJson(1009, "无法获取订单产品SKU");
        }
        $items = ProductsItem::getSkuItem($product_sku);
        $title = isset($items['title']) ? $items['title'] : '';
        $sku_name = isset($items['sku_name']) ? $items['sku_name'] : '';
        $title = $title . " " . $sku_name . " × " . $product_num;
    }
    $orders['title'] = $title;
    $orders['order_code'] = $order_code;
    ABase::toJson(0, 'SUCCESS', $orders);
}
Example #6
0
    $lists = ProductsItem::paging($page, $page_size, "category_id='{$cateid}' AND status=1", "create_time DESC");
    $products = $lists['data'];
    $products = getProducts($products);
    $paged = $lists['page'];
} else {
    foreach ($cateids as $cid) {
        $ccid = $cid['id'];
        if (!($ccids = ProductsCategory::getChild($ccid))) {
            $produs = ProductsItem::getCateProducts($ccid, '*', 'create_time DESC LIMIT 0,10');
        } else {
            $tmp = array();
            foreach ($ccids as $ccid) {
                $tmp[] = $ccid['id'];
            }
            $ccid = implode(',', $tmp);
            $produs = ProductsItem::getList("category_id IN ({$ccid}) AND status=1", '*', 'create_time DESC LIMIT 0,10');
        }
        $produs = getProducts($produs);
        $products[$cid['id']]['prod'] = $produs;
        $products[$cid['id']]['cate'] = array('id' => $cid['id'], 'name' => $cid['name']);
    }
}
//var_dump($products);
Templates::Assign('is_paged', $is_paged);
Templates::Assign('cateid', $cateid);
Templates::Assign('products', $products);
Templates::Assign('paged', $paged);
Templates::Display('products.html');
function getProducts($products)
{
    foreach ($products as $k => $product) {