Refund.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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\api\controller;
  13. use think\response\Json;
  14. use app\api\model\OrderRefund as OrderRefundModel;
  15. /**
  16. * 订单售后服务
  17. * Class service
  18. * @package app\api\controller\user\order
  19. */
  20. class Refund extends Controller
  21. {
  22. /**
  23. * 售后单列表
  24. * @param int $state
  25. * @return Json
  26. * @throws \cores\exception\BaseException
  27. * @throws \think\db\exception\DbException
  28. */
  29. public function list(int $state = -1): Json
  30. {
  31. $model = new OrderRefundModel;
  32. $list = $model->getList($state);
  33. return $this->renderSuccess(compact('list'));
  34. }
  35. /**
  36. * 售后单商品详情
  37. * @param int $orderGoodsId
  38. * @return Json
  39. * @throws \cores\exception\BaseException
  40. */
  41. public function goods(int $orderGoodsId): Json
  42. {
  43. $model = new OrderRefundModel;
  44. $goods = $model->getRefundGoods($orderGoodsId);
  45. return $this->renderSuccess(compact('goods'));
  46. }
  47. /**
  48. * 申请售后
  49. * @param int $orderGoodsId 订单商品ID
  50. * @return Json
  51. * @throws \cores\exception\BaseException
  52. */
  53. public function apply(int $orderGoodsId): Json
  54. {
  55. // 新增售后单记录
  56. $model = new OrderRefundModel;
  57. if ($model->apply($orderGoodsId, $this->postForm())) {
  58. return $this->renderSuccess([], '提交成功');
  59. }
  60. return $this->renderError($model->getError() ?: '提交失败');
  61. }
  62. /**
  63. * 售后单详情
  64. * @param int $orderRefundId 售后单ID
  65. * @return Json
  66. * @throws \cores\exception\BaseException
  67. */
  68. public function detail(int $orderRefundId): Json
  69. {
  70. $detail = OrderRefundModel::getDetail($orderRefundId, true);
  71. return $this->renderSuccess(compact('detail'));
  72. }
  73. /**
  74. * 用户发货
  75. * @param int $orderRefundId 售后单ID
  76. * @return Json
  77. * @throws \cores\exception\BaseException
  78. */
  79. public function delivery(int $orderRefundId): Json
  80. {
  81. // 售后单详情
  82. $model = OrderRefundModel::getDetail($orderRefundId, false);
  83. if ($model->delivery($this->postForm())) {
  84. return $this->renderSuccess([], '操作成功');
  85. }
  86. return $this->renderError($model->getError() ?: '提交失败');
  87. }
  88. }