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.
66 lines
1.6 KiB
66 lines
1.6 KiB
<?php
|
|
|
|
namespace App\Admin\Extensions\Grid;
|
|
|
|
use App\Common\ProductStatus;
|
|
use App\Models\IndustryProduct;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
/**
|
|
* 行业产品审核
|
|
* Class AuditAgentProduct
|
|
* @package App\Admin\Extensions\Grid
|
|
*/
|
|
class AuditIndustryProduct extends RowAction
|
|
{
|
|
private $action;
|
|
|
|
public function __construct($title = null, $action = 1)
|
|
{
|
|
parent::__construct($title);
|
|
$this->action = $action;
|
|
$this->title = $action == 1 ? '通过' : '拒绝';
|
|
}
|
|
|
|
protected function html()
|
|
{
|
|
$class = $this->action == 1 ? 'btn btn-sm btn-success' : 'btn btn-sm btn-danger';
|
|
$this->appendHtmlAttribute('class', $class);
|
|
$this->defaultHtmlAttribute('href', 'javascript:;');
|
|
|
|
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>";
|
|
}
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
$status = $request->action == 1 ? ProductStatus::ON_SALE : ProductStatus::REFUSE;
|
|
try {
|
|
//修改产品状态
|
|
$industry = IndustryProduct::find($this->getKey());
|
|
if ($status == ProductStatus::ON_SALE && $industry->single_deposit <= 0) {
|
|
throw new \Exception('请先设置交易金单价!');
|
|
}
|
|
|
|
$industry->status = $status;
|
|
$industry->single_deposit = 0;
|
|
$industry->save();
|
|
|
|
return $this->response()->success("审核成功")->refresh();
|
|
} catch (\Exception $e) {
|
|
return $this->response()->error($e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function confirm()
|
|
{
|
|
return ['确定要'.$this->title.'该产品吗?', ''];
|
|
}
|
|
|
|
public function parameters()
|
|
{
|
|
return ['action' => $this->action];
|
|
}
|
|
}
|