The Rays have a long history of trading very good players when in contention- either over the winter or at the deadline. I'm not sure it matters all that much when the deal is made. When you trade a very good player for prospects, when you are supposed to be in contention, it's a strategy not many teams use.
The Dodgers have made winter deals like the Rays, but I can't think of any deadline deals, so it does have a different set of issues. I grant that.
I think the Sox traded David Wells, when some thought we still had a shot.
The Rays have traded a few at the deadline. Here are some I remember:
July 2019: In the thick of a playoff race, they traded Ryne Stanek and a prospect for Nick Anderson, who was basically a prospect and Trevor Richards (2nd year in MLB)
July 2018: Chris Archer for Tyler Glasnow, Austin Meadows & Shane Baz. (Would you not want those 3 for Barnes?) The Rays had a nice 62-48 record at the time of the deal and were in the thick of a WC race. The ended up making the playoffs and finished closer to first in the ALE than they were at the time of the trade (7 GB to 7.5 GB).
In 2009, the Rays were 70-58 on the Waiver wire deadline. They still had a decent chance at making the playoffs as a WC team. They traded Scott Kazmir for 3 PTBNLs and ended up missing the playoffs and just 6 games above .500. The 3 PTBNLs were Matthew Sweeney, Alex Torres & Sean Rodriguez.
Speaking of Kazmir, they got him in a deadline trade for Victor Zambrano, but the Rays were not in contention that year.
Some memorable Rays winter trades while viewed as serious contenders:
Dec 2009: Jesse Chavez for Rafael Soriano
Jan 2011: Matt Garza for Chris Archer, R Chirinos, Sam Fuld & Brandon Guyer
Dec 2012: Jamie Shields & Wade Davis for Wil Myers, Jake Odorizzi & Mike Montgomery (they later traded Odorizzi for J Palacios)
Dec 2014: Wil Myers & scraps for Jake Bauers, R Rivera, Burch Smith and others.
Dec 2017: Longoria for Christian Arroyo & Denard Span
I'm probably forgetting some other deals.