diff --git a/application/admin/controller/ReceiptOrder.php b/application/admin/controller/ReceiptOrder.php index d3857ff..9539a19 100755 --- a/application/admin/controller/ReceiptOrder.php +++ b/application/admin/controller/ReceiptOrder.php @@ -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); + } } diff --git a/application/admin/service/OrderMainDao.php b/application/admin/service/OrderMainDao.php index c50f40b..62f7a4f 100644 --- a/application/admin/service/OrderMainDao.php +++ b/application/admin/service/OrderMainDao.php @@ -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" => []]); + } + } } \ No newline at end of file diff --git a/application/admin/service/ReceiptOrderDao.php b/application/admin/service/ReceiptOrderDao.php index 6bd7631..e430de3 100644 --- a/application/admin/service/ReceiptOrderDao.php +++ b/application/admin/service/ReceiptOrderDao.php @@ -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" => []]); diff --git a/application/admin/service/ReceiptOrderService.php b/application/admin/service/ReceiptOrderService.php index 672bd7a..b5edf02 100644 --- a/application/admin/service/ReceiptOrderService.php +++ b/application/admin/service/ReceiptOrderService.php @@ -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); + } } \ No newline at end of file