Order.php 2.4 KB

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