Operate.php 2.8 KB

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