Order.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\store\controller\apps\sharing;
  3. use app\store\controller\Controller;
  4. use app\store\model\Express as ExpressModel;
  5. use app\store\model\store\Shop as ShopModel;
  6. use app\store\model\sharing\Order as OrderModel;
  7. use app\store\model\store\shop\Clerk as ShopClerkModel;
  8. /**
  9. * 订单管理
  10. * Class Order
  11. * @package app\store\controller
  12. */
  13. class Order extends Controller
  14. {
  15. /**
  16. * 全部订单列表
  17. * @param string $dataType
  18. * @return mixed
  19. * @throws \think\exception\DbException
  20. */
  21. public function index($dataType = 'all')
  22. {
  23. // 订单列表
  24. $model = new OrderModel;
  25. $list = $model->getList($dataType, $this->request->param());
  26. // 自提门店列表
  27. $shopList = ShopModel::getAllList();
  28. return $this->fetch('index', compact('dataType', 'list', 'shopList'));
  29. }
  30. /**
  31. * 订单详情
  32. * @param $order_id
  33. * @return mixed
  34. * @throws \think\exception\DbException
  35. */
  36. public function detail($order_id)
  37. {
  38. // 订单详情
  39. $detail = OrderModel::detail($order_id);
  40. // 物流公司列表
  41. $expressList = ExpressModel::getAll();
  42. // 门店店员列表
  43. $shopClerkList = (new ShopClerkModel)->getList(true);
  44. return $this->fetch('detail', compact(
  45. 'detail',
  46. 'expressList',
  47. 'shopClerkList'
  48. ));
  49. }
  50. /**
  51. * 确认发货
  52. * @param $order_id
  53. * @return array
  54. * @throws \app\common\exception\BaseException
  55. * @throws \think\Exception
  56. * @throws \think\exception\DbException
  57. */
  58. public function delivery($order_id)
  59. {
  60. $model = OrderModel::detail($order_id);
  61. if ($model->delivery($this->postData('order'))) {
  62. return $this->renderSuccess('发货成功');
  63. }
  64. return $this->renderError($model->getError() ?: '发货失败');
  65. }
  66. /**
  67. * 修改订单价格
  68. * @param $order_id
  69. * @return array
  70. * @throws \think\exception\DbException
  71. */
  72. public function updatePrice($order_id)
  73. {
  74. $model = OrderModel::detail($order_id);
  75. if ($model->updatePrice($this->postData('order'))) {
  76. return $this->renderSuccess('修改成功');
  77. }
  78. return $this->renderError($model->getError() ?: '修改失败');
  79. }
  80. }