海南旅游SAAS
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.

62 lines
1.6 KiB

4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Admin\Extensions\Grid;
  3. use App\Common\ProductStatus;
  4. use App\Models\IndustryProduct;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid\RowAction;
  7. use Illuminate\Http\Request;
  8. use Illuminate\Support\Facades\DB;
  9. /**
  10. * 行业产品审核
  11. * Class AuditAgentProduct
  12. * @package App\Admin\Extensions\Grid
  13. */
  14. class AuditIndustryProduct extends RowAction
  15. {
  16. private $action;
  17. public function __construct($title = null, $action = 1)
  18. {
  19. parent::__construct($title);
  20. $this->action = $action;
  21. $this->title = $action == 1 ? '通过' : '拒绝';
  22. }
  23. protected function html()
  24. {
  25. $class = $this->action == 1 ? 'btn btn-sm btn-success' : 'btn btn-sm btn-danger';
  26. $this->appendHtmlAttribute('class', $class);
  27. $this->defaultHtmlAttribute('href', 'javascript:;');
  28. return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>";
  29. }
  30. public function handle(Request $request)
  31. {
  32. return $this->response()->warning('测试');
  33. try {
  34. //修改产品状态
  35. $industry = IndustryProduct::find($this->getKey());
  36. $industry->status = $request->action == 1 ? ProductStatus::ON_SALE : ProductStatus::REFUSE;
  37. $industry->single_deposit = 0; //TODO 交易金单价由前台审核时输入,代理商购买时还要存入行业产品订单表
  38. $industry->save();
  39. return $this->response()->success("审核成功")->refresh();
  40. } catch (\Exception $e) {
  41. return $this->response()->error($e->getMessage());
  42. }
  43. }
  44. public function confirm()
  45. {
  46. return ['确定要'.$this->title.'该产品吗?', ''];
  47. }
  48. public function parameters()
  49. {
  50. return ['action' => $this->action];
  51. }
  52. }