From 9fa7f7a802fcff3491da39e05d30c41127d2aa52 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Mon, 19 Oct 2020 17:11:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8--=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Actions/Grid/v3/CouponTime.php | 2 +- app/Admin/Forms/v3/CouponTimeForm.php | 26 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/Admin/Actions/Grid/v3/CouponTime.php b/app/Admin/Actions/Grid/v3/CouponTime.php index 638f91e..246fe0a 100644 --- a/app/Admin/Actions/Grid/v3/CouponTime.php +++ b/app/Admin/Actions/Grid/v3/CouponTime.php @@ -24,7 +24,7 @@ class CouponTime extends RowAction ->title($this->title) ->body(CouponTimeForm::make()->setKey($id)->payload([ 'id'=>$this->row->id, - 'status'=>$this->row->status, + 'inventory'=>$this->row->inventory, 'title'=>$this->row->title, 'start_time'=>$this->row->start_time, 'end_time'=>$this->row->end_time, diff --git a/app/Admin/Forms/v3/CouponTimeForm.php b/app/Admin/Forms/v3/CouponTimeForm.php index 0a93432..e18bc21 100644 --- a/app/Admin/Forms/v3/CouponTimeForm.php +++ b/app/Admin/Forms/v3/CouponTimeForm.php @@ -25,7 +25,7 @@ class CouponTimeForm extends Form implements LazyRenderable { // 获取外部传递参数 $id = $input['id']; - + $inventory = $input['inventory'] ?? 0; $start_time = $input['start_time'] ?? ''; $end_time = $input['end_time'] ?? ''; $usable_start_time = $input['usable_start_time'] ?? ''; @@ -40,10 +40,22 @@ class CouponTimeForm extends Form implements LazyRenderable case 0: case 1: case 3: - $coupon->start_time = $start_time; - $coupon->end_time = $end_time; - $coupon->usable_start_time = $usable_start_time; - $coupon->usable_end_time = $usable_end_time; + if(!empty($inventory)){ + $coupon->inventory = $inventory; + } + if(!empty($inventory)){ + $coupon->start_time = $start_time; + } + if(!empty($inventory)){ + $coupon->end_time = $end_time; + } + if(!empty($inventory)){ + $coupon->usable_start_time = $usable_start_time; + } + if(!empty($inventory)){ + $coupon->usable_end_time = $usable_end_time; + } + if($coupon->save()){ return $this->success('修改成功','/coupon'); } @@ -65,7 +77,7 @@ class CouponTimeForm extends Form implements LazyRenderable { $id = $this->payload['id'] ?? 0; $title = $this->payload['title'] ?? ''; - $status = $this->payload['status'] ?? -1; + $inventory = $this->payload['inventory'] ?? 0; $start_time = $this->payload['start_time'] ?? ''; $end_time = $this->payload['end_time'] ?? ''; @@ -75,6 +87,8 @@ class CouponTimeForm extends Form implements LazyRenderable $this->hidden('id')->value($id); $this->display('title','标题')->value($title); + $this->number('inventory','发放数量')->required()->type('number')->attribute('min', 1)->value($inventory)->default(1); + $this->datetime('start_time','活动开始时间')->required() ->customFormat(function () use($start_time){ return date('Y-m-d H:i:s',$start_time);