diff --git a/application/admin/dao/OrderMainDao.php b/application/admin/dao/OrderMainDao.php index a64045a..647c7c6 100644 --- a/application/admin/dao/OrderMainDao.php +++ b/application/admin/dao/OrderMainDao.php @@ -13,6 +13,7 @@ use app\admin\command\Util; use app\admin\model\OrderHotel; use app\admin\model\OrderItem; use app\admin\model\OrderMain; +use think\Db; use think\Exception; class OrderMainDao @@ -335,4 +336,34 @@ class OrderMainDao return []; } } + + /** + * 获取订单列表 + * @param $where + * @param $param + * @return array + */ + public function getOrderListByWhereStr($where, $param) { + $limit = $param['pageSize']; + $offset = ($param['pageNum']-1)*$param['pageSize']; + $sqlCnt="SELECT count(DISTINCT a.id) cnt + from hbp_order_main a + left join hbp_order_hotel b on b.order_id=a.id and b.del_flag=0 + left join hbp_order_item c on c.order_id = a.id and c.del_flag=0 + where {$where} + "; + $totalRe = Db::query($sqlCnt); + $sqlList="SELECT a.* + from hbp_order_main a + left join hbp_order_hotel b on b.order_id=a.id and b.del_flag=0 + left join hbp_order_item c on c.order_id = a.id and c.del_flag=0 + where {$where} + GROUP BY a.id + order by a.id desc + limit {$limit} offset {$offset} + "; + $list = Db::query($sqlList); + $result = ["list"=>$list,"total"=>$totalRe[0]['cnt']]; + return Util::returnArrSu("",$result); + } } \ No newline at end of file diff --git a/application/admin/dao/PaymentOrderDao.php b/application/admin/dao/PaymentOrderDao.php index 2b5e1e7..3f76f1e 100644 --- a/application/admin/dao/PaymentOrderDao.php +++ b/application/admin/dao/PaymentOrderDao.php @@ -219,7 +219,7 @@ class PaymentOrderDao ) ) x $where - ORDER BY x.create_time desc"; + "; $totalRe = Db::query($sqlCnt); $sql = "SELECT x.* from ( diff --git a/application/admin/service/OrderMainService.php b/application/admin/service/OrderMainService.php index 92239cd..e8e47dd 100644 --- a/application/admin/service/OrderMainService.php +++ b/application/admin/service/OrderMainService.php @@ -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; } diff --git a/application/admin/view/order_main/index.html b/application/admin/view/order_main/index.html index 5122f56..3e23b7b 100755 --- a/application/admin/view/order_main/index.html +++ b/application/admin/view/order_main/index.html @@ -96,11 +96,52 @@ ~ - + + - @@ -288,7 +329,11 @@ "startTime":"", "endTime":"", "pageNum":1, - "pageSize":10 + "pageSize":10, + "startInDate":"", + "endInDate":"", + "startOutDate":"", + "endOutDate":"" }, total: 0, tableData: [], @@ -328,6 +373,7 @@ {"id": 2, 'value': "已付款"} ], type_list:[], + supplierList:[] } }, created() { @@ -336,6 +382,7 @@ this.addShow = false this.getData(1) }); + this.getSupplierList() this.getAdminUser(); this.getChannelList(); this.getProvince(); @@ -390,6 +437,15 @@ }, }, methods: { + getSupplierList(){ + axios.post("/hotel.php/cf_suplier_info/getList", this.search).then((response) => { + console.log(response) + let data = response.data; + this.supplierList = data.list; + }).catch(function (error) { + console.log(error); + }); + }, getTypeName(info) { for (let i = 0; i < this.type_list.length; i++) { if (this.type_list[i].id == info.item_type) {