|
|
|
@ -9,7 +9,6 @@ use App\AdminAgent\Repositories\AgentProduct; |
|
|
|
use App\Common\AgentType; |
|
|
|
use App\Common\ProductStatus; |
|
|
|
use App\Models\AgentProductItem; |
|
|
|
use App\Models\AgentSetting; |
|
|
|
use App\Models\Category; |
|
|
|
use App\Models\Channel; |
|
|
|
use App\Models\Guide; |
|
|
|
@ -40,7 +39,7 @@ class AgentProductController extends AdminController |
|
|
|
->orWhere('stock', '<=', 0) |
|
|
|
->update(['status' => ProductStatus::SOLD_OUT]); |
|
|
|
|
|
|
|
return Grid::make(new AgentProduct(['product.supplier:id,name', 'category:id,name']), function (Grid $grid) { |
|
|
|
return Grid::make(new AgentProduct(['product.supplier:id,company_name', 'category:id,name']), function (Grid $grid) { |
|
|
|
$agent_id = Admin::user()->id; |
|
|
|
$grid->model()->where('agent_id', $agent_id); |
|
|
|
|
|
|
|
@ -68,7 +67,7 @@ class AgentProductController extends AdminController |
|
|
|
? "<img data-action=\"preview-img\" src=\"{$this->product->picture}\" style=\"max-width:80px;max-height:200px;cursor:pointer\" class=\"img img-thumbnail\">" |
|
|
|
: ''; |
|
|
|
$data = [[ |
|
|
|
$this->product->supplier->name ?? '', |
|
|
|
$this->product->supplier->company_name ?? '', |
|
|
|
$this->product->title ?? '', |
|
|
|
$pic, |
|
|
|
$this->product->original_price ?? '', |
|
|
|
@ -105,7 +104,7 @@ class AgentProductController extends AdminController |
|
|
|
$filter->like('product.title', '产品标题')->width(3); |
|
|
|
$filter->equal('status')->select(ProductStatus::array())->width(2); |
|
|
|
|
|
|
|
$options = Supplier::where('status', 1)->pluck('name', 'id')->toArray(); |
|
|
|
$options = Supplier::where('status', 1)->pluck('company_name', 'id')->toArray(); |
|
|
|
$filter->equal('product.supplier_Id', '供应商')->select($options)->width(2); |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -120,15 +119,15 @@ class AgentProductController extends AdminController |
|
|
|
*/ |
|
|
|
protected function detail($id) |
|
|
|
{ |
|
|
|
return Show::make($id, new AgentProduct(['agent:id,name', 'category:id,name', 'product.supplier:id,name', 'guide:id,name']), function (Show $show) { |
|
|
|
return Show::make($id, new AgentProduct(['category:id,name', 'product.supplier:id,company_name', 'guide:id,name']), function (Show $show) { |
|
|
|
//不允许查看非自己的数据
|
|
|
|
if ($show->model()->agent_id != Admin::user()->id) { |
|
|
|
Admin::exit('数据不存在'); |
|
|
|
} |
|
|
|
|
|
|
|
$show->field('id'); |
|
|
|
$show->field('agent_id'); |
|
|
|
$show->field('product_id'); |
|
|
|
$show->field('product.supplier.company_name', '供应商'); |
|
|
|
$show->field('price'); |
|
|
|
$show->field('original_price'); |
|
|
|
$show->field('sale'); |
|
|
|
@ -144,7 +143,7 @@ class AgentProductController extends AdminController |
|
|
|
$show->field('content')->unescape(); |
|
|
|
if (Admin::user()->type != AgentType::CLUSTER) { |
|
|
|
$show->field('is_rec')->using(['未推荐', '已推荐']); |
|
|
|
$show->field('channel_id'); |
|
|
|
$show->field('channel_id')->as(fn($v) => join(',', Channel::whereIn('id', explode(',', $v))->pluck('name')->toArray())); |
|
|
|
$show->field('earnest'); |
|
|
|
$show->field('earnest_timeout'); |
|
|
|
$show->field('deposit'); |
|
|
|
@ -152,19 +151,6 @@ class AgentProductController extends AdminController |
|
|
|
} |
|
|
|
$show->field('created_at'); |
|
|
|
$show->field('updated_at'); |
|
|
|
|
|
|
|
/*$show->html(Alert::make(null, '供应商产品详情')->info()); 因为可能是组合销售多个产品,这里暂时不显示 |
|
|
|
|
|
|
|
$show->field('product.id', '供应商产品ID'); |
|
|
|
$show->field('product.supplier.name'); |
|
|
|
$show->field('product.title'); |
|
|
|
$show->field('product.pictures')->image('', 80, 80); |
|
|
|
$show->field('product.original_price'); |
|
|
|
$show->field('product.price'); |
|
|
|
$show->field('product.sale'); |
|
|
|
$show->field('product.stock'); |
|
|
|
$show->field('product.created_at', '创建时间'); |
|
|
|
$show->field('product.updated_at', '更新时间');*/ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|