= 0){
$sql.=" and o.is_pin='".$search['is_pin']."'";
}
//date_added_begin
if(isset($search['date_added_begin']) && $search['date_added_begin'] >= 0){
$sql.=" and o.date_added >=".$search['date_added_begin'];
}
if(isset($search['date_added_end']) && $search['date_added_end'] >= 0){
$sql.=" and o.date_added <=".$search['date_added_end'];
}
if(isset($search['shipping_name']) && !empty($search['shipping_name']) ){
//
$sql.=" and o.shipping_name like '%".$search['shipping_name']."%'";
}
if(isset($search['user_name']) && !empty($search['user_name'])){
//
$sql.=" and o.shipping_name like '%".$search['user_name']."%'";
}
if(isset($search['status'])){
$sql.=" and os.order_status_id=".$search['status'];
}
if(isset($search['store_id']))
{
$sql.=" and og.store_id=".$search['store_id'];
}
if(isset($search['order_status_id']))
{
if($search['order_status_id'] == 999)
{
$sql.=" and o.is_balance = 0 and o.order_status_id in (1,4,6,11) ";
} else
{
$sql.=" and o.order_status_id=".$search['order_status_id'];
if( $search['order_status_id'] == 1)
{
$sql.=" and (o.type='normal' or o.type='pintuan' or ( o.type='lottery' and o.lottery_win =1 ) ) ";
}
}
}
$count=count(M()->query($sql));
$Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
$show = $Page->show();// 分页显示输出
if($is_daochu) {
//导出excel
$sql.=' group by o.order_id ORDER BY o.order_id DESC ';
} else {
$sql.=' group by o.order_id ORDER BY o.order_id DESC LIMIT '.$Page->firstRow.','.$Page->listRows;
}
$list=M()->query($sql);
$pin_model = D('Home/Pin');
foreach($list as $key => $val)
{
$val['pin_state'] = 0;
$order_goods_info_list = M('order_goods')->field('order_goods_id,name')->where( array('order_id' => $val['order_id']) )->select();
$name_arr = array();
foreach($order_goods_info_list as $order_goods_info)
{
$order_goods_id = $order_goods_info['order_goods_id'];
$option_list = M('order_option')->where( array('order_goods_id' =>$order_goods_id,'order_id'=> $val['order_id']) )->select();
if(!empty($option_list))
{
$str = '规格:';
foreach ($option_list as $option) {
$str .= $option['name'].': '.$option['value'].' ';
}
$name_arr[] = $order_goods_info['name'] .= $str;
} else {
$name_arr[] = $order_goods_info['name'];
}
}
$val['goods_name'] = implode('
',$name_arr);
//store_id
$seller_info = M('seller')->field('s_true_name')->where( array('s_id'=>$val['store_id']) )->find();
$val['s_true_name'] = $seller_info['s_true_name'];
//ordertype
if($val['is_pin'] == 1)
{
//pin_order $val['order_id']
$pin_order_info = M('pin_order')->where( array('order_id' => $val['order_id'] ) )->find();
$pin_id = $pin_order_info['pin_id'];
$state = $pin_model->getNowPinState($pin_id);
$pin_info = M('pin')->where( array('pin_id' => $pin_id) )->find();
$str = '';
if($state == 1)
{
$str .='';
$str .= $pin_info['need_count'].'人团 拼团id:'.$pin_id.'
已成团';
} else if($state == 2)
{
$str .='';
$str .= '拼团';
$str .= '';
} else {
$str = '进行中';
}
//Pin/show_order/pin_id/484
$val['pin_state'] = $state;
$val['ordertype'] = $str;
//已完成 拼团中,已失败
//{$v.ordertype}
//
} else {
$val['ordertype'] = '单独购买';
}
if($val['type'] == 'integral')
{
$integral_order = M('integral_order')->field('score')->where( array('order_id' => $val['order_id']) )->find();
$val['score'] = intval($integral_order['score']);
}
$list[$key] = $val;
}
return array(
'empty'=>'