This was a while ago (5+ years ago), so things could have changed. But my JFK to TPE flight was credited to China Airlines since it was their metal, but booked as a codeshare via Delta.com. DL informed me that China Airlines had total control over the mileage credit since it was their metal so I had to contact them. I called China Airlines to see if it was possible, and they requested that I fax over a letter with the boarding passes. I did, and the situation was amended almost immediately. So contacting DL may be of no use.
I always thought that the FF # is typically stored with the trip once you enter it. So I'm wondering why it would credit the out- and in-bound differently.