链街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.

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