Operate.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\store\controller\apps\sharing\order;
  3. use app\store\controller\Controller;
  4. use app\store\model\sharing\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 \think\exception\DbException
  67. */
  68. public function confirmCancel($order_id)
  69. {
  70. $model = OrderModel::detail($order_id);
  71. if ($model->confirmCancel($this->postData('order'))) {
  72. return $this->renderSuccess('操作成功');
  73. }
  74. return $this->renderError($model->getError() ?: '操作失败');
  75. }
  76. /**
  77. * 拼团失败手动退款
  78. * @param $order_id
  79. * @return array|bool
  80. * @throws \app\common\exception\BaseException
  81. * @throws \think\Exception
  82. * @throws \think\exception\DbException
  83. */
  84. public function refund($order_id)
  85. {
  86. $model = OrderModel::detail($order_id);
  87. if ($model->refund()) {
  88. return $this->renderSuccess('操作成功');
  89. }
  90. return $this->renderError($model->getError() ?: '操作失败');
  91. }
  92. /**
  93. * 门店自提核销
  94. * @param $order_id
  95. * @return array|bool
  96. * @throws \think\exception\DbException
  97. */
  98. public function extract($order_id)
  99. {
  100. $model = OrderModel::detail($order_id);
  101. $data = $this->postData('order');
  102. if ($model->verificationOrder($data['extract_clerk_id'])) {
  103. return $this->renderSuccess('核销成功');
  104. }
  105. return $this->renderError($model->getError() ?: '核销失败');
  106. }
  107. }