123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- /**
- * Created by 上海互教教育科技有限公司.
- * User: 刘红伟
- * Date: 2016/7/19
- * Email: 454303753@qq.com
- * File:CMSOrder.php
- */
- class CMSOrder extends CActiveRecord{
- public function getDbConnection() {
- return Yii::app()->db251;
- }
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return "order";
- }
- public function primaryKey(){
- return array('id');
- }
- public function getPageList($school_id,$classify){
- $data = array();
- $criteria = new CDbCriteria();
- $criteria->select = '*';
- $criteria->addCondition('t.school_id=:school_id');
- $criteria->params[':school_id'] = $school_id;
- if(is_array($classify)){
- $criteria->addInCondition('t.classify',$classify);
- }else{
- $criteria->addCondition('t.classify=:classify');
- $criteria->params[':classify'] = $classify;
- }
- // $criteria->params[':classify'] = $classify;
- $criteria->addCondition('(type=1 or type=0 and `status`=1)');
- $total = $this->count($criteria);
- $pager = new CPagination($total);
- $criteria->order = 't.id desc';
-
- $pager->pageSize = 12;
- $pager->applyLimit($criteria);
- $data['result'] = $this->findAll($criteria);
-
- $data['page'] = $pager;
- $data['page_total'] = $total;
- return $data;
- }
- public function getPageByOrderIdList($school_id,$classify,$order_ids=array(),$status=-1,$type=0){
-
- $data = array();
- $criteria = new CDbCriteria();
- $criteria->addCondition('school_id=:school_id');
- $criteria->params[':school_id'] = $school_id;
- if($status>-1)
- {
- $criteria->addCondition('status=:status');
- $criteria->params[':status'] = $status;
- }
- if(!is_array($classify)){
- $criteria->addCondition('classify=:classify');
- $criteria->params[':classify'] = $classify;
- }else{
- $criteria->addInCondition('classify',$classify);
- }
- if($order_ids){
- $criteria->addInCondition('id',$order_ids);
- }
- if($type>=0){
- $criteria->addCondition('type=:type');
- $criteria->params[':type'] = $type;
- }
- $criteria->addCondition('(type=1 or type=0 and `status`=1)');
- $total = $this->count($criteria);
- $pager = new CPagination($total);
- $criteria->order = 'id desc';
-
- $pager->pageSize = 12;
- $pager->applyLimit($criteria);
- $data['result'] = $this->findAll($criteria);
- $data['page'] = $pager;
- $data['page_total'] = $total;
- return $data;
- }
- public function getOrderInfo($orderid){
- $criteria = new CDbCriteria();
- $criteria->select = '*';
- $criteria->addCondition('id=:id');
- $criteria->params[':id'] = $orderid;
- return $this->find($criteria);
- }
- public function getBackOrder($orderid){
- $criteria = new CDbCriteria();
- $criteria->select = '*';
- $criteria->addCondition('original_order_id=:id');
- $criteria->params[':id'] = $orderid;
- return $this->findAll($criteria);
- }
- }
|