Browse Source

优惠券--添加库存修改

master
liangyuyan 5 years ago
parent
commit
9fa7f7a802
  1. 2
      app/Admin/Actions/Grid/v3/CouponTime.php
  2. 26
      app/Admin/Forms/v3/CouponTimeForm.php

2
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,

26
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);

Loading…
Cancel
Save