CMSOrder.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * Created by 上海互教教育科技有限公司.
  4. * User: 刘红伟
  5. * Date: 2016/7/19
  6. * Email: 454303753@qq.com
  7. * File:CMSOrder.php
  8. */
  9. class CMSOrder extends CActiveRecord{
  10. public function getDbConnection() {
  11. return Yii::app()->db251;
  12. }
  13. public static function model($className = __CLASS__){
  14. return parent::model($className);
  15. }
  16. public function tableName(){
  17. return "order";
  18. }
  19. public function primaryKey(){
  20. return array('id');
  21. }
  22. public function getPageList($school_id,$classify){
  23. $data = array();
  24. $criteria = new CDbCriteria();
  25. $criteria->select = '*';
  26. $criteria->addCondition('t.school_id=:school_id');
  27. $criteria->params[':school_id'] = $school_id;
  28. if(is_array($classify)){
  29. $criteria->addInCondition('t.classify',$classify);
  30. }else{
  31. $criteria->addCondition('t.classify=:classify');
  32. $criteria->params[':classify'] = $classify;
  33. }
  34. // $criteria->params[':classify'] = $classify;
  35. $criteria->addCondition('(type=1 or type=0 and `status`=1)');
  36. $total = $this->count($criteria);
  37. $pager = new CPagination($total);
  38. $criteria->order = 't.id desc';
  39. $pager->pageSize = 12;
  40. $pager->applyLimit($criteria);
  41. $data['result'] = $this->findAll($criteria);
  42. $data['page'] = $pager;
  43. $data['page_total'] = $total;
  44. return $data;
  45. }
  46. public function getPageByOrderIdList($school_id,$classify,$order_ids=array(),$status=-1,$type=0){
  47. $data = array();
  48. $criteria = new CDbCriteria();
  49. $criteria->addCondition('school_id=:school_id');
  50. $criteria->params[':school_id'] = $school_id;
  51. if($status>-1)
  52. {
  53. $criteria->addCondition('status=:status');
  54. $criteria->params[':status'] = $status;
  55. }
  56. if(!is_array($classify)){
  57. $criteria->addCondition('classify=:classify');
  58. $criteria->params[':classify'] = $classify;
  59. }else{
  60. $criteria->addInCondition('classify',$classify);
  61. }
  62. if($order_ids){
  63. $criteria->addInCondition('id',$order_ids);
  64. }
  65. if($type>=0){
  66. $criteria->addCondition('type=:type');
  67. $criteria->params[':type'] = $type;
  68. }
  69. $criteria->addCondition('(type=1 or type=0 and `status`=1)');
  70. $total = $this->count($criteria);
  71. $pager = new CPagination($total);
  72. $criteria->order = 'id desc';
  73. $pager->pageSize = 12;
  74. $pager->applyLimit($criteria);
  75. $data['result'] = $this->findAll($criteria);
  76. $data['page'] = $pager;
  77. $data['page_total'] = $total;
  78. return $data;
  79. }
  80. public function getOrderInfo($orderid){
  81. $criteria = new CDbCriteria();
  82. $criteria->select = '*';
  83. $criteria->addCondition('id=:id');
  84. $criteria->params[':id'] = $orderid;
  85. return $this->find($criteria);
  86. }
  87. public function getBackOrder($orderid){
  88. $criteria = new CDbCriteria();
  89. $criteria->select = '*';
  90. $criteria->addCondition('original_order_id=:id');
  91. $criteria->params[':id'] = $orderid;
  92. return $this->findAll($criteria);
  93. }
  94. }