use strict;

return sub
{
	my $dbh = shift;

	$dbh->do("update jin_user_rmem SET ctime=now() where sale_id=0 and ctime is NULL");
	
	my $sth = $dbh->prepare("select r.sale_id,r.owner_id,s.ctime from jin_user_rmem as r left join jin_sale as s on s.id=r.sale_id where r.sale_id<>0 and r.ctime is NULL");
	$sth->execute;
	
	while (my $row = $sth->fetchrow_hashref)
	{
		$dbh->do("update jin_user_rmem set ctime='$row->{ctime}' where owner_id=$row->{owner_id} and sale_id=$row->{sale_id}");
	}
	
	return;
};