AdminOrderController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\rob\controller;
  3. use app\rob\model\OrderModel;
  4. use cmf\controller\AdminBaseController;
  5. class AdminOrderController extends AdminBaseController
  6. {
  7. /**
  8. * 全部订单
  9. */
  10. public function index()
  11. {
  12. $where = [];
  13. return $this->_orderList($where);
  14. }
  15. /**
  16. * 待领取
  17. */
  18. public function unReceive()
  19. {
  20. $where = [['status', '=', 1]];
  21. return $this->_orderList($where);
  22. }
  23. /**
  24. * 已完成
  25. */
  26. public function finish()
  27. {
  28. $where = [['status', '=', 2]];
  29. return $this->_orderList($where);
  30. }
  31. /**
  32. * 订单列表
  33. */
  34. private function _orderList($where)
  35. {
  36. $param = $this->request->param();
  37. if (!empty($param['order_no'])) {
  38. $where[] = ['order_no', 'like', "%{$param['order_no']}%"];
  39. }
  40. $list = OrderModel::with('orderProduct')
  41. ->where($where)
  42. ->order('update_time desc')
  43. ->paginate(10, false, ['query' => $param]);
  44. $this->assign('order_no', isset($param['order_no']) ? $param['order_no'] : '');
  45. $this->assign('list', $list->items());
  46. $this->assign('page', $list->render());
  47. return $this->fetch();
  48. }
  49. /**
  50. * 详情
  51. */
  52. public function detail()
  53. {
  54. $id = $this->request->param('id', 0, 'intval');
  55. $order = OrderModel::with('user')->where($id)->find();
  56. $this->assign('order', $order);
  57. return $this->fetch();
  58. }
  59. /**
  60. * 核销
  61. */
  62. public function receive()
  63. {
  64. $id = $this->request->param('id', 0, 'intval');
  65. OrderModel::update([
  66. 'status' => 2,
  67. 'receive_time' => time(),
  68. ], ['id' => $id]);
  69. $this->success('操作成功!');
  70. }
  71. }