예제 #1
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'app/Lib/deal.php';
     /**
      * has_attr: 0:无属性; 1:有属性
      * 有商品属性在要购买时,要选择属性后,才能购买
      * change_cart_request_server: 
      * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
      * 0:提交,1:不提交;
      * image_attr_a_id_{$attr_a_id} 图片列表,可以根据属性ID值,来切换图片列表;默认为:0
      * limit_num: 库存数量
      */
     $id = intval($GLOBALS['request']['id']);
     //商品ID
     $item = get_deal($id);
     $root = getGoodsArray($item);
     $root['return'] = 1;
     $root['attr'] = getAttrArray($id);
     $images = array();
     //image_attr_1_id_{$attr_1_id} 图片列表,可以根据属性ID值,来切换图片列表
     $sql = "select img from " . DB_PREFIX . "deal_gallery where deal_id = " . intval($id);
     $list = $GLOBALS['db']->getAll($sql);
     $gallery = array();
     $big_gallery = array();
     foreach ($list as $k => $image) {
         $gallery[] = get_abs_img_root(get_spec_image($image['img'], 320, 320, 0));
         $big_gallery[] = get_abs_img_root(get_spec_image($image['img'], 0, 0, 0));
     }
     $root['gallery'] = $gallery;
     $root['big_gallery'] = $big_gallery;
     output($root);
 }
예제 #2
0
 public function index()
 {
     $goods_id = intval($GLOBALS['request']['id']);
     //商品ID
     $root = array();
     $root['return'] = 1;
     $root['attr'] = getAttrArray($goods_id);
     output($root);
 }
