goods
parent
86208dd0dd
commit
073eda2d5d
|
|
@ -71,18 +71,15 @@ class GoodsCategorySeeder extends Seeder
|
|||
]],
|
||||
]],
|
||||
];
|
||||
|
||||
|
||||
foreach ($categoryList as $index => $item) {
|
||||
$attributes = Arr::except($item, ['children']);
|
||||
$category = GoodsCategory::create(array_merge([
|
||||
'parent_id' => 0,
|
||||
'sort' => $index + 1,
|
||||
], $attributes));
|
||||
}
|
||||
|
||||
foreach ($categoryList as $index => $item) {
|
||||
if ($children = data_get($item, 'children')) {
|
||||
$this->createCategory($children, $item['id'] ?? 0);
|
||||
$this->createCategory($children, $category->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Peidikeji\Goods\Form\Check;
|
||||
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Contracts\LazyRenderable;
|
||||
use Dcat\Admin\Traits\LazyWidget;
|
||||
use Dcat\Admin\Widgets\Form;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Peidikeji\Goods\GoodsService;
|
||||
use Peidikeji\Goods\Models\GoodsCheck;
|
||||
|
||||
class HandleCheckForm extends Form implements LazyRenderable
|
||||
{
|
||||
use LazyWidget;
|
||||
|
||||
public function handle(array $input)
|
||||
{
|
||||
$info = GoodsCheck::findOrFail($this->payload['id']);
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
GoodsService::make()->handleCheck($info, Admin::user(), (bool) $input['check_status'], $input['check_remarks']);
|
||||
DB::commit();
|
||||
|
||||
return $this->response()->success('操作成功')->refresh();
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
|
||||
return $this->response()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function form()
|
||||
{
|
||||
$this->radio('check_status')->options([1 => '通过', 0 => '不通过'])->default(1);
|
||||
$this->textarea('check_remarks');
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,11 @@ use Illuminate\Support\ServiceProvider;
|
|||
|
||||
class GoodsServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $menu = [
|
||||
['title' => '商品模块', 'icon' => 'feather icon-layers', 'uri' => ''],
|
||||
['parent' => '商品模块', 'title' => '商品分类', 'icon' => '', 'uri' => '/goods-category'],
|
||||
];
|
||||
|
||||
public function register()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class GoodsCategoryController extends AdminController
|
|||
|
||||
$grid->disableRowSelector();
|
||||
|
||||
$grid->column('name')->tree(true, false);
|
||||
$grid->column('name')->tree();
|
||||
$grid->column('image')->image('', 100);
|
||||
$grid->column('sort')->editable(['mask' => '{alias:\'numeric\',min:0,max:999}']);
|
||||
$grid->column('is_enable')->switch();
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Peidikeji\Goods\Http\Admin;
|
||||
|
||||
use Dcat\Admin\Admin;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Grid\Displayers\Actions;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
use Dcat\Admin\Show;
|
||||
use Peidikeji\Goods\Action\Check\RowHandleCheck;
|
||||
use Peidikeji\Goods\Models\GoodsCheck;
|
||||
use Peidikeji\Merchant\Enums\CheckStatus;
|
||||
|
||||
class GoodsCheckController extends AdminController
|
||||
{
|
||||
protected $translation = 'dcat-admin-goods::goods';
|
||||
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(GoodsCheck::with(['merchant', 'category']), function (Grid $grid) {
|
||||
$grid->model()->sort();
|
||||
|
||||
$grid->column('merchant.name');
|
||||
$grid->column('category.name');
|
||||
$grid->column('name')->display(function () {
|
||||
return ($this->cover_image ? '<img src="'.$this->cover_image.'" width="60" class="img-thumbnail"/> ' : '').'<a href="'.admin_url('goods-check/'.$this->id).'">'.$this->name.'</a>';
|
||||
});
|
||||
$grid->column('price');
|
||||
$grid->column('vip_price');
|
||||
$grid->column('check_status')->display(fn () => $this->check_status->dot());
|
||||
$grid->column('created_at', '申请时间');
|
||||
|
||||
$grid->showViewButton();
|
||||
$grid->actions(function (Actions $actions) {
|
||||
$row = $actions->row;
|
||||
if ($row->check_status === CheckStatus::Processing) {
|
||||
$actions->append(new RowHandleCheck());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected function detail($id)
|
||||
{
|
||||
Admin::css([
|
||||
'vendor/dcat-admin-goods/goods.css',
|
||||
]);
|
||||
$info = GoodsCheck::with(['category', 'brand', 'type'])->findOrFail($id);
|
||||
$show = Show::make($info);
|
||||
$show->field('goods_sn');
|
||||
$show->field('category.name');
|
||||
$show->field('brand.name');
|
||||
$show->field('type.name');
|
||||
$show->field('name');
|
||||
$show->field('price');
|
||||
$show->field('vip_price');
|
||||
$show->field('score_discount_amount');
|
||||
$show->field('cover_image')->image('', 100);
|
||||
$show->field('images')->image('', 100);
|
||||
$show->field('content')->image('');
|
||||
$show->field('spec')->view('dcat-admin-goods::goods.grid-attr');
|
||||
$show->field('attr')->view('dcat-admin-goods::goods.grid-attr');
|
||||
$show->field('part')->view('dcat-admin-goods::goods.grid-attr');
|
||||
$show->field('on_sale')->bool();
|
||||
$show->field('sold_count');
|
||||
$show->field('check_status')->unescape()->as(fn () => $this->check_status->label());
|
||||
$show->field('check_at');
|
||||
$show->field('check_remarks');
|
||||
$show->field('check_user.name');
|
||||
$show->field('created_at')->as(fn ($v) => $this->created_at->format('Y-m-d H:i:s'));
|
||||
$show->field('updated_at')->as(fn ($v) => $this->updated_at->format('Y-m-d H:i:s'));
|
||||
|
||||
return $show;
|
||||
}
|
||||
}
|
||||
|
|
@ -53,20 +53,6 @@ class GoodsCategory extends Model
|
|||
});
|
||||
}
|
||||
|
||||
public static function selectOptions(\Closure $closure = null, $rootText = null)
|
||||
{
|
||||
$options = (new static())->withQuery($closure)->buildSelectOptions(static::query()->where('path', 'like', '-1-%')->sort()->get()->toArray(), 1);
|
||||
|
||||
$list = collect($options);
|
||||
|
||||
if ($rootText !== false) {
|
||||
$rootText = $rootText ?: admin_trans_label('root');
|
||||
$list->prepend($rootText, 0);
|
||||
}
|
||||
|
||||
return $list->all();
|
||||
}
|
||||
|
||||
public function modelFilter()
|
||||
{
|
||||
return GoodsCategoryFilter::class;
|
||||
|
|
|
|||
Loading…
Reference in New Issue