Browse Source

获取订单列表

dev
nizongfeng 3 years ago
parent
commit
184a015981
4 changed files with 68 additions and 8 deletions
  1. +11
    -1
      application/admin/controller/ReceiptOrder.php
  2. +17
    -0
      application/admin/service/OrderMainDao.php
  3. +14
    -7
      application/admin/service/ReceiptOrderDao.php
  4. +26
    -0
      application/admin/service/ReceiptOrderService.php

+ 11
- 1
application/admin/controller/ReceiptOrder.php View File

@@ -16,7 +16,7 @@ use think\exception\ValidateException;
*/
class ReceiptOrder extends Backend
{
protected $noNeedLogin = ['getOrderMainList',"getList"];
/**
* ReceiptOrder模型对象
* @var \app\admin\model\ReceiptOrder
@@ -245,5 +245,15 @@ class ReceiptOrder extends Backend
}


/**
* 获取订单列表
* @return \think\response\Json
*/
public function getOrderMainList(){
$params=$this->request->post();
$service = new ReceiptOrderService();
$result = $service->getOrderMainList($params);
return json($result);
}

}

+ 17
- 0
application/admin/service/OrderMainDao.php View File

@@ -199,4 +199,21 @@ class OrderMainDao
}
}

/**
* 获取订单列表
* @param $where
* @param $param
* @return array
*/
public function getOrderListByWhere($where,$param){
try {
$offset = ($param['pageNum'] - 1) * $param['pageSize'];
$model = new OrderMain();
$count = $model->where($where)->count();
$list = $model->where($where)->limit($offset,$param['pageSize'])->order("id","DESC")->select();
return Util::returnArrSu("", ["total" => $count, "list" => $list->toArray()]);
}catch (Exception $e){
return Util::returnArrSu("", ["total" => 0, "list" => []]);
}
}
}

+ 14
- 7
application/admin/service/ReceiptOrderDao.php View File

@@ -90,22 +90,29 @@ class ReceiptOrderDao
try {
$where = [];
if (!empty($param['name'])) {
$where['name'] = $param['name'];
$where['a.name'] = ["like","%".$param['name']."%"];
}
if ($param['status'] != 'all') {
$where["status"] = $param['status'];
$where["a.status"] = $param['status'];
}
$offset = ($param['pageNum'] - 1) * $param['pageSize'];
$receiptOrder = new ReceiptOrder();
$total = $receiptOrder
->alias("a")
->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left')
->field("a.*,count(1) cnt,sum(b.total_amount) total_amount")
->group("a.id")
->where($where)->count();

$list = $receiptOrder
->alias("a")
->join('hbp_order_main b', 'a.id = b.receipt_order_id', 'left')
->field("a.*,count(1),sum(b.total_amount)")
->field("a.*,count(1) cnt,sum(b.total_amount) total_amount")
->group("a.id")
->where($where);
$total = $list->count();
$list = $list->limit($offset, $param['pageSize'])->select();
$data = ["total" => $total, "list" => $list];
->where($where)
->limit($offset, $param['pageSize'])
->order("id","DESC")->select();
$data = ["total" => $total, "list" => $list->toArray()];
return Util::returnArrSu("", $data);
} catch (Exception $e) {
return Util::returnArrSu("", ["total" => 0, "list" => []]);


+ 26
- 0
application/admin/service/ReceiptOrderService.php View File

@@ -94,4 +94,30 @@ class ReceiptOrderService
$orderMainDao = new OrderMainDao();
return $orderMainDao->removeOrderMainFormReceipt($orderIds);
}

/**
* 获取主订单列表
* @param $param
* @return array
*/
public function getOrderMainList($param){
$orderMainDao = new OrderMainDao();
$where = ["id"=>["neq",""]];
if (!empty($param['order_id'])) {
$where["order"]=$param['order_id'];
}
switch ($param['inReceipt']) {
case 0:
break;
case 1:
$where["receipt_order_id"] = $param['receipt_order_id'];
break;
case 2:
$where["receipt_order_id"] = ["neq",$param['receipt_order_id']];
break;
case 3:
$where["receipt_order_id"] = "";
}
return $orderMainDao->getOrderListByWhere($where,$param);
}
}

Loading…
Cancel
Save