$sql = "select o.* from order_info AS o LEFT JOIN user as u ON u.id = o.user_id WHERE ((o.type_id IN (1,2)";
$sql .= ' '.'AND o.pay_status = "'.PAY_STATUS_SUCCESS.'"';
$sql .= ' '.'AND u.group_id = "'.USER_GROUP_PATIENT.'"'.')';
$sql .= ' '.'OR (o.pay_status = "'.PAY_STATUS_SUCCESS.'"';
$sql .= ' '.'AND o.type_id = 2';
$sql .= ' '.'AND u.group_id = "'.USER_GROUP_DOCTOR.'"'.'))';
if($order_sn){
$sql .= ' '.'AND o.order_sn LIKE "'.'%'.$order_sn.'%'.'"';
}
if($order_status){
$sql .= ' '.'AND o.order_status = "'.$order_status.'"';
}else{
$sql .= ' '.'AND o.order_status IN (3,4)';
}
$sql .= ' '.'ORDER BY o.created_at DESC';
//select o.* from order_info AS o LEFT JOIN user as u ON u.id = o.user_id WHERE ((o.type_id IN (1,2) AND o.pay_status = "2" AND u.group_id = "1") OR (o.type_id = 2 AND o.pay_status = "2" AND u.group_id = "2")) AND o.order_sn LIKE '%2017041220680004%' AND o.order_status IN (3,4) ORDER BY o.created_at DESC
$criteria=new CDbCriteria();
$result = Yii::app()->db->createCommand($sql)->query();
//echo $sql;die();
$pager=new CPagination($result->rowCount);
$pager->pageSize=20;
$pager->applyLimit($criteria);
$limit = $pager->pageSize;
$offset = $pager->currentPage*$pager->pageSize;
$sql .= ' '.'LIMIT '.$limit.' '.'OFFSET'.' '.$offset;
$results=Yii::app()->db->createCommand($sql)->query();
$this->render('list',array(
'pager'=>$pager,
'results'=>$results,
'order_sn'=>$order_sn,
'order_status'=>$order_status,
'is_doctor_order'=>$is_doctor_order
));
网友评论