예제 #3
0
파일: functions.php 프로젝트: macall/jsd
function getGoodsArray($item)
{
    /**
     * has_attr: 0:无属性; 1:有属性
     * 有商品属性在要购买时,要选择属性后,才能购买(用户在列表中点:购买时,要再弹出一个:商品属性选择对话框)
     * change_cart_request_server:
     * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
     * 0:提交,1:不提交;
     *
     * num_unit: 单位
     * limit_num: 库存数量
     *
     */
    $goods = array();
    $goods['city_name'] = "";
    $goods['goods_id'] = $item['id'];
    $goods['title'] = emptyTag($item['name']);
    if (empty($item['sub_name'])) {
        $goods['sub_name'] = emptyTag($item['name']);
    } else {
        $goods['sub_name'] = emptyTag($item['sub_name']);
    }
    //$goods['image']=get_abs_img_root(make_img($item['img'],0));
    $goods['image'] = get_abs_img_root(get_spec_image($item['img'], 320, 194, 1));
    //get_abs_img_root( get_spec_image($v['o_path'],160,0,0));
    $goods['buy_count'] = $item['buy_count'];
    $goods['start_date'] = $item['begin_time'];
    $goods['end_date'] = $item['end_time'];
    $goods['ori_price'] = round($item['origin_price'], 2);
    $goods['cur_price'] = round($item['current_price'], 2);
    if (empty($item['brief'])) {
        $goods['goods_brief'] = $item['name'];
    } else {
        $goods['goods_brief'] = $item['brief'];
    }
    $goods['ori_price_format'] = format_price($goods['ori_price']);
    $goods['cur_price_format'] = format_price($goods['cur_price']);
    $goods['discount'] = $item['discount'];
    $sp_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . $item['supplier_id'] . " order by is_main desc");
    $goods['address'] = $sp_info['address'];
    // 地址未完
    $goods['num_unit'] = "";
    //$item['num_unit'];
    $limit_num = intval($item['max_bought']);
    //如果库存为0时,不设置为:99999,不限制购买数量;
    if ($limit_num == 0) {
        $limit_num = 99999;
    }
    $goods['limit_num'] = $limit_num;
    $goods['goods_desc'] = $item['description'];
    $goods['is_shop'] = $item['is_shop'];
    $goods['is_hot'] = $item['is_hot'];
    $goods['notes'] = $item['notes'];
    $goods['package'] = $item['package'];
    $goods['supplier_location_id'] = $GLOBALS['db']->getOne("select location_id from " . DB_PREFIX . "deal_location_link where deal_id = " . $item['id']);
    $goods['any_refund'] = $item['any_refund'];
    $goods['expire_refund'] = $item['expire_refund'];
    //标签列表
    //支持随时退款
    $ext_label = array();
    if ($goods['any_refund'] == 1) {
        $ext_label[] = array('type' => 0, 'ico' => '', 'name' => '支持随时退款');
    }
    //支持过期退款
    if ($goods['expire_refund'] == 1) {
        $ext_label[] = array('type' => 1, 'ico' => '', 'name' => '支持过期退款');
    }
    $goods['ext_label'] = $ext_label;
    $goods['time_status'] = $item['time_status'];
    $goods['end_time'] = $item['end_time'];
    $goods['begin_time'] = $item['begin_time'];
    $goods['sp_location_id'] = $sp_info['id'];
    //供应商信息
    $goods['sp_detail'] = $sp_info['name'];
    //供应商信息
    $goods['sp_tel'] = $sp_info['tel'];
    /*供应商电话*/
    $pattern = "/<img([^>]*)\\/>/i";
    $replacement = "<img width=300 \$1 />";
    $goods['goods_desc'] = get_abs_img_root(format_html_content_image($goods['goods_desc'], 300));
    $goods['goods_desc'] = preg_replace($pattern, $replacement, $goods['goods_desc']);
    $goods['saving_format'] = $item['save_price_format'];
    if ($goods['end_date'] == 0) {
        $goods['less_time'] = "none";
        //永不过期,无倒计时
        $goods['less_time_format'] = "999天";
        //永不过期,无倒计时
    } else {
        $goods['less_time'] = $goods['end_date'] - get_gmtime();
        if ($goods['less_time'] < 0) {
            $goods['less_time'] = 0;
        }
        $goods['less_time_format'] = getTimeFormat($goods['less_time']);
    }
    $goods['has_attr'] = 0;
    //has_attr: 0:无属性; 1:有属性
    if ($item['is_delivery'] == 1) {
        $goods['has_delivery'] = 1;
        $goods['has_mcod'] = 1;
    } else {
        $goods['has_delivery'] = 0;
        $goods['has_mcod'] = 0;
    }
    if ($goods['cart_type'] == 0) {
        $goods['has_cart'] = 1;
        //1:可以跟其它商品一起放入购物车购买;0:不能放入购物车,只能独立购买
    } else {
        $goods['has_cart'] = 0;
    }
    $goods['change_cart_request_server'] = 1;
    $goods['is_refund'] = $item['is_refund'];
    /*0:不支持退款; 1:支持退款*/
    $goods['avg_point'] = $item['avg_point'];
    /*购买点评平均分*/
    $goods['distance'] = $item['distance'];
    $goods['attr'] = getAttrArray($item['id']);
    if (intval($goods['attr']['has_attr_1']) > 0 || intval($goods['attr']['has_attr_2']) > 0) {
        $goods['has_attr'] = 1;
    }
    //$goods['share_content']=msubstr($topic['content']).get_domain().str_replace("mapi/","",url("shop","topic",array("id"=>$topic['id'])));
    $goods['share_url'] = get_domain() . str_replace("sjmapi/", "", url("index", "deal#" . $item['id']));
    $goods['share_content'] = emptyTag($item['name']) . $goods['share_url'];
    return $goods;
}
예제 #4
0
function getGoodsArray($item)
{
    /**
     * has_attr: 0:无属性; 1:有属性
     * 有商品属性在要购买时,要选择属性后,才能购买(用户在列表中点:购买时,要再弹出一个:商品属性选择对话框)
     * change_cart_request_server:
     * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
     * 0:提交,1:不提交;
     *
     * num_unit: 单位
     * limit_num: 库存数量
     *
     */
    $goods = array();
    $goods['city_name'] = "";
    $goods['goods_id'] = $item['id'];
    $goods['title'] = emptyTag($item['name']);
    //$goods['image']=get_abs_img_root(make_img($item['img'],0));
    $goods['image'] = get_abs_img_root(get_spec_image($item['img'], 160, 160, 0));
    //get_abs_img_root( get_spec_image($v['o_path'],160,0,0));
    $goods['buy_count'] = $item['buy_count'];
    $goods['start_date'] = $item['begin_time'];
    $goods['end_date'] = $item['end_time'];
    $goods['ori_price'] = round($item['origin_price'], 2);
    $goods['cur_price'] = round($item['current_price'], 2);
    $goods['goods_brief'] = $item['brief'];
    $goods['ori_price_format'] = format_price($goods['ori_price']);
    $goods['cur_price_format'] = format_price($goods['cur_price']);
    $goods['discount'] = $item['discount'];
    $sp_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . $item['supplier_id'] . " and is_main = 1");
    $goods['address'] = $sp_info['address'];
    // 地址未完
    $goods['num_unit'] = "";
    //$item['num_unit'];
    $goods['limit_num'] = $item['max_bought'];
    $goods['goods_desc'] = $item['description'];
    $goods['sp_detail'] = $sp_info['name'] . "<br />" . $item['address'] . "<br />" . $item['tel'];
    //供应商信息
    $pattern = "/<img([^>]*)\\/>/i";
    $replacement = "<img width=300 \$1 />";
    $goods['goods_desc'] = preg_replace($pattern, $replacement, get_abs_img_root($goods['goods_desc']));
    $goods['saving_format'] = $item['save_price_format'];
    if ($goods['end_date'] == 0) {
        $goods['less_time'] = "none";
    } else {
        $goods['less_time'] = $goods['end_date'] - get_gmtime();
    }
    $goods['has_attr'] = 0;
    //has_attr: 0:无属性; 1:有属性
    if ($item['is_delivery'] == 1) {
        $goods['has_delivery'] = 1;
        $goods['has_mcod'] = 1;
    } else {
        $goods['has_delivery'] = 0;
        $goods['has_mcod'] = 0;
    }
    if ($goods['cart_type'] == 0) {
        $goods['has_cart'] = 1;
        //1:可以跟其它商品一起放入购物车购买;0:不能放入购物车,只能独立购买
    } else {
        $goods['has_cart'] = 0;
    }
    $goods['change_cart_request_server'] = 1;
    $goods['attr'] = getAttrArray($item['id']);
    $goods['distance'] = $item['distance'];
    if (intval($goods['attr']['true_has_attr_1']) > 0 || intval($goods['attr']['true_has_attr_2']) > 0) {
        $goods['has_attr'] = 1;
    }
    return $goods;
}