首先一个客户的导入1W条商品数据
一个导出的数据库
一个导入的数据库
sql语句/造个过程函数
BEGIN
insert into goods_basic
(
`seller_id` ,
`goods_id` ,
`cate_sys_alias_id` ,
`goods_name` ,
`goods_no` ,
`type_goods` ,
`unit_weight` ,
`unit_sixze` ,
`unit_qty` ,
`manufacture_name` ,
`is_contain_std` ,
`is_deleted` ,
`createtime` ,
`create_user_id` ,
`updatetime` ,
`update_user_id` ,
`old_id`,
`step`
)
SELECT
p_seller_id as `seller_id` ,
func_get_seq_no(p_seller_id,12) as `goods_id` ,
0 as `cate_sys_alias_id` ,
t1.pro_name as `goods_name` ,
t1.sku_num as `goods_no` ,
1 as `type_goods` ,
40 as `unit_weight` ,
52 as `unit_sixze` ,
54 as `unit_qty` ,
‘rinhoo‘ as `manufacture_name` ,
0 as `is_contain_std` ,
0 as `is_deleted` ,
NOW() as `createtime` ,
171 as `create_user_id` ,
NOW() as `updatetime` ,
171 as `update_user_id` ,
t1.id as `old_id`,
p_seller_id
from
`site_rinhooOTA=`.rinhoo_products t1;
insert into goods_main_pics
(
`seller_id` ,
`goods_id` ,
`image_url` ,
`image_big_name` ,
`image_small_name` ,
`image_tips` ,
`is_main_image` ,
`is_list_image` ,
`is_visibled` ,
`is_deleted`
)
select
t2.seller_id as `seller_id` ,
t2.goods_id as `goods_id` ,
CONCAT(‘http://site2.shop-9yu.com/image/product/‘,SUBSTR(t1.img_path FROM 1 FOR 11)) as `image_url` ,
SUBSTR(t1.img_path FROM 12) as `image_big_name` ,
SUBSTR(t1.img_path FROM 12) as `image_small_name` ,
t2.goods_name as `image_tips` ,
t1.img_main as `is_main_image` ,
0 as `is_list_image` ,
1 as `is_visibled` ,
0 as `is_deleted`
from `site_rinhooOTA=`.rinhoo_products_photo t1
INNER JOIN goods_basic t2
on t1.pc_id = t2.old_id
where step=p_seller_id;
insert into goods_desc
(
`seller_id` ,
`goods_id` ,
`goods_name_alias` ,
`page_title` ,
`page_keywords` ,
`page_description` ,
`goods_detail_desc` ,
`weight_deliver_alias` ,
`qty_store_alias`
)
select
t3.seller_id as `seller_id` ,
t3.goods_id as `goods_id` ,
t3.goods_name as `goods_name_alias` ,
t2.page_title as `page_title` ,
t2.page_keyword as `page_keywords` ,
t2.page_content as `page_description` ,
t1.content as `goods_detail_desc` ,
t2.weight as `weight_deliver_alias` ,
10 as `qty_store_alias`
from `site_rinhooOTA=`.rinhoo_goods_seodesc t1
INNER JOIN `site_rinhooOTA=`.rinhoo_products t2
on t1.gid = t2.gid
INNER JOIN goods_basic t3
on t2.id = t3.old_id
where step=p_seller_id;
insert into goods_std_extend_common
(
`seller_id` ,
`goods_id` ,
`std_goods_id` ,
`qty_per_case` ,
`production_date` ,
`weight` ,
`length` ,
`width` ,
`height` ,
`sale_state` ,
`production_cycle` ,
`is_deleted`
)
SELECT
t2.seller_id as `seller_id` ,
t2.goods_id as `goods_id` ,
0 as `std_goods_id` ,
0 as `qty_per_case` ,
‘2015-03-11‘ as `production_date` ,
t1.weight as `weight` ,
t1.chang as `length` ,
t1.weight as `width` ,
t1.gao as `height` ,
1 as `sale_state` ,
360 as `production_cycle` ,
0 as `is_deleted`
FROM `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
where step=p_seller_id;
insert into price_goods_supply
(
`seller_id` ,
`goods_id` ,
`std_goods_id` ,
`cost_price` ,
`sale_price` ,
`dis_price` ,
`description`
)
SELECT
t2.seller_id as `seller_id` ,
t2.goods_id as `goods_id` ,
0 as `std_goods_id` ,
round(t1.cost * 100,0) as `cost_price` ,
round(t1.total_price*100,0) as `sale_price` ,
round(t1.cost * 1.30*100,0) as `dis_price` ,
‘‘ as `description`
from `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
where step=p_seller_id;
insert into price_goods_shop_supply
(
`seller_id` ,
`shop_id`,
`goods_id` ,
`std_goods_id` ,
`cost_price` ,
`sale_price` ,
`bonus_sale` ,
`description`
)
SELECT
t2.seller_id as `seller_id` ,
1 as `shop_id`,
t2.goods_id as `goods_id` ,
0 as `std_goods_id` ,
round(t1.cost * 1.30*100,0) as `cost_price` ,
round(t1.total_price*100,0) as `sale_price` ,
0 as `bonus_sale`,
‘‘ as `description`
from `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
where step=p_seller_id;
update goods_basic t0 INNER JOIN
(
SELECT t1.ct_id,t4.cate_sys_alias_id,t2.seller_id,t2.goods_id
from `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
INNER JOIN `site_rinhooOTA=`.rinhoo_category t3
on t1.ct_id = t3.id
LEFT OUTER JOIN category_sys_alias_en t4
on t3.ct_name = t4.cate_sys_name_alias
) Q1
on t0.seller_id = Q1.seller_id and t0.goods_id = Q1.goods_id
set t0.cate_sys_alias_id = Q1.cate_sys_alias_id,t0.old_ct_id = Q1.ct_id
where t0.step=p_seller_id;
insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
33554432 + (Q1.step-1)*33554432 as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
t1.id,
0,
0,
0
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t2.id,count(*) as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.id >= t3.id
where t2.sct_deep = 1 and t3.sct_deep = 1
group by t2.id
) Q1
on t1.id = Q1.id;
insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
Q1.step as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
0,
t1.id,
0,
0
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t4.cate_shop_id,t2.id,func_get_shop_cate_id(t4.cate_shop_id,0,0,0,0,p_seller_id,1) + (count(*)-1)*1048576 as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.sct_pid = t3.sct_pid and t2.id >= t3.id
INNER JOIN category_shop t4
on t2.sct_pid = t4.old_sct_id_1
where t4.seller_id=p_seller_id and t2.sct_deep = 2 and t3.sct_deep = 2
group by t4.cate_shop_id,t2.id
) Q1
on t1.id = Q1.id;
insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
Q1.step as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
0,
0,
t1.id,
0
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t4.cate_shop_id,t2.id,func_get_shop_cate_id(0,t4.cate_shop_id,0,0,0,p_seller_id,1) + (count(*)-1)*32768 as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.sct_pid = t3.sct_pid and t2.id >= t3.id
INNER JOIN category_shop t4
on t2.sct_pid = t4.old_sct_id_2
where t4.seller_id=p_seller_id and t2.sct_deep = 3 and t3.sct_deep = 3
group by t4.cate_shop_id,t2.id
) Q1
on t1.id = Q1.id;
insert into category_shop
(
`seller_id`,
`shop_id`,
`cate_shop_id`,
`level`,
`cate_name`,
`page_title`,
`page_keywords`,
`page_description`,
`image_url`,
`image_base_name`,
`image_tips`,
`cate_shop_index`,
`is_visible` ,
`old_sct_id_1`,
`old_sct_id_2`,
`old_sct_id_3`,
`old_sct_id_4`
)
SELECT
p_seller_id as `seller_id`,
1 as `shop_id`,
-- `p_sys_id_1` int,`p_sys_id_2` int,`p_sys_id_3` int,`p_sys_id_4` int,`p_sys_id_5` int,`p_seller_id` int,`p_shop_id` int
-- func_get_shop_cate_id(0,0,0,0,0,16777216,1) as `cate_shop_id`,
Q1.step as `cate_shop_id`,
t1.sct_deep as `level`,
t1.sct_name as `cate_name`,
t1.sct_name`page_title`,
t1.sct_name as `page_keywords`,
t1.sct_name as `page_description`,
‘‘ as `image_url`,
‘‘ as `image_base_name`,
t1.sct_name as `image_tips`,
99 as `cate_shop_index`,
1 as `is_visible`,
0,
0,
0,
t1.id
FROM
`site_rinhooOTA=`.rinhoo_shop_category t1
INNER JOIN(
SELECT t4.cate_shop_id,t2.id,func_get_shop_cate_id(0,0,t4.cate_shop_id,0,0,p_seller_id,1) + (count(*)-1)*1024 as step from `site_rinhooOTA=`.rinhoo_shop_category t2
INNER JOIN `site_rinhooOTA=`.rinhoo_shop_category t3
on t2.sct_pid = t3.sct_pid and t2.id >= t3.id
INNER JOIN category_shop t4
on t2.sct_pid = t4.old_sct_id_3
where t4.seller_id=p_seller_id and t2.sct_deep = 4 and t3.sct_deep = 4
group by t4.cate_shop_id,t2.id
) Q1
on t1.id = Q1.id;
insert into relationship_shop_product
(
`shop_owner_id`,
`goods_id`,
`seller_shop_id`,
`cate_shop_id`,
`is_visible`,
`is_accept_price`,
`is_store_visible`,
`is_deleted`,
`create_time`,
`update_time`
)
SELECT
t2.seller_id,
t2.goods_id,
1,
t3.cate_shop_id,
1,
1,
1,
0,
NOW(),
NOW()
from `site_rinhooOTA=`.rinhoo_products t1
INNER JOIN goods_basic t2
on t1.id = t2.old_id
INNER JOIN category_shop t3
on t1.sct_id in (t3.old_sct_id_1,t3.old_sct_id_2,t3.old_sct_id_3,t3.old_sct_id_4)
where t2.step=p_seller_id and t3.cate_shop_id is not null;
insert into goods_attr_item
(
`seller_id`,
`goods_id`,
`cate_attr_type`,
`cate_attr_id`,
`attr_item_cate_id`,
`goods_attr_item_value`,
`old_id`
)
SELECT
t3.seller_id,
t3.goods_id,
16,
t1.attr_cate_sys_id,
0,
‘‘,
t1.id
from rinhoo_products_sx t1
INNER JOIN goods_basic t3
on t1.pc_id = t3.old_id
WHERE t3.step=p_seller_id and t1.attr_cate_sys_id >0;
update goods_attr_item t1
INNER JOIN rinhoo_products_sx t2
on t1.old_id = t2.id and t2.attr_cate_sys_id > 0 and (t2.sx_type=1 or t2.attr_item_cate_id > 0)
set t1.attr_item_cate_id = t2.attr_item_cate_id,
t1.goods_attr_item_value = (case when t2.sx_type = 1 then t2.sv_name else ‘‘ end)
where t1.seller_id=p_seller_id;
END
通过开发那边单元测试生成100个客户
每个客户循环
造个存储过程
BEGIN
DECLARE m_seller_id INT;
-- 遍历数据结束标志
DECLARE done INT DEFAULT FALSE;
-- 游标
DECLARE cur CURSOR FOR select seller_id from seller_sys where seller_id > 875626496;
-- 将结束标志绑定到游标
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
-- 打开游标
OPEN cur;
-- 开始循环
read_loop: LOOP
-- 提取游标里的数据,这里只有一个,多个的话也一样;
FETCH cur INTO m_seller_id;
-- 声明结束的时候
IF done THEN
LEAVE read_loop;
END IF;
call proc_import_data_rinhoo(m_seller_id);//一个客户的导入的过程名字,有个传入参数
END LOOP;
-- 关闭游标
CLOSE cur;
END