OperationController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/4/13
  6. * Time: 下午2:17
  7. */
  8. namespace app\frontend\modules\refund\controllers;
  9. use app\common\components\ApiController;
  10. use app\common\exceptions\AdminException;
  11. use app\common\exceptions\AppException;
  12. use app\common\modules\refund\services\RefundService;
  13. use app\frontend\modules\refund\models\RefundApply;
  14. use app\frontend\modules\refund\services\RefundMessageService;
  15. use app\frontend\modules\refund\services\RefundOperationService;
  16. /**
  17. * 统一售后操作接口
  18. * Class OperationController
  19. * @package app\frontend\modules\refund\controllers
  20. */
  21. class OperationController extends ApiController
  22. {
  23. public $transactionActions = ['*'];
  24. public function preAction()
  25. {
  26. parent::preAction(); // TODO: Change the autogenerated stub
  27. $this->validate([
  28. 'refund_id' => 'required|filled|integer',
  29. ]);
  30. $this->refundApply = RefundApply::find(request()->input('refund_id'));
  31. if (!isset($this->refundApply)) {
  32. throw new AppException('售后申请记录不存在');
  33. }
  34. if ($this->refundApply->uid != \YunShop::app()->getMemberId()) {
  35. throw new AppException('无效申请,该订单属于其他用户');
  36. }
  37. }
  38. /**
  39. * @return \Illuminate\Http\JsonResponse
  40. * @throws \app\common\exceptions\AppException
  41. * @throws \app\common\exceptions\ShopException
  42. */
  43. public function send()
  44. {
  45. $this->validate([
  46. 'express_company_code' => 'required|string',
  47. 'express_company_name' => 'required|string',
  48. 'express_sn' => 'required|filled|string',
  49. ]);
  50. RefundOperationService::refundSendBack(['refund_id'=> request()->input('refund_id')]);
  51. return $this->successJson('操作成功');
  52. }
  53. /**
  54. * @return \Illuminate\Http\JsonResponse
  55. * @throws \app\common\exceptions\AppException
  56. * @throws \app\common\exceptions\ShopException
  57. */
  58. public function complete()
  59. {
  60. RefundOperationService::refundExchangeComplete(['refund_id'=> request()->input('refund_id')]);
  61. return $this->successJson('操作成功');
  62. }
  63. /**
  64. * @return \Illuminate\Http\JsonResponse
  65. * @throws \app\common\exceptions\AppException
  66. * @throws \app\common\exceptions\ShopException
  67. */
  68. public function cancel()
  69. {
  70. RefundOperationService::refundCancel(['refund_id'=> request()->input('refund_id')]);
  71. return $this->successJson('操作成功');
  72. }
  73. }