⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shopex47.php

📁 本次新版本发布是在ECshop与ShopEx整合后的首次产品升级
💻 PHP
📖 第 1 页 / 共 3 页
字号:
        /* 查询商品并处理 */
        $sql = "SELECT * FROM ".$this->sprefix."mall_goods";
        $res = $this->sdb->query($sql);
        while ($row = $this->sdb->fetchRow($res))
        {
            $goods = array();

            if ($row['ifobject'] == '0')
            {
                /* 虚拟商品 */
                $goods['is_real'] = '0';
            }
            elseif ($row['ifobject'] == '1')
            {
                /* 实体商品 */
                $goods['is_real'] = '1';
            }
            elseif ($row['ifobject'] == '2')
            {
                /* 数字文件,暂时无法转换 */
                continue;
            }
            elseif ($row['ifobject'] == '3')
            {
                /* 捆绑销售,暂时无法转换 */
                continue;
            }
            else
            {
                /* 未知,无法转换 */
                continue;
            }
            $goods['goods_id']      = $row['gid'];
            $goods['cat_id']        = $row['catid'];
            $goods['goods_sn']      = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['bn']));
            $goods['goods_name']    = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['goods']));
            $goods['brand_id']      = trim($row['brand']) == '' ? '0' : $brand_list[ecs_iconv($this->scharset, $this->tcharset, addslashes($row['brand']))];
            $goods['goods_number']  = $row['storage'];
            $goods['goods_weight']  = $row['weight'];
            $goods['market_price']  = $row['priceintro'];
            $goods['shop_price']    = $row['ifdiscreteness'] == '1' ? $row['basicprice'] : $row['price'];
            if ($row['tejia2'] == '1')
            {
                $goods['promote_price']         = $goods['shop_price'];
                $goods['promote_start_date']    = gmtime();
                $goods['promote_end_date']      = gmstr2time('+1 weeks');
            }
            $goods['warn_number']   = $row['ifalarm'] == '1' ? $row['alarmnum'] : '0';
            $goods['goods_brief']   = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['intro']));
            $goods['goods_desc']    = str_replace('pictures/newsimg/', $this->tdocroot . '/images/upload/Image/', ecs_iconv($this->scharset, $this->tcharset, addslashes($row['memo'])));
            $goods['is_on_sale']    = $row['shop_iffb'];
            $goods['is_alone_sale'] = $row['onsale'];
            $goods['add_time']      = $row['uptime'];
            $goods['sort_order']    = $row['offer_ord'];
            $goods['is_delete']     = '0';
            $goods['is_best']       = $row['recommand2'];
            $goods['is_new']        = $row['new2'];
            $goods['is_hot']        = $row['hot2'];
            $goods['is_promote']    = $row['tejia2'];
            $goods['goods_type']    = isset($cat_type_list[$row['catid']]) ? $cat_type_list[$row['catid']] : 0;

            /* 图片:如果没有本地文件,取远程图片 */
            $file = $this->troot . '/images/' . date('Ym') . '/small_' . $row['gid'];
            if (file_exists($file. '.jpg'))
            {
                $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.jpg';
            }
            elseif (file_exists($file. '.jpeg'))
            {
                $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.jpeg';
            }
            elseif (file_exists($file. '.gif'))
            {
                $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.gif';
            }
            elseif (file_exists($file. '.png'))
            {
                $goods['goods_thumb'] = 'images/' . date('Ym') . '/small_' . $row['gid'] . '.png';
            }
            else
            {
                $goods['goods_thumb'] = $row['smallimgremote'];
            }

            $file = $this->troot . '/images/' . date('Ym') . '/big_' . $row['gid'];
            if (file_exists($file. '.jpg'))
            {
                $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.jpg';
                $goods['original_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.jpg';
            }
            elseif (file_exists($file. '.jpeg'))
            {
                $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.jpeg';
                $goods['original_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.jpeg';
            }
            elseif (file_exists($file. '.gif'))
            {
                $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.gif';
                $goods['original_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.gif';
            }
            elseif (file_exists($file. '.png'))
            {
                $goods['goods_img'] = 'images/' . date('Ym') . '/big_' . $row['gid'] . '.png';
                $goods['orinigal_img'] = 'images/' . date('Ym') . '/original_' . $row['gid'] . '.png';
            }
            else
            {
                $goods['goods_img'] = $row['bigimgremote'];
            }

            /* 积分:根据商店设置 */
            if ($config['offer_pointtype'] == '0')
            {
                /* 不使用积分 */
                $goods['integral'] = '0';
            }
            elseif ($config['offer_pointtype'] == '1')
            {
                /* 按比例 */
                $goods['integral'] = round($goods['shop_price'] * $config['offer_pointnum']);
            }
            else
            {
                /* 自定义 */
                $goods['integral'] = $row['point'];
            }

            /* 插入 */
            if (!$db->autoExecute($ecs->table('goods'), $goods, 'INSERT', '', 'SILENT'))
            {
                //return $db->error();
            }

            /* 扩展分类 */
            if ($row['linkclass'] != '')
            {
                $goods_cat = array();
                $goods_cat['goods_id'] = $row['gid'];
                $cat_id_list = explode(',', trim($row['linkclass'], ','));
                foreach ($cat_id_list as $cat_id)
                {
                    $goods_cat['cat_id'] = $cat_id;
                    if (!$db->autoExecute($ecs->table('goods_cat'), $goods_cat, 'INSERT', '', 'SILENT'))
                    {
                        //return $db->error();
                    }
                }
            }

            /* 取得该分类的所有属性 */
            $sql = "SELECT DISTINCT pv.prop_id, pv.prop_value " .
                    "FROM ".$this->sprefix."mall_goods_prop_grp_value AS gp, " .
                            $this->sprefix."mall_prop_value AS pv " .
                    "WHERE gp.prop_value_id = pv.prop_value_id " .
                    "AND gp.gid = '$row[gid]'";
            $res1 = $this->sdb->query($sql);
            while ($attr = $this->sdb->fetchRow($res1))
            {
                $goods_attr = array();
                $goods_attr['goods_id']     = $row['gid'];
                $goods_attr['attr_id']      = $attr['prop_id'];
                $goods_attr['attr_value']   = ecs_iconv($this->scharset, $this->tcharset, addslashes($attr['prop_value']));
                $goods_attr['attr_price']   = '0';
                if (!$db->autoExecute($ecs->table('goods_attr'), $goods_attr, 'INSERT', '', 'SILENT'))
                {
                    //return $db->error();
                }
            }

            /* 商品相册 */
            if ($row['multi_image'])
            {
                $goods_gallery = array();
                $goods_gallery['goods_id'] = $row['gid'];
                $img_list = explode('&&&', $row['multi_image']);
                foreach ($img_list as $img)
                {
                    if (substr($img, 0, 7) == 'http://')
                    {
                        $goods_gallery['img_url'] = $img;
                    }
                    else
                    {
                        make_dir('images/' . date('Ym') . '/');
                        $goods_gallery['img_url'] = 'images/' . date('Ym') . '/big_' . $img;
                        $goods_gallery['img_original'] = 'images/' . date('Ym') . '/original_' . $img;
                    }

                    if (!$db->autoExecute($ecs->table('goods_gallery'), $goods_gallery, 'INSERT', '', 'SILENT'))
                    {
                        //return $db->error();
                    }
                }
            }
        }

        /* 关联商品 */
        $sql = "SELECT * FROM ".$this->sprefix."mall_offer_linkgoods";
        $res = $this->sdb->query($sql);
        while ($row = $this->sdb->fetchRow($res))
        {
            $link_goods = array();
            $link_goods['goods_id']         = $row['pgid'];
            $link_goods['link_goods_id']    = $row['sgid'];
            $link_goods['is_double']        = $row['type'];

            if (!$db->autoExecute($ecs->table('link_goods'), $link_goods, 'INSERT', '', 'SILENT'))
            {
                //return $db->error();
            }

            if ($row['type'] == '1')
            {
                $link_goods = array();
                $link_goods['goods_id']         = $row['sgid'];
                $link_goods['link_goods_id']    = $row['pgid'];
                $link_goods['is_double']        = $row['type'];

                if (!$db->autoExecute($ecs->table('link_goods'), $link_goods, 'INSERT', '', 'SILENT'))
                {
                    //return $db->error();
                }
            }
        }

        /* 组合商品 */
        $sql = "SELECT DISTINCT gid, prop_goods_id, price FROM ".$this->sprefix."mall_pcat_prop_has_goods";
        $res = $this->sdb->query($sql);
        while ($row = $this->sdb->fetchRow($res))
        {
            $group_goods = array();
            $group_goods['parent_id']   = $row['gid'];
            $group_goods['goods_id']    = $row['prop_goods_id'];
            $group_goods['goods_price'] = $row['price'];

            if (!$db->autoExecute($ecs->table('group_goods'), $group_goods, 'INSERT', '', 'SILENT'))
            {
                //return $db->error();
            }
        }

        /* 返回成功 */
        return TRUE;
    }

    /**
     * 会员等级、会员、会员价格
     */
    function process_users()
    {
        global $db, $ecs;

        /* 清空会员、会员等级、会员价格、用户红包、用户地址、帐户明细 */
        truncate_table('user_rank');
        truncate_table('users');
        truncate_table('user_address');
        truncate_table('user_bonus');
        truncate_table('member_price');
        truncate_table('user_account');

        /* 查询并插入会员等级 */
        $sql = "SELECT * FROM ".$this->sprefix."mall_member_level order by point desc";
        $res = $this->sdb->query($sql);
        $max_points = 50000;
        while ($row = $this->sdb->fetchRow($res))
        {
            $user_rank = array();
            $user_rank['rank_id']       = $row['levelid'];
            $user_rank['rank_name']     = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['name']));
            $user_rank['min_points']    = $row['point'];
            $user_rank['max_points']    = $max_points;
            $user_rank['discount']      = round($row['discount'] * 100);
            $user_rank['show_price']    = '1';
            $user_rank['special_rank']  = '0';

            if (!$db->autoExecute($ecs->table('user_rank'), $user_rank, 'INSERT', '', 'SILENT'))
            {
                //return $db->error();
            }

            $max_points = $row['point'] - 1;
        }

        /* 查询并插入会员 */
        $sql = "SELECT * FROM ".$this->sprefix."mall_member";
        $res = $this->sdb->query($sql);
        while ($row = $this->sdb->fetchRow($res))
        {
            $user = array();
            $user['user_id']        = $row['userid'];
            $user['email']          = $row['email'];
            $user['user_name']      = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['user']));
            $user['password']       = $row['password'];
            $user['question']       = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['pw_question']));
            $user['answer']         = ecs_iconv($this->scharset, $this->tcharset, addslashes($row['pw_answer']));
            $user['sex']            = $row['sex'];
            if (!empty($row['birthday']))
            {
                $birthday           = strtotime($row['birthday']);
                if ($birthday != -1 && $birthday !== false)
                {
                    $user['birthday']   = date('Y-m-d', $birthday);
                }
            }
            $user['user_money']     = $row['advance'];
            $user['pay_points']     = $row['point'];
            $user['rank_points']    = $row['point'];
            $user['reg_time']       = $row['regtime'];
            $user['last_login']     = $row['regtime'];
            $user['last_ip']        = $row['ip'];
            $user['visit_count']    = '1';
            $user['user_rank']      = '0';

            if (!$db->autoExecute($ecs->table('users'), $user, 'INSERT', '', 'SILENT'))
            {
                //return $db->error();
            }
            uc_call('uc_user_register', array($user['user_name'], $user['password'], $user['email']));
        }

        /* 收货人地址 */
        $sql = "SELECT * FROM ".$this->sprefix."mall_member_receiver";
        $res = $this->sdb->query($sql);
        while ($row = $this->sdb->fetchRow($res))
        {
            $address = array();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -