Can there be a voltage spike from ULN2803 to MCP23017?
You need to consider your electric lock being most likely a coil. When you switch off your coil, you will have a voltage spike at the coil leads or anything connected to it.

To solve this problem, the common solution is to place a fly-back diode at the coil so that the voltage has somewhere to go.

The good thing is that the ULN2803 directly integrates this diode for each pin and they are all connected to the COM pin.


 Make sure the COM is connected to the + of the supply and coil, as you mentioned it should be fine.



Concerning connecting the ground altogether, it is probably not fine to connect -12VDC to the ground as it would short the power supply. Are you sure it is actually -12VDC? if so you probably don't need it at all and just connect the +12VDC and GND.