| xqd
@@ -5,7 +5,9 @@ namespace App\Admin\Controllers\CouponManagement;
|
|
|
use App\Admin\Actions\backstage\Coupon\CouponDetails;
|
|
|
use App\Admin\Actions\backstage\Coupon\CouponDistribution;
|
|
|
use App\Admin\Actions\backstage\Coupon\CouponDistributions;
|
|
|
+use App\Admin\Actions\backstage\Coupon\UpdateCouponType;
|
|
|
use App\Models\Coupon;
|
|
|
+use App\Models\CouponType;
|
|
|
use Encore\Admin\Controllers\AdminController;
|
|
|
use Encore\Admin\Form;
|
|
|
use Encore\Admin\Grid;
|
| xqd
@@ -35,6 +37,10 @@ class CouponManagementController extends AdminController
|
|
|
$grid->actions(function ($actions) {
|
|
|
$actions->disableView();
|
|
|
$actions->add(new CouponDetails());
|
|
|
+ if ($actions->row->usable_type == 2)
|
|
|
+ {
|
|
|
+ $actions->add(new UpdateCouponType());
|
|
|
+ }
|
|
|
});
|
|
|
$grid->filter(function($filter){
|
|
|
$filter->timestampBetween('start_time', "有效期开始时间")->datetime();
|
| xqd
@@ -138,11 +144,12 @@ class CouponManagementController extends AdminController
|
|
|
protected function form()
|
|
|
{
|
|
|
$form = new Form(new Coupon());
|
|
|
-
|
|
|
+ $form->hidden('id', __('id'));
|
|
|
$form->text('name', __('优惠券名称'));
|
|
|
$form->text('title', __('券标题'));
|
|
|
$form->text('desc', __('使用说明'));
|
|
|
$form->text('rules', __('使用规则'));
|
|
|
+// dd($form->toArray());
|
|
|
$form->image('icon', __('券图标'))->help('图标大小48px * 48px');
|
|
|
$form->select('type', '类型')
|
|
|
->options([
|
| xqd
@@ -157,23 +164,34 @@ class CouponManagementController extends AdminController
|
|
|
});
|
|
|
$form->select('position_type',__('发放平台'))->options([1=>'领券中心',2=>'后台发放']);
|
|
|
$form->number('num', __('数量'));
|
|
|
- $form->select('usable_type',__('可用类型'))
|
|
|
- ->options([
|
|
|
- 1=>'全部产品通用',
|
|
|
- 2=>'部分产品可用'
|
|
|
- ])->when(2,function (Form $form){
|
|
|
- $form->hasMany('CouponType','可用类型',function (Form\NestedForm $form){
|
|
|
- $form->select('product_type','可用类型')->options([
|
|
|
- 1=>'电话咨询',
|
|
|
- 2=>'图文咨询',
|
|
|
- 3=>'门诊咨询',
|
|
|
- 4=>'疫苗接种',
|
|
|
- 5=>'儿保预约',
|
|
|
- 6=>'服务包',
|
|
|
- 7=>'充值',
|
|
|
- ]);
|
|
|
+ if ($form->isCreating())
|
|
|
+ {
|
|
|
+ $form->select('usable_type',__('可用类型'))
|
|
|
+ ->options([
|
|
|
+ 1=>'全部产品通用',
|
|
|
+ 2=>'部分产品可用'
|
|
|
+ ])->when(2,function (Form $form){
|
|
|
+ $form->hasMany('CouponType','可用类型',function (Form\NestedForm $form){
|
|
|
+ $form->select('product_type','可用类型')->options([
|
|
|
+ 1=>'电话咨询',
|
|
|
+ 2=>'图文咨询',
|
|
|
+ 3=>'门诊咨询',
|
|
|
+ 4=>'疫苗接种',
|
|
|
+ 5=>'儿保预约',
|
|
|
+ 6=>'服务包',
|
|
|
+ 7=>'充值',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ $form->select('usable_type',__('可用类型'))
|
|
|
+ ->options([
|
|
|
+ 1=>'全部产品通用',
|
|
|
+ 2=>'部分产品可用'
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
$form->select('expire_type', '过期类型')
|
|
|
->options([
|
|
|
1 => '领取N天过期',
|
| xqd
@@ -186,9 +204,9 @@ class CouponManagementController extends AdminController
|
|
|
$form->saving(function ($form){
|
|
|
$form->start_time = strtotime($form->start_time);
|
|
|
$form->end_time = strtotime($form->end_time);
|
|
|
+ $form->money = $form->money*100;
|
|
|
+ $form->max_reduce_amount = $form->max_reduce_amount*100;
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
return $form;
|
|
|
}
|