Hello,
I'm trying to create a script that may be helpful to other store admins. Here's the scenario:
What I do
Created a store without using reCaptcha on registration.
Consequences
6,000 bot created fake customers were created.
How you know they're bots?
Fake users have all the following identical properties.
- Phone Number: 123456
- "Create on" date and time = "Last activity"
- Names are almost all in this format: textone textone(1 or 2 cap letter) [example: MomeGuavasova MomeGuavasovaHP]
- Address 1 = Address2 = City
What I do to fix this mess
1. Add reCaptcha for registration page.
2. Permanently delete fake customers.
Script Help Needed
I understand that if I dlete a customer through nopcommerce admin, it simply does a soft delete. However, since these are all fake accounts and they haven't been accessed, completely deleting them seems a better option in this scenario.
How can I write a SQL script that follows these criteria:
IF PhoneNumber = '123456'
Problem 1:
Even though they all show their phone number as '123456' I do not know where this is stored in DB since the [dbo].[Customer] for [BillingAddress_Id] and [ShippingAddress_Id] are both set to Null...
Assuming I can do the "if" above (if phone number = '123456).. Continuing with the script below
AND IF
From [dbo].[Customer] > [BillingAddress_Id] AND [ShippingAddress_Id] is null
AND IF
From [dbo].[Customer] > [CreatedOnUtc] = [LastActivityDateUtc]
AND IF
From [dbo].[Customer] > [CreatedOnUtc] < 2014-02-01 11:43:49.863 // Just to ensure new customer registering get a chance to sign up
THEN Take their ID
From [dbo].[Customer] > [id]
Then DELETE
[dbo].[Customer_CustomerRole_Mapping] where [Customer_Id] = [dbo].[Customer] > [id]
AND DELETE
From [dbo].[Customer] > [id]
Anyone can help turn this into a viable SQL script?
Thank you