Calculating stock sales over certain period

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
A unique problem that requires calculation, but I'm stumped in how to come up with a solution.

I sell items online and need to find a way to delete items that are selling, but not doing very well over a certain time period.

For example; if an item sells once every 30 days (say twice in 60 days), then keep. Otherwise I will delete it if, for example, sells once every 50 days.

How could I set this up?

Thanks.
 
Последнее редактирование:

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Hey. First you need some unique id for each item. Then just save in file this unique id along with day last sale was made. Then with other template or same ( depends on your other logic ) check timespan in days. If it is over 30 days then go and delete this item. Thats all. Or if you want to give your items more time to keep active before deleting, then you have to set minimal day count too. Like in your example. when only 60 days will be with only one or two sale then item will be deleted.
 

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
Thanks Lokiys, it's a good plan, but the data that I download from eBay doesn't include the last sale date - only when the auction went live.
 

shabbysquire

Client
Регистрация
25.11.2012
Сообщения
544
Благодарностей
26
Баллы
28
True, can use that but it's take a while to scrape eBay.

I'm going to do the following:

1) Grab the auction start date, and work out how many days have lapsed with this c#:

Код:
string someDate = project.Variables["listing_start_date"].Value;
// 1.
// Parse the date and put in DateTime object.
DateTime startDate = DateTime.Parse(someDate);
// 2.
// Get the current DateTime.
DateTime now = DateTime.Now;
// 3.
// Get the TimeSpan of the difference.
TimeSpan elapsed = now.Subtract(startDate);
// 4.
// Get number of days ago.
double daysAgo = elapsed.TotalDays;
// 5.
// Return days lapsed
return daysAgo.ToString("0");
2) Grab the number of items sold, and then divide: days lapsed & item sold. If over 30 (days), then delete.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)