Event.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2025 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 think\response\Json;
  14. use think\db\exception\DbException;
  15. use app\store\controller\Controller;
  16. use app\store\model\Order as OrderModel;
  17. /**
  18. * 订单事件控制器
  19. * Class Event
  20. * @package app\store\controller\order
  21. */
  22. class Event extends Controller
  23. {
  24. /**
  25. * 修改订单价格
  26. * @param int $orderId
  27. * @return Json
  28. */
  29. public function updatePrice(int $orderId): Json
  30. {
  31. $model = OrderModel::detail($orderId);
  32. if ($model->updatePrice($this->postForm())) {
  33. return $this->renderSuccess('操作成功');
  34. }
  35. return $this->renderError($model->getError() ?: '操作失败');
  36. }
  37. /**
  38. * 修改商家备注
  39. * @param int $orderId
  40. * @return Json
  41. */
  42. public function updateRemark(int $orderId): Json
  43. {
  44. $model = OrderModel::detail($orderId);
  45. if ($model->updateRemark($this->postForm())) {
  46. return $this->renderSuccess('操作成功');
  47. }
  48. return $this->renderError($model->getError() ?: '操作失败');
  49. }
  50. /**
  51. * 修改收货地址
  52. * @param int $orderId
  53. * @return Json
  54. */
  55. public function updateAddress(int $orderId): Json
  56. {
  57. $model = OrderModel::detail($orderId);
  58. if ($model->updateAddress($this->postForm())) {
  59. return $this->renderSuccess('操作成功');
  60. }
  61. return $this->renderError($model->getError() ?: '操作失败');
  62. }
  63. /**
  64. * 小票打印
  65. * @param int $orderId
  66. * @return Json
  67. * @throws DbException
  68. * @throws \cores\exception\BaseException
  69. * @throws \think\db\exception\DataNotFoundException
  70. * @throws \think\db\exception\ModelNotFoundException
  71. */
  72. public function printer(int $orderId): Json
  73. {
  74. $model = OrderModel::detail($orderId);
  75. if ($model->printer($this->postForm())) {
  76. return $this->renderSuccess('操作成功');
  77. }
  78. return $this->renderError($model->getError() ?: '操作失败');
  79. }
  80. /**
  81. * 审核:用户取消订单
  82. * @param $orderId
  83. * @return Json
  84. */
  85. public function confirmCancel($orderId): Json
  86. {
  87. $model = OrderModel::detail($orderId);
  88. if ($model->confirmCancel($this->postForm())) {
  89. return $this->renderSuccess('操作成功');
  90. }
  91. return $this->renderError($model->getError() ?: '操作失败');
  92. }
  93. /**
  94. * 删除订单记录
  95. * @param int $orderId
  96. * @return Json
  97. */
  98. public function delete(int $orderId): Json
  99. {
  100. $model = OrderModel::detail($orderId);
  101. if ($model->setDelete()) {
  102. return $this->renderSuccess('删除成功');
  103. }
  104. return $this->renderError($model->getError() ?: '操作失败');
  105. }
  106. }