Ver código fonte

订单列表 检索优化

dev
nizongfeng 3 anos atrás
pai
commit
61c10516d9
4 arquivos alterados com 149 adições e 44 exclusões
  1. +31
    -0
      application/admin/dao/OrderMainDao.php
  2. +1
    -1
      application/admin/dao/PaymentOrderDao.php
  3. +58
    -40
      application/admin/service/OrderMainService.php
  4. +59
    -3
      application/admin/view/order_main/index.html

+ 31
- 0
application/admin/dao/OrderMainDao.php Ver arquivo

@@ -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);
}
}

+ 1
- 1
application/admin/dao/PaymentOrderDao.php Ver arquivo

@@ -219,7 +219,7 @@ class PaymentOrderDao
)
) x
$where
ORDER BY x.create_time desc";
";
$totalRe = Db::query($sqlCnt);
$sql = "SELECT x.*
from (


+ 58
- 40
application/admin/service/OrderMainService.php Ver arquivo

@@ -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;
}


+ 59
- 3
application/admin/view/order_main/index.html Ver arquivo

@@ -96,11 +96,52 @@
<el-input-number v-model="search.startProfit" style="width: 170px;" placeholder="请输入内容" clearable></el-input-number>
~
<el-input-number v-model="search.endProfit" style="width: 170px;" placeholder="请输入内容" clearable></el-input-number>

</div>
<div class="header-search" style="width: 100%;margin-bottom: 10px">
<span>供应商</span>
<el-select v-model="search.supplier_id" style="width: 150px;" placeholder="请选择" clearable>
<el-option
v-for="item in supplierList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
<span>入住时间</span>
<el-date-picker
style="width: 150px;"
v-model="search.startInDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>
~
<el-date-picker
style="width: 150px;"
v-model="search.endInDate"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期">
</el-date-picker>
<span>离店时间</span>
<el-date-picker
style="width: 150px;"
v-model="search.startOutDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>
~
<el-date-picker
style="width: 150px;"
v-model="search.endOutDate"
value-format="yyyy-MM-dd"
type="date"
placeholder="选择日期">
</el-date-picker>
<el-button type="primary" icon="el-icon-search" @click="getData(1)">搜索</el-button>
<el-button type="primary" icon="el-icon-plus" @click="addShow=true" >新增</el-button>
</div>

<el-table ref="multipleTable" :data="tableData" border tooltip-effect="dark"
style="font-size:12px;width: 100%;margin-top: 12px">
<el-table-column prop="id" label="订单ID" min-width="30" ></el-table-column>
@@ -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) {


Carregando…
Cancelar
Salvar