|
|
@@ -306,78 +306,96 @@ class OrderMainService |
|
|
|
*/ |
|
|
|
public function getOrderList($param){ |
|
|
|
$orderMainDao = new OrderMainDao(); |
|
|
|
$where = ["del_flag"=>0]; |
|
|
|
$where = [" a.del_flag = 0 "]; |
|
|
|
if (!empty($param['order_id'])) { |
|
|
|
$where["id"]=$param['order_id']; |
|
|
|
$where[] =" a.id = {$param['order_id']} "; |
|
|
|
} |
|
|
|
if (!empty($param['channel_id'])) { |
|
|
|
$where['channel_id'] = $param['channel_id']; |
|
|
|
$where[] = " a.channel_id = {$param['channel_id']} "; |
|
|
|
} |
|
|
|
if ($param['order_status'] != '') { |
|
|
|
$where['order_status'] = $param['order_status']; |
|
|
|
$where[] = " a.order_status = {$param['order_status']} "; |
|
|
|
} |
|
|
|
if (!empty($param['commissioner_id'])) { |
|
|
|
$where['commissioner_id'] = $param['commissioner_id']; |
|
|
|
$where[] = " a.commissioner_id = {$param['commissioner_id']} "; |
|
|
|
} |
|
|
|
if (!empty($param['user_name'])) { |
|
|
|
$where['user_name'] = ["like","%".$param['user_name']."%"]; |
|
|
|
$where[] = " a.user_name like '%{$param['user_name']}%' "; |
|
|
|
} |
|
|
|
if (!empty($param['user_phone'])) { |
|
|
|
$where['user_phone'] = $param['user_phone']; |
|
|
|
$where[] = " a.user_phone = '{$param['user_phone']}' "; |
|
|
|
} |
|
|
|
if (!empty($param['create_id'])) { |
|
|
|
$where['create_id'] = $param['create_id']; |
|
|
|
$where[] = " a.create_id = {$param['create_id']} "; |
|
|
|
} |
|
|
|
//金额区间查询 |
|
|
|
if (!empty($param['startMoney'])&& empty($param['endMoney'])) { |
|
|
|
$where['total_amount'] = [">=",$param['startMoney']]; |
|
|
|
if (!empty($param['startMoney'])) { |
|
|
|
$where[] = " a.total_amount >= {$param['startMoney']} "; |
|
|
|
} |
|
|
|
if (!empty($param['endMoney']) && empty($param['startMoney'])) { |
|
|
|
$where['total_amount'] = ["<=",$param['endMoney']]; |
|
|
|
} |
|
|
|
if (!empty($param['endMoney']) && !empty($param['startMoney'])) { |
|
|
|
$where['total_amount'] = ["between",[$param['startMoney'],$param['endMoney']]]; |
|
|
|
if (!empty($param['endMoney']) ) { |
|
|
|
$where[] = " a.total_amount <= {$param['endMoney']} "; |
|
|
|
} |
|
|
|
|
|
|
|
//成本区间查询 |
|
|
|
if (!empty($param['startCost'])&& empty($param['endCost'])) { |
|
|
|
$where['cost_amount'] = [">=",$param['startCost']]; |
|
|
|
if (!empty($param['startCost'])) { |
|
|
|
$where[] = " a.cost_amount >= {$param['startCost']} "; |
|
|
|
} |
|
|
|
if (!empty($param['endCost']) && empty($param['startCost'])) { |
|
|
|
$where['cost_amount'] = ["<=",$param['endCost']]; |
|
|
|
} |
|
|
|
if (!empty($param['endCost']) && !empty($param['startCost'])) { |
|
|
|
$where['cost_amount'] = ["between",[$param['startCost'],$param['endCost']]]; |
|
|
|
if (!empty($param['endCost']) ) { |
|
|
|
$where[] = " a.cost_amount <= {$param['endCost']} "; |
|
|
|
} |
|
|
|
//利润区间查询 |
|
|
|
if (!empty($param['startProfit'])&& empty($param['endProfit'])) { |
|
|
|
$where['profit_amount'] = [">=",$param['startProfit']]; |
|
|
|
} |
|
|
|
if (!empty($param['endProfit']) && empty($param['startProfit'])) { |
|
|
|
$where['profit_amount'] = ["<=",$param['endProfit']]; |
|
|
|
if (!empty($param['startProfit'])) { |
|
|
|
$where[] = " a.profit_amount >= {$param['startProfit']} "; |
|
|
|
} |
|
|
|
if (!empty($param['endProfit']) && !empty($param['startProfit'])) { |
|
|
|
$where['profit_amount'] = ["between",[$param['startProfit'],$param['endProfit']]]; |
|
|
|
if (!empty($param['endProfit']) ) { |
|
|
|
$where[] = " a.profit_amount <= {$param['endProfit']} "; |
|
|
|
} |
|
|
|
|
|
|
|
//时间区间查询 |
|
|
|
if (!empty($param['startTime']) && empty($param['endTime'])) { |
|
|
|
$where['create_time'] = [">=",$param['startTime']." 00:00:00"]; |
|
|
|
} |
|
|
|
if (!empty($param['endTime'])&& empty($param['startTime'])) { |
|
|
|
$where['create_time'] = ["<=",$param['endTime']." 23:59:59"]; |
|
|
|
if (!empty($param['startTime'])) { |
|
|
|
$where[] = " a.create_time >= '{$param['startTime']} 00:00:00' "; |
|
|
|
} |
|
|
|
if(!empty($param['endTime'])&& !empty($param['startTime'])){ |
|
|
|
$where['create_time'] = ["between",[$param['startTime']." 00:00:00",$param['endTime']." 23:59:59"]]; |
|
|
|
if (!empty($param['endTime']) ) { |
|
|
|
$where[] = " a.create_time <= '{$param['endTime']} 23:59:59' "; |
|
|
|
} |
|
|
|
|
|
|
|
if ($param['receipt_order_status'] !== '') { |
|
|
|
$where['receipt_order_status'] = $param['receipt_order_status']; |
|
|
|
$where[] = " a.receipt_order_status = {$param['receipt_order_status']} "; |
|
|
|
} |
|
|
|
if ($param['receipt_order_id'] !== '') { |
|
|
|
$where['receipt_order_id'] = $param['receipt_order_id']; |
|
|
|
$where[] = " a.receipt_order_id = {$param['receipt_order_id']} "; |
|
|
|
} |
|
|
|
if ($param['channel_order_no'] != '') { |
|
|
|
$where['channel_order_no'] = $param['channel_order_no']; |
|
|
|
$where[] = " a.channel_order_no = '{$param['channel_order_no']}' "; |
|
|
|
} |
|
|
|
//子订单查询条件 入住时间 |
|
|
|
if (!empty($param['startInDate']) && empty($param['endInDate'])) { |
|
|
|
$where[] = " (b.check_in_date >= '{$param['startInDate']} 00:00:00' or c.check_in_date >= '{$param['startInDate']} 00:00:00' )"; |
|
|
|
} |
|
|
|
$result = $orderMainDao->getOrderListByWhere($where,$param); |
|
|
|
if (!empty($param['endInDate']) && empty($param['startInDate']) ) { |
|
|
|
$where[] = " (b.check_in_date <= '{$param['endInDate']} 23:59:59' or c.check_in_date <= '{$param['endInDate']} 23:59:59' ) "; |
|
|
|
} |
|
|
|
if (!empty($param['startInDate']) && !empty($param['endInDate']) ) { |
|
|
|
$where[] = " ( |
|
|
|
(b.check_in_date >= '{$param['startInDate']} 00:00:00' and b.check_in_date <= '{$param['endInDate']} 23:59:59') |
|
|
|
or |
|
|
|
(c.check_in_date >= '{$param['startInDate']} 00:00:00' and c.check_in_date <= '{$param['endInDate']} 23:59:59') |
|
|
|
) "; |
|
|
|
} |
|
|
|
//供应商 |
|
|
|
if (!empty($param['supplier_id'])) { |
|
|
|
$where[] = "(b.supplier_id = {$param['supplier_id']} or c.supplier_id = {$param['supplier_id']})"; |
|
|
|
} |
|
|
|
//子订单查询条件 离店时间 |
|
|
|
if (!empty($param['startOutDate'])) { |
|
|
|
$where[] = " c.check_out_date >= '{$param['startOutDate']} 00:00:00' "; |
|
|
|
} |
|
|
|
if (!empty($param['endOutDate']) ) { |
|
|
|
$where[] = " c.check_out_date <= '{$param['endOutDate']} 23:59:59' "; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$result = $orderMainDao->getOrderListByWhereStr(join(" and ",$where),$param); |
|
|
|
if (!$result['flag'] || $result['data']['total']==0) { |
|
|
|
return $result; |
|
|
|
} |
|
|
|