调整商品赠品添加的权限
parent
63b58ccd93
commit
8f54ffc9e4
|
|
@ -29,7 +29,7 @@ class SkuGift extends RowAction
|
||||||
*/
|
*/
|
||||||
protected function authorize($user): bool
|
protected function authorize($user): bool
|
||||||
{
|
{
|
||||||
return $user->can('dcat.admin.product_skus.gift');
|
return $user->can('dcat.admin.product_skus.sku_gift');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,22 @@ class SkuGift extends Form implements LazyRenderable
|
||||||
if ($gift['_remove_'] == 1) {
|
if ($gift['_remove_'] == 1) {
|
||||||
$delGiftIds[] = $gift['id'];
|
$delGiftIds[] = $gift['id'];
|
||||||
} else {
|
} else {
|
||||||
$giftSku[] = new ProductGift($gift);
|
if (is_null($gift['id'])) {
|
||||||
|
$giftSku[] = new ProductGift($gift);
|
||||||
|
} else {
|
||||||
|
$_gift = ProductGift::find($gift['id']);
|
||||||
|
$_gift->gift_sku_id = $gift['gift_sku_id'];
|
||||||
|
$_gift->num = $gift['num'];
|
||||||
|
$_gift->limit = $gift['limit'];
|
||||||
|
$giftSku[] = $_gift;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$skuId = $input['sku_id'];
|
$skuId = $input['sku_id'];
|
||||||
$sku = ProductSku::findOrFail($skuId);
|
$sku = ProductSku::findOrFail($skuId);
|
||||||
|
if ($sku->verify_state == 1 || !is_null($sku->release_at)) {//如果是审核中,或者上架中,则无法修改。
|
||||||
|
return $this->response()->error('当前商品目前无法修改赠品')->refresh();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$sku->gifts()->saveMany($giftSku);
|
$sku->gifts()->saveMany($giftSku);
|
||||||
|
|
|
||||||
|
|
@ -72,22 +72,24 @@ class ProductSkuTable extends Grid
|
||||||
if (Admin::user()->can('dcat.admin.product_skus.release_up')) {
|
if (Admin::user()->can('dcat.admin.product_skus.release_up')) {
|
||||||
$actions->append(new ReleaseUp());
|
$actions->append(new ReleaseUp());
|
||||||
}
|
}
|
||||||
|
if (Admin::user()->can('dcat.admin.product_skus.sku_sync_spu')) {
|
||||||
|
$actions->append(new SkuSyncSpu());
|
||||||
|
}
|
||||||
|
if (Admin::user()->can('dcat.admin.product_skus.sku_gift')) {
|
||||||
|
$actions->append(new SkuGift());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($actions->row->verify_state == 1) {
|
if ($actions->row->verify_state == 1) {
|
||||||
if (Admin::user()->can('dcat.admin.product_skus.release_cancel')) {
|
if (Admin::user()->can('dcat.admin.product_skus.release_cancel')) {
|
||||||
$actions->append(new ReleaseCancel());
|
$actions->append(new ReleaseCancel());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Admin::user()->can('dcat.admin.product_skus.sku_sync_spu')) {
|
|
||||||
$actions->append(new SkuSyncSpu());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($actions->row->release_at) {//已上架
|
if ($actions->row->release_at) {//已上架
|
||||||
if (Admin::user()->can('dcat.admin.product_skus.release_down')) {
|
if (Admin::user()->can('dcat.admin.product_skus.release_down')) {
|
||||||
$actions->append(new ReleaseDown());
|
$actions->append(new ReleaseDown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$actions->append(new SkuGift());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$grid->filter(function (Grid\Filter $filter) {
|
$grid->filter(function (Grid\Filter $filter) {
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ class AdminPermissionSeeder extends Seeder
|
||||||
'batch_release_down'=>['name' =>'批量下架'],
|
'batch_release_down'=>['name' =>'批量下架'],
|
||||||
'batch_release_cacel'=>['name' =>'批量取消申请'],
|
'batch_release_cacel'=>['name' =>'批量取消申请'],
|
||||||
'batch_sku_sync_spu'=>['name' =>'批量同步主商品'],
|
'batch_sku_sync_spu'=>['name' =>'批量同步主商品'],
|
||||||
|
'sku_gift' =>['name' =>'赠品管理'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'product_sku_verifies'=>[
|
'product_sku_verifies'=>[
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue