链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Extensions;
  3. use App\Admin\Common\Rpc;
  4. use App\Admin\Forms\RefundNote;
  5. use App\Models\ImsCjdcOrderMain;
  6. use Dcat\Admin\Grid\Displayers\Modal;
  7. use Dcat\Admin\Grid\RowAction;
  8. use Dcat\Admin\Layout\Content;
  9. use Illuminate\Http\Request;
  10. use Illuminate\Support\Facades\Log;
  11. class OrderStateHandle extends RowAction
  12. {
  13. protected $model;
  14. protected $state;
  15. protected $title;
  16. protected $content;
  17. public function __construct($title=null,$state=null)
  18. {
  19. parent::__construct($title);
  20. $this->state = $state;
  21. }
  22. /**
  23. * 处理请求
  24. *
  25. * @param Request $request
  26. *
  27. * @return \Dcat\Admin\Actions\Response
  28. */
  29. public function handle(Request $request)
  30. {
  31. // 获取当前行ID
  32. $id = $this->getKey();
  33. $orderMain = new ImsCjdcOrderMain();
  34. $state = $request->get('state');
  35. if ($state==4){
  36. $order = $orderMain::where('id',$id)->first();
  37. //记录分账流水
  38. $result = json_decode(Rpc::separateAccounts($order->global_order_id,$order->user_id),true)['result'];
  39. if ($result['code']!=0){
  40. Log::error('订单完成时分账接口调用失败',$result);
  41. return $this->response()->error('操作失败')->refresh();
  42. }
  43. return $this->response()->success('操作成功')->refresh();
  44. }elseif ($state==9){//同意退款
  45. $order = $orderMain::where('id',$id)->first();
  46. $result = json_decode(Rpc::orderRefund($order->global_order_id,$order->user_id),true)['result'];
  47. if ($result['code']!=0){
  48. Log::error('订单退款接口调用失败',$result);
  49. return $this->response()->error('操作失败')->refresh();
  50. }
  51. return $this->response()->success('操作成功')->refresh();
  52. }
  53. $res = $orderMain->modifyState($id,$state);
  54. if ($res==true){
  55. return $this->response()->success('操作成功')->refresh();
  56. }else{
  57. return $this->response()->error('操作失败');
  58. }
  59. }
  60. /**
  61. * 设置要POST到接口的数据
  62. *
  63. * @return array
  64. */
  65. public function parameters()
  66. {
  67. return [
  68. 'state' => $this->state,
  69. ];
  70. }
  71. }