-- 太原树英商贸 / yangtangyoupin 数据清理
-- 依据: docs/com-sxsy80-data-imgration.md
-- 执行前请备份数据库。建议在事务中先 SELECT 核对影响行数后再 COMMIT。

SET NAMES utf8mb4;

START TRANSACTION;

SET FOREIGN_KEY_CHECKS = 0;

-- 订单类：整表清空
TRUNCATE TABLE `wa_order`;
TRUNCATE TABLE `wa_withdraw`;
TRUNCATE TABLE `eb_store_order`;

-- 寄售商品：仅保留 created_at >= 2026-04-24 且卖家 user_id 在保留名单内
DELETE FROM `wa_merchandise`
WHERE NOT (
  `created_at` >= '2026-04-24 00:00:00'
  AND `user_id` IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638)
);

-- 日志类：仅保留名单内 user_id
DELETE FROM `wa_selfbonus_log`
WHERE `user_id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);

DELETE FROM `wa_sharebonus_log`
WHERE `user_id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);

DELETE FROM `wa_coupon_log`
WHERE `user_id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);

-- 积分记录表实际字段为 uid（非 user_id）
DELETE FROM `eb_user_integral_record`
WHERE `uid` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);

-- 商城用户：保留 uid 在名单内
DELETE FROM `eb_user`
WHERE `uid` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);

-- WA 用户：保留 id 在名单内
DELETE FROM `wa_users`
WHERE `id` NOT IN (92566,92801,92839,93004,92637,92965,93093,93096,93116,92787,93121,93129,92884,93007,93020,93094,93099,93110,92638);

SET FOREIGN_KEY_CHECKS = 1;

COMMIT;
