use strict;

return sub
{
	my $dbh = shift;
	

	my $sth = $dbh->prepare("select id,notifysale_settings from jin_package where notifysale_yes=1");
	$sth->execute;
	
	while (my $row = $sth->fetchrow_hashref)
	{
		my %data = map { s/%(.{2})/pack("C", hex($1))/ge; $_ } split ':', $row->{notifysale_settings};
		
		my $url_q = $dbh->quote($data{notifysale_url});
		my $params_q = $dbh->quote($data{notifysale_params});
		my $method_q = $dbh->quote($data{notifysale_method});
		
		$dbh->do("insert into jin_api_post SET id='$row->{id}',type='notifysale',title=$url_q,url=$url_q,params=$params_q,method=$method_q");
		$dbh->do("update jin_package set api_post_notifysale='$row->{id}' where id='$row->{id}'");
	}
	
	return;
};
