Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public function getOderAmountByOrderType($options = array())
  2. {
  3. $orderDec = 'Desc';
  4. $limit = false;
  5. $conditions = array();
  6. if(isset($options['conditions'])){
  7. $conditions = array_merge($conditions, $options['conditions']);
  8. }
  9.  
  10. if(isset($options['orderDesc'])){
  11. $orderDec = $options['orderDesc'];
  12. }
  13.  
  14. if(isset($options['limit'])){
  15. $limit = $options['limit'];
  16. }
  17.  
  18. $fields = array(
  19. 'SUM(CASE WHEN Order.is_paid = 0 THEN 1 ELSE 0 END) AS freeOrder',
  20. 'SUM(CASE WHEN Order.is_paid = 0 THEN Order.cost_total ELSE 0 END) AS freeOrderAmount',
  21. 'SUM(CASE WHEN Order.is_paid = 1 THEN 1 ELSE 0 END) AS paidOrder',
  22. 'SUM(CASE WHEN Order.is_paid = 1 THEN Order.cost_total ELSE 0 END) AS paidOrderAmount',
  23. 'SUM(CASE WHEN Order.is_paid = 2 THEN 1 ELSE 0 END) AS sampleOrder',
  24. 'SUM(CASE WHEN Order.is_paid = 2 THEN Order.cost_total ELSE 0 END) AS sampleOrderAmount',
  25. 'COUNT(Order.is_paid) as totalOrder',
  26. 'SUM(Order.cost_total) as totalOrderAmount'
  27. );
  28.  
  29. $option = array(
  30. 'fields' => $fields,
  31. 'conditions' => $conditions,
  32. 'recursive' => -1,
  33. 'limit' => $limit
  34. );
  35.  
  36. $result = $this->find('all', $option);
  37.  
  38. return $result;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement