Order.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace app\store\controller;
  3. use app\store\model\Order as OrderModel;
  4. use app\store\model\Express as ExpressModel;
  5. use app\store\model\store\shop\Clerk as ShopClerkModel;
  6. use app\store\model\store\Shop as ShopModel;
  7. /**
  8. * 订单管理
  9. * Class Order
  10. * @package app\store\controller
  11. */
  12. class Order extends Controller
  13. {
  14. /**
  15. * 待发货订单列表
  16. * @return mixed
  17. * @throws \think\exception\DbException
  18. */
  19. public function delivery_list()
  20. {
  21. return $this->getList('待发货订单列表', 'delivery');
  22. }
  23. /**
  24. * 待收货订单列表
  25. * @return mixed
  26. * @throws \think\exception\DbException
  27. */
  28. public function receipt_list()
  29. {
  30. return $this->getList('待收货订单列表', 'receipt');
  31. }
  32. /**
  33. * 待付款订单列表
  34. * @return mixed
  35. * @throws \think\exception\DbException
  36. */
  37. public function pay_list()
  38. {
  39. return $this->getList('待付款订单列表', 'pay');
  40. }
  41. /**
  42. * 已完成订单列表
  43. * @return mixed
  44. * @throws \think\exception\DbException
  45. */
  46. public function complete_list()
  47. {
  48. return $this->getList('已完成订单列表', 'complete');
  49. }
  50. /**
  51. * 已取消订单列表
  52. * @return mixed
  53. * @throws \think\exception\DbException
  54. */
  55. public function cancel_list()
  56. {
  57. return $this->getList('已取消订单列表', 'cancel');
  58. }
  59. /**
  60. * 全部订单列表
  61. * @return mixed
  62. * @throws \think\exception\DbException
  63. */
  64. public function all_list()
  65. {
  66. return $this->getList('全部订单列表', 'all');
  67. }
  68. /**
  69. * 订单详情
  70. * @param $order_id
  71. * @return mixed
  72. * @throws \think\exception\DbException
  73. */
  74. public function detail($order_id)
  75. {
  76. // 订单详情
  77. $detail = OrderModel::detail($order_id);
  78. // 物流公司列表
  79. $expressList = ExpressModel::getAll();
  80. // 门店店员列表
  81. $shopClerkList = (new ShopClerkModel)->getList(true);
  82. return $this->fetch('detail', compact(
  83. 'detail',
  84. 'expressList',
  85. 'shopClerkList'
  86. ));
  87. }
  88. /**
  89. * 确认发货
  90. * @param $order_id
  91. * @return array
  92. * @throws \app\common\exception\BaseException
  93. * @throws \think\Exception
  94. * @throws \think\exception\DbException
  95. */
  96. public function delivery($order_id)
  97. {
  98. $model = OrderModel::detail($order_id);
  99. if ($model->delivery($this->postData('order'))) {
  100. return $this->renderSuccess('发货成功');
  101. }
  102. return $this->renderError($model->getError() ?: '发货失败');
  103. }
  104. /**
  105. * 修改订单价格
  106. * @param $order_id
  107. * @return array
  108. * @throws \think\exception\DbException
  109. */
  110. public function updatePrice($order_id)
  111. {
  112. $model = OrderModel::detail($order_id);
  113. if ($model->updatePrice($this->postData('order'))) {
  114. return $this->renderSuccess('修改成功');
  115. }
  116. return $this->renderError($model->getError() ?: '修改失败');
  117. }
  118. /**
  119. * 订单列表
  120. * @param string $title
  121. * @param string $dataType
  122. * @return mixed
  123. * @throws \think\exception\DbException
  124. */
  125. private function getList($title, $dataType)
  126. {
  127. // 订单列表
  128. $model = new OrderModel;
  129. $list = $model->getList($dataType, $this->request->param());
  130. // 自提门店列表
  131. $shopList = ShopModel::getAllList();
  132. return $this->fetch('index', compact('title', 'dataType', 'list', 'shopList'));
  133. }
  134. }