Exemplo n.º 1
0
/**
 * 取得购物车商品
 * @param   int     $type   类型:默认普通商品
 * @return  array   购物车商品数组
 */
function cart_goods($type = CART_GENERAL_GOODS)
{
    $sql = "SELECT c.rec_id, c.user_id, c.goods_id, c.goods_name, g.goods_thumb, c.goods_sn, c.goods_number, " . "c.market_price, c.goods_price, c.goods_attr, c.is_real, c.extension_code, c.extension_id, c.parent_id, c.is_gift, c.is_shipping, " . "c.goods_price * c.goods_number AS subtotal, c.free_more " . "FROM " . $GLOBALS['ecs']->table('cart', 'c') . " LEFT JOIN " . $GLOBALS['ecs']->table('goods', 'g') . " ON c.goods_id = g.goods_id WHERE " . get_cart_cond() . "AND rec_type = '{$type}'";
    $arr = $GLOBALS['db']->getAll($sql);
    /* 格式化价格及礼包商品 */
    foreach ($arr as &$value) {
        $value['formated_market_price'] = price_format($value['market_price'], false);
        $value['formated_goods_price'] = price_format($value['goods_price'], false);
        $value['formated_subtotal'] = price_format($value['subtotal'], false);
        $value['free_more_desc'] = get_free_more_desc($value['free_more']);
        $value['goods_number_subtotal'] = $value['goods_number'] + get_free_more_number($value['free_more'], $value['goods_number']);
        if ($value['extension_code'] == 'package_buy') {
            $value['package_goods_list'] = get_package_goods($value['goods_id']);
        }
    }
    return $arr;
}
Exemplo n.º 2
0
/**
 * 获取指定用户可取货的商品列表
 * 
 * @param array $pids
 */
