Пример #1
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;
 }
Пример #2
0
    if (!$keyword) {
        //DB::Debug();
        $order = Orders::paging($page, $page_size, $where, "id DESC", "*");
    } else {
        if ('bh' == $keyword) {
            //DB::Debug();
            $ordertable = Orders::table();
            $orderproducttable = OrdersProducts::table();
            $sql = " SELECT a.* FROM {$ordertable} AS a, {$orderproducttable} AS b WHERE RIGHT(a.order_code,2)='BH' AND a.order_code=b.order_code AND a.user_code='{$user_code}' ORDER BY a.id DESC";
            $order = Paging::bySQL($sql, $page, $page_size, 'a');
        } else {
            //DB::Debug();
            $ordertable = Orders::table();
            $orderproducttable = OrdersProducts::table();
            $sql = " SELECT a.* FROM {$ordertable} AS a, {$orderproducttable} AS b WHERE (RIGHT(a.order_code,2)='SK' OR LEFT(a.order_code,4)='FXAD') AND a.order_code=b.order_code AND a.user_code='{$user_code}' AND (a.order_code LIKE '%{$keyword}%' OR b.product_sku LIKE '%{$keyword}%')  GROUP BY a.order_code ORDER BY a.id DESC";
            $order = Paging::bySQL($sql, $page, $page_size, 'a');
        }
    }
}
$orders = $order['data'];
$paged = $order['page'];
foreach ($orders as $k => $order) {
    $order_code = $order['order_code'];
    $products = OrdersProducts::getUserProducts($order_code);
    $tmp = array();
    //获取各个PRODCUT STOCK
    $len = count($products);
    for ($i = 0; $i < $len; $i++) {
        if (!isset($products[$i])) {
            continue;
        }