Event.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 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 app\store\controller\Controller;
  15. use app\store\model\Order as OrderModel;
  16. /**
  17. * 订单事件控制器
  18. * Class Event
  19. * @package app\store\controller\order
  20. */
  21. class Event extends Controller
  22. {
  23. /**
  24. * 修改订单价格
  25. * @param int $orderId
  26. * @return Json
  27. */
  28. public function updatePrice(int $orderId): Json
  29. {
  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. // 订单详情
  45. $model = OrderModel::detail($orderId);
  46. if ($model->updateRemark($this->postForm())) {
  47. return $this->renderSuccess('操作成功');
  48. }
  49. return $this->renderError($model->getError() ?: '操作失败');
  50. }
  51. /**
  52. * 小票打印
  53. * @param int $orderId
  54. * @return Json
  55. * @throws \cores\exception\BaseException
  56. */
  57. public function printer(int $orderId): Json
  58. {
  59. // 订单详情
  60. $model = OrderModel::detail($orderId);
  61. if ($model->printer($this->postForm())) {
  62. return $this->renderSuccess('操作成功');
  63. }
  64. return $this->renderError($model->getError() ?: '操作失败');
  65. }
  66. /**
  67. * 审核:用户取消订单
  68. * @param $orderId
  69. * @return Json
  70. */
  71. public function confirmCancel($orderId): Json
  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. /**
  81. * 删除订单记录
  82. * @param int $orderId
  83. * @return Json
  84. */
  85. public function delete(int $orderId): Json
  86. {
  87. // 订单详情
  88. $model = OrderModel::detail($orderId);
  89. // 确认删除
  90. if ($model->setDelete()) {
  91. return $this->renderSuccess('删除成功');
  92. }
  93. return $this->renderError($model->getError() ?: '操作失败');
  94. }
  95. }