Fix backend order query only to use distinct when needed

* This fixes most of the cases for redundant distinct usage. There may
  be more. But these are most common and most pressing on the DB size we
  have.
Remove unnecessary test to determine if the order should be voided

* The logic can be simplified so that if the payment total is zero
  (which indicates no payments, a capture + refund, or a void) the order
  payment_state should be set to void.
Fix performance of cart promotion handler select