VueOperationController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. /**
  3. * 退款申请操作接口版
  4. * Created by PhpStorm.
  5. * User: Administrator
  6. * Date: 2020/12/11
  7. * Time: 14:24
  8. */
  9. namespace app\backend\modules\refund\controllers;
  10. use app\backend\modules\refund\services\operation\RefundComplete;
  11. use app\backend\modules\refund\services\RefundOperationService;
  12. use app\common\components\BaseController;
  13. use app\backend\modules\refund\models\RefundApply;
  14. use app\common\events\order\AfterOrderRefundedEvent;
  15. use app\common\events\order\AfterOrderRefundRejectEvent;
  16. use app\common\events\order\AfterOrderRefundSuccessEvent;
  17. use app\common\exceptions\AdminException;
  18. use app\common\exceptions\AppException;
  19. use app\common\models\refund\RefundChangeLog;
  20. use app\common\models\refund\ResendExpress;
  21. use Illuminate\Support\Facades\DB;
  22. use app\backend\modules\refund\services\RefundMessageService;
  23. /**
  24. * 统一售后操作接口
  25. * Class VueOperationController
  26. * @package app\backend\modules\refund\controllers
  27. */
  28. class VueOperationController extends BaseController
  29. {
  30. /**
  31. * @var $refundApply RefundApply
  32. */
  33. private $refundApply;
  34. public function preAction()
  35. {
  36. parent::preAction();
  37. $this->validate([
  38. 'refund_id' => 'required',
  39. ]);
  40. $this->refundApply = RefundApply::find(request()->input('refund_id'));
  41. if (!isset($this->refundApply)) {
  42. throw new AdminException('退款记录不存在');
  43. }
  44. }
  45. public function test()
  46. {
  47. }
  48. /**
  49. * 拒绝
  50. * @param \Request $request
  51. * @return mixed
  52. */
  53. public function reject()
  54. {
  55. RefundOperationService::refundReject(['refund_id' => request()->input('refund_id')]);
  56. return $this->successJson('操作成功');
  57. }
  58. /**
  59. * 同意
  60. * @return \Illuminate\Http\JsonResponse
  61. * @throws AppException
  62. */
  63. public function pass()
  64. {
  65. RefundOperationService::refundPass(['refund_id' => request()->input('refund_id')]);
  66. return $this->successJson('操作成功');
  67. }
  68. /**
  69. * @return \Illuminate\Http\JsonResponse
  70. * @throws AppException
  71. */
  72. public function batchResend()
  73. {
  74. RefundOperationService::refundBatchResend(['refund_id' => request()->input('refund_id')]);
  75. return $this->successJson('操作成功');
  76. }
  77. /**
  78. * @return \Illuminate\Http\JsonResponse
  79. * @throws AppException
  80. */
  81. public function resend()
  82. {
  83. RefundOperationService::refundResend(['refund_id' => request()->input('refund_id')]);
  84. return $this->successJson('操作成功');
  85. }
  86. public function close()
  87. {
  88. RefundOperationService::refundClose(['refund_id' => request()->input('refund_id')]);
  89. return $this->successJson('操作成功');
  90. }
  91. /**
  92. * 手动退款
  93. * @param \Request $request
  94. * @return mixed
  95. */
  96. public function consensus()
  97. {
  98. RefundOperationService::refundConsensus(['refund_id' => request()->input('refund_id')]);
  99. return $this->successJson('操作成功');
  100. }
  101. /**
  102. * 修改退款金额
  103. * @return \Illuminate\Http\JsonResponse
  104. */
  105. public function changePrice()
  106. {
  107. $params = [
  108. 'refund_id' => request()->input('refund_id'),
  109. 'change_price' => request()->input('change_price'),
  110. ];
  111. $bool = RefundOperationService::refundChangePrice($params);
  112. if ($bool) {
  113. return $this->successJson('改价成功');
  114. }
  115. return $this->errorJson('改价失败');
  116. }
  117. }