FundAdminForm.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Module\Fund\Admin\Actions;
  3. use App\Module\Fund\Models\FundModel;
  4. use App\Module\Fund\Services\FundService;
  5. use Dcat\Admin\Admin;
  6. use Dcat\Admin\Traits\LazyWidget;
  7. use Dcat\Admin\Contracts\LazyRenderable;
  8. use UCore\DcatAdmin\Widgets\Form;
  9. use UCore\Helper\Logger;
  10. /**
  11. * 资金处理
  12. *
  13. */
  14. class FundAdminForm extends Form implements LazyRenderable
  15. {
  16. use LazyWidget;
  17. protected string $trans_path = 'fund.form';
  18. public function run($input)
  19. {
  20. $id = $this->payload['id'] ?? null;
  21. $add = $input['add'];
  22. $remark = $input['remark'];
  23. if (!$id) {
  24. return $this->error('input-error');
  25. }
  26. $admin_id = $this->getAdminId();
  27. $funddata = FundModel::query()->find($id);
  28. $admin = new FundService($funddata->user_id, $funddata->fund_id);
  29. $re18 = $admin->admin_operate($admin_id, $funddata->fund_id, $add, $remark, '');
  30. if (is_string($re18)) {
  31. Logger::error($re18);
  32. return $this->_error('fundadmin-error')->refresh();
  33. }
  34. return $this->_success('fundadmin-ok')->refresh();
  35. }
  36. public function form()
  37. {
  38. $this->text('remark')->default('Admin Approved')->required();
  39. $this->text('add')->default(0)->required();
  40. }
  41. }