Event.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\store\controller\order;
  13. use app\store\controller\Controller;
  14. use app\store\model\Order as OrderModel;
  15. /**
  16. * 订单操作控制器
  17. * Class Operate
  18. * @package app\store\controller\order
  19. */
  20. class Event extends Controller
  21. {
  22. // 订单模型类
  23. /* @var OrderModel $model */
  24. private $model;
  25. /**
  26. * 构造方法
  27. * @throws \app\common\exception\BaseException
  28. * @throws \think\db\exception\DataNotFoundException
  29. * @throws \think\db\exception\DbException
  30. * @throws \think\db\exception\ModelNotFoundException
  31. */
  32. public function initialize()
  33. {
  34. parent::initialize();
  35. $this->model = new OrderModel;
  36. }
  37. /**
  38. * 确认发货
  39. * @param int $orderId
  40. * @return array
  41. * @throws \Exception
  42. */
  43. public function delivery(int $orderId)
  44. {
  45. // 订单详情
  46. $model = OrderModel::detail($orderId);
  47. if ($model->delivery($this->postForm())) {
  48. return $this->renderSuccess('发货成功');
  49. }
  50. return $this->renderError($model->getError() ?: '发货失败');
  51. }
  52. /**
  53. * 修改订单价格
  54. * @param int $orderId
  55. * @return array
  56. */
  57. public function updatePrice(int $orderId)
  58. {
  59. // 订单详情
  60. $model = OrderModel::detail($orderId);
  61. if ($model->updatePrice($this->postForm())) {
  62. return $this->renderSuccess('操作成功');
  63. }
  64. return $this->renderError($model->getError() ?: '操作失败');
  65. }
  66. /**
  67. * 审核:用户取消订单
  68. * @param $orderId
  69. * @return array|bool
  70. */
  71. public function confirmCancel($orderId)
  72. {
  73. // 订单详情
  74. $model = OrderModel::detail($orderId);
  75. if ($model->confirmCancel($this->postForm())) {
  76. return $this->renderSuccess('操作成功');
  77. }
  78. return $this->renderError($model->getError() ?: '操作失败');
  79. }
  80. }