123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\rob\controller;
- use app\rob\model\OrderModel;
- use cmf\controller\AdminBaseController;
- class AdminOrderController extends AdminBaseController
- {
- /**
- * 全部订单
- */
- public function index()
- {
- $where = [];
- return $this->_orderList($where);
- }
- /**
- * 待领取
- */
- public function unReceive()
- {
- $where = [['status', '=', 1]];
- return $this->_orderList($where);
- }
- /**
- * 已完成
- */
- public function finish()
- {
- $where = [['status', '=', 2]];
- return $this->_orderList($where);
- }
- /**
- * 订单列表
- */
- private function _orderList($where)
- {
- $param = $this->request->param();
- if (!empty($param['order_no'])) {
- $where[] = ['order_no', 'like', "%{$param['order_no']}%"];
- }
- $list = OrderModel::with('orderProduct')
- ->where($where)
- ->order('update_time desc')
- ->paginate(10, false, ['query' => $param]);
- $this->assign('order_no', isset($param['order_no']) ? $param['order_no'] : '');
- $this->assign('list', $list->items());
- $this->assign('page', $list->render());
- return $this->fetch();
- }
- /**
- * 详情
- */
- public function detail()
- {
- $id = $this->request->param('id', 0, 'intval');
- $order = OrderModel::with('user')->where($id)->find();
- $this->assign('order', $order);
- return $this->fetch();
- }
- /**
- * 核销
- */
- public function receive()
- {
- $id = $this->request->param('id', 0, 'intval');
- OrderModel::update([
- 'status' => 2,
- 'receive_time' => time(),
- ], ['id' => $id]);
- $this->success('操作成功!');
- }
- }
|