6
0
Fork 0

修改赠品后台修改处理

release
vine_liutk 2021-12-21 11:48:48 +08:00
parent 07256db41b
commit fb89addef4
2 changed files with 7 additions and 1 deletions

View File

@ -42,12 +42,17 @@ class SkuGift extends Form implements LazyRenderable
$delGiftIds[] = $gift['id'];
} else {
if (is_null($gift['id'])) {
$gift['remaining'] = $gift['limit'];//剩余数量;
$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'];
$_gift->remaining = $gift['limit'] > 0 ? ($gift['limit'] - $_gift->sent) : $gift['limit'];
if ($_gift->remaining < 0) {
return $this->response()->error('无法设置限制数量小于已发数量');
}
$giftSku[] = $_gift;
}
}
@ -55,7 +60,7 @@ class SkuGift extends Form implements LazyRenderable
$skuId = $input['sku_id'];
$sku = ProductSku::findOrFail($skuId);
if ($sku->verify_state == 1 || !is_null($sku->release_at)) {//如果是审核中,或者上架中,则无法修改。
return $this->response()->error('当前商品目前无法修改赠品')->refresh();
return $this->response()->error('当前商品目前无法修改赠品');
}
try {
DB::beginTransaction();

View File

@ -12,6 +12,7 @@ class ProductGift extends Model
protected $fillable = [
'sku_id',
'gift_sku_id',
'limit',
'num',
'sent',
'remaining',