RefundOrder.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\outapi\controller;
  12. use app\Request;
  13. use app\services\order\OutStoreOrderRefundServices;
  14. use think\facade\App;
  15. /**
  16. * 售后单控制器
  17. * Class RefundOrder
  18. * @package app\outapi\controller
  19. */
  20. class RefundOrder extends AuthController
  21. {
  22. /**
  23. * RefundOrder constructor.
  24. * @param App $app
  25. * @param OutStoreOrderRefundServices $service
  26. * @method temp
  27. */
  28. public function __construct(App $app, OutStoreOrderRefundServices $service)
  29. {
  30. parent::__construct($app);
  31. $this->services = $service;
  32. }
  33. /**
  34. * 获取售后订单列表
  35. * @return mixed
  36. * @throws \think\db\exception\DataNotFoundException
  37. * @throws \think\db\exception\DbException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. */
  40. public function lst()
  41. {
  42. $where = $this->request->getMore([
  43. ['order_id', ''],
  44. ['time', ''],
  45. ['refund_type', 0]
  46. ]);
  47. $where['is_cancel'] = 0;
  48. return app('json')->success($this->services->refundList($where));
  49. }
  50. /**
  51. * 修改备注
  52. * @param string $order_id 售后单号
  53. * @return mixed
  54. */
  55. public function remark(string $order_id)
  56. {
  57. if (!$order_id) return app('json')->fail(100100);
  58. [$remark] = $this->request->postMore([['remark', '']], true);
  59. $this->services->remark($order_id, $remark);
  60. return app('json')->success(100024);
  61. }
  62. /**
  63. * 同意退款
  64. * @param string $order_id 售后单号
  65. * @return mixed
  66. */
  67. public function agree(string $order_id)
  68. {
  69. if (!$order_id) return app('json')->fail(100100);
  70. $this->services->agree($order_id);
  71. return app('json')->success(100010);
  72. }
  73. /**
  74. * 订单不退款
  75. * @param string $order_id 售后单号
  76. * @return mixed
  77. * @throws \think\db\exception\DataNotFoundException
  78. * @throws \think\db\exception\DbException
  79. * @throws \think\db\exception\ModelNotFoundException
  80. */
  81. public function refuse(string $order_id)
  82. {
  83. if (!$order_id) return app('json')->fail(100100);
  84. [$refund_reason] = $this->request->postMore([['refund_reason', '']], true);
  85. $this->services->refuse($order_id, $refund_reason);
  86. return app('json')->success(100010);
  87. }
  88. /**
  89. * 订单详情
  90. * @param string $order_id 售后单号
  91. * @return mixed
  92. */
  93. public function read(string $order_id)
  94. {
  95. if (!$order_id) return app('json')->fail(100100);
  96. $data = $this->services->getInfo($order_id);
  97. return app('json')->success($data);
  98. }
  99. /**
  100. * 订单退款
  101. * @param string $order_id 售后单号
  102. * @param Request $request
  103. * @return mixed
  104. * @throws \think\db\exception\DataNotFoundException
  105. * @throws \think\db\exception\DbException
  106. * @throws \think\db\exception\ModelNotFoundException
  107. */
  108. public function refundPrice(string $order_id, Request $request)
  109. {
  110. if (!$order_id) return app('json')->fail(100100);
  111. [$refund_price] = $request->postMore([['refund_price', '']], true);
  112. $this->services->refundPrice($order_id, $refund_price);
  113. return app('json')->success(400149);
  114. }
  115. }