刪除用戶的函數

BEGIN

/*添加客戶時追加*/
DELETE FROM `seller_sys` WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
DELETE FROM `seller_token` WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*客戶認證表*/
delete from seller_auth_sys WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
-- delete from seller_bank_info WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from seller_bank_relation WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from seller_extend WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from seller_info_extend WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*客戶諮詢表*/
delete from seller_topics WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
#delete from attr_customer_industry WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*客戶信用表*/
delete from customer_auth WHERE (p_seller_id = 0 and owner_id <> 1) or (`owner_id`=p_seller_id and p_seller_id > 1);
/*客戶帳期表*/
delete from customer_pay_period WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*客戶訂單彙總表*/
delete from customer_order_gather WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*客戶關係分類表*/
delete from cate_customer_relation WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);
/*客戶關係表*/
delete from customer_relation WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*客戶歸屬表*/
delete from customer_assign  WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);


delete t1 from user_sys t1 INNER JOIN account_mapping_platform t2 on t1.user_id = t2.user_id
WHERE (p_seller_id = 0 and t2.seller_id <> 1) or (t2.`seller_id`=p_seller_id and p_seller_id > 1);
delete from account_mapping_platform WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from role_platform WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);
-- delete from node_platform
delete from subscribe_platform WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);
delete from access_platform WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);
delete from role_platform WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);


DELETE FROM `shop_basic` WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from shop_manger WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from shop_rate WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from shop_template WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from shop_template_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

-- delete from template
-- delete from attr_template_sys
-- delete from attr_item_template_sys
delete from relationship_shop_other WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from relationship_shop_product WHERE (p_seller_id = 0 and shop_owner_id <> 1) or (`shop_owner_id`=p_seller_id and p_seller_id > 1);

-- delete from lang

delete t1 from user_shopper t1 INNER JOIN account_mapping_terminal t2
on t1.user_id = t2.user_id
WHERE (p_seller_id = 0 and t2.seller_id <> 1) or (t2.`seller_id`=p_seller_id and p_seller_id > 1);
delete from account_mapping_terminal WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from seller_owner WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

/*店鋪分類*/
delete from category_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from standard_seller WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from std_item_seller WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from attr_item_seller WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from attr_seller WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from relationship_supplier_other WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

/*商品信息*/
DELETE from goods_basic WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_attr_item WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from goods_desc WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_extend WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_feedback WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_main_pics WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_relation_other WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from goods_relation_supplier WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_relation_supplier_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_cloud WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

-- delete from goods_cloud_industry WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_statistics WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_std_extend_color WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from goods_std_extend_common WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_std_include WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_std_item WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from goods_temp WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

#delete from promise_distribution WHERE (p_seller_id = 0 and seller_supplier_id <> 1) or (`seller_supplier_id`=p_seller_id and p_seller_id > 1);

/*價格體系*/
DELETE FROM `price_shop_level` WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
DELETE FROM `price_customer_level` WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from price_goods_bargain WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from price_goods_qty_range WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from price_goods_supply WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from rebate_goods_sales WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);



delete from price_goods_shop_bargain WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from price_goods_shop_qty_range WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from price_goods_shop_supply WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from bonus_rule_sales WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from bonus_rule_detail_sales WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


/*倉儲中心*/

DELETE FROM `warehouse_owner` WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_storage WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_logic WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_booking WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_booking_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_income WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_income_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_output WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_output_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_return WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_return_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


delete from warehouse_move WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_move_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_alloc WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_alloc_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_exchange WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_exchange_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


delete from warehouse_recycle WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_recycle_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete t1 from warehouse_temp_detail t1 INNER JOIN warehouse_temp t2 on t1.temp_id = t2.temp_id WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_temp  WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


delete from warehouse_storage_relation WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_storage_log WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from warehouse_storage_detail_log WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_warnning_rule WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);

delete from warehouse_storage_warnning WHERE (p_seller_id = 0 and customer_id <> 1) or (`customer_id`=p_seller_id and p_seller_id > 1);

delete t1 from deliver_service_sys t1 INNER JOIN deliver_sys t2
on t1.deliver_id = t2.deliver_id
WHERE (p_seller_id = 0 and t2.seller_id <> 1) or (t2.`seller_id`=p_seller_id and p_seller_id > 1);

delete t1 from deliver_template t1 INNER JOIN deliver_sys t2 on t1.deliver_id = t2.deliver_id
WHERE (p_seller_id = 0 and t2.seller_id <> 1) or (t2.`seller_id`=p_seller_id and p_seller_id > 1);

delete from deliver_sys WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from relationship_deliver_template_product WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from deliver_template_area WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from deliver_template_area_contain WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from deliver_template_detail WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


/*訂單信息*/
delete from org_order_detail_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from org_order_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from order_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from order_detail_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from deliver_bill_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from pay_info_daily WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
delete from pay_info_assign WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from order_return_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);
/*退貨明細*/
delete from order_detail_return_shop WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


/*在線支付配置表*/
delete from online_pay_config WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

-- delete from online_pay_ments WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);

delete from order_deliver_address WHERE (p_seller_id = 0 and seller_id <> 1) or (`seller_id`=p_seller_id and p_seller_id > 1);


ENDnode

相關文章
相關標籤/搜索