Order.php 3.7 KB

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