修改赠品后台修改处理
parent
07256db41b
commit
fb89addef4
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class ProductGift extends Model
|
|||
protected $fillable = [
|
||||
'sku_id',
|
||||
'gift_sku_id',
|
||||
'limit',
|
||||
'num',
|
||||
'sent',
|
||||
'remaining',
|
||||
|
|
|
|||
Loading…
Reference in New Issue