Apple complied while still retaining as much security as possible. They assert that the data is still encrypted, and they hold the keys:
https://www.nytimes.com/2017/07/12/business/apple-china-data...
Apple had, as I see it, two choices: disable current customers and refuse to sell any more devices, or comply with the law.
So, yes, Apple could have walked away from their customers, but how would that have helped anyone? Their phones are still more secure from non-state actors than nearly anyone else's, and Chinese citizens, for better or worse, have to live with the dictatorship's rules.
(And to preempt the inevitable comparison: https://www.theguardian.com/technology/2015/sep/21/google-is...)
So "They literally made a deal to spy on Chinese citizens as soon as that made them profit" is only true if you assume Apple is lying about the encryption and lying about their reasons for opening the new data center.
It's also possible the OP is talking about some other Apple cooperation with China, but that seems to be the one most people throw at them.