function get_pickup_goods($pids)
{
    global $ecs, $db;
    $sql = "SELECT og.goods_id, og.goods_sn, og.goods_name, og.goods_attr, sum(og.goods_number) AS goods_number, og.free_more " . " FROM " . $ecs->table('order_info', 'o') . "," . $ecs->table('order_goods', 'og') . " WHERE o.order_id = og.order_id AND o.package_id IN (" . implode(',', $pids) . ")" . " GROUP BY og.goods_id, og.free_more ORDER BY og.goods_id";
    $rs = $db->getAll($sql);
    $goods = array();
    foreach ($rs as $g) {
        if (!empty($g['free_more'])) {
            $g['goods_number'] += get_free_more_number($g['free_more'], $g['goods_number']);
            $g['free_more_desc'] = get_free_more_desc($g['free_more']);
        }
        if (array_key_exists($g['goods_id'], $goods)) {
            $goods[$g['goods_id']]['goods_number'] += $g['goods_number'];
        } else {
            $goods[$g['goods_id']] = $g;
        }
    }
    return $goods;
}
Exemplo n.º 3
0
     }
     echo $html;
     exit;
 } elseif (isset($_POST['print_prepare']) || isset($_POST['summary'])) {
     if ($_POST['print_prepare']) {
         $cond = " a.order_status = 1 AND a.shipping_status = 3 ";
     } else {
         $cond = " a.order_status = 0 AND a.pay_status = 2 ";
     }
     $sql = "SELECT a.shop_id, a.user_id, b.goods_sn, b.goods_name, b.goods_attr, b.goods_price, SUM(b.goods_number) AS goods_number, b.free_more FROM " . $ecs->table('order_info', 'a') . ',' . $ecs->table('order_goods', 'b') . " WHERE a.order_id = b.order_id AND " . $cond . " GROUP BY a.shop_id, a.user_id, b.goods_id, b.goods_attr, b.free_more";
     $query = $db->query($sql);
     $goods_list = array();
     $shop_list = array();
     while ($rs = $db->fetch_array($query)) {
         $key = "{$rs[goods_sn]}-{$rs[goods_attr]}-{$rs[free_more]}";
         $goods_number = $rs['goods_number'] + get_free_more_number($rs['free_more'], $rs['goods_number']);
         // 汇总
         if (array_key_exists($key, $goods_list)) {
             $goods_list[$key]['goods_number'] += $goods_number;
         } else {
             $goods_list[$key] = array('goods_sn' => $rs['goods_sn'], 'goods_name' => $rs['goods_name'], 'goods_attr' => $rs['goods_attr'], 'goods_price' => $rs['goods_price'], 'free_more' => $rs['free_more'], 'goods_number' => $goods_number);
         }
         // 门店别
         $shop = $rs['shop_id'];
         if (!array_key_exists($shop, $shop_list)) {
             $shop_list[$shop] = array('goods_list' => array(), 'money_paid' => 0, 'bonus' => 0, 'discount' => 0);
         }
         $list =& $shop_list[$shop]['goods_list'];
         if (array_key_exists($key, $list)) {
             $list[$key]['goods_number'] += $goods_number;
         } else {
Exemplo n.º 4
0
    make_json_result($smarty->fetch('pickup_pack_list.htm'), '', array('filter' => $result['filter'], 'page_count' => $result['page_count']));
} elseif ($_REQUEST['act'] == 'print_shipping') {
    $print_date = empty($_REQUEST['print_date']) ? date('Ymd', time()) : trim($_REQUEST['print_date']);
    $sql = "SELECT p.*, u.mobile_phone, g.goods_sn, g.goods_name, g.goods_attr, g.free_more, o.order_id, o.money_paid, " . " o.shop_id, o.order_sn, o.postscript, s.short_name AS shop_name, " . " sum(g.goods_number) AS goods_number FROM " . $ecs->table('pickup_pack', 'p') . ',' . $ecs->table('users', 'u') . ',' . $ecs->table('order_info', 'o') . ',' . $ecs->table('order_goods', 'g') . ',' . $ecs->table('shop', 's') . " WHERE p.user_id = u.user_id AND p.id = o.package_id AND o.order_id = g.order_id AND s.shop_id = o.shop_id " . " AND p.create_date = '{$print_date}' AND o.order_status != " . OS_CANCELED . " GROUP BY o.shop_id, p.user_id, g.goods_id, g.goods_attr, g.free_more " . " ORDER BY o.shop_id, p.user_id, o.order_id ASC";
    $query = $db->query($sql);
    $packlist = array();
    $pack_id = 0;
    $shop_id = 0;
    while ($rs = $db->fetch_array($query)) {
        if ($pack_id != $rs['id']) {
            $pack_id = $rs['id'];
            $packlist[$pack_id] = array('sn' => substr($rs['create_date'], 6, 2) . '-' . $rs['pos_row'] . '-' . str_pad($rs['pos_sn'], 2, '0', STR_PAD_LEFT), 'mobile_phone' => $rs['mobile_phone'], 'shop_name' => $rs['shop_name'], 'money_paid' => 0, 'goods_list' => array());
            $order_id = 0;
        }
        $pack =& $packlist[$pack_id];
        $pack['goods_list'][] = array('goods_sn' => $rs['goods_sn'], 'goods_name' => $rs['goods_name'], 'goods_attr' => $rs['goods_attr'], 'free_more' => $rs['free_more'], 'goods_number' => $rs['goods_number'], 'total_number' => $rs['goods_number'] + get_free_more_number($rs['free_more'], $rs['goods_number']));
        // 计算订单金额
        if ($order_id != $rs['order_id']) {
            $pack['money_paid'] += $rs['money_paid'];
            $pack['order_sn'] .= (empty($pack['order_sn']) ? '' : ', ') . $rs['order_sn'];
            $pack['postscript'] .= (empty($pack['postscript']) ? '' : '; ') . $rs['postscript'];
            $order_id = $rs['order_id'];
        }
        // 设置分页符
        if ($shop_id != $rs['shop_id']) {
            $pack['page_break'] = 1;
            $shop_id = $rs['shop_id'];
        }
    }
    $smarty->assign('packlist', $packlist);
    $smarty->assign('date', $print_date);