Operate.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\store\controller\order;
  3. use app\store\controller\Controller;
  4. use app\store\model\Order as OrderModel;
  5. use app\store\model\Express as ExpressModel;
  6. /**
  7. * 订单操作控制器
  8. * Class Operate
  9. * @package app\store\controller\order
  10. */
  11. class Operate extends Controller
  12. {
  13. /* @var OrderModel $model */
  14. private $model;
  15. /**
  16. * 构造方法
  17. * @throws \app\common\exception\BaseException
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. * @throws \think\exception\DbException
  21. */
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->model = new OrderModel;
  26. }
  27. /**
  28. * 订单导出
  29. * @param string $dataType
  30. * @throws \think\exception\DbException
  31. */
  32. public function export($dataType)
  33. {
  34. return $this->model->exportList($dataType, $this->request->param());
  35. }
  36. /**
  37. * 批量发货
  38. * @return array|bool|mixed
  39. * @throws \think\db\exception\DataNotFoundException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. * @throws \think\exception\DbException
  42. */
  43. public function batchDelivery()
  44. {
  45. if (!$this->request->isAjax()) {
  46. return $this->fetch('batchDelivery', [
  47. 'express_list' => ExpressModel::getAll()
  48. ]);
  49. }
  50. if ($this->model->batchDelivery($this->postData('order'))) {
  51. return $this->renderSuccess('发货成功');
  52. }
  53. return $this->renderError($this->model->getError() ?: '发货失败');
  54. }
  55. /**
  56. * 批量发货模板
  57. */
  58. public function deliveryTpl()
  59. {
  60. return $this->model->deliveryTpl();
  61. }
  62. /**
  63. * 审核:用户取消订单
  64. * @param $order_id
  65. * @return array|bool
  66. * @throws \app\common\exception\BaseException
  67. * @throws \think\exception\DbException
  68. */
  69. public function confirmCancel($order_id)
  70. {
  71. $model = OrderModel::detail($order_id);
  72. if ($model->confirmCancel($this->postData('order'))) {
  73. return $this->renderSuccess('操作成功');
  74. }
  75. return $this->renderError($model->getError() ?: '操作失败');
  76. }
  77. /**
  78. * 门店自提核销
  79. * @param $order_id
  80. * @return array|bool
  81. * @throws \think\exception\DbException
  82. */
  83. public function extract($order_id)
  84. {
  85. $model = OrderModel::detail($order_id);
  86. $data = $this->postData('order');
  87. if ($model->verificationOrder($data['extract_clerk_id'])) {
  88. return $this->renderSuccess('核销成功');
  89. }
  90. return $this->renderError($model->getError() ?: '核销失败');
  91. }
  92. }