DetailController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/4/13
  6. * Time: 下午2:00
  7. */
  8. namespace app\frontend\modules\refund\controllers;
  9. use app\common\components\ApiController;
  10. use app\common\exceptions\AppException;
  11. use app\common\models\refund\RefundProcessLog;
  12. use app\frontend\modules\refund\models\RefundApply;
  13. use app\frontend\modules\refund\services\RefundService;
  14. class DetailController extends ApiController
  15. {
  16. public function index(\Illuminate\Http\Request $request){
  17. $this->validate([
  18. 'refund_id' => 'required|integer',
  19. ]);
  20. $refundApply = RefundApply::detail()->find($request->query('refund_id'));
  21. if(!isset($refundApply)){
  22. throw new AppException('未找到该退款申请');
  23. }
  24. $refundApply->resend_express_id = 0;
  25. if ($refundApply->refund_type == RefundApply::REFUND_TYPE_EXCHANGE_GOODS && $refundApply->hasManyResendExpress->count() == 1) {
  26. $refundApply->resend_express_id = $refundApply->hasManyResendExpress->first()->id;
  27. }
  28. $refundApply->remark = $refundApply->remark ?: '';
  29. //判断是门店还是供应商
  30. $plugin = RefundApply::getIsPlugin($refundApply->order_id);
  31. if($plugin->is_plugin) {
  32. $refundApply->is_plugin = $plugin->is_plugin;
  33. $refundApply->supplier_id = RefundApply::getSupplierId($refundApply->order_id);
  34. }
  35. if ($plugin->plugin_id == 32) {
  36. $refundApply->plugin_id = $plugin->plugin_id;
  37. $refundApply->store_id = RefundApply::getStoreId($refundApply->order_id);
  38. }
  39. $refundApply->reject_time = $refundApply->reject_time ? date('Y-m-d H:i:s') : '';
  40. $refundApply['other_data'] = RefundService::getSendBackWayDetailData($refundApply);
  41. return $this->successJson('成功',$refundApply);
  42. }
  43. public function processLog()
  44. {
  45. $list = RefundProcessLog::where('refund_id', request()->input('refund_id'))->get();
  46. return $this->successJson('list', $list);
  47. }
  48. }