diff --git a/app/Admin/Actions/Grid/v3/CouponForbidden.php b/app/Admin/Actions/Grid/v3/CouponForbidden.php index 0224d6f..52d63fe 100644 --- a/app/Admin/Actions/Grid/v3/CouponForbidden.php +++ b/app/Admin/Actions/Grid/v3/CouponForbidden.php @@ -18,16 +18,16 @@ class CouponForbidden extends RowAction $id = $this->getKey(); $coupon = CouponModel::getInfo($id); if(empty($coupon)){ - return $this->response()->success('找不到优惠券!'); + return $this->response()->error('找不到优惠券!'); }else if($coupon->status == 1){ $coupon->status = 3; if($coupon->save()){ - return $this->response()->success('禁用成功!','/coupon'); + return $this->response()->redirect('/coupon'); } }else if($coupon->status == 3){ return $this->response()->error('优惠券已禁用!'); } - return $this->response()->success('禁用失败!'); + return $this->response()->error('禁用失败!'); } // 确认弹窗信息 diff --git a/app/Admin/Actions/Grid/v3/CouponPublish.php b/app/Admin/Actions/Grid/v3/CouponPublish.php index 9a98a4c..159216c 100644 --- a/app/Admin/Actions/Grid/v3/CouponPublish.php +++ b/app/Admin/Actions/Grid/v3/CouponPublish.php @@ -20,7 +20,7 @@ class CouponPublish extends RowAction $modal = Modal::make() ->xl() ->title($this->title) - ->body(CouponPublishForm::make()->setKey($id)) + ->body(CouponPublishForm::make()->setKey($id)->payload(['id'=>$this->row->id,'status'=>$this->row->status,'title'=>$this->row->title])) ->button($this->title); return $modal; diff --git a/app/Admin/Forms/v3/CouponPublishForm.php b/app/Admin/Forms/v3/CouponPublishForm.php index 668d64b..d1959f1 100644 --- a/app/Admin/Forms/v3/CouponPublishForm.php +++ b/app/Admin/Forms/v3/CouponPublishForm.php @@ -8,10 +8,12 @@ use Symfony\Component\HttpFoundation\Response; use App\Models\v3\CouponReceiveType as ReceiveTypeModel; use App\Models\v3\CouponSetting as SettingModel; use App\Models\v3\Coupon as CouponModel; +use Dcat\Admin\Contracts\LazyRenderable; +use Dcat\Admin\Traits\LazyWidget; -class CouponPublishForm extends Form +class CouponPublishForm extends Form implements LazyRenderable { - + use LazyWidget; /** * Handle the form request. * @@ -39,24 +41,26 @@ class CouponPublishForm extends Form return $this->error('活动时间已经接近,请重新设置!'); } - $coupon->status = 1; - if(!$coupon->save()){ - return $this->error('发布失败!'); + if($coupon->status == 0){ + // 删除领取方式 + $delRes = ReceiveTypeModel::where('coupon_id',$id)->delete(); + if($delRes === false){ + return $this->error('发布失败!'); + } + // 添加领取方式 + $receiveModel = new ReceiveTypeModel(); + $receiveModel->coupon_id = $id; + $receiveModel->receive_type = $receiveType; + // 获取一次可领取数量 + $receiveNumber = SettingModel::getSettingInfo($receiveType,'value'); + $receiveModel->one_receive_number = empty($receiveNumber) ? 1 : $receiveNumber->value; + if(!$receiveModel->save()){ + return $this->error('发布失败!'); + } } - // 删除领取方式 - $delRes = ReceiveTypeModel::where('coupon_id',$id)->delete(); - if($delRes === false){ - return $this->error('发布失败!'); - } - // 添加领取方式 - $receiveModel = new ReceiveTypeModel(); - $receiveModel->coupon_id = $id; - $receiveModel->receive_type = $receiveType; - // 获取一次可领取数量 - $receiveNumber = SettingModel::getSettingInfo($receiveType,'value'); - $receiveModel->one_receive_number = empty($receiveNumber) ? 1 : $receiveNumber->value; - - if($receiveModel->save()){ + + $coupon->status = 1; + if($coupon->save()){ return $this->success('发布成功','/coupon'); } break; @@ -78,12 +82,20 @@ class CouponPublishForm extends Form */ public function form() { - $id = $this->getKey(); - $receiveTypeInfo = ReceiveTypeModel::getReceiveTypeInfo($id,'receive_type'); + $id = $this->payload['id'] ?? 0; + $title = $this->payload['title'] ?? ''; + $status = $this->payload['status'] ?? -1; + + $this->hidden('id')->value($id); + $this->display('title','标题')->value($title); + $receiveTypeInfo = ReceiveTypeModel::getReceiveTypeOne([['coupon_id','=',$id]],'receive_type'); $list = SettingModel::getSettingArray(); $receiveType = empty($receiveTypeInfo->receive_type)? 0 :$receiveTypeInfo->receive_type; - $this->hidden('id')->value($id); - $this->select('receive_type','领取方式')->required()->options($list)->value($receiveType); + if($status == 0){ + $this->select('receive_type','领取方式')->required()->options($list)->value($receiveType); + }else{ + $this->select('receive_type','领取方式')->options($list)->value($receiveType)->disable(); + } } /** diff --git a/app/Models/v3/SystemConfig.php b/app/Models/v3/SystemConfig.php index 5976adc..0f52534 100644 --- a/app/Models/v3/SystemConfig.php +++ b/app/Models/v3/SystemConfig.php @@ -17,7 +17,7 @@ class SystemConfig extends Model /* 查询记录数 limit */ protected $perPage = 10; - public static $_CATEGORY= [1=>'奖励类',2=>'店铺设置类',3=>'市场管理后台配置',4=>'订单相关设置']; + public static $_CATEGORY= [1=>'奖励类',2=>'店铺设置类',3=>'市场管理后台配置',4=>'订单相关设置',5=>'提现设置']; public static $_STATUS = ['禁用','启用']; protected $appends = [